private string GetOrderDataCSV() { int countLines = 0; if (CurrentInOrder == null) { return(null); } StringBuilder sb = new StringBuilder(); // 17. Always access the data context with a new EF-Database-Instance because the Entities in the root workflow-node are in DETACHED-State! using (MyCompanyDB dbApp = new MyCompanyDB()) { InOrder inOrder = dbApp.InOrder.Include(c => c.InOrderPos_InOrder) .Include("InOrderPos_InOrder.Material") .Where(c => c.InOrderID == CurrentInOrder.InOrderID) .FirstOrDefault(); if (inOrder != null) { sb.AppendLine(String.Format("{0};{1};", inOrder.InOrderNo, inOrder.InOrderDate)); foreach (var line in inOrder.InOrderPos_InOrder) { countLines++; sb.AppendLine(String.Format("{0};{1};", line.Material.MaterialNo, line.TargetQuantity)); } } } using (ACMonitor.Lock(_20015_LockValue)) { _CountLines = countLines; } return(sb.ToString()); }
private void Window_Loaded(object sender, RoutedEventArgs e) { string[] cmLineArg = System.Environment.GetCommandLineArgs(); ACRoot.SRoot.RootPageWPF = this; ACMenuItem mainMenu; if (ACRoot.SRoot.Environment.User.MenuACClassDesign == null) { ACClassDesign acClassDesign = ACRoot.SRoot.GetDesign(Global.ACKinds.DSDesignMenu); mainMenu = acClassDesign.GetMenuEntryWithCheck(ACRoot.SRoot); } else { using (ACMonitor.Lock(ACRoot.SRoot.Database.ContextIPlus.QueryLock_1X000)) { mainMenu = ACRoot.SRoot.Environment.User.MenuACClassDesign.GetMenuEntryWithCheck(ACRoot.SRoot); } } if (mainMenu != null) { CreateMenu(mainMenu.Items, MainMenu.Items); } InitAppCommands(); InitMainDockManager(); }
/// <summary>Clears the cache of configuration entries. (ConfigurationEntries) /// Re-accessing the ConfigurationEntries property rereads all configuration entries from the database.</summary> public void ClearCacheOfConfigurationEntries() { using (ACMonitor.Lock(_10020_LockValue)) { _ACConfigListCache = null; } }
// 11. Implementation of IACMyConfigCache for resetting the local cache (_MyConfiguration) public void ClearMyConfiguration() { using (ACMonitor.Lock(_20015_LockValue)) { _MyConfiguration = null; } HasRules.ValueT = 0; }
public override void Recycle(IACObject content, IACObject parentACObject, ACValueList parameter, string acIdentifier = "") { // 9. Reset local members to make this instance reusable when it was taken from the component pool using (ACMonitor.Lock(_20015_LockValue)) { _CurrentInOrder = null; } base.Recycle(content, parentACObject, parameter, acIdentifier); }
public override bool ACDeInit(bool deleteACClassTask = false) { // 15. Reset local members to make this instance reusable before it will be added to the component pool using (ACMonitor.Lock(_20015_LockValue)) { _CountLines = 0; } ClearMyConfiguration(); return(base.ACDeInit(deleteACClassTask)); }
public override bool ACDeInit(bool deleteACClassTask = false) { // 9. Reset local members to make this instance reusable before it will be added to the component pool using (ACMonitor.Lock(_20015_LockValue)) { _CurrentInOrder = null; } if (!base.ACDeInit(deleteACClassTask)) { return(false); } return(true); }
// 7. Override this method to control if Start-Node (PWNodeStart) can be activated to run the workflow protected override bool CanRunWorkflow() { bool canRunWF = false; using (ACMonitor.Lock(_20015_LockValue)) { canRunWF = _CurrentInOrder != null; } if (!canRunWF) { return(false); } return(ProcessAlarm.ValueT == PANotifyState.Off); }
// 4. Override the Start-Method public override ACMethodEventArgs Start(ACMethod acMethod) { // 5. Read the data context: InOrder inOrder = GetInOrder(acMethod); if (inOrder == null) { return(CreateNewMethodEventArgs(acMethod, Global.ACMethodResultState.Failed)); } using (ACMonitor.Lock(_20015_LockValue)) { _CurrentInOrder = inOrder; } // 6. Call base-Start() to start the Workflow return(base.Start(acMethod)); }
// 8. Method that reads the data context when iPlus-Service was restarted protected virtual void LoadEntities() { var rootPW = RootPW; if (rootPW == null || CurrentACMethod == null || CurrentACMethod.ValueT == null) { return; } InOrder inOrder = GetInOrder(CurrentACMethod.ValueT); using (ACMonitor.Lock(_20015_LockValue)) { _CurrentInOrder = inOrder; } }
public override void SMStarting() { string csv = GetOrderDataCSV(); if (String.IsNullOrEmpty(csv) || (CountLines <= 0 && SkipIfNoLines)) { if (CurrentACState == ACStateEnum.SMStarting) { CurrentACState = ACStateEnum.SMCompleted; } return; } if (ParentPWGroup != null && this.ContentACClassWF != null) { // 5. RefPAACClassMethod is a reference to the virtual "WriteOrder"-Method ACClassMethod refPAACClassMethod = null; using (ACMonitor.Lock(this.ContextLockForACClassWF)) { refPAACClassMethod = this.ContentACClassWF.RefPAACClassMethod; } if (refPAACClassMethod != null) { PAProcessModule module = ParentPWGroup.AccessedProcessModule; if (module == null) { Msg msg = new Msg("AccessedProcessModule is null", this, eMsgLevel.Error, PWClassName, "SMStarting", 1010); if (IsAlarmActive(ProcessAlarm, msg.Message) == null) { Messages.LogError(this.GetACUrl(), "SMStarting(10)", msg.Message); } OnNewAlarmOccurred(ProcessAlarm, msg, true); SubscribeToProjectWorkCycle(); return; } // 6. With TypeACSignature() you get ACMethod for "WriteOrder" ACMethod paramMethod = refPAACClassMethod.TypeACSignature(); if (!(bool)ExecuteMethod("GetConfigForACMethod", paramMethod, true)) { return; } // 7. Set all necessary parameters paramMethod.ParameterValueList["Content"] = csv; RecalcTimeInfo(); if (CreateNewProgramLog(paramMethod) <= CreateNewProgramLogResult.ErrorNoProgramFound) { return; } _ExecutingACMethod = paramMethod; // 8. Start asynchronous task on PAFOrder. if (!module.TaskInvocationPoint.AddTask(paramMethod, this)) { SubscribeToProjectWorkCycle(); return; } else { UnSubscribeToProjectWorkCycle(); } UpdateCurrentACMethod(); } } // 9. Switch to State SMRunning // (If module.AddTask was exceuted syncronously then state is maybe already Runnning.) if (IsACStateMethodConsistent(ACStateEnum.SMStarting) < ACStateCompare.WrongACStateMethod) { CurrentACState = ACStateEnum.SMRunning; } }