|
I am creating a C# windows application. The processes are listed in a listview as subitems. How do i get a processes start time and duraion it has been running?
|
|
|
|
|
BenchMarkDotNet, open-source: [^]
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
If you have a list of Process Class (System.Diagnostics)[^] components, just use the provided properties like StartTime , ExitTime , TotalProcessorTime , and UserProcessorTime . These can be used to calculate the run time (current time resp. exit time minus start time) and the kernel processor time (total processor time minus user processor time).
Note that you have to call Refresh() to get actual values and should check if the process is still running when the list has been created some time ago.
|
|
|
|
|
is there any code to visual studio that till the sql table is updated the button doesnot get visible in web form
<asp:button id="Button1" runat="server" text="Your Quortation Is Ready Click Here" visible="false" cssclass="btn btn-danger" onclick="Button1_Click">
i want code for this button
plz help
|
|
|
|
|
Member 13870544 wrote: is there any code to visual studio Yes.
Member 13870544 wrote: i want code for this button Hire a programmer or learn to code. Learning would probably go quicker, it's not that hard to hide or show a button.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
You just mentioned the code for button but you need to share what have you tried to hide it if that code is not working.
modified 20-Sep-20 21:01pm.
|
|
|
|
|
How much is a Quortation?
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
On the open market, they can run as high as $125, so try to find them on the black market if possible. That's where you'll find an object's true worth.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
use asynchronous calls, disable button until the call being processed
|
|
|
|
|
Good day, I need to do Something like this https://youtu.be/ecvunlsNm9k But Instead Of using tables, using textboxes In one form, and with different Files, let me explain you with an example: In Form 1, There are 2 Textboxes, and 1 button that button opens a file like in the video, but with the difference that can open different Files (Ex. File A and file B) like File A in one Textbox and File B in the second one. What I Have Tried I've tried doing a list in the application settings of type file, and when the form 1 loads do a for each loop like foreach (File in List) //Deserialize file in List But it doesn't allow me to do lists with 'file' type. Thanks. Update And what if I save Two strings in a XML file, and let's say that now there are 4 textboxes, 2 for file a and another 2 for file B, how can I deserialize that info and place it into that textboxes?
|
|
|
|
|
You cannot create a List<File> because the File Class (System.IO)[^] contains only static methods, you cannot instantiate a File object. But you could create a list of filenames that you wish to use. As to deserialising multiple XML files, there is no good reason why it would not work.
|
|
|
|
|
Thanks, but any idea of how could I create that list?
|
|
|
|
|
|
PS: Mi code is the same code of the video
|
|
|
|
|
I also have this question posted on Unity as well, but I figured that branching out for answers wouldn't be a bad thing.
Unity is primarily a Game Engine, but I am using it to make a non-game app. What I essentially need to have happen is that I take in a email, parse it- pick and choose what I need out of it, then send and display another email as well as display graphically that edited version.
As of right now, I am using EAGetMail library to try and keep track of the messages and then I am hoping I can access them while the "game" (application) is running. I know that Unity has a way of sending out emails obviously, as developers want to send out surveys and vital information, but as far as receiving those emails during game runtime, that seems like a big stretch and there is probably an easier way to do this.
If you have any information that would be helpful! Looking for ideas and concepts and maybe a little example code.
|
|
|
|
|
Things will make a lot more sense if you first create a console or windows app to "test" the "email logic".
It shouldn't be that hard to integrate "emails" into Unity; the fact that you are asking the question means:
1) You do not understand Unity "scripts"
2) You do not know how to "partition / package" code properly
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
0
down vote
favorite
I need to write a code in script component in SSIS that will move files to corresponding folders. Files that I'm getting are usually named, for example "Dem323_04265.45.23.4", "Dem65_459.452.56", "Ec2345_456.156.7894" and I need to move them to a corresponding folders. The name of my folders are "Oklahoma City (323)", "New York(65)".. I need to move those files to matching folders, so for example "Dem323_04265.45.23.4" would go to folder "Oklahoma City (323)". I need to modify my code so the number that is located between first two or three letter and underline matches number located in parenthesis. I've been working on this for several days already and I'm new with ssis and c#, so any help would be appreciated. This is the code I have so far:
public void Main()
{
string filename;
// string datepart;
bool FolderExistFlg;
filename = Dts.Variables["User::FileName"].Value.ToString();
// datepart = (filename.Substring(filename.Length - 12)).Substring(0, 8);
var folderNumber = Regex.Match(
filename,
//Dts.Variables["OutputMainFolder"].Value.ToString(),
@"\(([^)]*)\)").Groups[1].Value;
FolderExistFlg = Directory.Exists(Dts.Variables["OutputMainFolder"].Value.ToString() + "\\" + folderNumber);
if (!FolderExistFlg)
{
Directory.CreateDirectory(Dts.Variables["OutputMainFolder"].Value.ToString() + "\\" + folderNumber);
}
File.Move(Dts.Variables["SourceFolder"].Value.ToString() + "\\" + filename + "\\" + folderNumber,
Dts.Variables["OutputMainFolder"].Value.ToString() + "\\" + filename);
Dts.TaskResult = (int)ScriptResults.Success;
}
#region ScriptResults declaration
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
}
}
|
|
|
|
|
Most of us here can't read your mind: is your code not compiling, or crashing: what are the error messages, and where do they occur ?
If it's not crashing, set breakpoints, and examine the state of inputs, outputs, and variables: describe the places where "state" is not what you expect it to be.
Details, details, details.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
So what exact error you are facing on this code? You can debug and share that specific information
modified 20-Sep-20 21:01pm.
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using HtmlAgilityPack;
using System.Net;
using System.IO;
namespace DocumentosSubsidios.Infrastructure.RobotBase
{
public abstract class BaseRoboAddress
{
public enum EncodingEnum
{
Default,
UTF8,
ASCII,
ISO_8859_1,
ANSICodePage
}
public BaseRoboAddress() { }
public BaseRoboBaseRoboAddress(WebClientSession webClientSession)
{
this._webClientSession = webClientSession;
}
public delegate void MyMethodInvoker<T>(T t);
public event MyMethodInvoker<string> ResultRequest;
#region [Membros Privados]
private CredentialCache _credentialCache;
private WebClientSession _webClientSession;
private CookieCollection _cookies = null;
private HtmlNodeCollection _inputs = null;
#endregion
#region [Propriedades]
public WebClientSession WebClientSession
{
get
{
if (_webClientSession == null) _webClientSession = new WebClientSession();
return _webClientSession;
}
set
{
_webClientSession = value;
}
}
private CredentialCache mCredentialCache
{
get
{
if (_credentialCache == null) _credentialCache = new CredentialCache();
return _credentialCache;
}
set
{
_credentialCache = value;
}
}
public CookieCollection Cookies
{
get
{
if (_cookies == null)
_cookies = new CookieCollection();
return _cookies;
}
set { _cookies = value; }
}
public HtmlNodeCollection Inputs
{
get
{
if (_inputs == null)
_inputs = new HtmlNodeCollection(null);
return _inputs;
}
set { _inputs = value; }
}
#endregion
#region [Métodos Publicos]
public virtual HtmlDocument Get(string url)
{
return this.Get(url, false, EncodingEnum.UTF8);
}
public HtmlDocument Get(string url, EncodingEnum encoding)
{
return this.Get(url, false, encoding);
}
public HtmlDocument Get(string url, bool fire, EncodingEnum encoding)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
byte[] pagina = this.WebClientSession.DownloadData(url);
switch (encoding)
{
case EncodingEnum.UTF8:
htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ASCII:
htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.Default:
htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ISO_8859_1:
htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
break;
}
return htmlDocument;
}
public HtmlDocument Post(string url, NameValueCollection parametros, bool fire)
{
return this.Post(url, parametros, fire, EncodingEnum.UTF8);
}
public HtmlDocument Post(string url, NameValueCollection parametros, EncodingEnum encoding)
{
return this.Post(url, parametros, true, encoding);
}
public HtmlDocument Post(string url, NameValueCollection parametros)
{
return this.Post(url, parametros, true);
}
public HtmlDocument Post(string url, NameValueCollection parametros, bool fire, EncodingEnum encoding)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
byte[] pagina = this.WebClientSession.UploadValues(url, parametros);
switch (encoding)
{
case EncodingEnum.Default:
htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.UTF8:
htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ASCII:
htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ISO_8859_1:
htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
break;
}
return htmlDocument;
}
public byte[] PostBinario(string url, NameValueCollection parametros)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
return this.WebClientSession.UploadValues(url, parametros);
}
public HtmlDocument PostData(string url, IEnumerable<byte> IBody, bool fire)
{
lock (this)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
byte[] pagina = this.WebClientSession.UploadData(url, "POST", IBody.ToArray());
htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
return htmlDocument;
}
}
public HtmlDocument PostData(string url, IEnumerable<byte> IBody)
{
return this.PostData(url, IBody, true);
}
public HtmlDocument PostData(string url, IEnumerable<byte> IBody, EncodingEnum encoding)
{
lock (this)
{
byte[] pagina = this.WebClientSession.UploadData(url, "POST", IBody.ToArray());
HtmlDocument htmlDocument = LoadHtmlDocument(encoding, pagina);
return htmlDocument;
}
}
private HtmlDocument LoadHtmlDocument(EncodingEnum encoding, byte[] pagina)
{
HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
switch (encoding)
{
case EncodingEnum.Default:
htmlDocument.LoadHtml(Encoding.Default.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.UTF8:
htmlDocument.LoadHtml(Encoding.UTF8.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ASCII:
htmlDocument.LoadHtml(Encoding.ASCII.GetString(pagina, 0, pagina.Count()));
break;
case EncodingEnum.ISO_8859_1:
htmlDocument.LoadHtml(Encoding.GetEncoding("ISO-8859-1").GetString(pagina, 0, pagina.Count()));
break;
}
return htmlDocument;
}
|
|
|
|
|
Correct. It won't.
Now, what would you like us to do about it?
If you have compiler errors, tell us what they are. It makes our lives a whole load easier...
You are missing a #endregion directive, and two close curly brackets, and your parameterized constructor is misspelt:
public BaseRoboBaseRoboAddress(WebClientSession webClientSession)
{
this._webClientSession = webClientSession;
}
Just reading the error messages would have told you that - and fixing them is trivial.
public BaseRoboAddress(WebClientSession webClientSession)
{
this._webClientSession = webClientSession;
}
Sent from my Amstrad PC 1640
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Thanks for the help. The problem was even in the constructor
|
|
|
|
|
You're welcome!
Sent from my Amstrad PC 1640
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Nice! "Getters" that update properties ...
Why didn't I think of that.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thanks for the help. The problem was even in the constructor
|
|
|
|
|