public static string GetDesignXml(IMMWMSDesign design, IMMPxApplication PxApp, bool CompatibilityMode) { IMMWMSDesign4 dn4 = design as IMMWMSDesign4; if (dn4.DesignerProductType == mmWMSDesignerProductType.mmExpress) { //return GetExpressDesignXml(design, PxApp); throw new Exception("Retrieving design Xml for Designer Express designs is not supported."); } else if (dn4.DesignerProductType == mmWMSDesignerProductType.mmStaker) { throw new Exception("Retrieving design Xml for Staker designs is not supported."); } else { if (CompatibilityMode) { return(GetClassicDesignXml(design.ID)); } else { return(GetClassicPxXml(design, PxApp)); } } }
/// <summary> /// Updates the EDMPROP element with the Extended Data associated with the specified WFM node. /// </summary> /// <param name="element">The element.</param> /// <param name="node">A WFM node object representing a Work Request, Design, Work Location, or Compatible Unit.</param> private void UpdateEdm(IXMLDOMElement element, IMMWMSNode node) { IMMWMSWorkRequest workRequest = node as IMMWMSWorkRequest; if (workRequest != null) { this.SetProperty(element, _EdmRepository.WorkRequest, string.Format(CultureInfo.InvariantCulture, "{0} = {1}", Fields.WorkRequestID, workRequest.ID)); } else { IMMWMSDesign design = node as IMMWMSDesign; if (design != null) { this.SetProperty(element, _EdmRepository.Design, string.Format(CultureInfo.InvariantCulture, "{0} = {1}", Fields.DesignID, design.ID)); } else { IMMWMSWorklocation workLocation = node as IMMWMSWorklocation; if (workLocation != null) { this.SetProperty(element, _EdmRepository.WorkLocation, string.Format(CultureInfo.InvariantCulture, "{0} = {1}", Fields.WorkLocationID, workLocation.ID)); } else { IMMWMSCompatibleUnit compatibleUnit = node as IMMWMSCompatibleUnit; if (compatibleUnit != null) { this.SetProperty(element, _EdmRepository.CompatibleUnit, string.Format(CultureInfo.InvariantCulture, "{0} = {1}", Fields.CompatibleUnitID, compatibleUnit.ID)); } } } } }
/// <summary> /// This will save the given node and edm struct data into the correct configured edm tables. /// </summary> /// <param name="node">IMMWMSNode which can be the WorkRequest, Design, WorkLocation, or CU.</param> /// <param name="edm">EDM struct containing the data.</param> private void Save(IMMWMSNode node, EDM edm) { string sql = null; EdmTable table = null; IMMWMSWorkRequest workRequest = node as IMMWMSWorkRequest; if (workRequest != null) // WorkRequest { table = _EdmRepository.WorkRequest; sql = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0} ({1},{2},{3},{4},{5}) VALUES ({6}, {7},'{8}','{9}','{10}')", "{0}", Fields.WorkRequestID, Fields.DesignID, EDM.Fields.Name, EDM.Fields.Value, EDM.Fields.Type, workRequest.ID, _ID, edm.Name, edm.Value, edm.Type); } else { IMMWMSDesign design = node as IMMWMSDesign; if (design != null) // Design { table = _EdmRepository.Design; sql = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0} ({1},{2},{3},{4}) VALUES ({5}, {6},'{7}','{8}', '{9}')", "{0}", Fields.DesignID, EDM.Fields.Name, EDM.Fields.Value, EDM.Fields.Type, design.ID, _ID, edm.Name, edm.Value, edm.Type); } else { IMMWMSWorklocation workLocation = node as IMMWMSWorklocation; if (workLocation != null) // WorkLocation { table = _EdmRepository.WorkLocation; sql = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0} ({1},{2},{3},{4},{5}) VALUES ({6}, {7},'{8}','{9}','{10}')", "{0}", Fields.WorkLocationID, Fields.DesignID, EDM.Fields.Name, EDM.Fields.Value, EDM.Fields.Type, workLocation.ID, _ID, edm.Name, edm.Value, edm.Type); } else { IMMWMSCompatibleUnit compatibleUnit = node as IMMWMSCompatibleUnit; if (compatibleUnit != null) // CompatibleUnit { table = _EdmRepository.CompatibleUnit; sql = string.Format(CultureInfo.InvariantCulture, "INSERT INTO {0} ({1},{2},{3},{4},{5}) VALUES ({6}, {7},'{8}','{9}','{10}')", "{0}", Fields.CompatibleUnitID, Fields.DesignID, EDM.Fields.Name, EDM.Fields.Value, EDM.Fields.Type, compatibleUnit.ID, _ID, edm.Name, edm.Value, edm.Type); } } } } // Insert the EDM when the table is valid. if (table != null && table.Valid) { // Check to see that the field is not being excluded. if (table.Fields.Count(o => o.Name.Equals(edm.Name, StringComparison.OrdinalIgnoreCase)) == 0) { // Add the EDM record into the table. _PxApp.ExecuteNonQuery(string.Format(CultureInfo.InvariantCulture, sql, _PxApp.GetQualifiedTableName(table.TableName))); } } }
/// <summary> /// Creates the process framework node wrapper for the specified the <paramref name="user" />. /// </summary> /// <param name="extension">The extension.</param> /// <param name="user">The current user.</param> /// <returns> /// Returns <see cref="bool" /> representing <c>true</c> if the node was successfully created; otherwise <c>false</c>. /// </returns> protected override bool Initialize(IMMWorkflowManager extension, IMMPxUser user) { int ownerID = user.Id; string nodeTypeName = NodeTypeName; _Design = (IMMWMSDesign)extension.CreateWMSNode(ref nodeTypeName); _Design.set_OwnerID(ref ownerID); return(_Design != null); }
public static string GetClassicPxXml(IMMWMSDesign design, IMMPxApplication PxApp) { object clsDXml = (Activator.CreateInstance(Type.GetTypeFromProgID("mmWorkflowManager.clsDesignerXmlDN"))); IMMPxXml pxXml = (IMMPxXml)clsDXml; //Initialize the above instance with the current application pxXml.Initialize(PxApp); //Export the xml file for the node with id = _pxNode.Id and store it in a string return(pxXml.Export(design.ID)); }
public static string GetClassicPxXml(IMMWMSDesign design, IMMPxApplication PxApp) { object clsDXml = (Activator.CreateInstance(Type.GetTypeFromProgID("mmWorkflowManager.clsDesignerXmlDN"))); IMMPxXml pxXml = (IMMPxXml)clsDXml; //Initialize the above instance with the current application pxXml.Initialize(PxApp); //Export the xml file for the node with id = _pxNode.Id and store it in a string return pxXml.Export(design.ID); }
/// <summary> /// Initializes the process framework node wrapper using the specified <paramref name="nodeId" /> for the node. /// </summary> /// <param name="extension">The extension.</param> /// <param name="nodeId">The node identifier.</param> /// <returns> /// Returns <see cref="bool" /> representing <c>true</c> if the node was successfully initialized; otherwise /// <c>false</c>. /// </returns> protected override bool Initialize(IMMWorkflowManager extension, int nodeId) { if (_Design != null && _Design.ID == nodeId) { return(true); } bool ro = false; bool sm = true; string nodeTypeName = NodeTypeName; _Design = (IMMWMSDesign)extension.GetWMSNode(ref nodeTypeName, ref nodeId, ref ro, ref sm); return(_Design != null); }
public static string GetDesignXml(IMMWMSDesign design, IMMPxApplication PxApp, bool CompatibilityMode) { IMMWMSDesign4 dn4 = design as IMMWMSDesign4; if (dn4.DesignerProductType == mmWMSDesignerProductType.mmExpress) //return GetExpressDesignXml(design, PxApp); throw new Exception("Retrieving design Xml for Designer Express designs is not supported."); else if (dn4.DesignerProductType == mmWMSDesignerProductType.mmStaker) throw new Exception("Retrieving design Xml for Staker designs is not supported."); else { if (CompatibilityMode) return GetClassicDesignXml(design.ID); else return GetClassicPxXml(design, PxApp); } }
/// <summary> /// Releases unmanaged and - optionally - managed resources /// </summary> /// <param name="disposing"> /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only /// unmanaged resources. /// </param> protected override void Dispose(bool disposing) { if (disposing) { if (_Design != null) { while (Marshal.ReleaseComObject(_Design) > 0) { // Loop until reference counter zero. } } _Design = null; } base.Dispose(disposing); }
/// <summary> /// Determines if the node is valid, which means it needs to have a design id > 0. /// </summary> /// <param name="node">IMMWMSNode which can be the WorkRequest, Design, WorkLocation, or CU.</param> /// <returns>Returns true if this node has a valid IMMWMSDesign ID</returns> private bool IsValid(IMMWMSNode node) { // The design node should be the first node passed to this component (even before the Work Request). if (_ID != 0) { return(true); } IMMWMSDesign design = node as IMMWMSDesign; if (design != null) { _ID = design.ID; } else { return(false); } return(_ID != 0); }
private static System.Xml.XmlDocument GetReportingXml(IMMPxApplication PxApp, IMMPersistentXML ListItem, LabelXmlType XmlType) { if (PxApp == null) { throw new Exception("No Px Application found"); } if (ListItem == null) { throw new Exception("No item given to generate notes for"); } /* * Stack<ID8ListItem> items = new Stack<ID8ListItem>(); * ((ID8List)ListItem).Reset(); * items.Push((ID8ListItem)ListItem); * * int wlCount = 1; * while (items.Count > 0) * { * var item = items.Pop(); * if (item is ID8TopLevel || * item is ID8WorkRequest || * item is ID8Design) * { * ((ID8List)item).Reset(); * for (ID8ListItem child = ((ID8List)item).Next(true); * child != null; * child = ((ID8List)item).Next(true)) * items.Push(child); * } * else if (item is ID8WorkLocation) * { * ((ID8WorkLocation)item).ID = wlCount.ToString(); * wlCount++; * } * else * continue; * } */ switch (XmlType) { case LabelXmlType.DesignTree: { Miner.Interop.msxml2.IXMLDOMDocument xDoc = new Miner.Interop.msxml2.DOMDocument(); ListItem.SaveToDOM(mmXMLFormat.mmXMLFDesign, xDoc); var newDoc = new System.Xml.XmlDocument(); newDoc.LoadXml(xDoc.xml); return(newDoc); } default: case LabelXmlType.DesignerXml: { //Hidden packages int currentDesign = ((IMMPxApplicationEx)PxApp).CurrentNode.Id; return(new System.Xml.XmlDocument() { InnerXml = DesignerUtility.GetClassicDesignXml(currentDesign) }); } case LabelXmlType.PxXml: { //Hidden packages int currentDesign = ((IMMPxApplicationEx)PxApp).CurrentNode.Id; IMMWMSDesign design = DesignerUtility.GetWmsDesign(PxApp, currentDesign); if (design == null) { throw new Exception("Unable to load design with id of " + currentDesign); } return(new System.Xml.XmlDocument() { InnerXml = DesignerUtility.GetClassicPxXml(design, PxApp) }); } case LabelXmlType.CostEngine: { //get the px config, load it, run it, return it string costEngineProgID = DesignerUtility.GetPxConfig(PxApp, "WMSCostEngine"); if (string.IsNullOrEmpty(costEngineProgID)) { throw new Exception("Cost Engine Xml Source Defined, but no cost engine is defined"); } Type costEngineType = Type.GetTypeFromProgID(costEngineProgID); if (costEngineType == null) { throw new Exception("Unable to load type for specified cost engine: " + costEngineProgID); } var rawType = Activator.CreateInstance(costEngineType); if (rawType == null) { throw new Exception("Unable to instantiate cost engine type " + costEngineType); } IMMWMSCostEngine costEngine = rawType as IMMWMSCostEngine; if (costEngine == null) { throw new Exception("Configured cost engine " + costEngineProgID + " is not of type IMMWMSCostEngine"); } if (!costEngine.Initialize(PxApp)) { throw new Exception("Failed to initialize cost engine"); } return(new System.Xml.XmlDocument() { InnerXml = costEngine.Calculate(((IMMPxApplicationEx)PxApp).CurrentNode) }); } case LabelXmlType.Custom: throw new Exception("No custom xml reporting source defined"); /*Or you can reference a custom cost / reporting engine * CostingEngine.SimpleCostEngine SCE = new Telvent.Applications.Designer.CostingEngine.SimpleCostEngine(); * SCE.Initialize(PxApp); * CalculatedXml = SCE.Calculate(xDoc.xml); */ break; } //Fall through return(null); }
/// <summary> /// Initializes a new instance of the <see cref="Design" /> class. /// </summary> /// <param name="pxApp">The process framework application reference.</param> /// <param name="design">The design.</param> public Design(IMMPxApplication pxApp, IMMWMSDesign design) : base(pxApp, NodeTypeName, design.ID) { _Design = design; }