/// <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 (_WorkRequest != null) { while (Marshal.ReleaseComObject(_WorkRequest) > 0) { // Loop until reference counter zero. } } if (_Location != null) { _Location.Dispose(); } if (_Customer != null) { _Customer.Dispose(); } _WorkRequest = null; _Location = null; _Customer = null; } base.Dispose(true); }
/// <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> protected override bool Initialize(IMMWorkflowManager extension, IMMPxUser user) { int ownerID = user.Id; string nodeTypeName = NodeTypeName; _WorkRequest = (IMMWMSWorkRequest)extension.CreateWMSNode(ref nodeTypeName); _WorkRequest.set_OwnerID(ref ownerID); return(_WorkRequest != null); }
/// <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 ID.</param> /// <returns> /// Returns <see cref="Boolean" /> representing <c>true</c> if the node was successfully initialized; otherwise /// <c>false</c>. /// </returns> protected override bool Initialize(IMMWorkflowManager extension, int nodeID) { if (_WorkRequest != null && _WorkRequest.ID == nodeID) { return(true); } bool ro = false; bool sm = true; string nodeTypeName = NodeTypeName; _WorkRequest = (IMMWMSWorkRequest)extension.GetWMSNode(ref nodeTypeName, ref nodeID, ref ro, ref sm); return(_WorkRequest != null); }
/// <summary> /// Initializes a new instance of the <see cref="WorkRequest" /> class. /// </summary> /// <param name="pxApp">The process framework application reference.</param> /// <param name="workRequest">The work request.</param> public WorkRequest(IMMPxApplication pxApp, IMMWMSWorkRequest workRequest) : base(pxApp, NodeTypeName, workRequest.ID) { _WorkRequest = workRequest; }
/// <summary> /// Initializes a new instance of the <see cref="Design" /> class. /// </summary> /// <param name="pxApp">The process application.</param> /// <param name="workRequest">The work request.</param> public Design(IMMPxApplication pxApp, IMMWMSWorkRequest workRequest) : base(pxApp, NodeTypeName) { this.WorkRequestID = workRequest.ID; }