private void UcLoadFileOnStorage_Load(object sender, EventArgs e) { try { waitForm.Show(); BackgroundWorker bcw = new BackgroundWorker(); bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1) { using (DocumentsClient client = new DocumentsClient("Binding_Documents")) archives = client.GetArchives(); }; bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1) { waitForm.Close(); if (e1.Error != null) { MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ddlArchives.DisplayMember = "Name"; ddlArchives.ValueMember = "IdArchive"; ddlArchives.DataSource = archives; } }; bcw.RunWorkerAsync(); } catch (Exception ex) { waitForm.Close(); MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void backgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) { if (waitForm == null) { return; } if (waitForm.bIsInterrupted && this.backgroundWorker.CancellationPending) { timer.Stop(); this.backgroundWorker.CancelAsync(); waitForm.Close(); waitForm = null; return; } if (e.UserState != null) { Exception ex = e.UserState as Exception; if (ex != null) { timer.Stop(); this.backgroundWorker.CancelAsync(); return; } string statusString = e.UserState as string; if (statusString != null) { waitForm.labelStatus.Text = statusString; } } waitForm.pb.Value = e.ProgressPercentage; waitForm.pb.Update(); }
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { waitForm.Close(); if (e.Error == null) { gwAttributes.DataSource = attributes; } else { MessageBox.Show(e.Error.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Enabled = true; }
public UcFindFile() { InitializeComponent(); client = new ServiceReferenceContentSearch.ContentSearchClient("ContentSearch"); client.SearchQueryPagedCompleted += (object s, SearchQueryPagedCompletedEventArgs args) => { if (args.Error != null || args.Result.HasErros) { waitForm.Close(); this.UseWaitCursor = false; this.Enabled = true; MessageBox.Show(args.Error == null ? args.Result.Error.Message : args.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { ServiceReferenceContentSearch.Document currDoc; for (int i = 0; i < args.Result.Documents.Count; i++) { currDoc = args.Result.Documents[i]; var metadataDetails = currDoc.AttributeValues .Select(x => x.Attribute.Name + ": " + x.Value) .ToArray(); this.radGridFindResults.Rows.Add(new string[] { (skip + i + 1).ToString(), currDoc.Name, (currDoc.Status != null && !string.IsNullOrEmpty(currDoc.Status.Description))? currDoc.Status.Description : "N/A", string.Join(" ", metadataDetails), currDoc.IdDocument.ToString(), }); } if ((skip + TAKE) >= args.Result.TotalRecords) { waitForm.Close(); this.UseWaitCursor = false; this.Enabled = true; MessageBox.Show("Retrieved " + args.Result.TotalRecords + " record.", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); this.btnFind.Enabled = true; } else { skip += TAKE; ricercaDocumenti(); } } }; }
async void Post() { var wait = new WaitForm { Status = TextUI.SavingData, OwnerForm = this }; wait.Show(); var rs = await Object.Post(); wait.Close(); wait.Dispose(); if (rs.StatusCode == HttpStatusCode.OK) { var error = ApiResponse.ParseError(rs.Content); if (!String.IsNullOrEmpty(error)) { MessageBox.Show(error); } else { MessageBox.Show(TextUI.DataSuccessfullySaved); DialogResult = DialogResult.OK; Close(); } } else { MessageBox.Show(ErrorTexts.FailedToSendDataToServer); } }
private void CheckForUpdates() { DialogResult retry; do { retry = DialogResult.Cancel; var waitForm = new WaitForm(30); var task = Task.Run(() => { waitForm.ShowDialog(); }); var requestResult = repoChecker.CheckForUpdates(Settings.Default.CheckUrl); waitForm.Invoke(new Action(() => waitForm.Close())); if (requestResult.Success) { if (requestResult.Result && MessageBox.Show(this, "Update Bot to newer version?", "Updates available", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { DownloadUpdates(); } } else { retry = MessageBox.Show(this, requestResult.Exception.Message, "Checking for Updates", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation); } } while (retry == DialogResult.Retry); }
private void downloadFile(object objFolder) { int BufferLen = 4096; string folder = objFolder.ToString(); string file = string.Empty; string fileServiceUrl = string.Empty; using (BugTraceEntities zentity = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { var currVersion = zentity.SYS_Version.Where(p => p.IsDefault == 1).FirstOrDefault(); file = currVersion.FilePath; fileServiceUrl = currVersion.FileServiceUrlPort; } string fileName = Path.GetFileName(file); Stream sourceStream = null; try { EndpointAddress address = new EndpointAddress("http://" + fileServiceUrl + "/JAJ.WinServer/FileService"); FileTransferSvc.FileServiceClient _client = new FileTransferSvc.FileServiceClient("BasicHttpBinding_IFileService", address); sourceStream = _client.DowndloadFile(file); } catch (Exception ex) { this.Invoke(new MethodInvoker(() => { WaitForm.Close(); MessageBox.Show("下载客户端失败!"); })); MyLog.LogError("下载客户端失败!", ex); return; } FileStream targetStream = null; if (!sourceStream.CanRead) { MyLog.LogError("下载异常", new Exception("Invalid Stream!")); throw new Exception("Invalid Stream!"); } string filePath = Path.Combine(folder, fileName); using (targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None)) { byte[] buffer = new byte[BufferLen]; int count = 0; while ((count = sourceStream.Read(buffer, 0, BufferLen)) > 0) { targetStream.Write(buffer, 0, count); } targetStream.Close(); sourceStream.Close(); } this.Invoke(new MethodInvoker(() => { WaitForm.Close(); MessageBox.Show("下载成功,请使用最新下载的客户端,谢谢!"); this.Close(); })); }
async void PostSignature(DrivingLicense obj) { var wait = new WaitForm { Status = TextUI.SavingData, OwnerForm = this }; wait.Show(); var rs = await obj.PostSignature(); wait.Close(); wait.Dispose(); if (rs.StatusCode == HttpStatusCode.OK) { var error = ApiResponse.ParseError(rs.Content); if (!String.IsNullOrEmpty(error)) { MessageBox.Show(error); } else { pbSignature.Image = GraphicsHelper.GetStretchedImage(obj.Signature, pbSignature.Height, pbSignature.Width); pbSignature.Refresh(); } } else { MessageBox.Show(ErrorTexts.FailedToSendDataToServer); } FillDataGrid(); }
async void PostPublishedStatus(DrivingLicense obj) { kbtnPrint.Enabled = false; obj.Status = TextUI.Published; var wait = new WaitForm { Status = TextUI.SavingData, OwnerForm = this }; wait.Show(); var rs = await obj.PostPublishedStatus(); wait.Close(); wait.Dispose(); if (rs.StatusCode == HttpStatusCode.OK) { var error = ApiResponse.ParseError(rs.Content); if (!String.IsNullOrEmpty(error)) { MessageBox.Show(error); } else { var suc = obj.SendToPrint(); MessageBox.Show(!suc ? DrivingLicense.LastError : TextUI.DataTransferredToPrint); } } else { MessageBox.Show(ErrorTexts.FailedToSendDataToServer); } FillDataGrid(); }
private void radComboBoxStorage_SelectedIndexChanged(object sender, EventArgs e) { waitForm = new WaitForm(); waitForm.Show(); BackgroundWorker bcw = new BackgroundWorker(); bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1) { using (DocumentsClient client = new DocumentsClient()) if (Storage != null) { storageAreas = client.GetStorageAreas(Storage); } }; bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1) { waitForm.Close(); if (e1.Error != null) { MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { radComboBoxStorageArea.DisplayMember = "Name"; radComboBoxStorageArea.ValueMember = "IdStorageArea"; radComboBoxStorageArea.DataSource = storageAreas; } }; bcw.RunWorkerAsync(); }
private void btnProcessAll_Click(object sender, System.EventArgs e) { waitForm = new WaitForm(); waitForm.Show(); BackgroundWorker bcw = new BackgroundWorker(); string archiveName = archives.Where(x => x.IdArchive == new Guid(radComboBoxArchive.SelectedValue.ToString())).FirstOrDefault().Name; bool result = false; bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1) { using (serviceTransito.TransitClient client = new serviceTransito.TransitClient("Binding_Transit")) { result = client.StoreTransitArchiveDocuments(archiveName); } }; bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1) { waitForm.Close(); if (e1.Error == null) { RadMessageBox.Show(result ? "File in transito processato correttamente." : "Non tutti i file in transito processati.", "Risultato processo", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Info); LoadDocument(0); } else { RadMessageBox.Show(e1.Error.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error); } }; bcw.RunWorkerAsync(); }
public static void Close() { if (form != null) { form.Close(); } form = null; }
public void readRecordsRunWorkerCompletedEventHandler(object sender, RunWorkerCompletedEventArgs e) { Tuple <Table, List <ListViewItem> > result = (Tuple <Table, List <ListViewItem> >)e.Result; List <ListViewItem> listViewItemList = (List <ListViewItem>)result.Item2; //mainForm.setRecordListMethod(listViewItemList); mainForm.Invoke(mainForm.setRecordListDelegate, new object[] { listViewItemList }); waitForm.Close(); }
private void TitleRadioButton_CheckedChanged(object sender, EventArgs e) { if (MagazinesDGV.Rows.Count == 0) { return; } WaitForm WF = new WaitForm(); this.Invoke((MethodInvoker) delegate { WF.Show(this); WF.Update(); }); string[] TextToSearch = { "", "" }; if (SygRadioButton.Checked) { TextToSearch[0] = MagazinesDGV.SelectedRows[0].Cells["Sygnatura"].Value.ToString().ToLower(); TextToSearch[1] = MagazinesDGV.SelectedRows[0].Cells["Magazine"].Value.ToString().ToLower(); LoadMagazines("2"); for (int i = 0; i < MagazinesDGV.Rows.Count; i++) { if (MagazinesDGV.Rows[i].Cells["Magazine"].Value.ToString().ToLower().StartsWith(TextToSearch[1].ToLower()) && MagazinesDGV.Rows[i].Cells["Sygnatura"].Value.ToString().ToLower().StartsWith(TextToSearch[0].ToLower())) { MagazinesDGV.ClearSelection(); MagazinesDGV.Rows[i].Selected = true; MagazinesDGV.CurrentCell = MagazinesDGV["Magazine", i]; MagazinesDGV.FirstDisplayedScrollingRowIndex = i; break; } } } else if (TitleRadioButton.Checked) { TextToSearch[0] = MagazinesDGV.SelectedRows[0].Cells["Sygnatura"].Value.ToString().ToLower(); TextToSearch[1] = MagazinesDGV.SelectedRows[0].Cells["Magazine"].Value.ToString().ToLower(); LoadMagazines("1"); for (int i = 0; i < MagazinesDGV.Rows.Count; i++) { if (MagazinesDGV.Rows[i].Cells["Magazine"].Value.ToString().ToLower().StartsWith(TextToSearch[1].ToLower()) && MagazinesDGV.Rows[i].Cells["Sygnatura"].Value.ToString().ToLower().StartsWith(TextToSearch[0].ToLower())) { MagazinesDGV.ClearSelection(); MagazinesDGV.Rows[i].Selected = true; MagazinesDGV.CurrentCell = MagazinesDGV[1, i]; MagazinesDGV.FirstDisplayedScrollingRowIndex = i; break; } } } WF.Close(); MagazinesDGV.Focus(); }
/// <summary> /// Chiude la wait dialog e riabilita il controllo /// </summary> protected virtual void CloseWaitDialog() { if (dlg != null) { dlg.Close(); dlg = null; } Cursor = Cursors.Default; this.Enabled = true; }
void documentoCheckOut_Click(object sender, EventArgs e) { try { var currentDoc = radGridView2.SelectedRows.First().DataBoundItem as ServiceReferenceDocument.Document; if (currentDoc != null && !currentDoc.IsLatestVersion) { RadMessageBox.Show(this, "Impossibile mettere in check-out una versione precedente del documento.", "", MessageBoxButtons.OK, RadMessageIcon.Exclamation); return; } if (RadMessageBox.Show("Sei sicuro di volere estrarre il documento?", "Check-Out", MessageBoxButtons.YesNo, Telerik.WinControls.RadMessageIcon.Question) == DialogResult.Yes) { ServiceReferenceDocument.Document document = new BiblosDs.Document.AdminCentral.ServiceReferenceDocument.Document(); Guid id = (Guid)radGridView2.SelectedRows[0].Cells["IdDocument"].Value; string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name; BackgroundWorker bcw = new BackgroundWorker(); waitForm = new WaitForm(); waitForm.Show(); bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1) { using (DocumentsClient client = new DocumentsClient("Binding_Documents")) { document = client.CheckOutDocument(id, user, ContentFormat.Bynary, null); } }; bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1) { waitForm.Close(); if (e1.Error != null) { MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { saveFileDialog1 = new SaveFileDialog(); radGridView2.SelectedRows[0].Cells["IsCheckOut"].Value = true; radGridView2.SelectedRows[0].Cells["IdUserCheckOut"].Value = System.Security.Principal.WindowsIdentity.GetCurrent().Name; if (document.Content != null && saveFileDialog1.ShowDialog() == DialogResult.OK) { File.WriteAllBytes(saveFileDialog1.FileName, document.Content.Blob); } } }; bcw.RunWorkerAsync(); } } catch (Exception ex) { RadMessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error); } }
private void UpdateGrid() { if (_waitForm == null || _waitForm.IsDisposed) { _waitForm = new WaitForm(); _waitForm.Worker.DoWork += Worker_DoWork; _waitForm.Worker.RunWorkerCompleted += Worker_RunWorkerCompleted; } _waitForm.TopMost = true; _waitForm.Show(); try { this.pDataSet = new DataSet("总表"); this.stable = new DataTable("属性表"); this.Geotable = new DataTable("空间"); this.gridControl1.DataSource = (null); this.cmbStatField.Items.Clear(); if (AddItems() == false) { _waitForm.Close(); return; } IFeatureCursor pCursor = _layerInfo.FeatureClass.Search(_spatialFilter, false); IDataStatistics dataStatistics = new DataStatisticsClass(); dataStatistics.Field = _layerInfo.FeatureClass.OIDFieldName; dataStatistics.Cursor = pCursor as ICursor; _waitForm.Count = dataStatistics.Statistics.Count; Marshal.ReleaseComObject(pCursor); _waitForm.Worker.RunWorkerAsync(); } catch (Exception exception) { _waitForm.Close(); MessageBox.Show(exception.Message); } }
void documentoCheckIn_Click(object sender, EventArgs e) { try { ServiceReferenceDocument.Document document = (ServiceReferenceDocument.Document)radGridView2.SelectedRows[0].DataBoundItem; if (MessageBox.Show("Si vuole modificare il contenuto del file?", "Modificare il file?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { document.Content = new Content(); document.Content.Blob = File.ReadAllBytes(openFileDialog1.FileName); } } Forms.AttributeEdit attrEdit = new AttributeEdit(document.Archive.Name, document.AttributeValues); if (attrEdit.ShowDialog() == DialogResult.OK) { document.AttributeValues = attrEdit.GetAttributeValue(); BackgroundWorker bcw = new BackgroundWorker(); waitForm = new WaitForm(); waitForm.Show(); string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name; bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1) { using (DocumentsClient client = new DocumentsClient("Binding_Documents")) { client.CheckInDocument(document, user, ContentFormat.Bynary, null); } }; bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1) { waitForm.Close(); if (e1.Error != null) { MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { radGridView2.SelectedRows[0].Cells["IsCheckOut"].Value = true; radGridView2.SelectedRows[0].Cells["IdUserCheckOut"].Value = System.Security.Principal.WindowsIdentity.GetCurrent().Name; radGridView1_CurrentRowChanged(); } }; bcw.RunWorkerAsync(); } } catch (Exception ex) { RadMessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error); } }
private void btnAddChain_Click(object sender, EventArgs e) { ServiceReferenceDocument.Document document = new ServiceReferenceDocument.Document(); document.Archive = CurrentArchive; try { waitForm = new WaitForm(); waitForm.Show(); BackgroundWorker bcw = new BackgroundWorker(); bcw.DoWork += delegate(object sender1, DoWorkEventArgs e1) { using (DocumentsClient client = new DocumentsClient("Binding_Documents")) { document.IdDocument = client.CreateDocumentChain(CurrentArchive.Name, new BindingList <AttributeValue>()); } }; bcw.RunWorkerCompleted += delegate(object sender1, RunWorkerCompletedEventArgs e1) { waitForm.Close(); if (e1.Error != null) { MessageBox.Show(e1.Error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { WriteChainToFile(document, false); } }; bcw.RunWorkerAsync(); } catch (Exception ex) { waitForm.Close(); MessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void metadataView_Click(object sender, EventArgs e) { waitForm = new WaitForm(); waitForm.Show(); try { DocumentsClient client = new DocumentsClient("Binding_Documents"); client.GetDocumentInfoCompleted += (object o, GetDocumentInfoCompletedEventArgs args) => { waitForm.Close(); if (args.Error != null) { MessageBox.Show(args.Error.ToString()); } else { var doc = args.Result.Where(x => x.IdDocument == (Guid)args.UserState).FirstOrDefault(); if (doc != null) { Forms.MetaDataView metadata = new Forms.MetaDataView(); metadata.Attributes = doc.AttributeValues; metadata.ShowDialog(); } else { MessageBox.Show("Nessun documento presente con l'id cercato."); } } }; client.GetDocumentInfoAsync((Guid)radGridView2.SelectedRows[0].Cells["IdDocument"].Value, null, true, (Guid)radGridView2.SelectedRows[0].Cells["IdDocument"].Value); } catch (Exception ex) { waitForm.Close(); MessageBox.Show(ex.ToString()); } }
public static void CloseForm() { messages.Pop(); if (instance != null) { if (messages.Count == 0) { instance.Close(); } else { instance.lblMessage.Text = messages.Peek(); } } }
private void radGridView1_CurrentRowChanged() { try { waitForm = new WaitForm(); waitForm.Show(); ServiceReferenceContentSearch.ContentSearchClient client = new ServiceReferenceContentSearch.ContentSearchClient("ContentSearch"); client.GetAllDocumentChainsCompleted += new EventHandler <ServiceReferenceContentSearch.GetAllDocumentChainsCompletedEventArgs>(client_GetAllDocumentChainsCompleted); client.GetAllDocumentChainsAsync(radComboBoxArchive.SelectedValue.ToString(), currentPage * documentInPage, documentInPage); } catch (Exception ex) { waitForm.Close(); RadMessageBox.Show(ex.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error); } }
private void DownloadUpdates() { var waitForm = new WaitForm(50); var task = Task.Run(() => { waitForm.ShowDialog(); }); var requestResult = repoChecker.DownloadUpdates(Settings.Default.DownloadUrl); waitForm.Invoke(new Action(() => waitForm.Close())); if (requestResult.Success) { UpdateApplication(requestResult.Result); } else { MessageBox.Show(this, requestResult.Exception.Message, "Can't download Update", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void UpdateApplication(string sourcePath) { var waitForm = new WaitForm(100); var task = Task.Run(() => { waitForm.ShowDialog(); }); var requestResult = repoChecker.UpdateApplication(sourcePath); waitForm.Invoke(new Action(() => waitForm.Close())); if (requestResult.Success) { FinishUpdate(requestResult.Result); } else { MessageBox.Show(this, requestResult.Exception.Message, "Can't update Bot", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void UcTransit_Load(object sender, System.EventArgs e) { waitForm = new WaitForm(); waitForm.Show(); serviceDocument.DocumentsClient client = new serviceDocument.DocumentsClient("Binding_Documents"); client.GetArchivesAsync(); client.GetArchivesCompleted += delegate(object s, serviceDocument.GetArchivesCompletedEventArgs args) { waitForm.Close(); if (args.Error == null) { archives = args.Result; radComboBoxArchive.DisplayMember = "Name"; radComboBoxArchive.ValueMember = "IdArchive"; radComboBoxArchive.DataSource = archives; } else { RadMessageBox.Show(args.Error.Message, "Errore", MessageBoxButtons.OK, Telerik.WinControls.RadMessageIcon.Error); } }; }
async void FillDataGrid() { kdgvData.EndEdit(); var newSrc = new BindingSource(); var curSrc = (BindingSource)kdgvData.DataSource; kdgvData.DataSource = newSrc; if (!ReferenceEquals(curSrc.DataSource, null)) { var v = (BindingListView <DrivingLicense>)curSrc.DataSource; v.DataSource = new List <DrivingLicense>(); } //curSrc.Clear(); var wait = new WaitForm { Status = TextUI.RetrievingData, OwnerForm = this }; wait.Show(); var data = await DrivingLicense.GetDrivingLicenses((int)pcPage.CurrentPage, (int)pcPage.PageSize); wait.Close(); wait.Dispose(); if (ReferenceEquals(data, null)) { MessageBox.Show(ErrorTexts.FailedToGetDataFromServer); } else { pcPage.TotalRecords = data.TotalNumber; var view = new BindingListView <DrivingLicense>(data.Items); curSrc.DataSource = view; //data.Items; } kdgvData.DataSource = curSrc; newSrc.Dispose(); kdgvData.Invalidate(); }
void client_GetAllDocumentChainsCompleted(object sender, ServiceReferenceContentSearch.GetAllDocumentChainsCompletedEventArgs e) { waitForm.Close(); if (e.Error != null) { MessageBox.Show(e.Error.Message, "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } LblMessage.Text = "Documents in archive: " + e.docunentsInArchiveCount + ", Current record from " + currentPage * documentInPage + " to " + ((currentPage * documentInPage) + documentInPage) + "."; double numPag = (double)e.docunentsInArchiveCount / (double)documentInPage; this.ucPager.Initialize(1, (int)Math.Ceiling(numPag), currentPage + 1); var result = e.Result; if (result != null) { result = new BindingList <ServiceReferenceContentSearch.Document>(result.OrderBy(x => x.Name).ThenByDescending(x => x.Version).ThenByDescending(x => x.DateCreated).ToList()); } radGridView1.DataSource = result; }
private void ThreadLogin(object obj) { string userCode = obj.ToString(); bool isCorrectVersion = true; bool isLogin = login(userCode, ref isCorrectVersion); this.Invoke(new MethodInvoker(() => { WaitForm.Close(); this.Enabled = true; if (isLogin) { if (this.chkRememberUserCode.Checked && this.chkRememberPassword.Checked) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["ID"].Value = userCode; config.Save(); } this.DialogResult = DialogResult.OK; this.Close(); } else { if (!isCorrectVersion) { if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string folder = folderBrowserDialog1.SelectedPath; Thread downloadThread = new Thread(downloadFile); downloadThread.Start(folder); WaitForm.Show(this, "正 在 下 载 请 稍 候"); } } } })); }
private void buttonNext_Click(object sender, EventArgs e) { //check for selected stratum //rowCount = selectedItemsGridViewStratum.SelectedItems.Count; if (Owner.selectedStratum.Code.Length <= 0) { MessageBox.Show("Please select a stratum.", "Information"); return; } // create historical data WaitForm waitFrm = new WaitForm(); Cursor.Current = Cursors.WaitCursor; waitFrm.Show(); createHistoricalData(); waitFrm.Close(); Cursor.Current = this.Cursor; Owner.GoToUnitPage(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); ISqlLocalDbApi localDB = new SqlLocalDbApiWrapper(); if (!localDB.IsLocalDBInstalled()) { MessageBox.Show("Máy tính của bạn phải cài đặt SQL Server LocalDB hoặc phiên bản Express để có thể sử dụng phần mềm."); return; } string uuid = "nhom7-928cf731-171f-464f-aa55-24e814eeb224"; ISqlLocalDbProvider provider = new SqlLocalDbProvider(); IList <ISqlLocalDbInstanceInfo> instances = provider.GetInstances(); bool flag = false; foreach (ISqlLocalDbInstanceInfo instanceInfo in instances) { if (instanceInfo.Name == uuid) { flag = true; break; } } if (!flag) { WaitForm frm = new WaitForm(); frm.Show(); ISqlLocalDbInstance instance = provider.CreateInstance(uuid); instance.Start(); try { if (IsCurrentUserAdmin()) { } try { using (SqlConnection connection = instance.CreateConnection()) { connection.Open(); try { string scriptText = Resources.script.ToString(); string[] splitter = new string[] { "\r\nGO\r\n" }; string[] commandTexts = scriptText.Split(splitter, StringSplitOptions.RemoveEmptyEntries); foreach (string commandText in commandTexts) { using (SqlCommand command = new SqlCommand(commandText, connection)) { command.ExecuteNonQuery(); } } } finally { connection.Close(); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { if (IsCurrentUserAdmin()) { } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } finally { instance.Stop(); } frm.Close(); } else { ISqlLocalDbInstance instance = provider.GetInstance(uuid); } Global.connstring = @"Data Source=(LocalDB)\nhom7-928cf731-171f-464f-aa55-24e814eeb224;Initial Catalog=QUANLYTHUVIEN_Nhom7_14521100_15520048_15520062_15520115;Integrated Security=True"; Application.Run(new frmDangNhap()); }
private void addReconStratum(bool addSG) { // use historical data logic WaitForm waitFrm = new WaitForm(); Cursor.Current = Cursors.WaitCursor; waitFrm.Show(); int nestPlots = 0; // open recon file List<StratumDO> reconStratum = new List<StratumDO>(Owner.rDAL.Read<StratumDO>("Stratum", null, null)); foreach (StratumDO myRSt in reconStratum) { // add stratum Owner.newStratum = new StratumDO(Owner.cdDAL); // set unit codes if (!checkNestedPlots(myRSt)) { myRSt.CuttingUnits.Populate(); float totalAcres = 0; foreach (CuttingUnitDO rcu in myRSt.CuttingUnits) { Owner.myCuttingUnit = Owner.cdDAL.ReadSingleRow<CuttingUnitDO>("CuttingUnit", "WHERE Code = ?", rcu.Code); Owner.newStratum.CuttingUnits.Add(Owner.myCuttingUnit); float acres = Owner.myCuttingUnit.Area; totalAcres += acres; } // copy stratum from recon Owner.newStratum.Code = myRSt.Code; Owner.newStratum.Method = "100"; Owner.newStratum.Description = myRSt.Description; Owner.newStratum.Save(); Owner.newStratum.CuttingUnits.Save(); //check for tree vs plot and one vs two stage methods // copy stratumstats to design Owner.newStratumStats = new StratumStatsDO(Owner.cdDAL); // Owner.currentStratumStats.Stratum = Owner.currentStratum; Owner.newStratumStats.Stratum_CN = Owner.newStratum.Stratum_CN; Owner.newStratumStats.Code = Owner.newStratum.Code; Owner.newStratumStats.Description = Owner.newStratum.Description; Owner.newStratumStats.Method = "100"; Owner.newStratumStats.SgSetDescription = ""; Owner.newStratumStats.SgSet = 1; Owner.newStratumStats.Used = 2; Owner.newStratumStats.TotalAcres = totalAcres; Owner.newStratumStats.Save(); Owner.cdStratum.Add(Owner.newStratum); if (addSG) { List<SampleGroupDO> reconSG = new List<SampleGroupDO>(Owner.rDAL.Read<SampleGroupDO>("SampleGroup", "WHERE Stratum_CN = ?", myRSt.Stratum_CN)); // getSampleGroupStats(); foreach (SampleGroupDO myRsg in reconSG) { // create samplegroupstats Owner.newSgStats = new SampleGroupStatsDO(Owner.cdDAL); //set foriegn key Owner.newSgStats.StratumStats = Owner.newStratumStats; Owner.newSgStats.SgSet = 1; Owner.newSgStats.Code = myRsg.Code; Owner.newSgStats.CutLeave = myRsg.CutLeave; Owner.newSgStats.UOM = myRsg.UOM; Owner.newSgStats.PrimaryProduct = myRsg.PrimaryProduct; Owner.newSgStats.SecondaryProduct = myRsg.SecondaryProduct; Owner.newSgStats.DefaultLiveDead = myRsg.DefaultLiveDead; Owner.newSgStats.Description = myRsg.Description; Owner.newSgStats.Save(); // loop through TDV information myRsg.TreeDefaultValues.Populate(); foreach (TreeDefaultValueDO tdv in myRsg.TreeDefaultValues) { // check with current TDV values Owner.newTreeDefault = Owner.cdDAL.ReadSingleRow<TreeDefaultValueDO>("TreeDefaultValue", "WHERE Species = ? AND PrimaryProduct = ? AND LiveDead = ?", tdv.Species, tdv.PrimaryProduct, tdv.LiveDead); // if exists, create link Owner.newSgStats.TreeDefaultValueStats.Add(Owner.newTreeDefault); } Owner.newSgStats.Save(); Owner.newSgStats.TreeDefaultValueStats.Save(); } } } else { nestPlots++; } } waitFrm.Close(); Cursor.Current = this.Cursor; if (nestPlots > 0) MessageBox.Show("Some units had nested plots with different cruise methods or plot sizes.\n Those strata could not be created.","Information"); }
/// <summary> /// 关闭进度条窗口 这个函数将来要加到CloseProgressBarDelegate上 /// </summary> public static void CloseProgressBar( ) { waitForm.Invoke(new MethodInvoker(() => waitForm.Close())); }