public void Run(object sender, DoWorkEventArgs e) { this.bw = (BackgroundWorker)sender; this.bw.ReportProgress(0, "Checking update..."); var source = Paths.GetServerSystemDirectory(); var destination = Properties.Settings.Default.SystemDirectory; var userName = Properties.Settings.Default.ServerUserName; var password = Properties.Settings.Default.ServerPassword; MasterFileLoader.Authorize(source, userName, password); this.localVersion = GetMasterVersion(destination); this.serverVersion = GetMasterVersion(source); if (this.serverVersion == 0) { throw new ApplicationException(Messages.FailedToGetMasterVersion(source + VERSION_TEXT)); } if (this.serverVersion <= this.localVersion) { return; } this.progressCount = 0; this.fileCount = this.GetFileCount(source); if (this.fileCount == 0) { return; } this.CopyDirectory(source, destination); }
private void saveButton_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { if (!this.Validate()) { return; } var pattern = new SocketBoxPattern(); pattern.Id = this.patternId; pattern.Name = this.nameText.Text; pattern.IndividualWRDwgPath = this.individualWRText.Text; pattern.IndividualWSDwgPath = this.individualWSText.Text; pattern.IndividualBRDwgPath = this.individualBRText.Text; pattern.IndividualBSDwgPath = this.individualBSText.Text; pattern.PatternWRDwgPath = this.patternWRText.Text; pattern.PatternWSDwgPath = this.patternWSText.Text; pattern.PatternBRDwgPath = this.patternBRText.Text; pattern.PatternBSDwgPath = this.patternBSText.Text; pattern.SocketBoxSize = (int)this.sizeCombo.SelectedValue; pattern.SocketBoxDepth = this.depthCombo.SelectedItem.ToString(); pattern.NeedCSV = this.outputCheck.Checked; pattern.CategoryId = (int)this.categoryCombo.SelectedValue; if (this.detailGrid.Rows.Count == 0) { pattern.DetailsList = new List <SocketBoxPatternDetail>(); } else { pattern.DetailsList = (this.detailGrid.DataSource as BindingSource).DataSource as List <SocketBoxPatternDetail>; } pattern.ColorsList = (this.colorGrid.DataSource as BindingSource).DataSource as List <SocketBoxPatternColor>; int id; using (var service = new SocketPlanService()) { id = service.RegisterSocketBoxPattern(pattern, Environment.MachineName); } #if !DEBUG var userName = Properties.Settings.Default.ServerUserName; var password = Properties.Settings.Default.ServerPassword; var source = Paths.GetServerSystemDirectory(); MasterFileLoader.Authorize(source, userName, password); #endif this.CopyToServer(pattern); this.IncrementMasterFileVersion(); this.UpdateTree(); this.SelectPatternNode(id); UnitWiring.Masters.UpdateSocketBoxPatterns(); MessageDialog.ShowInformation(this, "Saved successfully."); } catch (Exception exp) { MessageDialog.ShowError(exp); } finally { this.Cursor = Cursors.Default; } }
private void saveButton_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; try { if (!this.Validate()) { return; } var specific = new SocketBoxSpecific(); specific.Id = this.specificId; specific.Serial = this.serialText.Text; specific.ImagePath = this.imagePathText.Text; specific.BlockPath = this.blockPathText.Text; if ((int)this.sizeCombo.SelectedValue == 0) { specific.SocketBoxSize = null; } else { specific.SocketBoxSize = (int)this.sizeCombo.SelectedValue; } specific.Color = this.colorCombo.SelectedItem.ToString(); specific.Shape = this.shapeCombo.SelectedItem.ToString(); specific.SocketBoxDepth = this.depthCombo.SelectedItem.ToString(); specific.SpecificCategoryId = (int)this.categoryCombo.SelectedValue; specific.Relations = this.CreateRelations().ToArray(); using (var service = new SocketPlanService()) { specific.Id = service.RegisterSocketBoxSpecific(specific); } #if !DEBUG var userName = Properties.Settings.Default.ServerUserName; var password = Properties.Settings.Default.ServerPassword; var source = Paths.GetServerSystemDirectory(); MasterFileLoader.Authorize(source, userName, password); #endif this.CopyToServer(specific); this.IncrementMasterFileVersion(); this.UpdateTree(true); this.SelectSpecificNode(specific.Id); UnitWiring.Masters.UpdateSocketBoxSpecificCategories(); MessageDialog.ShowInformation(this, "Saved successfully."); } catch (Exception exp) { MessageDialog.ShowError(exp); } finally { this.Cursor = Cursors.Default; } }