public void OnWorkFlowStepStarted(IDataWorkFlowEventArgs e) { throw new NotImplementedException(); }
private IErrorsInfo RunCopyDataBackWorker() { int tot = 0; int cur = 0; BackgroundWorker = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = true }; BackgroundWorker.WorkerReportsProgress = true; BackgroundWorker.ProgressChanged += (sender, eventArgs) => { IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item = new ObjectItem(); item.obj = eventArgs; item.Name = "backgroundworkerprogress"; passedArgs.Objects.Add(item); WorkFlowStepRunning?.Invoke(this, passedArgs); DMEEditor.RaiseEvent(this, passedArgs); DMEEditor.AddLogMessage("Copy Data Action ", "Success in Copying Data " + eventArgs.ProgressPercentage + " out of " + tot, DateTime.Now, eventArgs.ProgressPercentage, "", Errors.Ok); }; BackgroundWorker.DoWork += (sender, e) => { IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item1 = new ObjectItem(); item1.obj = e; item1.Name = "backgroundworkerstarted"; passedArgs.Objects.Add(item1); WorkFlowStepStarted?.Invoke(this, passedArgs); // OutData = await Inds.GetEntityDataAsTableAsync(OutParameters[0].Parameter, " 1=2 "); if (InParameters[1] != null) { if (InParameters[1].Objects != null) { List <string> ents = (List <string>)InParameters[1].Objects.Where(c => c.Name == "ENTITIES").FirstOrDefault().obj; if (ents != null) { EntitesNames = ents; } } } if (EntitesNames == null || EntitesNames.Count == 0) { if (Inds.EntitiesNames.Count() == 0) { Inds.GetEntitesList(); } EntitesNames = Inds.EntitiesNames; } //-------------------------------------------------- DMEEditor.ErrorObject.Flag = Errors.Ok; foreach (string item in EntitesNames) { cur += 1; var t = Task.Run <object>(() => { return(Inds.RunQuery(item)); }); t.Wait(); InData = t.Result; if (!Outds.CheckEntityExist(item)) { Outds.CreateEntityAs(Inds.GetEntityStructure(item, true)); } var t1 = Task.Run <IErrorsInfo>(() => { return(Outds.UpdateEntity(item, InData)); }); t1.Wait(); DMEEditor.ErrorObject = t1.Result; ((BackgroundWorker)sender).ReportProgress(cur); if (BackgroundWorker.CancellationPending) { break; } } //-------------------------------------------------- e.Result = ErrorObject; }; BackgroundWorker.RunWorkerCompleted += (sender, eventArgs) => { // do something on the UI thread, like // update status or display "result" IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item = new ObjectItem(); item.obj = eventArgs; item.Name = "backgroundworkerended"; passedArgs.Objects.Add(item); WorkFlowStepEnded?.Invoke(this, passedArgs); DMEEditor.AddLogMessage("End of Copy Entity Action ", "Success in Coping entity " + cur + " out of " + tot, DateTime.Now, tot, "", Errors.Ok); DMEEditor.AddLogMessage("Copy Entity Action ", "Success in Coping entity " + cur + " out of " + tot, DateTime.Now, tot, "", Errors.Ok); }; BackgroundWorker.RunWorkerAsync(); return(ErrorObject); }
private IErrorsInfo RunBackWorker() { int tot = 0; int cur = 0; BackgroundWorker = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = true }; BackgroundWorker.WorkerReportsProgress = true; BackgroundWorker.ProgressChanged += (sender, eventArgs) => { IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item = new ObjectItem(); item.obj = eventArgs; item.Name = "backgroundworkerprogress"; passedArgs.Objects.Add(item); WorkFlowStepRunning?.Invoke(this, passedArgs); DMEEditor.AddLogMessage("Copy Entity Action ", "Success in Coping entity " + eventArgs.ProgressPercentage + " out of " + tot, DateTime.Now, eventArgs.ProgressPercentage, "", Errors.Ok); }; BackgroundWorker.DoWork += (sender, e) => { IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item1 = new ObjectItem(); item1.obj = e; item1.Name = "backgroundworkerstarted"; passedArgs.Objects.Add(item1); WorkFlowStepStarted?.Invoke(this, passedArgs); if (Outds.EntitiesNames.Count() == 0) { Outds.GetEntitesList(); } tot = Outds.EntitiesNames.Count(); foreach (string item in Outds.EntitiesNames) { cur += 1; string SourceEntityName = item; if (Outds.CheckEntityExist(SourceEntityName) == false) { Outds.CreateEntityAs(Outds.GetEntityStructure(SourceEntityName, false)); ((BackgroundWorker)sender).ReportProgress(cur); if (BackgroundWorker.CancellationPending) { break; } } } e.Result = DMEEditor.ErrorObject; }; BackgroundWorker.RunWorkerCompleted += (sender, eventArgs) => { // do something on the UI thread, like // update status or display "result" IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item = new ObjectItem(); item.obj = eventArgs; item.Name = "backgroundworkerended"; passedArgs.Objects.Add(item); WorkFlowStepEnded?.Invoke(this, passedArgs); DMEEditor.AddLogMessage("End of Copy Entity Action ", "Success in Coping entity " + cur + " out of " + tot, DateTime.Now, tot, "", Errors.Ok); DMEEditor.AddLogMessage("Copy Entity Action ", "Success in Coping entity " + cur + " out of " + tot, DateTime.Now, tot, "", Errors.Ok); }; BackgroundWorker.RunWorkerAsync(); return(DMEEditor.ErrorObject); }
private IErrorsInfo RunCreateEntityBackWorker() { int tot = 0; int cur = 0; BackgroundWorker = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = true }; BackgroundWorker.WorkerReportsProgress = true; BackgroundWorker.ProgressChanged += (sender, eventArgs) => { IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item = new ObjectItem(); item.obj = eventArgs; item.Name = "backgroundworkerprogress"; passedArgs.Objects.Add(item); WorkFlowStepRunning?.Invoke(this, passedArgs); DMEEditor.AddLogMessage("Copy Entity Action ", "Success in Coping entity " + eventArgs.ProgressPercentage + " out of " + tot, DateTime.Now, eventArgs.ProgressPercentage, "", Errors.Ok); }; //---- Do Work here BackgroundWorker.DoWork += (sender, e) => { IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item1 = new ObjectItem(); item1.obj = e; item1.Name = "backgroundworkerstarted"; passedArgs.Objects.Add(item1); WorkFlowStepStarted?.Invoke(this, passedArgs); if (InParameters[1] != null) { if (InParameters[1].Objects != null) { List <string> ents = (List <string>)InParameters[1].Objects.Where(c => c.Name == "ENTITIES").FirstOrDefault().obj; if (ents != null) { EntitesNames = ents; } } } if (EntitesNames == null || EntitesNames.Count == 0) { if (Inds.EntitiesNames.Count() == 0) { Inds.GetEntitesList(); } EntitesNames = Inds.EntitiesNames; } tot = EntitesNames.Count(); // List<LScript> sc =Outds.GetCreateEntityScript(EntitesNames); // Outds.RunScripts(sc); foreach (string item in EntitesNames) { cur += 1; string SourceEntityName = item; //if (Outds.CheckEntityExist(SourceEntityName) == false) //{ // Outds.CreateEntityAs(Inds.GetEntityStructure(SourceEntityName,false)); // ((BackgroundWorker)sender).ReportProgress(cur); // if (BackgroundWorker.CancellationPending) // { // break; // } //} } e.Result = ErrorObject; }; //----- Worker finish BackgroundWorker.RunWorkerCompleted += (sender, eventArgs) => { // do something on the UI thread, like // update status or display "result" IDataWorkFlowEventArgs passedArgs = new IDataWorkFlowEventArgs(); ObjectItem item = new ObjectItem(); item.obj = eventArgs; item.Name = "backgroundworkerended"; passedArgs.Objects.Add(item); WorkFlowStepEnded?.Invoke(this, passedArgs); DMEEditor.AddLogMessage("End of Copy Entity Action ", "Success in Coping entity " + cur + " out of " + tot, DateTime.Now, tot, "", Errors.Ok); DMEEditor.AddLogMessage("Copy Entity Action ", "Success in Coping entity " + cur + " out of " + tot, DateTime.Now, tot, "", Errors.Ok); }; BackgroundWorker.RunWorkerAsync(); return(ErrorObject); }