/// <summary> /// Gets the document action value /// </summary> /// <returns>The document action value</returns> public DocAction?GetDocActionValue() { if (Value == null) { return(null); } if (Value is string) { Type typeDocAction = typeof(DocAction); FieldInfo[] fieldInfo = typeDocAction.GetFields(); foreach (FieldInfo field in fieldInfo) { if (field.Name.Equals("value__")) { continue; } DocAction docAction = (DocAction)Enum.Parse(typeof(DocAction), field.Name, false); if (Value.ToString().Equals(docAction.GetValue())) { return(docAction); } } return((DocAction)Enum.Parse(typeof(DocAction), Value.ToString(), false)); } return((DocAction)Value); }
/// <summary> /// /// </summary> /// <param name="po"></param> /// <param name="docStatus"></param> public DocumentEngine(DocAction po, String docStatus) { _document = po; if (docStatus != null) { _status = docStatus; } }
/// <summary> /// Gets the iDempiere Document Action Value /// </summary> /// <returns>The iDempiere Document Action Value</returns> /// <param name="docAction">iDempiere Document Action Value</param> public static string GetValue(this DocAction?docAction) { if (docAction == null) { return(null); } DocAction doc = docAction.Value; return(GetValue(doc)); }
/// <summary> /// Is this a Valid Transition For .. /// </summary> /// <param name="activity">activity</param> /// <returns>true if valid</returns> public bool IsValidFor(MWFActivity activity) { if (IsStdUserWorkflow()) { PO po = activity.GetPO(); if (po.GetType() == typeof(DocAction) || po.GetType().GetInterface("DocAction") == typeof(DocAction)) { DocAction da = (DocAction)po; String docStatus = da.GetDocStatus(); String docAction = da.GetDocAction(); if (!DocActionVariables.ACTION_COMPLETE.Equals(docAction) || DocActionVariables.STATUS_COMPLETED.Equals(docStatus) || DocActionVariables.STATUS_WAITINGCONFIRMATION.Equals(docStatus) || DocActionVariables.STATUS_WAITINGPAYMENT.Equals(docStatus) || DocActionVariables.STATUS_VOIDED.Equals(docStatus) || DocActionVariables.STATUS_CLOSED.Equals(docStatus) || DocActionVariables.STATUS_REVERSED.Equals(docStatus)) /* || DocAction.ACTION_Complete.equals(docAction) || DocAction.ACTION_ReActivate.equals(docAction) || DocAction.ACTION_None.equals(docAction) || DocAction.ACTION_Post.equals(docAction) || DocAction.ACTION_Unlock.equals(docAction) || DocAction.ACTION_Invalidate.equals(docAction) ) */ { log.Fine("isValidFor =NO= StdUserWF - Status=" + docStatus + " - Action=" + docAction); return(false); } } } // No Conditions if (GetConditions(false).Length == 0) { log.Fine("#0 " + ToString()); return(true); } // First condition always AND bool ok = _conditions[0].Evaluate(activity); for (int i = 1; i < _conditions.Length; i++) { if (_conditions[i].IsOr()) { ok = ok || _conditions[i].Evaluate(activity); } else { ok = ok && _conditions[i].Evaluate(activity); } } // for all conditions log.Fine("isValidFor (" + ok + ") " + ToString()); return(ok); }
/// <summary> /// Gets the iDempiere Document Action Value /// </summary> /// <returns>The iDempiere Document Action Value</returns> /// <param name="docAction">iDempiere Document Action Value</param> public static string GetValue(this DocAction docAction) { switch (docAction) { case DocAction.Complete: return("CO"); case DocAction.WaitComplete: return("WC"); case DocAction.Approve: return("AP"); case DocAction.Reject: return("RJ"); case DocAction.Post: return("PO"); case DocAction.Void: return("VO"); case DocAction.Close: return("CL"); case DocAction.ReverseCorrect: return("RC"); case DocAction.ReverseAccrual: return("RA"); case DocAction.ReActivate: return("RE"); case DocAction.Prepare: return("PR"); case DocAction.Unlock: return("XL"); case DocAction.Invalidate: return("IN"); case DocAction.ReOpen: return("OP"); case DocAction.None: default: return("--"); } }
/// <summary> /// Check to see if the appropriate periods are open for this document /// </summary> /// <param name="doc">Doc</param> /// <returns>null if all periods open; otherwise the error message</returns> public static String IsPeriodOpen(DocAction doc) { List <int> docOrgs = new List <int>(); String errorMsg = null; if (errorMsg == null) { // check if lines exist // get all the orgs stamped on the document lines VAdvantage.Utility.Env.QueryParams qParams = doc.GetLineOrgsQueryInfo(); if (qParams != null) { //Object[][] result = QueryUtil.ExecuteQuery(doc.Get_Trx(), qParams.sql, // qParams.parameters.ToList()); Object[][] result = VAdvantage.Utility.QueryUtil.ExecuteQuery(doc.Get_Trx(), qParams.sql, qParams.parameters.ToList()); foreach (Object[] row in result) { docOrgs.Add(Utility.Util.GetValueOfInt(Utility.Util.GetValueOfDecimal(row[0]))); } // check if lines are missing if (result.Length == 0) { errorMsg = "@NoLines@"; } } } if (errorMsg == null) { DateTime?docDate = doc.GetDocumentDate(); String docBaseType = doc.GetDocBaseType(); if (docDate != null && docBaseType != null) { // check if period is open // add doc header org to the list of orgs if (!docOrgs.Contains(doc.GetAD_Org_ID())) { docOrgs.Add(doc.GetAD_Org_ID()); } // Std Period open? errorMsg = MPeriod.IsOpen(doc.GetCtx(), doc.GetAD_Client_ID(), docOrgs, docDate, docBaseType); } } return(errorMsg); }
public DocActionModel(DocAction actionDoc) { if (actionDoc == null) { throw new ArgumentNullException(nameof(actionDoc), "Action Documentation not specified"); } ActionId = actionDoc.ActionId; Description = actionDoc.Description; RouteParams = actionDoc.ActionParams; ErrorCodes = actionDoc.HttpCodes; EmbeddedResources = actionDoc.EmbeddedResources; ResponseDescription = actionDoc.ResponseDescription; Relations = actionDoc.Relations; }
/// <summary> /// Set User from /// - (1) Responsible /// - (2) Document Sales Rep /// - (3) Document UpdatedBy /// - (4) Process invoker /// </summary> /// <param name="User_ID">process invoker</param> private void SetUser_ID(int User_ID) { // Responsible MWFResponsible resp = MWFResponsible.Get(GetCtx(), GetAD_WF_Responsible_ID()); // (1) User - Directly responsible int AD_User_ID = resp.GetAD_User_ID(); // Invoker - get Sales Rep or last updater of Document if (AD_User_ID == 0 && resp.IsInvoker()) { GetPO(); // (2) Doc Owner //if (_po != null && _po instanceof DocAction) if (_po != null && (_po.GetType() == typeof(DocAction) || _po.GetType().GetInterface("DocAction") == typeof(DocAction))) { DocAction da = (DocAction)_po; AD_User_ID = da.GetDoc_User_ID(); } // (2) Sales Rep if (AD_User_ID == 0 && _po != null && _po.Get_ColumnIndex("SalesRep_ID") != -1) { Object sr = _po.Get_Value("SalesRep_ID"); if (sr != null && sr.GetType() == typeof(int)) { AD_User_ID = int.Parse(sr.ToString()); } } // (3) UpdatedBy if (AD_User_ID == 0 && _po != null) { AD_User_ID = _po.GetUpdatedBy(); } } // (4) Process Owner if (AD_User_ID == 0) { AD_User_ID = User_ID; } // Fallback if (AD_User_ID == 0) { AD_User_ID = GetCtx().GetAD_User_ID(); } // SetAD_User_ID(AD_User_ID); }
///Manfacturing /// <summary> /// Process document. This replaces DocAction.processIt(). /// </summary> /// <param name="doc">Doc Action</param> /// <param name="processAction">processAction</param> /// <returns>true if performed</returns> /// <date>07-march-2011</date> /// <writer>raghu</writer> public static Boolean ProcessIt(DocAction doc, String processAction) { DateTime time = DateTime.Now.Date; Boolean success = false; VAdvantage.Utility.Ctx ctx = doc.GetCtx(); Boolean oldIsBatchMode = ctx.IsBatchMode(); ctx.SetBatchMode(true); DocumentEngine engine = new DocumentEngine(doc, doc.GetDocStatus()); success = engine.ProcessIt(processAction, doc.GetDocAction()); ctx.SetBatchMode(oldIsBatchMode); return(success); }
/// <summary> /// Try to read a Sord object. /// </summary> /// <param name="objId">Object ID</param> /// <param name="accessMode">A combination of the FWAccessMode constants.</param> /// <param name="docAction">DocAction. /// If the Sord object is a <c>FWDocument</c> and the parameter is set to <c>DocAction.EditDocument</c> and FWAccessMode.Lock is set, the document will copied to the checkout-directory. /// Th eparameter will be ignored, if the Sord object is a <c>FWFolder</c>. /// </param> /// <returns>Sord object or null, if the object does not exist and accessMode does not include MustExist.</returns> /// <exception>IOException: object already locked, access denied, etc.</exception> public virtual FWSord TryGetSord(string objId, FWAccessModes accessMode, DocAction docAction) { FWSord xsord = null; bool exceptionOccured = false; FWSord tmpSord = null; try { //GetSord(objId); LockZ lockZ = FWLockMode.MakeLockZ(FWAccessModes.MustExist); Sord sord = Conn.Ix.checkoutDoc(objId, null, EditZ, lockZ).sord; sord.changedMembers = EditZ.bset; if (sord.id == 1 || sord.type < SordC.LBT_DOCUMENT) { tmpSord = ClassFactory.NewFolder(sord); } else { tmpSord = ClassFactory.NewDocument(sord); } } catch (Exception e) { exceptionOccured = true; if ((accessMode & FWAccessModes.MustExist) != 0) { throw e; } if (e.Message.IndexOf("[ELOIX:" + IXExceptionC.NOT_FOUND) < 0) { throw e; } } if (tmpSord != null && tmpSord.IsDocument() && docAction == DocAction.EditDocument) { CheckoutResult result = checkedOutDocumentsManagerVal.Checkout(tmpSord as FWDocument); if (result.Success) { xsord = result.FWDocument; } } else if (!exceptionOccured) { try { LockZ lockZ = FWLockMode.MakeLockZ(accessMode); Sord sord = Conn.Ix.checkoutDoc(objId, null, EditZ, lockZ).sord; sord.changedMembers = EditZ.bset; if (sord.id == 1 || sord.type < SordC.LBT_DOCUMENT) { xsord = ClassFactory.NewFolder(sord); } else { xsord = ClassFactory.NewDocument(sord); } } catch (Exception e) { if ((accessMode & FWAccessModes.MustExist) != 0) { throw e; } if (e.Message.IndexOf("[ELOIX:" + IXExceptionC.NOT_FOUND) < 0) { throw e; } } } return(xsord); }
private DocBase CreateModel() { // Find assembly var a = Assembly.GetExecutingAssembly().GetReferencedAssemblies().FirstOrDefault(a => a.Name == _options.Value.PluginName); if (a == null) { throw new FileNotFoundException("Unable to load assembly for reflection."); } var model = new DocBase { Title = "MSFS 2020 TouchPortal Plugin", Overview = "This plugin will provide a two way interface between Touch Portal and Microsoft Flight Simulator 2020 through SimConnect." }; var assembly = Assembly.Load(a); var assemblyList = assembly.GetTypes().ToList(); // Get all classes with the TouchPortalCategory var classList = assemblyList.Where(t => t.CustomAttributes.Any(att => att.AttributeType == typeof(TouchPortalCategoryAttribute))).OrderBy(o => o.Name).ToList(); // Loop through categories classList.ForEach(cat => { var catAttr = (TouchPortalCategoryAttribute)Attribute.GetCustomAttribute(cat, typeof(TouchPortalCategoryAttribute)); var newCat = new DocCategory { Name = catAttr.Name }; // Loop through Actions var actions = cat.GetMembers().Where(t => t.CustomAttributes.Any(att => att.AttributeType == typeof(TouchPortalActionAttribute))).ToList(); actions.ForEach(act => { var actionAttribute = (TouchPortalActionAttribute)Attribute.GetCustomAttribute(act, typeof(TouchPortalActionAttribute)); var newAct = new DocAction { Name = actionAttribute.Name, Description = actionAttribute.Description, Type = actionAttribute.Type, Format = actionAttribute.Format }; // Loop through Action Data var choiceAttributes = act.GetCustomAttributes <TouchPortalActionChoiceAttribute>()?.ToList(); if (choiceAttributes?.Count > 0) { for (int i = 0; i < choiceAttributes.Count; i++) { var data = new DocActionData { Type = "choice", DefaultValue = choiceAttributes[i].DefaultValue, Values = string.Join(",", choiceAttributes[i].ChoiceValues) }; newAct.Data.Add(data); } } newCat.Actions.Add(newAct); }); newCat.Actions = newCat.Actions.OrderBy(c => c.Name).ToList(); // Loop through States var states = cat.GetFields().Where(m => m.CustomAttributes.Any(att => att.AttributeType == typeof(TouchPortalState))).ToList(); states.ForEach(state => { var stateAttribute = state.GetCustomAttribute <TouchPortalStateAttribute>(); if (stateAttribute != null) { var newState = new DocState { Id = $"{_options.Value.PluginName}.{catAttr.Id}.State.{stateAttribute.Id}", Type = stateAttribute.Type, Description = stateAttribute.Description, DefaultValue = stateAttribute.Default }; newCat.States.Add(newState); } }); newCat.States = newCat.States.OrderBy(c => c.Description).ToList(); // Loop through Events model.Categories.Add(newCat); }); model.Categories = model.Categories.OrderBy(c => c.Name).ToList(); return(model); }
public void SpinDocAction(DocAction action) { Spin(delegate() { return HandleDocAction(action); }, string.Empty); }
public void SpinDocAction(DocAction action, string message) { Spin(delegate() { return HandleDocAction(action); }, message); }
public bool HandleDocAction(DocAction action) { IEDoc doc = IEDoc.FromIE(Window); if(doc == null) return false; return action(doc); }
/// <summary> /// Locks the Sord object with the given numeric object ID. /// The document must exist. /// </summary> /// <param name="objId">Object-ID</param> /// <param name="docAction">DocAction. /// If the Sord object is a <c>FWDocument</c> and the parameter is set to <c>DocAction.EditDocument</c> the document will copied to the checkout-directory. /// Th eparameter will be ignored, if the Sord object is a <c>FWFolder</c>. /// </param> /// <returns>Document object</returns> public virtual FWSord LockSord(int objId, DocAction docAction) { return(LockSord(Convert.ToString(objId), docAction)); }
/// <summary> /// Locks the Sord object with the given object ID, GUID, ARCPATH etc. /// The document must exist. /// </summary> /// <param name="objId">Object-ID</param> /// <param name="docAction">DocAction. /// If the Sord object is a <c>FWDocument</c> and the parameter is set to <c>DocAction.EditDocument</c> the document will copied to the checkout-directory. /// Th eparameter will be ignored, if the Sord object is a <c>FWFolder</c>. /// </param> /// <returns>Document object</returns> public virtual FWSord LockSord(string objId, DocAction docAction) { return(TryGetSord(objId, FWAccessModes.MustExist | FWAccessModes.Lock)); }
/// <summary> /// Try to read a document object. /// </summary> /// <remarks>This function calls internally <see cref="TryGetSord"/>. /// An Exception is thrown, if the returned object is not a document object.</remarks> /// <param name="objId"><see cref="TryGetSord"/></param> /// <param name="accessMode"><see cref="TryGetSord"/></param> /// <param name="docAction">DocAction. If set to <c>DocAction.EditDocument</c> and AccessModes.Lock, the document will copied to the checkout-directory.</param> /// <returns><see cref="TryGetSord"/></returns> /// <exception>IOException: <see cref="TryGetSord"/></exception> /// <exception>InvalidOperationException: object is not a document.</exception> public virtual FWDocument TryGetDocument(string objId, FWAccessModes accessMode, DocAction docAction) { FWSord xsord = TryGetSord(objId, accessMode); if (xsord != null) { if (!(xsord is FWDocument)) { throw new InvalidOperationException("Object " + objId + " is not a document."); } } return((FWDocument)xsord); }
/// <summary> /// Locks the document object with the given numeric object ID. /// The document must exist. /// </summary> /// <param name="objId">Object-ID</param> /// <param name="docAction">DocAction. If set to <c>DocAction.EditDocument</c> the document will copied to the checkout-directory.</param> /// <returns>Document object</returns> public virtual FWDocument LockDocument(int objId, DocAction docAction) { return(LockDocument(Convert.ToString(objId), docAction)); }
/// <summary> /// Doc Engine (Drafted) /// </summary> /// <param name="po">document</param> public DocumentEngine(DocAction po) : this(po, STATUS_DRAFTED) { }
/// <summary> /// Locks the document object with the given ID, GUID, ARCPATH etc. /// The document must exist. /// </summary> /// <param name="objId">Object-ID</param> /// <param name="docAction">DocAction. If set to <c>DocAction.EditDocument</c> the document will copied to the checkout-directory.</param> /// <returns>Document object</returns> public virtual FWDocument LockDocument(string objId, DocAction docAction) { return(TryGetDocument(objId, FWAccessModes.MustExist | FWAccessModes.Lock)); }