bool ExportPeople(Lib.XmlExporter xml, Data.IInvoice pool, int count) { if (!xml.OK) { return(false); } xml.Writer.WriteStartElement("PERS_LIST"); xml.Writer.WriteStartElement("ZGLV"); xml.Writer.WriteElementString("VERSION", VERSION_PEOPLE); xml.Writer.WriteElementString("DATA", DateTime.Today.AsXml()); xml.Writer.WriteElementString("FILENAME", invoiceFilename.PersonFile); xml.Writer.WriteElementString("FILENAME1", invoiceFilename.InvoiceFile); xml.Writer.WriteEndElement(); Lib.Progress progress = new Progress("Пациенты", count); foreach (Person p in pool.LoadPeople(invoiceFilename.Section, invoiceFilename.Subsection)) { p.Write(xml, pool, invoiceFilename.Section); progress.Step(); #if DEBUG if (--count <= 0) { break; } #endif } progress.Close(); xml.Writer.WriteEndElement(); return(true); }
private void button_backup_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult result = fbd.ShowDialog(); if (result == DialogResult.OK) { int lastFoo = (int)Enum.GetValues(typeof(ECRComms.program)).Cast<ECRComms.program>().Last(); for (int p = 0; p <= lastFoo; p++) { Progress pr = new Progress(Program.ecr); pr.Show(); string name = ((ECRComms.program)p).ToString(); data = Program.ecr.getprogram((ECRComms.program)p); pr.Close(); try { writedata(data.ToArray(), Path.Combine(fbd.SelectedPath, name + ".dat")); } catch (Exception _Exception) { Console.WriteLine("Exception caught saving file{0}", _Exception.ToString()); } } } }
public override bool make(List <Object> objects) { m_objects = objects; Progress progressForm = new Progress(); progressForm.Cancel += new Progress.EventHandlerCancel(onFormCancel); Started += new EventHandlerStart(progressForm.onStarted); Progress += new EventHandlerProgress(progressForm.onProgress); ProgressA += new EventHandlerProgressA(progressForm.onProgressA); ProgressB += new EventHandlerProgressB(progressForm.onProgressB); Finished += new EventHandlerFinish(progressForm.onFinished); m_worker = new System.Threading.Thread(new System.Threading.ThreadStart(worker)); progressForm.Shown += new EventHandler(onDialogShown); progressForm.ShowDialog(); m_worker.Join(); progressForm.Close(); return(true); }
/// <summary> /// Have the utility do what it does. /// </summary> public void Export(string outFullName) { Common.SetupLocalization(); Debug.Assert(DataType == "Scripture" || DataType == "Dictionary", "DataType must be Scripture or Dictionary"); Debug.Assert(outFullName.IndexOf(Path.DirectorySeparatorChar) >= 0, "full path for output must be given"); string caption = LocalizationManager.GetString("PsExport.ExportClick.Caption", "Pathway Export", ""); try { pb = new Progress(); //get xsltFile from ExportThroughPathway.cs XsltPreProcess(outFullName); string supportPath = GetSupportPath(); Backend.Load(Common.ProgInstall); LoadProgramSettings(supportPath); LoadDataTypeSettings(); var outDir = Path.GetDirectoryName(outFullName); DefaultProjectFileSetup(outDir); SubProcess.BeforeProcess(outFullName); var mainXhtml = Path.GetFileNameWithoutExtension(outFullName) + ".xhtml"; var mainFullName = Common.PathCombine(outDir, mainXhtml); Debug.Assert(mainFullName.IndexOf(Path.DirectorySeparatorChar) >= 0, "Path for input file missing"); if (string.IsNullOrEmpty(mainFullName) || !File.Exists(mainFullName)) { var msg = new[] { "Input File(main.xhtml) is not Found" }; LocDB.Message("errFnFound", "Input File(main.xhtml) is not Found.", msg, LocDB.MessageTypes.Error, LocDB.MessageDefault.First); return; } string cssFullName = GetCssFullName(outDir, mainFullName); if (cssFullName == null) return; SetPageCenterTitle(cssFullName); _selectedCssFromTemplate = Path.GetFileNameWithoutExtension(cssFullName); string fluffedCssFullName; string revFileName = string.Empty; if (Path.GetFileNameWithoutExtension(outFullName) == "FlexRev") { fluffedCssFullName = GetFluffedCssFullName(GetRevFullName(outFullName), outDir, cssFullName); } else { fluffedCssFullName = GetFluffedCssFullName(outFullName, outDir, cssFullName); revFileName = GetRevFullName(outDir); } string fluffedRevCssFullName = string.Empty; if (revFileName.Length > 0) { fluffedRevCssFullName = GetFluffedCssFullName(revFileName, outDir, cssFullName); } DestinationSetup(); SetDefaultLanguageFont(fluffedCssFullName, mainFullName, fluffedRevCssFullName); Common.StreamReplaceInFile(fluffedCssFullName, "\\2B27", "\\25C6"); if (DataType == "Scripture") { SeExport(mainXhtml, Path.GetFileName(fluffedCssFullName), outDir); } else if (DataType == "Dictionary") { string revFullName = GetRevFullName(outDir); DeExport(outFullName, fluffedCssFullName, revFullName, fluffedRevCssFullName); } } catch (InvalidStyleSettingsException err) { if (_fromNUnit) { Console.WriteLine(string.Format(err.ToString(), err.FullFilePath), "Pathway Export"); } else { Utils.MsgBox(string.Format(err.ToString(), err.FullFilePath), caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } catch (UnauthorizedAccessException err) { if (_fromNUnit) { Console.WriteLine(string.Format(err.ToString(), "Sorry! You might not have permission to use this resource.")); } else { var msg = LocalizationManager.GetString("PsExport.ExportClick.Message", "Sorry! You might not have permission to use this resource.", ""); Utils.MsgBox(string.Format(err.ToString(), msg), caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } catch (Exception ex) { if (_fromNUnit) { Console.WriteLine(ex.ToString()); } else { if (ex.ToString().IndexOf("Module1.xml") == -1) { Utils.MsgBox(ex.ToString(), caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } return; } finally { if (pb != null) { pb.Close(); } } }
private void ImportIntoLibrary_OnClick(object sender, RoutedEventArgs e) { string module = $"{_product}.{_class}.{MethodBase.GetCurrentMethod().Name}()"; Globals.Chem4WordV3.Telemetry.Write(module, "Action", "Triggered"); try { if (Globals.Chem4WordV3.LibraryNames == null) { Globals.Chem4WordV3.LoadNamesFromLibrary(); } int fileCount = 0; StringBuilder sb; // Start with V2 Add-In data path string importFolder = Path.Combine(Globals.Chem4WordV3.AddInInfo.AppDataPath, @"Chemistry Add-In for Word"); if (Directory.Exists(importFolder)) { if (Directory.Exists(Path.Combine(importFolder, "Chemistry Gallery"))) { importFolder = Path.Combine(importFolder, "Chemistry Gallery"); } } else { importFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); } if (Directory.Exists(importFolder)) { // Fix scrolling to selected item by using code from https://social.msdn.microsoft.com/Forums/expression/en-US/1257aebc-22a6-44f6-975b-74f5067728bc/autoposition-showfolder-dialog?forum=vbgeneral VistaFolderBrowserDialog browser = new VistaFolderBrowserDialog(); browser.Description = "Select a folder to import cml files from"; browser.UseDescriptionForTitle = true; browser.RootFolder = Environment.SpecialFolder.Desktop; browser.ShowNewFolderButton = false; browser.SelectedPath = importFolder; Forms.DialogResult dr = browser.ShowDialog(); if (dr == Forms.DialogResult.OK) { string selectedFolder = browser.SelectedPath; string doneFile = Path.Combine(selectedFolder, "library-import-done.txt"); sb = new StringBuilder(); sb.AppendLine("Do you want to import the Gallery structures into the Library?"); sb.AppendLine("(This cannot be undone.)"); dr = UserInteractions.AskUserYesNo(sb.ToString()); if (dr == Forms.DialogResult.Yes) { if (File.Exists(doneFile)) { sb = new StringBuilder(); sb.AppendLine($"All files have been imported already from '{selectedFolder}'"); sb.AppendLine("Do you want to rerun the import?"); dr = UserInteractions.AskUserYesNo(sb.ToString()); if (dr == Forms.DialogResult.Yes) { File.Delete(doneFile); } } } if (dr == Forms.DialogResult.Yes) { Progress pb = new Progress(); try { var xmlFiles = Directory.GetFiles(selectedFolder, "*.cml"); pb.Maximum = xmlFiles.Length; pb.TopLeft = new Point(TopLeft.X + Constants.TopLeftOffset, TopLeft.Y + Constants.TopLeftOffset); pb.Show(); foreach (string cmlFile in xmlFiles) { pb.Message = cmlFile.Replace(selectedFolder, "."); pb.Increment(1); var cml = File.ReadAllText(cmlFile); var lib = new Database.Library(); if (lib.ImportCml(cml)) { fileCount++; } } pb.Hide(); pb.Close(); File.WriteAllText(doneFile, $"{fileCount} cml files imported into library"); FileInfo fi = new FileInfo(doneFile); fi.Attributes = FileAttributes.Hidden; Globals.Chem4WordV3.LoadNamesFromLibrary(); UserInteractions.InformUser($"Successfully imported {fileCount} structures from '{selectedFolder}'."); } catch (Exception ex) { pb.Hide(); pb.Close(); new ReportError(Globals.Chem4WordV3.Telemetry, TopLeft, module, ex).ShowDialog(); } } } } } catch (Exception ex) { new ReportError(Globals.Chem4WordV3.Telemetry, TopLeft, module, ex).ShowDialog(); } }
private void FillGrid() { lock (lockReadWrite) { // Progress bar for loading the items in the event log Progress progress = null; // Reset the counters for event log types ResetCounters(); //// Show the progress bar only if the event log is not on the local machine //if (!((log.MachineName == ".") || (log.MachineName == System.Net.Dns.GetHostName()))) //{ progress = new Progress(); progress.Show(); progress.btnCancel.Click += new EventHandler(Progress_Cancel_Click); //} Application.DoEvents(); this.Cursor = Cursors.WaitCursor; try { dgEvents.SelectionChanged -= dgEvents_SelectionChanged; DataSet currentEntries = null; // Retrieve the Event Log Entries via WMI using (ManagementObjectCollection entries = GetEvents()) { currentEntries = BuildDataSet(entries, progress); } // The request was cancelled if (currentEntries == null) { return; } if (bindingSource == null) { bindingSource = new BindingSource(currentEntries, "Entries"); } else { bindingSource.DataSource = currentEntries; } UpdateBindingSourceFilter(); dgEvents.DataSource = bindingSource; dgEvents.Refresh(); UpdateCounterButtons(); dgEvents.SelectionChanged += dgEvents_SelectionChanged; } catch (Exception ex) { MessageBox.Show("Exception caught : " + ex.ToString(), "EventLog Viewer", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; if (progress != null) { progress.Close(); } this.Focus(); } } }
private static void ShutDownProgress(Progress pb) { pb.Value = 0; pb.Hide(); pb.Close(); }
private void bildSpeichernToolStripMenuItem_Click(object sender, EventArgs e) { Tuple<string, string> data = (Tuple<string, string>)pictureBox1.Tag; string filetype = string.Empty; switch (data.Item1) { case "image/jpeg": case "image/jpg": filetype = "jpg"; break; } if (data.Item2.StartsWith("http")) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = string.Format("*.{0}|*.{0}", filetype); GedcomIndividual individual = (GedcomIndividual)familyTreeView.SelectedNode.Tag; sfd.FileName = individual.Name.ToString(); if (sfd.ShowDialog() == DialogResult.OK) { Progress progress = new Progress(); progress.Show(); WebClient client = new WebClient(); string tmpFile = string.Concat(Path.GetTempFileName(), filetype); client.DownloadProgressChanged += (x, args) => { progress.ReportProgress(args.ProgressPercentage); progress.ReportProgress(string.Format("{0} of {1}", args.BytesReceived.FormatBytes(), args.TotalBytesToReceive.FormatBytes())); }; client.DownloadFileCompleted += (y, args) => { progress.Close(); }; client.DownloadFileAsync(new Uri(data.Item2), sfd.FileName); } } }
private void zuXMLToolStripMenuItem_Click(object sender, EventArgs e) { if (this.file != null) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "XML-Datei (*.xml)|*.xml"; if (sfd.ShowDialog() == DialogResult.OK) { Progress progress = new Progress(); progress.Show(); progress.ReportProgress(40); GedcomReader.ToXml(this.filename).Save(sfd.FileName); progress.ReportProgress(100); progress.Close(); } } }
private void LoadFile(string filename) { this.filename = filename; this.Enabled = false; Progress progress = new Progress(); progress.Canceled += Progress_Canceled; progress.Show(); familyTreeView.Nodes.Clear(); progress.ReportProgress(2); this.file = GedcomReader.ToGedcomFile(filename); progress.ReportProgress(5); double increaseValue = (double)95 / file.Families.Count; double currentValue = 5; foreach (GedcomFamily family in file.Families) { if (this.progressCanceled) break; if (family.Children.Count == 0) progress.ReportProgress(string.Concat("Load family ", family.Identifier)); TreeNode famNode = new TreeNode("Familie") { ImageIndex = 3, SelectedImageIndex = 3 }; TreeNode husband = new TreeNode() { ImageIndex = 1, SelectedImageIndex = 1, Tag = family.Husband }; husband.Text = family.Husband != null ? family.Husband.Name.ToString() : string.Empty; TreeNode wife = new TreeNode() { ImageIndex = 0, SelectedImageIndex = 0, Tag = family.Wife }; wife.Text = family.Wife != null ? family.Wife.Name.ToString() : string.Empty; famNode.Nodes.AddRange(new TreeNode[] { husband, wife }); DateTime marriage = new DateTime(); if (family.Marriage != null && family.Marriage.Date?.Content != null && DateTime.TryParse(family.Marriage.Date.Content, out marriage)) famNode.Nodes.Add(Guid.NewGuid().ToString(), "Heirat: " + marriage.ToShortDateString(), 2, 2); if (family.Children.Count > 0) { progress.ReportProgress(string.Concat("Load family ", family.Identifier, " (", family.Children.Count, " children)")); TreeNode children = new TreeNode("Kinder") { ImageIndex = 3, SelectedImageIndex = 3 }; children.Nodes.AddRange(family.Children.Select(p => new TreeNode(p.Name.ToString() ) { ImageIndex = p.Sex.Content.ToLower().Equals("m") ? 1 : 0, SelectedImageIndex = p.Sex.Content.ToLower().Equals("m") ? 1 : 0, Tag = p }).ToArray()); famNode.Nodes.Add(children); } familyTreeView.Nodes.Add(famNode); progress.ReportProgress((int)currentValue); Application.DoEvents(); currentValue += increaseValue; famNode.ExpandAll(); } if (!this.progressCanceled) { familyTreeView.Nodes[0].EnsureVisible(); progress.ReportProgress(100); statusLabel.Text = string.Format("GEDCOM Source: {0} ({1})", this.file.Head.Source.Name, this.file.Head.Source.Version); } progress.Close(); this.Enabled = true; this.progressCanceled = false; if (!this.Focused) this.Focus(); }
public static int CalculateProperties(List <Molecule> newMolecules) { string module = $"{Product}.{Class}.{MethodBase.GetCurrentMethod().Name}()"; var molConverter = new SdFileConverter(); int changedProperties = 0; int newProperties = 0; int webServiceCalls = newMolecules.Count + 1; Progress pb = new Progress(); pb.TopLeft = Globals.Chem4WordV3.WordTopLeft; pb.Value = 0; pb.Maximum = webServiceCalls; foreach (var molecule in newMolecules) { Model temp = new Model(); var mol = molecule.Copy(); temp.AddMolecule(mol); // GitHub: Issue #9 https://github.com/Chem4Word/Version3/issues/9 int maxAtomicNumber = temp.MaxAtomicNumber; int minAtomicNumber = temp.MinAtomicNumber; var invalidBonds = new List <Bond>(); if (mol.Bonds.Any()) { invalidBonds = mol.Bonds.Where(b => b.OrderValue != null && (CtabProcessor.MdlBondType(b.Order) < 1 || CtabProcessor.MdlBondType(b.Order) > 4)).ToList(); } var calculatedNames = new List <TextualProperty>(); var calculatedFormulae = new List <TextualProperty>(); if (mol.HasFunctionalGroups || invalidBonds.Any() || minAtomicNumber < 1 || maxAtomicNumber > 118) { // IUPAC InChi (1.05) generator does not support Mdl Bond Types < 1 or > 4 or Elements < 1 or > 118 or 'our' functional groups #region Set Default properties Globals.Chem4WordV3.Telemetry.Write(module, "Information", $"Not sending structure to Web Service; HasFunctionalGroups: {mol.HasFunctionalGroups} Invalid Bonds: {invalidBonds?.Count} Min Atomic Number: {minAtomicNumber} Max Atomic Number: {maxAtomicNumber}"); calculatedNames.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordInchiName, Value = "Unable to calculate" }); //calculatedNames.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordAuxInfoName, Value = "Unable to calculate" }); calculatedNames.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordInchiKeyName, Value = "Unable to calculate" }); calculatedFormulae.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordResolverFormulaName, Value = "Not requested" }); calculatedNames.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordResolverIupacName, Value = "Not requested" }); calculatedFormulae.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordResolverSmilesName, Value = "Not requested" }); #endregion Set Default properties } else { pb.Show(); pb.Increment(1); pb.Message = $"Calculating InChiKey and Resolving Names using Chem4Word Web Service for molecule {molecule.Id}"; #region Obtain Calculated Properties try { string afterMolFile = molConverter.Export(temp); ChemicalServices cs = new ChemicalServices(Globals.Chem4WordV3.Telemetry); var csr = cs.GetChemicalServicesResult(afterMolFile); if (csr?.Properties != null && csr.Properties.Any()) { var first = csr.Properties[0]; if (first != null) { var value = string.IsNullOrEmpty(first.Inchi) ? "Not found" : first.Inchi; calculatedNames.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordInchiName, Value = value }); //value = string.IsNullOrEmpty(first.AuxInfo) ? "Not found" : first.AuxInfo; //calculatedNames.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordAuxInfoName, Value = value }); value = string.IsNullOrEmpty(first.InchiKey) ? "Not found" : first.InchiKey; calculatedNames.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordInchiKeyName, Value = value }); value = string.IsNullOrEmpty(first.Formula) ? "Not found" : first.Formula; calculatedFormulae.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordResolverFormulaName, Value = value }); value = string.IsNullOrEmpty(first.Name) ? "Not found" : first.Name; calculatedNames.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordResolverIupacName, Value = value }); value = string.IsNullOrEmpty(first.Smiles) ? "Not found" : first.Smiles; calculatedFormulae.Add(new TextualProperty { FullType = CMLConstants.ValueChem4WordResolverSmilesName, Value = value }); } } } catch (Exception e) { Globals.Chem4WordV3.Telemetry.Write(module, "Exception", $"{e}"); } #endregion Obtain Calculated Properties } #region Merge in properties foreach (var formula in calculatedFormulae) { var target = molecule.Formulas.FirstOrDefault(f => f.FullType.Equals(formula.FullType)); if (target == null) { molecule.Formulas.Add(formula); newProperties++; } else { if (!target.Value.Equals(formula.Value)) { target.Value = formula.Value; changedProperties++; } } } foreach (var name in calculatedNames) { var target = molecule.Names.FirstOrDefault(f => f.FullType.Equals(name.FullType)); if (target == null) { molecule.Names.Add(name); newProperties++; } else { if (!target.Value.Equals(name.Value)) { target.Value = name.Value; changedProperties++; } } } #endregion Merge in properties } pb.Value = 0; pb.Hide(); pb.Close(); return(changedProperties + newProperties); }
private void B_MangleSource_Click(object sender, RoutedEventArgs e) { //validate input if (Text_RootFolder.Text.Length == 0) { MessageBox.Show("Please select a valid root folder", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } DirectoryInfo rootInfo = new DirectoryInfo(Text_RootFolder.Text); if (!rootInfo.Exists) { MessageBox.Show("Please select a valid root folder","",MessageBoxButton.OK,MessageBoxImage.Error); return; } if (Text_NewNotice.Text.Length == 0) { MessageBox.Show("Please enter a new copyright message", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (Text_FileTypes.Text.Length == 0) { MessageBox.Show("Please enter at least one file type to mangle", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } //build filetype list _fileTypes = Text_FileTypes.Text.Split(new[] { ' ', ','}, StringSplitOptions.RemoveEmptyEntries); //display UI _window = new Progress(); _window.T_Current.Content = "Currently Mangling:"; _window.T_Files.Content = "Files Mangled:"; _window.Show(); _window.Focus(); //recurse long start; long stop; long frequency = Stopwatch.Frequency; //Activator start = Stopwatch.GetTimestamp(); Recurse(rootInfo); stop = Stopwatch.GetTimestamp(); double time = (double)(stop - start) / (double)frequency; //mangle files //Display results _window.Close(); MessageBox.Show("Mangled " + _filesMangled + " source files in " + (time * 1000.0).ToString("F1") + " mS"); }
bool ExportInvoice(Lib.XmlExporter xml, Data.IInvoice pool) { if (!xml.OK) { return(false); } xml.Writer.WriteStartElement("ZL_LIST"); xml.Writer.WriteStartElement("ZGLV"); xml.Writer.WriteElementString("VERSION", VERSION_INVOICES); xml.Writer.WriteElementString("DATA", DateTime.Today.AsXml()); xml.Writer.WriteElementString("FILENAME", invoiceFilename.InvoiceFile); // TODO: Invoices count, not people int count = pool.GetInvoiceRecordsCount(invoiceFilename.Section, invoiceFilename.Subsection); #if DEBUG count = Math.Min(Properties.Settings.Default.DebugSelectionLimit, count); #endif xml.Writer.WriteElementString("SD_Z", count.ToString()); xml.Writer.WriteEndElement(); xml.Writer.WriteStartElement("SCHET"); xml.Writer.WriteElementString("CODE", invoiceFilename.Code.ToString()); xml.Writer.WriteElementString("CODE_MO", invoiceFilename.ClinicCode); xml.Writer.WriteElementString("YEAR", invoiceFilename.Year.ToString()); xml.Writer.WriteElementString("MONTH", invoiceFilename.Month.ToString()); xml.Writer.WriteElementString("NSCHET", invox.Options.InvoiceNumber); xml.Writer.WriteElementString("DSCHET", invox.Options.InvoiceDate.AsXml()); xml.WriteIfValid("PLAT", invoiceFilename.CompanyCode); xml.Writer.WriteElementString("SUMMAV", pool.Total(invoiceFilename.Section, invoiceFilename.Subsection).ToString("F2", Options.NumberFormat)); // 20191028 if (invoiceFilename.Section == OrderSection.D3) { xml.Writer.WriteElementString("DISP", ProphSubsectionHelper.GetCodeV016(invoiceFilename.Subsection)); } xml.Writer.WriteEndElement(); Lib.Progress progress = new Progress("Случаи обращения", count); int number = 0; foreach (InvoiceRecord irec in pool.LoadInvoiceRecords(invoiceFilename.Section, invoiceFilename.Subsection)) { irec.Identity = number; irec.Write(xml, () => progress.Step(), pool, invoiceFilename.Section, invoiceFilename.Subsection); number = irec.Identity; #if DEBUG if (--count <= 0) { break; } #endif } progress.Close(); xml.Writer.WriteEndElement(); return(true); }
public void RX2RestoreCalData() { Progress p = new Progress("Retrieving Calibration Data from RX2 EEPROM"); p.SetPercent(0.0f); this.Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); float total_reads = 55.0f; int count = 0; FWCEEPROM.ReadRX2Level(rx2_level_table); // 33 reads p.SetPercent((count+=33)/total_reads); Application.DoEvents(); FWCEEPROM.ReadRX2Image(rx2_image_gain_table, rx2_image_phase_table); // 22 reads p.SetPercent((count+=22)/total_reads); Application.DoEvents(); RX2SyncCalDateTime(); p.Hide(); p.Close(); }
public void FLEX5000RestoreCalData() { Progress p = new Progress("Retrieving Calibration Data from TRX EEPROM"); p.SetPercent(0.0f); this.Invoke(new MethodInvoker(p.Show)); Application.DoEvents(); float total_reads = 324.0f; int count = 0; FWCEEPROM.ReadRXLevel(rx1_level_table); // 33 reads p.SetPercent((count+=33)/total_reads); Application.DoEvents(); FWCEEPROM.ReadRXImage(rx1_image_gain_table, rx1_image_phase_table); // 22 reads p.SetPercent((count+=22)/total_reads); Application.DoEvents(); FWCEEPROM.ReadTXImage(tx_image_gain_table, tx_image_phase_table); // 22 reads p.SetPercent((count+=22)/total_reads); Application.DoEvents(); FWCEEPROM.ReadTXCarrier(tx_carrier_table); // 11 reads p.SetPercent((count+=11)/total_reads); Application.DoEvents(); FWCEEPROM.ReadPABias(pa_bias_table); // 8 reads p.SetPercent((count+=8)/total_reads); Application.DoEvents(); FWCEEPROM.ReadPAPower(power_table); // 143 reads p.SetPercent((count+=143)/total_reads); Application.DoEvents(); FWCEEPROM.ReadPABridge(pa_bridge_table); // 66 reads p.SetPercent((count+=66)/total_reads); Application.DoEvents(); FWCEEPROM.ReadPASWR(swr_table); // 11 reads p.SetPercent((count+=11)/total_reads); Application.DoEvents(); if(flex5000DebugForm != null && !flex5000DebugForm.IsDisposed) { for(int i=0; i<8; i++) flex5000DebugForm.SetPAPot(i, (byte)pa_bias_table[0][i]); } p.SetPercent((count+=8)/total_reads); Application.DoEvents(); FLEX5000SyncCalDateTime(); p.Hide(); p.Close(); Application.DoEvents(); for(int i=(int)Band.B2M; i<(int)Band.LAST; i++) for(int j=0; j<13; j++) power_table[i][j] = power_table[10][j]; }
public static bool ToBase(string firetakeNumber) { var res = true; var xml = XDocument.Load("firetakes.xml"); var node = xml.Element("Firetakes").Element("Firetake"); var progress = new Progress(); progress.Show(); progress.SetBarSize(node.Elements().Count<XElement>()+1); try { progress.Focus(); for (int i = 0; i < int.Parse(firetakeNumber); i++) { node = node.NextNode as XElement; } foreach (XElement student in node.Elements()) { var commandText = "INSERT INTO FIRETAKE(DATETAKEN,STATUS,GRADE,COMMENT,DELETED,STUDENT_ID,TEACHER_ID,SCORE) VALUES('" + node.Attribute("Time").Value + "',0," + student.Attribute("Mark").Value + ",'',0," + student.Attribute("Id").Value + "," + node.Attribute("Teacher").Value + "," + student.Attribute("Score").Value + ")"; var con = new MySqlConnection(conStr); var com = new MySqlCommand(commandText, con); con.Open(); com.ExecuteNonQuery(); con.Close(); progress.Increment(); System.Threading.Thread.Sleep(200); } node.Remove(); xml.Save("firetakes.xml"); } catch { res = false; } progress.Close(); return res; }