private void _worker_DoWork(object sender, DoWorkEventArgs e) { WorkerArg workerArg = e.Argument as WorkerArg; if ((workerArg != null) && (workerArg.AbortTask)) { // abort the specified task AbortTaskRequest abortRequest = new AbortTaskRequest(); abortRequest.ClientData = UserSettings.Settings.GenerateClientData(); abortRequest.ContextId = workerArg.ContextId; abortRequest.TaskType = workerArg.TaskType; ServiceProxy.Services.Admin.AbortTask(abortRequest); } // get an updated service status GetStackHashServiceStatusRequest request = new GetStackHashServiceStatusRequest(); request.ClientData = UserSettings.Settings.GenerateClientData(); GetStackHashServiceStatusResponse response = ServiceProxy.Services.Admin.GetServiceStatus(request); DumpStatus(response.Status); e.Result = response.Status; }
/// <summary> /// バックグラウンド処理本体 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { WorkerArg arg = (WorkerArg)e.Argument; string tmpdir = Path.Combine(Path.GetTempPath(), "EPubMaker"); string mime = Path.Combine(tmpdir, "mimetype"); string meta = Path.Combine(tmpdir, "META-INF"); string contents = Path.Combine(tmpdir, "OEBPS"); string bookid = Guid.NewGuid().ToString(); // まずメタデータを生成する FileStream fs = GenerateMetadata(bookid, arg.title, arg.author, arg.rtl, tmpdir, mime, meta, contents); // 画像を変換しPNGを出力する if (!ConvertPictures(arg.pages, arg.width, arg.height, Path.Combine(contents, "data"), fs)) { fs.Close(); e.Cancel = true; return; } // 目次を生成する if (!GenerateToc(arg.pages, bookid, arg.title, arg.author, arg.rtl, contents, fs)) { fs.Close(); e.Cancel = true; return; } fs.Close(); // ePubファイルを生成する PackEPub(arg.path, tmpdir, mime, meta, contents); e.Result = true; }
public static void DoWork(object sender, DoWorkEventArgs e) { WorkerArg arg = (WorkerArg)e.Argument; lock (arg.portal) { if (arg.top is PlcBlockGroup) { arg.ctxt.HandleBlockFolder((PlcBlockGroup)arg.top); } else { arg.ctxt.HandleDataBlock((PlcBlock)arg.top); } } }
/// <summary> /// フォームコンストラクタ /// </summary> /// <param name="pages">ページ</param> /// <param name="title">書籍タイトル</param> /// <param name="author">著者</param> /// <param name="width">出力幅</param> /// <param name="height">出力高さ</param> /// <param name="rtl">ページ送り</param> /// <param name="path">出力ファイルパス</param> public FormProgress(List <Page> pages, string title, string author, int width, int height, bool rtl, string path) { InitializeComponent(); WorkerArg arg = new WorkerArg(); arg.pages = pages; arg.title = title.Trim(); arg.author = author.Trim(); arg.width = width; arg.height = height; arg.rtl = rtl; arg.path = path; this.DialogResult = DialogResult.None; backgroundWorker.RunWorkerAsync(arg); }
private void btnPhysicalPersonParcel_Click(object sender, EventArgs e) { gridSearchResultPhysicalPerson.MainView.PostEditor(); List <PHYSICAL_PERSON> physicalPersonList = pHYSICALPERSONBindingSource.DataSource as List <PHYSICAL_PERSON>; if (physicalPersonList != null && physicalPersonList.Where(c => c.IsSelected).Count() > 0) { if (!_workerSearchCadastreNo.IsBusy) { progressBarPhysicalPerson.Visible = true; WorkerArg arg = new WorkerArg(); arg.ArgType = 1; arg.PhysicalPersons = physicalPersonList.Where(c => c.IsSelected).ToList(); _workerSearchCadastreNo.RunWorkerAsync(arg); } } }
private void btnLegalPersonParcel_Click(object sender, EventArgs e) { gridSearchResultLegalPerson.MainView.PostEditor(); List <LEGAL_PERSON> legalPersons = lEGALPERSONBindingSource.DataSource as List <LEGAL_PERSON>; if (legalPersons != null && legalPersons.Where(c => c.IsSelected).Count() > 0) { if (!_workerSearchCadastreNo.IsBusy) { progressBarLegalPerson.Visible = true; WorkerArg arg = new WorkerArg(); arg.ArgType = 2; arg.LegalPersons = legalPersons.Where(c => c.IsSelected).ToList(); _workerSearchCadastreNo.RunWorkerAsync(arg); } } }
public void ParseAsync(IEngineeringCompositionOrObject top, MessageLog log = null, Options options = 0) { if (worker != null && worker.IsBusy) { return; } worker = new BackgroundWorker(); worker.WorkerSupportsCancellation = true; worker.DoWork += DoWork; worker.RunWorkerCompleted += RunWorkerCompleted; callback_ctxt = SynchronizationContext.Current; ParseCtxt parse = new ParseCtxt(HandleTagAsync, options); parse.Log = log; WorkerArg arg = new WorkerArg(portal, top, parse); worker.RunWorkerAsync(arg); }
void _backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { WorkerArg args = e.Argument as WorkerArg; List <ParcelSearchResult> lstParcel = _srvParcel.LoadAllParcel(_businessParam); List <ParcelSearchResult> resutlist = null; try { if (args.ArgType == 0 && !string.IsNullOrEmpty(args.CadstralNo)) { string cadastralCode = args.CadstralNo.ToString(); lstParcel = _srvParcel.FindParcelsStartsWithCadastralNo(cadastralCode, false, _businessParam); } else if (args.ArgType == 1 && args.PhysicalPersons != null) { lstParcel = _srvParcel.FindParcelsByPhysicalPersons(args.PhysicalPersons, _businessParam).ToList(); } else if (args.ArgType == 2 && args.LegalPersons != null) { lstParcel = _srvParcel.FindParcelsByLegalPersons(args.LegalPersons, _businessParam).ToList(); } resutlist = lstParcel; if (args.Id_OLDDOCTYPE != null && args.Id_OLDDOCTYPE != -1) { resutlist = resutlist.Where(c => c.Id_OLDDOCTYPE == args.Id_OLDDOCTYPE).ToList(); } if (args.MinDocumentedArea != null && args.MaxDocumentedArea != null) { resutlist = resutlist.Where(c => c.DocumentedArea > args.MinDocumentedArea && c.DocumentedArea < args.MaxDocumentedArea).ToList(); } if (args.MinFacticalArea != null && args.MaxFacticalArea != null) { resutlist = resutlist.Where(c => c.FacticalArea > args.MinFacticalArea && c.FacticalArea < args.MaxFacticalArea).ToList(); } if (args.id_user != null && args.id_user != 0 && args.id_user != -1) { resutlist = resutlist.Where(c => c.Id_User == args.id_user).ToList(); } if (args.Id_PropertyType != null && args.Id_PropertyType != -1) { resutlist = resutlist.Where(c => c.Id_PropertyType == args.Id_PropertyType).ToList(); } if (args.Id_UsingForm != null && args.Id_UsingForm != -1) { resutlist = resutlist.Where(c => c.Id_UsingForm == args.Id_UsingForm).ToList(); } if (args.Id_LandCategory != null && args.Id_LandCategory != -1) { resutlist = resutlist.Where(c => c.Id_LandCategory == args.Id_LandCategory).ToList(); } if (args.date1 != null && args.date2.Value != null) { resutlist = resutlist.Where(c => c.dateTime >= args.date1 && c.dateTime <= args.date2).ToList(); } } catch (Exception ex) { } e.Result = resutlist; }
private void btnSearchCadastrNo_Click(object sender, EventArgs e) { if (txtCodeRegionZone.Text == "") { _errProvider.SetError(txtCodeRegionZone, "Kadastr zonası mütləq seçilməlidir"); } _errProvider.SetError(txtCodeRegionZone, ""); StringBuilder codePattern = new StringBuilder(txtCodeRegionZone.Text); if (txtCodeRegion.Text != "") { codePattern.Append(txtCodeRegion.Text); } else { codePattern.Append("__"); } if (txtCodeMunicipality.Text != "") { codePattern.Append(txtCodeMunicipality.Text); } else { codePattern.Append("___"); } if (txtCodeTerriturialUnit.Text != "") { codePattern.Append(txtCodeTerriturialUnit.Text); } else { codePattern.Append("__"); } codePattern.Append(txtParcelCadastralNo.Text); codePattern.Append("%"); string cadastralCode = codePattern.ToString(); if (!string.IsNullOrEmpty(cadastralCode)) { progressBarCadastreNo.Visible = true; if (!_workerSearchCadastreNo.IsBusy) { WorkerArg arg = new WorkerArg(); arg.CadstralNo = cadastralCode; arg.ArgType = 0; // APP_USER user = cboUser.SelectedItem as APP_USER; PROPERTY_TYPE type = cboPropertyType.SelectedItem as PROPERTY_TYPE; USING_FORM usingForm = cboUsingForm.SelectedItem as USING_FORM; LAND_CATEGORY category = cboCategory.SelectedItem as LAND_CATEGORY; OLD_DOCK_TYPE docType = cboDocType.SelectedItem as OLD_DOCK_TYPE; arg.id_user = idUser; arg.Id_PropertyType = type.ID_PROPERTY_TYPE; arg.Id_UsingForm = usingForm.ID_USING_FORM; arg.Id_LandCategory = category.ID_LAND_CATEGORY; arg.Id_OLDDOCTYPE = docType.ID_OLD_DOCK_TYPE; string argvalue = date1.Value.ToShortDateString(); string nowdate = DateTime.Now.ToShortDateString(); if (argvalue == nowdate) { arg.date1 = null; } else { arg.date1 = date1.Value; } arg.date2 = date2.Value; arg.MinFacticalArea = Convert.ToInt32(txtMinFacticalArea.Value); arg.MaxFacticalArea = txtMaxFacticalArea.Value != 0 ? Convert.ToInt32(txtMaxFacticalArea.Text) : (int?)null; if (txtMindocArea.Text != "") { arg.MinDocumentedArea = Convert.ToInt32(txtMindocArea.Text); } arg.MaxDocumentedArea = txtMaxdocArea.Value != 0 ? Convert.ToInt32(txtMaxdocArea.Text) : (int?)null; arg.ParcelOwners = parcel_owner_list; _workerSearchCadastreNo.RunWorkerAsync(arg); } } else { gridControl1.DataSource = new List <ParcelSearchResult>(); } }
void _worker_DoWork(object sender, DoWorkEventArgs e) { WorkerResult result = new WorkerResult(); InstallerInterface installer = null; try { WorkerArg arg = e.Argument as WorkerArg; result.TestConnectionOnly = arg.TestConnectionOnly; result.TestStatus = StackHashErrorIndexDatabaseStatus.Unknown; // configure for local access to the service if (!_localServiceConfigComplete) { _localServiceGuid = ClientLogic.GetLocalServiceGuid(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location); CheckVersionRequest checkVersionRequest = new CheckVersionRequest(); checkVersionRequest.ServiceGuid = _localServiceGuid == Guid.Empty ? null : _localServiceGuid.ToString(); checkVersionRequest.ClientData = GenerateClientData(); checkVersionRequest.MajorVersion = fvi.ProductMajorPart; checkVersionRequest.MinorVersion = fvi.ProductMinorPart; CheckVersionResponse checkVersionResponse = ServiceProxy.Services.Admin.CheckVersion(checkVersionRequest); _localServiceConfigComplete = true; } // always test that the service can access the database StackHashSqlConfiguration sqlConfig = new StackHashSqlConfiguration(); sqlConfig.ConnectionString = arg.MasterConnectionString; sqlConfig.ConnectionTimeout = DefaultSqlConnectionTimeout; sqlConfig.EventsPerBlock = DefaultSqlEventsPerBlock; sqlConfig.InitialCatalog = arg.ProfileName; sqlConfig.MaxPoolSize = DefaultSqlMaxPoolSize; sqlConfig.MinPoolSize = DefaultSqlMinPoolSize; TestDatabaseConnectionRequest request = new TestDatabaseConnectionRequest(); request.ClientData = GenerateClientData(); request.ContextId = -1; request.SqlSettings = sqlConfig; request.TestDatabaseExistence = false; request.CabFolder = arg.CabFolder; TestDatabaseConnectionResponse response = ServiceProxy.Services.Admin.TestDatabaseConnection(request); result.TestStatus = response.TestResult; result.TestLastExceptionText = response.LastException; result.CanAccessCabFolder = response.IsCabFolderAccessible; result.CabFolderExceptionText = response.CabFolderAccessLastException; // contine if the test succeeded and we're not just testing if ((result.TestStatus == StackHashErrorIndexDatabaseStatus.Success) && (result.CanAccessCabFolder) && (!arg.TestConnectionOnly)) { // make sure NETWORK SERVICE can access the cab folder FolderPermissionHelper.NSAddAccess(arg.CabFolder); if (arg.CreateDatabase) { installer = new InstallerInterface(arg.MasterConnectionString, arg.ProfileName, arg.CabFolder); installer.Connect(); if (!installer.DatabaseExists()) { installer.CreateDatabase(arg.UseDefaultLocation); } } DBConfigSettings.Settings.ProfileName = arg.ProfileName; DBConfigSettings.Settings.ConnectionString = arg.ConnectionString; DBConfigSettings.Settings.ProfileFolder = arg.CabFolder; DBConfigSettings.Settings.Save(); _configurationSucceeded = true; } } catch (Exception ex) { result.WorkerException = ex; } finally { if (installer != null) { installer.Disconnect(); } } // if a test exception was reported include it in the WorkerException if (!string.IsNullOrEmpty(result.TestLastExceptionText)) { if (result.WorkerException == null) { result.WorkerException = new AdminReportException(result.TestLastExceptionText); } else { result.WorkerException = new AdminReportException(result.TestLastExceptionText, result.WorkerException); } } else if (!string.IsNullOrEmpty(result.CabFolderExceptionText)) { if (result.WorkerException == null) { result.WorkerException = new AdminReportException(result.CabFolderExceptionText); } else { result.WorkerException = new AdminReportException(result.CabFolderExceptionText, result.WorkerException); } } e.Result = result; }