/*----------------------------------------------------*/ protected void WfTaskOutcome_SaveNewTaskAssignment(cDataObject aWfTaskAssgDataObject, XmlNode aTaskNode) { if (cXMLDoc.AttributeToInt(aTaskNode, "RoleID", 0) > 0) aWfTaskAssgDataObject["WfTaskRoleID"] = cXMLDoc.AttributeToInt(aTaskNode, "RoleID", 0); else aWfTaskAssgDataObject["WfTaskRoleID"] = this["WfTaskRoleID"]; aWfTaskAssgDataObject["GranteeProjectID"] = this["GranteeProjectID"]; if (aWfTaskAssgDataObject.GetRelatedPropertyValue("WfProjectTask.OpenDate") == null) aWfTaskAssgDataObject["OpenDate"] = System.DateTime.Now; aWfTaskAssgDataObject["CreateUser"] = this.DataObjectFactory.User.UserID; aWfTaskAssgDataObject["CreateDate"] = System.DateTime.Now; aWfTaskAssgDataObject["WfTaskStatusID"] = cXMLDoc.AttributeToInt(aTaskNode, "Status", 0); if (IndexNewWfTAs) NewWfTACollection.Add(cXMLDoc.AttributeToString(aTaskNode, "Key"), aWfTaskAssgDataObject); //update status and outcome on either new or existing WfTaskAssignment Object. If the task specifies NoPersonID=True //(i.e., a workgroup task assignment), the status will not be updated unless the UpdateStatus=True attribute is also present. if (!cXMLDoc.AttributeToBool(aTaskNode, "NoPersonID", false) || cXMLDoc.AttributeToBool(aTaskNode, "UpdateStatus", false)) aWfTaskAssgDataObject["WfTaskStatusID"] = cXMLDoc.AttributeToInt(aTaskNode, "Status", 0); if (cXMLDoc.AttributeToInt(aTaskNode, "Outcome", 0) > 0) aWfTaskAssgDataObject["WfTaskOutcomeID"] = cXMLDoc.AttributeToInt(aTaskNode, "Outcome"); if (cXMLDoc.AttributeToString(aTaskNode, "WorkgroupID", "") != "") aWfTaskAssgDataObject["WorkgroupID"] = cXMLDoc.AttributeToInt(aTaskNode, "WorkgroupID"); //save WfTaskAssignment object aWfTaskAssgDataObject.SaveData(); }
/*----------------------------------------------------*/ protected void WfTaskOutcome_UpdateData(XmlNodeList aUpdateDataNodeList) { foreach (XmlNode aUpdateDataNode in aUpdateDataNodeList) { WfTaskOutcome_SetRelatedDataObjectArgValues(null, aUpdateDataNode); String aPropertyKey = cXMLDoc.AttributeToString(aUpdateDataNode, "PropertyKey"); String aFinalKey; int aIndex = aPropertyKey.LastIndexOf("."); if (aIndex == -1) { cDataObject aDataObject = this; aFinalKey = aPropertyKey; if (cXMLDoc.AttributeToBool(aUpdateDataNode, "Null")) aDataObject[aFinalKey] = System.DBNull.Value; else aDataObject[aFinalKey] = cXMLDoc.AttributeToString(aUpdateDataNode, "Value"); aDataObject.SaveData(); } else { aFinalKey = aPropertyKey.Substring(aIndex + 1); cDataObjectList aDataObjectList = this.GetRelatedPropertyDataObjectList(aPropertyKey.Substring(0, aIndex)); foreach (cDataObject aDataObject in aDataObjectList) { if (cXMLDoc.AttributeToBool(aUpdateDataNode, "Null")) aDataObject[aFinalKey] = System.DBNull.Value; else aDataObject[aFinalKey] = cXMLDoc.AttributeToString(aUpdateDataNode, "Value"); aDataObject.SaveData(); } } } }
/*----------------------------------------------------*/ protected cDataObject WfTaskOutcome_CreateTARelatedDataObject(cDataObject aNewWfTaskAssgDataObject, XmlNode aRelatedDONode) { //Get related data object if it already exists. String aDODefKey = cXMLDoc.AttributeToString(aRelatedDONode, "DataObjectDefinitionKey"); XmlNodeList aFilterArgsList = aRelatedDONode.SelectNodes("Filters/Argument"); foreach (XmlNode aArgNode in aFilterArgsList) { WfTaskOutcome_SetRelatedDataObjectArgValues(aNewWfTaskAssgDataObject, aArgNode); } cDataObject aDataObject = DataObjectFactory.GetDataObject(aRelatedDONode); //If not, create a new one. if (aDataObject == null) aDataObject = DataObjectFactory.CreateNewDataObjectFromKey(aDODefKey); //Populate properties and save. XmlNodeList aPropertyArgsList = aRelatedDONode.SelectNodes("DataObjectProperties/Argument"); foreach (XmlNode aArgNode in aPropertyArgsList) { WfTaskOutcome_SetRelatedDataObjectArgValues(aNewWfTaskAssgDataObject, aArgNode); String aPropertyKey = cXMLDoc.AttributeToString(aArgNode, "PropertyKey"); aDataObject[aPropertyKey] = cXMLDoc.AttributeToString(aArgNode, "Value"); } int aUserID; aUserID = ((cPerson) this.GetRelatedPropertyDataObject("Person")).Get_EG_User(); aDataObject.DataObjectList.UserID = aUserID; aDataObject.SaveData(); if (cXMLDoc.AttributeToString(aRelatedDONode, "Key") != "") { RelatedDataObjectCollection.Add(cXMLDoc.AttributeToString(aRelatedDONode, "Key"), aDataObject); } return aDataObject; }
/*====================================================*/ /* DataPresenter calls this function when updating or inserting data*/ public void SaveDataObject(cDataObject aDataObject) { if (mUser != null) { aDataObject.DataObjectList.UserID = mUser.UserID; } aDataObject.SaveData(); //virtual method to give sub-classes pre- and post- processing }
/*-----------------------------------------------------*/ public virtual void Submit_UpdateData(cXMLDoc aOutcomeConfigDoc) { cWfTaskAssignment aWfTaskAssignment = (cWfTaskAssignment)WebSession.DataObjectFactory.GetDataObjectFromPrimaryKey("WfTaskAssignment", WfTaskAssignmentID); aWfTaskAssignment.RaiseProcessEvents = true; //flag to raise pre and post submission processing events cDataObject aSubmissionHistory = null; if (WebAppl.CreateSubmissionHistory) { aSubmissionHistory = WebSession.DataObjectFactory.CreateNewDataObjectFromKey("SubmissionHistory"); aSubmissionHistory["WfTaskAssignmentID"] = WfTaskAssignmentID; aSubmissionHistory["WfTaskID"] = aWfTaskAssignment.GetPropertyInt("WfTaskID"); aSubmissionHistory["PersonID"] = aWfTaskAssignment.GetPropertyInt("PersonID"); //aSubmissionHistory["StartDate"] = (System.DateTime)aWfTaskAssignment.GetPropertyValue("StartDate"); aSubmissionHistory["OpenDate"] = aWfTaskAssignment.GetPropertyValue("OpenDate"); aSubmissionHistory["DueDate"] = aWfTaskAssignment.GetPropertyValue("DueDate"); aSubmissionHistory["CloseDate"] = aWfTaskAssignment.GetPropertyValue("CloseDate"); //aSubmissionHistory["EndDate"] = (System.DateTime)aWfTaskAssignment.GetPropertyValue("EndDate"); aSubmissionHistory["PreWfTaskStatusID"] = aWfTaskAssignment.GetPropertyValue("WfTaskStatusID"); aSubmissionHistory.SaveData(); } aWfTaskAssignment["WfTaskStatusID"] = 2; aWfTaskAssignment["SubmittedDate"] = System.DateTime.Now; aWfTaskAssignment["SubmittedBy"] = WebSession.DataObjectFactory.User.UserID; aWfTaskAssignment["ModifyUser"] = WebSession.DataObjectFactory.User.UserID; aWfTaskAssignment["ModifyDate"] = System.DateTime.Now; WebSession.DataObjectFactory.SaveDataObject(aWfTaskAssignment); aWfTaskAssignment.RaiseProcessEvents = false; //Continue processing the post submission workflow tasks only if the ContinueProcessing is still true if (aWfTaskAssignment.ContinueProcessing) { aWfTaskAssignment.SetWfTaskOutcome(aOutcomeConfigDoc); } if (WebAppl.CreateSubmissionHistory) { aSubmissionHistory["SubmittedDate"] = aWfTaskAssignment.GetPropertyValue("SubmittedDate"); aSubmissionHistory["WfTaskOutcomeID"] = aWfTaskAssignment.GetPropertyValue("WfTaskOutcomeID"); aSubmissionHistory["PostWfTaskStatusID"] = aWfTaskAssignment.GetPropertyValue("WfTaskStatusID"); aSubmissionHistory.SaveData(); } WebSession.DataObjectFactory.CopyDataObject(aWfTaskAssignment, ((cEGUser)ModuleUser).WfTaskAssignmentObject); }
/*====================================================*/ public override void SaveData() { bool aNewObj; int aTaskTypeID; aNewObj = this.IsNewDataObject; base.SaveData(); //If this is a new review stage, create the corresponding row in the //REVIEW_STAGE table aTaskTypeID = GetPropertyInt("WfTaskTypeID"); if (aNewObj && (aTaskTypeID == 2 || aTaskTypeID == 3)) { cDataObject aReviewStage = DataObjectFactory.CreateNewDataObjectFromKey("ReviewStage"); aReviewStage["WfTaskID"] = GetPropertyInt("WfTaskID"); aReviewStage["IsInterviewStage"] = false; aReviewStage.SaveData(); } }
/*----------------------------------------------------*/ public void CalculateAverageScores() { cXMLDoc aXMLDoc; XmlNode aDataObjectNode; XmlNode aFiltersNode; XmlNode aArgNode; cDataObjectList aReviewWFTAList; cDataObject aWfProjectTask = GetRelatedPropertyDataObject("WfProjectTask"); foreach (cGranteeProject aGPDO in GranteeProjectList) { //Get all review WfTaskAssignment objects for this grantee project and review stage. aXMLDoc = DataObjectFactory.CreateDataObjectNode("WfTaskAssignment", out aDataObjectNode, out aFiltersNode); aArgNode = DataObjectFactory.CreateArgumentNode(aXMLDoc, "", "WfTaskID", aWfProjectTask.GetPropertyString("WfTaskID")); aFiltersNode.AppendChild(aArgNode); aArgNode = DataObjectFactory.CreateArgumentNode(aXMLDoc, "", "GranteeProjectID", aGPDO.GetPropertyString("GranteeProjectID")); aFiltersNode.AppendChild(aArgNode); aReviewWFTAList = DataObjectFactory.GetDataObjectList(aDataObjectNode); //Loop through list, getting sum and count of ReviewRating property. int aCount = 0; double aTotalRating = 0; foreach (cDataObject aReviewWFTADO in aReviewWFTAList) { if (aReviewWFTADO["ReviewRating"] != System.DBNull.Value) { aCount += 1; aTotalRating += aReviewWFTADO.GetPropertyDouble("ReviewRating"); } } //Calculate mean and save to GranteeProjectReviewStage data object. if (aCount > 0) { cDataObject aGPRSDO = aGPDO.GetGranteeProjectReviewStageDO(aWfProjectTask.GetPropertyInt("WfProjectTaskID")); aGPRSDO["AverageRating"] = aTotalRating / aCount; aGPRSDO.SaveData(); } } }
/*====================================================*/ public void SetWfTaskOutcome(cXMLDoc aOutcomeConfigDoc, bool aUseEvaluateData, bool aRaiseSingleEvent, bool aRaiseEvents, string aRcptPersonIDPropertyKey) { /*This override of the SetWfTaskOutcome method exists so that both the old (EvaluateOutcome) and new (EvaluateOutcome_EvaluateData) models of outcome configuration file processing can be used at the same time. Existing pages that call SetWfTaskOutcome with no parameters will use the old model to which they were written. The old model may or may not eventually be done away with. Peter Larsen 3/25/04. */ XmlNodeList aTaskNodeList; XmlNodeList aUpdateDataList; XmlNodeList aEventNodeList; XmlNode aOutcomeNode; String aOutcomeID = ""; int aUserID; aUserID = ((cPerson) this.GetRelatedPropertyDataObject("Person")).Get_EG_User(); if (aUseEvaluateData) { aOutcomeID = EvaluateOutcome_EvaluateData(aOutcomeConfigDoc); aOutcomeNode = cXMLDoc.FindNode(aOutcomeConfigDoc.DocElement.SelectSingleNode("Outcomes"), "Outcome", "OutcomeKey", aOutcomeID.ToString()); } else aOutcomeNode = EvaluateOutcome(aOutcomeConfigDoc); if (aOutcomeNode == null) { aOutcomeID = cXMLDoc.AttributeToString(aOutcomeConfigDoc.DocElement.SelectSingleNode("Outcomes"), "DefaultOutcomeKey"); if (aOutcomeID != "") { this["WfTaskOutcomeID"] = aOutcomeID; } this.DataObjectList.DataObjectFactory.SaveDataObject(this); } else { String aOutcomeValue = OutcomeValue_GetArgumentValue(GetOutcomeNode(aOutcomeNode)); if (aOutcomeValue != "") aOutcomeID = aOutcomeValue; else aOutcomeID = cXMLDoc.AttributeToString(aOutcomeNode, "OutcomeKey"); if (Convert.ToInt32(aOutcomeID) > 0) { this["WfTaskOutcomeID"] = aOutcomeID; this.DataObjectList.DataObjectFactory.SaveDataObject(this); } XmlNode aProcessingEventsNode = aOutcomeNode.SelectSingleNode("ProcessingEvents"); if (ContinueProcessing && aProcessingEventsNode != null) { XmlNodeList aDataObjectNodeList = aProcessingEventsNode.SelectNodes("DataObject"); if (aDataObjectNodeList != null && aDataObjectNodeList.Count > 0) { foreach (XmlNode aDataObjectNode in aDataObjectNodeList) { XmlNodeList aFilterArgsList = aDataObjectNode.SelectNodes("Filters/Argument"); foreach (XmlNode aArgNode in aFilterArgsList) { WfTaskOutcome_SetRelatedDataObjectArgValues(null, aArgNode); } cProcessingEvent aProcessingEvent; aProcessingEvent = cProcessingEvent.CreateProcessingEventInstance(cXMLDoc.AttributeToString(aDataObjectNode, "DataObjectDefinitionKey"), this.DataObjectFactory); aProcessingEvent.ProcessEvent(aDataObjectNode); if (aProcessingEvent.StatusID < 1) { ContinueProcessing = false; break; } } } } if (!ContinueProcessing) return; //if the event processing failed, stopping continuing the process of creating the tasks or sending emails cDataObjectList aWftaReopenRequestDOL=DataObjectFactory.GetDataObjectListWithFilter("WftaReopenRequest","ReopenWfTaskAssignmentID",this.GetPropertyString("WfTaskAssignmentID"),"Active","True"); if (aWftaReopenRequestDOL.Count > 0){ cDataObject aRequestingWfTaskAssignmentDo = aWftaReopenRequestDOL[0].GetRelatedPropertyDataObject("RequestingWfTaskAssignment"); aRequestingWfTaskAssignmentDo["WfTaskStatusID"] = "1"; //Incomplete aRequestingWfTaskAssignmentDo.SaveData(); aWftaReopenRequestDOL[0]["Active"]="False"; aWftaReopenRequestDOL[0].SaveData(); } else { XmlNode aTasksNode = aOutcomeNode.SelectSingleNode("Tasks"); if (aTasksNode != null) { IndexNewWfTAs = cXMLDoc.AttributeToBool(aTasksNode, "Index", false); aTaskNodeList = aTasksNode.SelectNodes("Task"); if (aTaskNodeList != null) //assign tasks associated with outcome ContinueProcessing = WfTaskOutcome_CreateNewTaskAssignments(aTaskNodeList); } } if (!ContinueProcessing) return; //if the pre and post assignment event processing failed, stopping continuing the process of updating and sending emails aUpdateDataList = aOutcomeNode.SelectNodes("UpdateData/Argument"); if (aUpdateDataList != null) //update data related to the submitted WfTaskAssignment WfTaskOutcome_UpdateData(aUpdateDataList); if (aRaiseEvents) { aEventNodeList = aOutcomeNode.SelectNodes("Events/Event"); if (aEventNodeList != null) { //raise events associated with task outcome foreach (XmlNode aEventNode in aEventNodeList) { XmlNode aEventDataObjectListNode = aEventNode.SelectSingleNode("EventDataObjectList"); if (aEventDataObjectListNode == null) { if (aRaiseSingleEvent) { if (aRcptPersonIDPropertyKey != "") { RaiseSingleEvent(cXMLDoc.AttributeToInt(aEventNode, "EventKey"), aUserID, aRcptPersonIDPropertyKey); } else { RaiseSingleEvent(cXMLDoc.AttributeToInt(aEventNode, "EventKey"), aUserID); } } else RaiseEvent(cXMLDoc.AttributeToInt(aEventNode, "EventKey"), aUserID); } else { //Get the PersonID attribute of the EventDataObjectList node set in case this event is assigned to Grant Primary Staff, etc String aPersonPropertyKey = cXMLDoc.AttributeToString(aEventDataObjectListNode, "PersonID", ""); if (aPersonPropertyKey != "") { String aPersonID = ""; aPersonID = this.GetRelatedPropertyString(aPersonPropertyKey); if (aPersonID == "") continue; } XmlNodeList aFilterArgsList = aEventDataObjectListNode.SelectNodes("Filters/Argument"); foreach (XmlNode aArgNode in aFilterArgsList) { WfTaskOutcome_SetRelatedDataObjectArgValues(null, aArgNode); //if email is assigned to a grant primary staff person and there is no primary staff person assigned //if (cXMLDoc.AttributeToBool(aArgNode, "Null", false) && cXMLDoc.AttributeToString(aArgNode, "TypeKey", "") == "GranteeProject.GranteeProjectPrimaryStaffAffiliation.StaffPersonID" ) { if (cXMLDoc.AttributeToBool(aArgNode, "Null", false)) { cDataObject aDefaultWorkgroupDO = DataObjectFactory.GetDataObjectListWithFilter("WorkGroup", "IsPrimary", "True")[0]; if (aDefaultWorkgroupDO != null) { aEventDataObjectListNode.Attributes["DataObjectDefinitionKey"].Value = "WorkGroupMember"; aArgNode.Attributes["TypeKey"].Value = "WorkGroupID"; aArgNode.Attributes["PropertyKey"].Value = "WorkGroupID"; aArgNode.Attributes["Value"].Value = aDefaultWorkgroupDO.GetPropertyString("WorkGroupID"); } } } cDataObjectList aEventDataObjectList = DataObjectFactory.GetDataObjectList(aEventDataObjectListNode); if (aRaiseSingleEvent) { if (aRcptPersonIDPropertyKey != "") { RaiseSingleEvent(cXMLDoc.AttributeToInt(aEventNode, "EventKey"), aUserID, aEventDataObjectList, aRcptPersonIDPropertyKey); } else { RaiseSingleEvent(cXMLDoc.AttributeToInt(aEventNode, "EventKey"), aUserID, aEventDataObjectList); } } else RaiseEvent(cXMLDoc.AttributeToInt(aEventNode, "EventKey"), aUserID, aEventDataObjectList); } } } } } }