protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L3N_UPNC_1521 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Base(); //Put your code here #region Remove existing collaborators ORM_TMS_PRO_Project_Note_Collaborators.Query noteCollaboratorsQuery = new ORM_TMS_PRO_Project_Note_Collaborators.Query(); noteCollaboratorsQuery.ProjectNote_RefID = Parameter.ProjectNote_ID; ORM_TMS_PRO_Project_Note_Collaborators.Query.SoftDelete(Connection, Transaction, noteCollaboratorsQuery); #endregion #region Update new collaborators query if (Parameter.ProjectNote_Collaborators != null) { foreach (var currentCollaborator in Parameter.ProjectNote_Collaborators) { ORM_TMS_PRO_Project_Note_Collaborators tempCollaboratorAssignment = new ORM_TMS_PRO_Project_Note_Collaborators(); tempCollaboratorAssignment.Account_RefID = currentCollaborator; tempCollaboratorAssignment.ProjectNote_RefID = Parameter.ProjectNote_ID; tempCollaboratorAssignment.Tenant_RefID = securityTicket.TenantID; tempCollaboratorAssignment.Save(Connection, Transaction); } } #endregion return(returnValue); #endregion UserCode }
protected static FR_L6PR_GPMwSIfPN_1832_Array Execute(DbConnection Connection, DbTransaction Transaction, P_L6PR_GPMwSIfPN_1832 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6PR_GPMwSIfPN_1832_Array(); //Put your code here List <L6PR_GPMwSIfPN_1832> tempResult = new List <L6PR_GPMwSIfPN_1832>(); ORM_TMS_PRO_Project_Notes projectNote = new ORM_TMS_PRO_Project_Notes(); projectNote.Load(Connection, Transaction, Parameter.ProjectNote_ID); #region ProjectMembers ORM_TMS_PRO_ProjectMember.Query membersQuery = new ORM_TMS_PRO_ProjectMember.Query(); membersQuery.Project_RefID = projectNote.Project_RefID; membersQuery.IsDeleted = false; List <ORM_TMS_PRO_ProjectMember> currentProject_Members = ORM_TMS_PRO_ProjectMember.Query.Search(Connection, Transaction, membersQuery); P_L3US_GUBIfUA_1057 userAccountInfoParameter = new P_L3US_GUBIfUA_1057(); if (currentProject_Members.Count > 0) { foreach (var currentMember in currentProject_Members) { L6PR_GPMwSIfPN_1832 tempResultItem = new L6PR_GPMwSIfPN_1832(); tempResultItem.ProjectMember_AccountID = currentMember.USR_Account_RefID; tempResultItem.ProjectMember_ID = currentMember.TMS_PRO_ProjectMemberID; userAccountInfoParameter.UserAccountID = currentMember.USR_Account_RefID; var userAccountInfoResult = cls_Get_UserBasicInfo_for_UserAccountID.Invoke(Connection, Transaction, userAccountInfoParameter, securityTicket).Result; tempResultItem.ProjectMember_FirstName = userAccountInfoResult.FirstName; tempResultItem.ProjectMember_LastName = userAccountInfoResult.LastName; tempResultItem.ProjectMember_ProfileImage_ServerLocation = userAccountInfoResult.File_ServerLocation; tempResult.Add(tempResultItem); } } #endregion #region Is member note collaborator ORM_TMS_PRO_Project_Note_Collaborators.Query noteCollaboratorsQuery = new ORM_TMS_PRO_Project_Note_Collaborators.Query(); noteCollaboratorsQuery.IsDeleted = false; noteCollaboratorsQuery.ProjectNote_RefID = Parameter.ProjectNote_ID; foreach (var currentMember in tempResult) { noteCollaboratorsQuery.Account_RefID = currentMember.ProjectMember_AccountID; currentMember.ProjectMember_IsNoteCollaborator = ORM_TMS_PRO_Project_Note_Collaborators.Query.Exists(Connection, Transaction, noteCollaboratorsQuery); } #endregion returnValue.Result = tempResult.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L3NT_SN_0921 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Base(); //Put your code here ORM_USR_Account noteCreatorAccount = new ORM_USR_Account(); noteCreatorAccount.Load(Connection, Transaction, Parameter.CreatorID); if (Parameter.ProjectNoteID != Guid.Empty) { if (Parameter.IsDeleted) { ORM_CMN_NoteRevision.Query noteRevisionsQuery = new ORM_CMN_NoteRevision.Query(); noteRevisionsQuery.Note_RefID = Parameter.NoteID; noteRevisionsQuery.IsDeleted = false; List <ORM_CMN_NoteRevision> existingRevisions = ORM_CMN_NoteRevision.Query.Search(Connection, Transaction, noteRevisionsQuery); if (existingRevisions.Count > 1) { existingRevisions = existingRevisions.Where(er => er.CMN_NoteRevisionID != Parameter.NoteRevisionID).OrderBy(er => er.Version).ToList(); noteRevisionsQuery.CMN_NoteRevisionID = Parameter.NoteRevisionID; ORM_CMN_NoteRevision.Query.SoftDelete(Connection, Transaction, noteRevisionsQuery); ORM_CMN_Note parentNote = new ORM_CMN_Note(); parentNote.Load(Connection, Transaction, Parameter.NoteID); parentNote.Current_NoteRevision_RefID = existingRevisions.Last().CMN_NoteRevisionID; parentNote.Save(Connection, Transaction); } else { ORM_CMN_Note.Query cmnNoteQuery = new ORM_CMN_Note.Query(); cmnNoteQuery.CMN_NoteID = Parameter.NoteID; ORM_CMN_Note.Query.SoftDelete(Connection, Transaction, cmnNoteQuery); ORM_TMS_PRO_Project_Notes.Query projectNotesQuery = new ORM_TMS_PRO_Project_Notes.Query(); projectNotesQuery.Ext_CMN_Note_RefID = Parameter.NoteID; ORM_TMS_PRO_Project_Notes.Query.SoftDelete(Connection, Transaction, projectNotesQuery); ORM_CMN_NoteRevision.Query.SoftDelete(Connection, Transaction, noteRevisionsQuery); ORM_TMS_PRO_Project_Note_Collaborators.Query notesCollaboratorQuery = new ORM_TMS_PRO_Project_Note_Collaborators.Query(); notesCollaboratorQuery.ProjectNote_RefID = Parameter.ProjectNoteID; ORM_TMS_PRO_Project_Note_Collaborators.Query.SoftDelete(Connection, Transaction, notesCollaboratorQuery); ORM_TMS_PRO_Project_Note_2_Tag.Query note2tagQuery = new ORM_TMS_PRO_Project_Note_2_Tag.Query(); note2tagQuery.Project_Note_RefID = Parameter.ProjectNoteID; ORM_TMS_PRO_Project_Note_2_Tag.Query.SoftDelete(Connection, Transaction, note2tagQuery); } } else { ORM_TMS_PRO_Project_Notes existingProjectNote = new ORM_TMS_PRO_Project_Notes(); existingProjectNote.Load(Connection, Transaction, Parameter.ProjectNoteID); ORM_CMN_NoteRevision existingNoteVersion = new ORM_CMN_NoteRevision(); existingNoteVersion.Load(Connection, Transaction, Parameter.NoteRevisionID); if (Parameter.SaveAsNewVersion) { ORM_CMN_NoteRevision.Query RevisionCountQuery = new ORM_CMN_NoteRevision.Query(); RevisionCountQuery.Note_RefID = Parameter.NoteID; ORM_CMN_NoteRevision newNoteVersion = new ORM_CMN_NoteRevision(); newNoteVersion.CreatedBy_BusinessParticipant_RefID = noteCreatorAccount.BusinessParticipant_RefID; newNoteVersion.Content = Parameter.Content; newNoteVersion.Note_RefID = Parameter.NoteID; newNoteVersion.Tenant_RefID = securityTicket.TenantID; newNoteVersion.Version = ORM_CMN_NoteRevision.Query.Search(Connection, Transaction, RevisionCountQuery).Count + 1; newNoteVersion.Title = Parameter.Title; newNoteVersion.Save(Connection, Transaction); if (Parameter.ReplaceCreator) { //Find current creator of note and make him a collaborator to this note ORM_USR_Account.Query currentCreatorQuery = new ORM_USR_Account.Query(); currentCreatorQuery.BusinessParticipant_RefID = existingNoteVersion.CreatedBy_BusinessParticipant_RefID; currentCreatorQuery.IsDeleted = false; currentCreatorQuery.Tenant_RefID = securityTicket.TenantID; ORM_USR_Account currentCreator = ORM_USR_Account.Query.Search(Connection, Transaction, currentCreatorQuery).FirstOrDefault(); ORM_TMS_PRO_Project_Note_Collaborators.Query noteCollaboratorQuery = new ORM_TMS_PRO_Project_Note_Collaborators.Query(); noteCollaboratorQuery.ProjectNote_RefID = Parameter.ProjectNoteID; noteCollaboratorQuery.IsDeleted = false; noteCollaboratorQuery.Account_RefID = noteCreatorAccount.USR_AccountID; if (ORM_TMS_PRO_Project_Note_Collaborators.Query.Exists(Connection, Transaction, noteCollaboratorQuery)) { //If current creator was collaborator on existing note, delete him, because he has the role of creator now, and //old creator will be added to collaborators. ORM_TMS_PRO_Project_Note_Collaborators.Query.SoftDelete(Connection, Transaction, noteCollaboratorQuery); } ORM_TMS_PRO_Project_Note_Collaborators newNoteCollaborator = new ORM_TMS_PRO_Project_Note_Collaborators(); newNoteCollaborator.Account_RefID = currentCreator.USR_AccountID; newNoteCollaborator.ProjectNote_RefID = Parameter.ProjectNoteID; newNoteCollaborator.Tenant_RefID = securityTicket.TenantID; newNoteCollaborator.Save(Connection, Transaction); ORM_CMN_Note.Query cmnNoteCreatorUpdateFind = new ORM_CMN_Note.Query(); cmnNoteCreatorUpdateFind.CMN_NoteID = Parameter.NoteID; ORM_CMN_Note.Query cmnNoteCreatorUpdate = new ORM_CMN_Note.Query(); cmnNoteCreatorUpdate.CreatedBy_BusinessParticipant_RefID = noteCreatorAccount.BusinessParticipant_RefID; ORM_CMN_Note.Query.Update(Connection, Transaction, cmnNoteCreatorUpdateFind, cmnNoteCreatorUpdate); } } else { existingNoteVersion.Content = Parameter.Content; existingNoteVersion.Title = Parameter.Title; existingNoteVersion.Save(Connection, Transaction); if (existingProjectNote.Project_RefID != Parameter.ProjectID) { existingProjectNote.Project_RefID = Parameter.ProjectID; existingProjectNote.Save(Connection, Transaction); } } //Update note tags (Delete existing ones and save new ones) P_L3TG_ATtN_1738 tagParameter = new P_L3TG_ATtN_1738(); tagParameter.ProjectNoteID = Parameter.ProjectNoteID; List <P_L3TG_ATtN_1738a> tagListParameter = new List <P_L3TG_ATtN_1738a>(); foreach (var currentTag in Parameter.Tags) { P_L3TG_ATtN_1738a tempTag = new P_L3TG_ATtN_1738a(); tempTag.TagValue = currentTag.TagValue; tempTag.TMS_PRO_TagID = currentTag.TagID; tagListParameter.Add(tempTag); } tagParameter.NoteTags = tagListParameter.ToArray(); cls_Add_Tags_to_Note.Invoke(Connection, Transaction, tagParameter, securityTicket); } } else { ORM_CMN_Note newCmnNote = new ORM_CMN_Note(); ORM_CMN_NoteRevision newNoteRevision = new ORM_CMN_NoteRevision(); ORM_TMS_PRO_Project_Notes newProjectNote = new ORM_TMS_PRO_Project_Notes(); newNoteRevision.Note_RefID = newCmnNote.CMN_NoteID; newNoteRevision.Content = Parameter.Content; newNoteRevision.CreatedBy_BusinessParticipant_RefID = noteCreatorAccount.BusinessParticipant_RefID; newNoteRevision.Tenant_RefID = securityTicket.TenantID; newNoteRevision.Title = Parameter.Title; newNoteRevision.Version = 1; newNoteRevision.Save(Connection, Transaction); newCmnNote.Current_NoteRevision_RefID = newNoteRevision.CMN_NoteRevisionID; newCmnNote.CreatedBy_BusinessParticipant_RefID = noteCreatorAccount.BusinessParticipant_RefID; newCmnNote.Tenant_RefID = securityTicket.TenantID; newCmnNote.Save(Connection, Transaction); newProjectNote.Ext_CMN_Note_RefID = newCmnNote.CMN_NoteID; newProjectNote.Project_RefID = Parameter.ProjectID; newProjectNote.Tenant_RefID = securityTicket.TenantID; newProjectNote.Save(Connection, Transaction); //Update note tags (Delete existing ones and save new ones) P_L3TG_ATtN_1738 tagParameter = new P_L3TG_ATtN_1738(); tagParameter.ProjectNoteID = newProjectNote.TMS_PRO_Project_NoteID; List <P_L3TG_ATtN_1738a> tagListParameter = new List <P_L3TG_ATtN_1738a>(); foreach (var currentTag in Parameter.Tags) { P_L3TG_ATtN_1738a tempTag = new P_L3TG_ATtN_1738a(); tempTag.TagValue = currentTag.TagValue; tempTag.TMS_PRO_TagID = currentTag.TagID; tagListParameter.Add(tempTag); } tagParameter.NoteTags = tagListParameter.ToArray(); cls_Add_Tags_to_Note.Invoke(Connection, Transaction, tagParameter, securityTicket); } return(returnValue); #endregion UserCode }