///<summary>Called after file is downloaded. Throws exceptions.</summary> //public static void ImportAdministrativeSex(string tempFileName) ... not necessary. ///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportCdcrec(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Cdcrecs.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayCDCREC; Cdcrec cdcrec=new Cdcrec(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arrayCDCREC=lines[i].Split('\t'); if(codeHash.Contains(arrayCDCREC[0])) {//code already existed continue; } cdcrec.CdcrecCode =arrayCDCREC[0]; cdcrec.HeirarchicalCode =arrayCDCREC[1]; cdcrec.Description =arrayCDCREC[2]; Cdcrecs.Insert(cdcrec); } }
protected virtual void OnProgress (long position, long duration) { ProgressHandler handler = Progress; if (handler != null) { ProgressArgs args = new ProgressArgs(); args.Position = position; args.Duration = duration; handler (this, args); } }
///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportIcd9(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } //Customers may have an old codeset that has a truncated uppercase description, if so we want to update with new descriptions. bool IsOldDescriptions=ICD9s.IsOldDescriptions(); HashSet<string> codeHash=new HashSet<string>(ICD9s.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayICD9; ICD9 icd9=new ICD9(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arrayICD9=lines[i].Split('\t'); if(codeHash.Contains(arrayICD9[0])) {//code already exists if(!IsOldDescriptions) { continue;//code exists and has updated description } string command="UPDATE icd9 SET description='"+POut.String(arrayICD9[1])+"' WHERE ICD9Code='"+POut.String(arrayICD9[0])+"'"; Db.NonQ(command); continue;//we have updated the description of an existing code. } icd9.ICD9Code =arrayICD9[0]; icd9.Description=arrayICD9[1]; ICD9s.Insert(icd9); } }
///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportIcd10(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Icd10s.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayICD10; Icd10 icd10=new Icd10(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arrayICD10=lines[i].Split('\t'); if(codeHash.Contains(arrayICD10[0])) {//code already exists continue; } icd10.Icd10Code =arrayICD10[0]; icd10.Description =arrayICD10[1]; icd10.IsCode =arrayICD10[2]; Icd10s.Insert(icd10); } }
///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportHcpcs(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Hcpcses.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayHCPCS; Hcpcs hcpcs=new Hcpcs(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arrayHCPCS=lines[i].Split('\t'); if(codeHash.Contains(arrayHCPCS[0])) {//code already exists continue; } hcpcs.HcpcsCode =arrayHCPCS[0]; hcpcs.DescriptionShort =arrayHCPCS[1]; Hcpcses.Insert(hcpcs); } }
private void MainFrm_Load(object sender, EventArgs e) { //版本号 this.Text = String.Format("串口升级工具 V{0}", AssemblyFileVersion()); mTaskParam = new TaskParameters(); mSerialParam = new SerialPortParameter(); mPcuItem = new ListViewItem(); mPcuItem.UseItemStyleForSubItems = false; mCcuItem = new ListViewItem(); mCcuItem.UseItemStyleForSubItems = false; //加载配置文件 LoadSetting(); mTaskManager = new TaskManager(mTaskParam); //设置参数 ccuProgressBar.Value = 0; ccuProgressBar.Maximum = 100; pcuProgressBar.Value = 0; pcuProgressBar.Maximum = 100; mTaskManager.ccuProgressBarHandler += (object _sender, EventArgs _e) => { ProgressArgs mArgs = _e as ProgressArgs; if (mArgs != null) { UpdateCcuProgressBar(mArgs.percentage); } }; mTaskManager.pcuProgressBarHandler += (object _sender, EventArgs _e) => { ProgressArgs mArgs = _e as ProgressArgs; if (mArgs != null) { UpdatePcuProgressBar(mArgs.percentage); } }; mTaskManager.ccuListViewItemHandler += (object _sender, EventArgs _e) => { TaskArgs mArgs = _e as TaskArgs; if (mArgs != null) { UpdateCcuItems(mArgs.msg, mArgs.level); } }; mTaskManager.pcuListViewItemHandler += (object _sender, EventArgs _e) => { TaskArgs mArgs = _e as TaskArgs; if (mArgs != null) { UpdatePcuItems(mArgs.msg, mArgs.level); } }; CcuTimeCounts = 0; CcuTestTimeTicker = new System.Timers.Timer(1000); CcuTestTimeTicker.Enabled = false; CcuTestTimeTicker.Elapsed += new ElapsedEventHandler((object source, ElapsedEventArgs ElapsedEventArgs) => { CcuTimeCounts++; SetTimeTicker(Devices.CCU, CcuTimeCounts); }); PcuTimeCounts = 0; PcuTestTimeTicker = new System.Timers.Timer(1000); PcuTestTimeTicker.Enabled = false; PcuTestTimeTicker.Elapsed += new ElapsedEventHandler((object source, ElapsedEventArgs ElapsedEventArgs) => { PcuTimeCounts++; SetTimeTicker(Devices.PCU, PcuTimeCounts); }); string msg = String.Format("当前串口:{0} ", Const.COM_PORT); UpdateStatusBar(0, msg, ""); this.toolStripBtn_Stop.Enabled = false; }
///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportSop(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Sops.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arraySop; Sop sop=new Sop(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arraySop=lines[i].Split('\t'); if(codeHash.Contains(arraySop[0])) {//code already exists continue; } sop.SopCode =arraySop[0]; sop.Description =arraySop[1]; Sops.Insert(sop); } }
static void ProgressHandler(object sender, ProgressArgs e) { Console.Write($"\r{e.Percentage}% ... "); }
public void ReportProgress(ProgressArgs progress) { Clients.All.updateProgress(progress); }
/// <summary> /// Updates the Progress Window based on a <see cref="ProgressArgs"/> /// </summary> /// <param name="arg"></param> public void Update(ProgressArgs arg) { ViewModel.Update(arg); }
/// <summary> /// Represents the method that will be called to update the current /// step's precent complete value. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">A <see cref="ProgressArgs" /> that contains the event data.</param> private void OnDocBuildingProgress(object sender, ProgressArgs e) { Log(Level.Verbose, e.Progress + ResourceUtils.GetString("String_PercentageComplete")); }
protected virtual void OnProgressChanged(ProgressArgs e) { this.ProgressChanged?.Invoke(this, e); }
private void ReportComplete() { ProgressArgs args = new ProgressArgs("Completed Task.", true, 0); ReportProgress?.Invoke(this, args); }
private void Upload() { StartUpload(); this.Dispatcher.BeginInvoke(new Action(delegate () { StringBuilder stringUploadinfo = new StringBuilder(); labelPatientInfo.Content = string.Format("{0}, {1}, {2}, {3}, {4}", PatientName, PatientSex, PatientAge, InstitutionName, acquisitionDate); stringUploadinfo.AppendFormat("正在连接服务器"); if (_lastProgress != null) { stringUploadinfo.Append(string.Format(Environment.NewLine + "【已上传:{0}/{1}】", _lastProgress.Finished.HasValue ? HumanReadableFilesize(_lastProgress.Finished.Value) : HumanReadableFilesize(0), HumanReadableFilesize(_lastProgress.Total))); } labelDownloadInfo.Content = stringUploadinfo.ToString(); })); UploadFileWorker.CreateOrderThenUploadFileThenUploadDicomInfo( filename: FileName, InstitutionName: InstitutionName, PatientAge: PatientAge, PatientName: PatientName, PatientSex: PatientSex, SeriesInstanceUID: SeriesInstanceUID, StudyInstanceUID: StudyInstanceUID, acquisitionDate: acquisitionDate, acquisitionTime: acquisitionTime, UploadTimestamp: DateTime.Now, successCallback: delegate () { this.Dispatcher.Invoke(new Action(delegate () { FinishUpload(); //MessageBox.Show("上传成功!"); Dicom成功上传 Dicom成功上传 = new Dicom成功上传(); Dicom成功上传.Owner = MainWindow.Instance; Dicom成功上传.Evt完成 += delegate { Close(); MainWindow.Instance.Switch2UploadList(); }; Dicom成功上传.Evt继续上传 += delegate { Close(); MainWindow.Instance.Switch2UploadWindowThenPopupFileSelectDialog(); }; Dicom成功上传.ShowDialog(); //this.dataGridViewFileList.DataSource = eInner.Result; })); }, failureCallback: delegate (string errMsg) { UploadErrorOccurred(); //MessageBox.Show(errMsg); if (!cancelUploadManually) { System.Threading.Thread.Sleep(5000); Upload(); } }, errorCallback: delegate (Exception ex) { UploadErrorOccurred(); //Util.ShowExceptionMessage(ex); if (!cancelUploadManually) { System.Threading.Thread.Sleep(5000); Upload(); } }, uploadProgressCallback: delegate (ProgressArgs eProgress) { this.Dispatcher.Invoke(new Action(delegate () { _lastProgress = eProgress; alreadySent = eProgress.Finished.Value; //StringBuilder stringUploadinfo = new StringBuilder(); //stringUploadinfo.AppendLine("已上传 :" + HumanReadableFilesize(eProgress.Finished.Value)); //if (eProgress.RemainTimeInMillisecond.HasValue) //{ // stringUploadinfo.AppendLine("剩余时间:" + eProgress.RemainTimeInMillisecond.Value.ToString("0.0") + " s"); //} //if (eProgress.Percentage.HasValue) //{ // stringUploadinfo.AppendLine("上传进度:" + (eProgress.Percentage.Value * 100).ToString("0.00") + " %"); //} //stringUploadinfo.AppendLine("文件大小:" + HumanReadableFilesize(eProgress.Total)); //labelDownloadInfo.Content = stringUploadinfo.ToString(); StringBuilder stringUploadinfo = new StringBuilder(); //stringUploadinfo.AppendLine(string.Format("{0} {1} {2}",PatientName,PatientSex, PatientAge)); stringUploadinfo.AppendFormat("【预计剩余时间:{0},当前速度:{3},已上传:{1}/{2}】", eProgress.RemainTimeHumanReadable, eProgress.Finished.HasValue ? HumanReadableFilesize(eProgress.Finished.Value) : HumanReadableFilesize(0), HumanReadableFilesize(eProgress.Total), eProgress.Speed.HasValue ? HumanReadableFilesize((long)eProgress.Speed.Value) + "/秒" : "未知"); labelDownloadInfo.Content = stringUploadinfo.ToString(); uploadProgress.Value = eProgress.Percentage.Value; System.Windows.Forms.Application.DoEvents(); Console.ResetColor(); stringUploadinfo.Clear(); })); } ); }
///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportLoinc(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Loincs.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayLoinc; Loinc loinc=new Loinc(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arrayLoinc=lines[i].Split('\t'); if(codeHash.Contains(arrayLoinc[0])) {//code already exists continue; } loinc.LoincCode =arrayLoinc[0]; loinc.Component =arrayLoinc[1]; loinc.PropertyObserved =arrayLoinc[2]; loinc.TimeAspct =arrayLoinc[3]; loinc.SystemMeasured =arrayLoinc[4]; loinc.ScaleType =arrayLoinc[5]; loinc.MethodType =arrayLoinc[6]; loinc.StatusOfCode =arrayLoinc[7]; loinc.NameShort =arrayLoinc[8]; loinc.ClassType =arrayLoinc[9]; loinc.UnitsRequired =arrayLoinc[10]=="Y"; loinc.OrderObs =arrayLoinc[11]; loinc.HL7FieldSubfieldID =arrayLoinc[12]; loinc.ExternalCopyrightNotice =arrayLoinc[13]; loinc.NameLongCommon =arrayLoinc[14]; loinc.UnitsUCUM =arrayLoinc[15]; loinc.RankCommonTests =PIn.Int(arrayLoinc[16]); loinc.RankCommonOrders =PIn.Int(arrayLoinc[17]); Loincs.Insert(loinc); } }
void InstallProgress(object sender, ProgressArgs args) { OnProgress(args.TotalCount, args.TotalPercent, args.CurrentIndex, args.CurrentPercent, args.Info); }
///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportRxNorm(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(RxNorms.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayRxNorm; RxNorm rxNorm=new RxNorm(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arrayRxNorm=lines[i].Split('\t'); if(codeHash.Contains(arrayRxNorm[0])) {//code already exists continue; } rxNorm.RxCui =arrayRxNorm[0]; rxNorm.MmslCode =arrayRxNorm[1]; rxNorm.Description =arrayRxNorm[2]; RxNorms.Insert(rxNorm); } }
///<summary>Called after file is downloaded. Throws exceptions.</summary> //public static void ImportCDT(string tempFileName) ... not necessary. ///<summary>Called after user provides resource file. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportCpt(string tempFileName,ProgressArgs progress,ref bool quit,ref int numCodesImported,string versionID) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Cpts.GetAllCodes()); Regex regx=new Regex(@"^([\d]{4}[\d\w])\s+(.+?)$");//Regex = "At the beginning of the string, find five numbers, followed by a white space (tab or space) followed by one or more characters (but as few as possible) to the end of the line." string[] lines=File.ReadAllLines(tempFileName); string[] arrayCpt; bool isHeader=true; Cpt cpt=new Cpt(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } if(isHeader) { if(!regx.IsMatch(lines[i])) { //if(!lines[i].Contains("\t")) { continue;//Copyright info is present at the head of the file. } isHeader=false; } arrayCpt=new string[2]; arrayCpt[0]=regx.Match(lines[i]).Groups[1].Value;//First five alphanumeric characters arrayCpt[1]=regx.Match(lines[i]).Groups[2].Value;//Everything after the 6th character if(codeHash.Contains(arrayCpt[0])) {//code already exists Cpts.UpdateDescription(arrayCpt[0],arrayCpt[1],versionID); } else { cpt.CptCode =arrayCpt[0]; cpt.Description =arrayCpt[1]; cpt.VersionIDs =versionID; Cpts.Insert(cpt); numCodesImported++; } } }
///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportUcum(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Ucums.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayUcum; Ucum ucum=new Ucum(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arrayUcum=lines[i].Split('\t'); if(codeHash.Contains(arrayUcum[0])) {//code already exists continue; } ucum.UcumCode =arrayUcum[0]; ucum.Description =arrayUcum[1]; ucum.IsInUse =false; Ucums.Insert(ucum); } }
///<summary>Called after file is downloaded. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportCvx(string tempFileName,ProgressArgs progress,ref bool quit,ref int numCodesImported) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Cvxs.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayCvx; Cvx cvx=new Cvx(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } arrayCvx=lines[i].Split('\t'); if(codeHash.Contains(arrayCvx[0])) {//code already exists continue; } cvx.CvxCode =arrayCvx[0]; cvx.Description =arrayCvx[1]; Cvxs.Insert(cvx); numCodesImported++; } }
///<summary>Called after file is downloaded. Throws exceptions.</summary> //public static void ImportCDT(string tempFileName) ... not necessary. ///<summary>Called after user provides resource file. Throws exceptions. It is assumed that this is called from a worker thread. Progress delegate will be called every 100th iteration to inform thread of current progress. Quit flag can be set at any time in order to quit importing prematurely.</summary> public static void ImportCpt(string tempFileName,ProgressArgs progress,ref bool quit) { if(tempFileName==null) { return; } HashSet<string> codeHash=new HashSet<string>(Cpts.GetAllCodes()); string[] lines=File.ReadAllLines(tempFileName); string[] arrayCpt; bool isHeader=true; Cpt cpt=new Cpt(); for(int i=0;i<lines.Length;i++) {//each loop should read exactly one line of code. and each line of code should be a unique code if(quit) { return; } if(i%100==0) { progress(i+1,lines.Length); } if(isHeader) { if(!lines[i].Contains("\t")) { continue;//Copyright info is present at the head of the file. } isHeader=false; } arrayCpt=lines[i].Split('\t'); if(codeHash.Contains(arrayCpt[0])) {//code already exists continue; } cpt.CptCode =arrayCpt[0]; cpt.Description =arrayCpt[1]; Cpts.Insert(cpt); } }
public void OnProgress(object sender, ProgressArgs e) { Dispatcher.Invoke(() => ((ProgressControl)State).UpdateSize(e.Key, e.ProcessedSize, e.TotalSize)); }