|
It's a job ad: if you don't understand the requirements, then it's a waste of time applying as you won;t be able to do the job.
Keep looking for something where you understand at least 75% of what they are looking for.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
My Php file is returning this json. how can i covert it in c#.
{"response"[
{"user_id":"26","crtloc_lat":"47.678238","crtloc_lng":"-122.131416"},
{"user_id":"27","crtloc_lat":"9.350192","crtloc_lng":"-95.391006"},
{"user_id":"28","crtloc_lat":"47.678238","crtloc_lng":"-122.131416"}
]
}
php file is present at anybodyhere.net/returntest.php
My Code
public async void sendmsg() {
WebRequest request = WebRequest.Create(http://anybodyhere.net/returntest.php);
WebResponse response = await request.GetResponseAsync();
List<Responsemsg> responsemsg;
using (var stream = new StreamReader(response.GetResponseStream()))
{
responsemsg=JsonConvert.DeserializeObject<Responsemsg>(stream.ReadToEnd());
}
foreach (var item in responsemsg)
{
Console.WriteLine("id={0},latitude={1},longitude={2}", item.user_id, item.crtloc_lat, item.crtloc_lng);
}
}
}
public class Responsemsg
{
public string user_id { get; set; }
public string crtloc_lat { get; set; }
public string crtloc_lng { get; set; }
}
public class RootObject
{
public List<Responsemsg> responsemsg { get; set; }
}
</pre>
|
|
|
|
|
Your JSON is invalid - it's missing a ":" between the "response" property name and the value.
Once that's fixed, update your RootObject to match the structure, and deserialize that:
public class RootObject
{
public List<Responsemsg> response { get; set; }
}
...
RootObject responseData;
using (var stream = new StreamReader(response.GetResponseStream()))
{
responseData = JsonConvert.DeserializeObject<RootObject>(stream.ReadToEnd());
}
foreach (var item in responseData.response)
{
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Please how do i save frames from multiple IP Camera, i am using an update of the Camera Vision by Andrew Kirilov.
Thank you.
|
|
|
|
|
|
Thanks alot for the reply
|
|
|
|
|
I wanted to upload my pdf files in MySQL and view from datagrid....
I have an error...This is the error..
"
Additional information: Could not find a part of the path 'C:\WSmfgIT\WSmfgIT\WSmfgIT\wsmfgit\wsmfgit\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction "
asp.net:
<asp:Button ID="btn_upload" runat="server" style="z-index: 1; left: 610px; top: 337px; position: absolute; height: 23px; width: 63px" Text="Upload" OnClick="btn_upload_Click" />
<div>
<asp:GridView ID="workinstruc" CssClass="Gridview" runat="server" AutoGenerateColumns="false" DataKeyNames="FileView" >
<HeaderStyle BackColor="#df5015" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="FileName" HeaderText="FileName" />
<asp:TemplateField HeaderText="FileView">
<ItemTemplate>
<asp:LinkButton ID="lnkView" runat="server" Text="View" ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
c#:
<pre lang="cs">using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.Windows.Forms;
using System.Data;
using MySql.Data.MySqlClient;
namespace wsmfgit
{
public partial class workinstruction : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindGrid();
}
}
private void BindGrid()
{
string constr = @"Data Source=192.168.8.124; Database=pmdb; User ID=client; Password=client";
using (MySqlConnection con = new MySqlConnection(constr))
{
using (MySqlCommand cmd = new MySqlCommand("SELECT ID, FileName, FileView FROM work_inst"))
{
using (MySqlDataAdapter sda = new MySqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
workinstruc.DataSource = dt;
workinstruc.DataBind();
}
}
}
}
}
protected void imgbtn_home_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("default.aspx");
}
protected void btn_upload_Click(object sender, EventArgs e)
{
string constr = @"Data Source=192.168.8.124; Database=pmdb; User ID=client; Password=client";
using (MySqlConnection con = new MySqlConnection(constr))
{
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(Server.MapPath(@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf" + filename));
con.Open();
MySqlCommand cmd = new MySqlCommand("insert into work_inst(FileName,FileView) values(@Name,@Path)");
cmd.Parameters.AddWithValue("@FileName", filename);
cmd.Parameters.AddWithValue(@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf",filename);
cmd.ExecuteNonQuery();
Response.Write("Pdf File Save in Database");
con.Close();
BindGrid();
}
}
}
}
</pre>
This are my code...could anyone help me...
|
|
|
|
|
Well the error is quite clear - the path
C:\WSmfgIT\WSmfgIT\WSmfgIT\wsmfgit\wsmfgit\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction does not exist or the account that you are running this under does not have access to that folder.
For example, if you are running this on a server you won't have access to "C:\..." - Try using relative pathnames
Are you sure that the path is correctly constructed? The repeated sequence WSmfgIT\WSmfgIT\WSmfgIT\wsmfgit\wsmfgit looks as if something has gone wong
|
|
|
|
|
my actual path is this :
@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf"
|
|
|
|
|
The reason you're having a problem is because you're using Server.MapPath along with mapping to a specific address. Do one, or the other, and not both.
|
|
|
|
|
this is my path
@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf" so how should I declare it? can you pls help me..
|
|
|
|
|
Member 12016106 wrote: Server.MapPath(@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf" + filename)
The Server.MapPath method expects a virtual path within the current application. It should look something like:
Server.MapPath("~/workinstruction/pdf/" + filename)
You've passed in a physical UNC path, which won't work.
If you want to save the file in the UNC path, don't use Server.MapPath :
FileUpload1.SaveAs(@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf" + filename);
Member 12016106 wrote: cmd.Parameters.AddWithValue(@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf", filename);
Your query doesn't have a parameter with the name \\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf . I suspect you meant to pass that as the path:
cmd.Parameters.AddWithValue("@Path", @"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf");
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have try what you mentioned above but I still have an error...
this is the error:
An exception of type 'System.InvalidOperationException' occurred in MySql.Data.dll but was not handled in user code
Additional information: Connection must be valid and open.
c#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using System.Windows.Forms;
using System.Data;
using MySql.Data.MySqlClient;
namespace wsmfgit
{
public partial class workinstruction : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindGrid();
}
}
private void BindGrid()
{
string constr = @"Data Source=192.168.8.124; Database=pmdb; User ID=client; Password=client";
using (MySqlConnection con = new MySqlConnection(constr))
{
using (MySqlCommand cmd = new MySqlCommand("SELECT ID, FileName, FileView FROM work_inst"))
{
using (MySqlDataAdapter sda = new MySqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
workinstruc.DataSource = dt;
workinstruc.DataBind();
}
}
}
}
}
protected void imgbtn_home_Click(object sender, ImageClickEventArgs e)
{
Response.Redirect("default.aspx");
}
protected void btn_upload_Click(object sender, EventArgs e)
{
string constr = @"Data Source=192.168.8.124; Database=pmdb; User ID=client; Password=client";
using (MySqlConnection con = new MySqlConnection(constr))
{
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(@"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf" + filename);
con.Open();
MySqlCommand cmd = new MySqlCommand("insert into work_inst(FileName,FileView) values(@Name,@Path)");
cmd.Parameters.AddWithValue("@FileName", filename);
cmd.Parameters.AddWithValue("@Path", @"\\192.168.5.10\fbar\TOOLS\ProbingApps\ProbingSystem\workinstruction\pdf");
cmd.ExecuteNonQuery();
Response.Write("Pdf File Save in Database");
con.Close();
BindGrid();
}
}
}
}
|
|
|
|
|
In your btn_upload_Click method, you've not set the command's connection property.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank You soo much for your kind explanation..
I got the answer..
|
|
|
|
|
I am developing a instructional aids for school, that should be able to lock student windows tab to one app, and he cannot access other app. This locking is on request sent by server, and the lock/unlock action should be performed in a timely basis.
I have looked into "assigned access", but it seems not suitable, because it require a special user account, and need a reboot to enter the mode.
Do you have any idea or direction to handle this?
Target platform is Windows 10.
|
|
|
|
|
Windows doesn't support this because, well, it's a shared system running many applications at once.
The only way I know of is that you'd have to install an application on the target machines that, on command, installs a global keyboard hook to catch and eat Alt-Tab, Ctrl-Esc and Ctrl-Shift-Esc. You'd also have to set the policy on the machines that prevent users from running Task Manager.
|
|
|
|
|
Have you examine the possibilities of using "kiosk mode" ? There are resources here on CP: [^].
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
I just cannot seem to figure this out. It is more IDE/XAML question, I realize. I tried
<GridViewColumn x:Name="GridViewColumnTotal" Header="Total"
DisplayMemberBinding="{Binding Total}"
Width="100"
TextBlock.TextAlignment="Right"
TextBlock.FontWeight="ExtraBold"/>
the column is neither bold or Right aligned
Can someone point me to an example on how to do this?
thanks!
|
|
|
|
|
Use the correct forum:
Silverlight/WPF[^]
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G.K. Chesterton
|
|
|
|
|
I may be off-base as I'm currently learning XAML myself ... but it looks like there is a "layer" missing from the tree... maybe
<GridViewColumn x:Name="GridViewColumnTotal" Header="Total" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Total}" TextAlignment="Right" FontWeight="ExtraBold"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn> (Not tested!)
modified 8-Oct-15 12:19pm.
|
|
|
|
|
Thanks for the reply. I have a problem that I get an error on the line:
<GridViewColumn.CellTemplate> The error is "An attribute name is missing"
Gawd! This user interface stuff is more complicated than writing an algorithm!
modified 8-Oct-15 12:17pm.
|
|
|
|
|
I edited your response as the code line wasn't showing.
I also missed a closing > from my post - I've edited it
|
|
|
|
|
Wow!, that fixed the bold issue perfectly, big thanks!
Now, I just need to figure out why right alignment is not working...
Really, thanks!
|
|
|
|
|
Cool! I'm obviously getting better with WPF
For the alignment have a look at this post[^]
|
|
|
|