|
Hi,
I have Cisco PBX outputing date in NTP format like this:
09:47:55.999 BAH Sun Dec 7 2014
10:06:58.245 BAH Sun Dec 7 2014
11:21:18.723 BAH Sun Dec 7 2014
I want to know how can I convert it to UTC format in order to save it to MySQL database datetime field?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
|
Assuming the format you want is ISO 8601 [^]:
09:47:55.999 BAH Sun Dec 7 2014
Should be transformed into: YYYY-MM-DDThh:mm:ss.sTZD
2014-12-07T09:47:55.999+03:00
?
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Sir,I want use datagridview with tab control.plz send me link where i can understand,how can i use tabcontrol with datagridview.
thanks
|
|
|
|
|
Hi,
Check my Article which is realted to adding controls to Datagridview.You can use the same functionality add tab control
DataGridView Helper Class[^]
|
|
|
|
|
Hi guys!
When i create my project, i want to display a single page in a c# WinForms, same as a website, when i click on an item of navibar, other page will display. I have already tried to search but i can't find out.
Like this <a href="http://paulstovell.com/blog/wpf-navigation"></a>
Can you point me control or library extended in c# to do that, not MDI form?
Thanks!
|
|
|
|
|
Where are your 'pages' coming from and how are you switching between them?
|
|
|
|
|
|
Presumably, by calling some methods, or setting some properties in the tab control. Your question is far from clear.
|
|
|
|
|
Hello Everyone,
I have run into a coding problem that has been driving me crazy for two days. I am running a console project from within my C# project using Process.Start() and trying to read the output into a string in my project. I have tried everything that I have found on the internet over the last two days and nothing works. Always returning an empty string. I have tried both synchronous and asynchronous methods and everything in between ie reading standarderror as well as standoutput. The exe that is being called is codegen.exe which is the compiled binary for creating a song fingerprint in Echoprint.
I can run this from a code prompt and it works perfectly every time outputting a fingerprint string. I am running windows 7 / VS2013 Express. The funny thing is, I have the source code for the codegen.exe and the data being output to the console is using nothing other than printf statements so there is nothing surprising going on there.
I did try doing a simple call to cmd.exe with "dir" argument and it responds correctly and fills my string with its output.
I am hoping that someone can suggest something that I have not yet tried, however I have tried all the different examples from MSDN as well as the internet.
Perhaps some one has had a similar issue and can offer some suggestions or point me in a different direction.
Any help would be appreciated.
Ray H
modified 8-Dec-14 11:21am.
|
|
|
|
|
I have never used EchoPrint, or launched a Console Application using Process.Start from within a WinForms project, so what follows may be irrelevant, or useless, but, given the fact you've done thorough searching, and haven't come up with anything, and on the odd chance it may be helpful, I'll put it out here.
If I find out this is not relevant, I'll remove this message, and my "feelings" will not be "hurt"
Is it possible that if you launch a Console from a C# project using the 'AllocConsole API, you can then, somehow, get that Console running codegen.exe ... so you would, then, be able to interact ?
Your C# project is WinForms, or WPF, or C++ ?
The 'AllocConsole API works for me (only tested in .NET 4.5) to enable two-way interaction between a Win Form and a Console it launches:
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern bool AllocConsole();
private void button1_Click(object sender, EventArgs e)
{
AllocConsole();
MessageBox.Show(ConsoleWriteAndReadLine(new string[]{"arg 1","arg 2","arg 3"}));
}
private string ConsoleWriteAndReadLine(string[] values)
{
Console.WriteLine("Command line = {0}", Environment.CommandLine);
for (int i = 0; i < values.Length; i++)
{
Console.WriteLine("argument{0} = {1}", i + 1, values[i]);
}
Console.Write("? ");
return Console.ReadLine();
} Perhaps the techniques shown in this CodeProject article would be helpful: [^] ?
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Thanks Bill,
The project is a WinForms project and this is a code snippet from MSDN on how to do exactly what I want to do. But it never works.
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Write500Lines.exe";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
|
|
|
|
|
This is the latest iteration that I tried which I found on the web.
using (var process = new Process())
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "Codegen.exe";
process.StartInfo.Arguments = open.FileName + " 10 30";
process.Start();
//Thread.Sleep(100);
using (Task processWaiter = Task.Factory.StartNew(() => process.WaitForExit()))
using (Task<string> outputReader = Task.Factory.StartNew(() => process.StandardOutput.ReadToEnd()))
using (Task<string> errorReader = Task.Factory.StartNew(() => process.StandardError.ReadToEnd()))
{
Task.WaitAll(processWaiter, outputReader, errorReader);
standardOutput = outputReader.Result;
standardError = errorReader.Result;
}
|
|
|
|
|
Wish I could be more helpful, Ray, but you're traveling in terra incognita for me. I was surprised I could get two-way interaction working starting-up the Console with 'AllocConsole.
Hopefully, one our deeply knowledgeable wizards will show up, soon, with the right incantations.
cheers, Bill
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
May be something like this will help:
StringBuilder returnValue = new StringBuilder();
Process P = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Codegen.exe";
p.StartInfo.Arguments = open.FileName + " 10 30";
p.Start();
p.OutputDataReceived += (o, e) =>
{
if (e.Data != null)
returnValue.AppendLine(e.Data);
};
p.ErrorDataReceived += (o, e) =>
{
if (e.Data != null)
returnValue.AppendLine(e.Data);
};
p.Start();
p.BeginOutputReadLine();
p.BeginErrorReadLine();
p.WaitForExit();
p.Close();
p.Dispose();
if (returnValue.Length > 0)
{
standardOutput = returnValue.ToString();
}
|
|
|
|
|
Harsh, thanks so much as this now works. I cant explain the difference between
p.OutputDataReceived += (o, e) =>
{
if (e.Data != null)
returnValue.AppendLine(e.Data);
};
and what I tried before which was using a separate handler assigned to OutputDataReceived.
Is your code different from
sortProcess.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler);
private static void SortOutputHandler(object sendingProcess,
DataReceivedEventArgs outLine)
{
}
However your code works so thanks very much
Regards
Ray
|
|
|
|
|
I am glad that it worked for you.
Basically your code and mine is almost same. While your code is creating explicitly named event handler, mine creates anonymous function.
I think the difference is that I am capturing the stdErr output to the string variable as well.
|
|
|
|
|
i want to show the selected cheakbok values from one grid view to another grid view in windows form.
|
|
|
|
|
Fine, that is what you want to do, but you will need to explain in more detail why you cannot do it.
|
|
|
|
|
private void cheakbox_Load(object sender, EventArgs e)
{
con = new SqlConnection("Data Source=(local);Initial Catalog=vediocon;Integrated Security=True");
con.Open();
string s = "Select Date,DealerCode,AmounTransfer,ActualAmount,TransactionCode from [Transaction]where TransactionType='PBT' order by TransactionId desc";
cmd = new SqlCommand(s, con);
SqlDataReader reader = cmd.ExecuteReader();
DataTable dt = new DataTable();
dt.Load(reader);
dataGridView1.DataSource = dt;
DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
dataGridView1.Columns.Add(chk);
chk.HeaderText = "Check Data";
chk.Name = "chk";
// dataGridView1.Rows[0].Cells[1].Value = true;
}
private void btnupload_Click(object sender, EventArgs e)
{
int RowNo = 0;
foreach (DataGridViewRow row in dataGridView1.Rows)
{
RowNo = RowNo + 1;
bool Checkbox = ((CheckBox)row.FindControl("CheckBox1")).Checked;
if (Checkbox = true)
{
// Perform copy...
}
}
Logic to seclect the row..i m new so help me in this..thnks in advance!!
|
|
|
|
|
Keshav Shivhare wrote: // Perform copy. You need a reference to the other DataGridView, and you know the row and column,
so it's just a matter of setting the checkbox in that grid to the correct value.
|
|
|
|
|
i have done by using temp table..but i want to directly in the gridview...can you send me sample code.
|
|
|
|
|
In Datagridview you can use CellClick event and CellContentClick.Usign this event you can get the current clicked cell value and check for your checkbox checked.if its checked you can set the value to another datagridview.
Check my article related to datagridview helperclass.hope it might usefull for you.
DataGridView-Helper-Class
|
|
|
|
|
private void btnupload_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Cells[5].Value!=null)
{
if ((Boolean)row.Cells[5].Value == true)
{
con = new SqlConnection("Data Source=(local);Initial Catalog=vediocon;Integrated Security=True");
con.Open();
string s = "insert into Temptransaction (date,dealercode,amounttranfer,actualamount,transactioncode)values'" + row.Cells[1].ToString() + "','" + row.Cells[2].ToString() + "','" + row.Cells[3].ToString() + "','" + row.Cells[4].ToString() + "','" + row.Cells[5].ToString() + "'";
cmd = new SqlCommand(s, con);
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
query in which i m trying to extract the though cell value and store in the temp table gives the error.
|
|
|
|
|