コード例 #1
0
        protected static FR_L6US_GDMDMDfAU_1802 Execute(DbConnection Connection, DbTransaction Transaction, P_L6US_GDMDMDfAU_1802 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_L6US_GDMDMDfAU_1802();
            //Put your code here
            returnValue.Result = new L6US_GDMDMDfAU_1802();


            #region ActiveTask
            P_L3DT_GADTfAU_1505 Parameter_ActiveTask = new P_L3DT_GADTfAU_1505();
            Parameter_ActiveTask.IsBeingPrepared_Only = Parameter.IsBeingPrepared_Only;
            returnValue.Result.ActiveTask             = cls_Get_ActiveDeveloperTask_for_ActiveUser.Invoke(Connection, Transaction, Parameter_ActiveTask, securityTicket).Result.FirstOrDefault();
            #endregion


            #region ProjectIDs
            P_L3PR_GPIDLfAUaRPL_1344 Paramater_Project = new P_L3PR_GPIDLfAUaRPL_1344();
            Paramater_Project.IsArchived      = Parameter.IsArchived;
            Paramater_Project.RightPackIDList = Parameter.RightPackIDList;
            List <L3PR_GPIDLfAUaRPL_1344> AvailableProjects = cls_Get_ProjectIDList_for_ActiveUser_and_RightPackageList.Invoke(Connection, Transaction, Paramater_Project, securityTicket).Result.ToList();
            #endregion

            if (AvailableProjects != null && AvailableProjects.Count > 0)
            {
                #region AssignedTasks
                P_L3DT_GADTLfAUaPL_1559 Parameter_AssignedTasks = new P_L3DT_GADTLfAUaPL_1559();
                Parameter_AssignedTasks.IsBeingPrepared_Only       = Parameter.IsBeingPrepared_Only;
                Parameter_AssignedTasks.ProjectID_List             = AvailableProjects.Select(p => p.Project_ID).ToArray();
                Parameter_AssignedTasks.FeatureStatusExcluded      = Parameter.FeatureStatusDifferentFromThis;
                Parameter_AssignedTasks.BusinessTaskStatusExcluded = Parameter.BusinessTaskStatusDifferentFromThis;
                Parameter_AssignedTasks.ProjectStatusExcluded      = Parameter.ProjectStatusDifferenFromThis;
                returnValue.Result.AssignedTasks = cls_Get_AssignedDeveloperTaskList_for_ActiveUser_and_ProjectList.Invoke(Connection, Transaction, Parameter_AssignedTasks, securityTicket).Result;
                #endregion

                #region CompletedTasks
                P_L3DT_GCDTfAUaPL_1610 Parameter_CompletedTasks = new P_L3DT_GCDTfAUaPL_1610();
                Parameter_CompletedTasks.ProjectID_List = AvailableProjects.Select(p => p.Project_ID).ToArray();
                returnValue.Result.CompletedTasks       = cls_Get_CompletedDeveloperTasks_for_ActiveUser_and_ProjectList.Invoke(Connection, Transaction, Parameter_CompletedTasks, securityTicket).Result;
                #endregion

                #region MentionedTasks
                P_L3DT_GDTIDwAUiM_1712 Parameter_MentionTasks = new P_L3DT_GDTIDwAUiM_1712();
                Parameter_MentionTasks.BusinessTaskStatusExcluded = Parameter.BusinessTaskStatusDifferentFromThis;
                Parameter_MentionTasks.FeatureStatusExcluded      = Parameter.FeatureStatusDifferentFromThis;
                Parameter_MentionTasks.ProjectStatusExcluded      = Parameter.ProjectStatusDifferenFromThis;
                returnValue.Result.MentionTasks = cls_Get_DeveloperTaskIDs_where_ActiveUser_is_Mentioned.Invoke(Connection, Transaction, Parameter_MentionTasks, securityTicket).Result;
                #endregion

                #region FreeTasks
                P_L3DT_GFDTLfAUIDaPL_1643 Parameter_FreeTasks = new P_L3DT_GFDTLfAUIDaPL_1643();
                Parameter_FreeTasks.IsBeingPrepared_Only       = Parameter.IsBeingPrepared_Only;
                Parameter_FreeTasks.ProjectID_List             = AvailableProjects.Select(p => p.Project_ID).ToArray();
                Parameter_FreeTasks.BusinessTaskStatusExcluded = Parameter.BusinessTaskStatusDifferentFromThis;
                Parameter_FreeTasks.FeatureStatusExcluded      = Parameter.FeatureStatusDifferentFromThis;
                Parameter_FreeTasks.ProjectStatusExcluded      = Parameter.ProjectStatusDifferenFromThis;
                returnValue.Result.FreeTasks = cls_Get_FreeDeveloperTasksList_for_ActiveUser_and_ProjectList.Invoke(Connection, Transaction, Parameter_FreeTasks, securityTicket).Result;
                #endregion

                #region RecommendedTasks
                P_L3DT_GRDTLfAU_1408 Parameter_RecommendedTasks = new P_L3DT_GRDTLfAU_1408();
                Parameter_RecommendedTasks.BusinessTaskStatusExcluded = Parameter.BusinessTaskStatusDifferentFromThis;
                Parameter_RecommendedTasks.FeatureStatusExcluded      = Parameter.FeatureStatusDifferentFromThis;
                Parameter_RecommendedTasks.ProjectStatusExcluded      = Parameter.ProjectStatusDifferenFromThis;
                Parameter_RecommendedTasks.IsBeingPrepared_Only       = Parameter.IsBeingPrepared_Only;
                Parameter_RecommendedTasks.ProjectID_List             = AvailableProjects.Select(p => p.Project_ID).ToArray();
                returnValue.Result.RecomendedTasks = cls_Get_RecommendedDeveloperTaskList_for_ActiveUser.Invoke(Connection, Transaction, Parameter_RecommendedTasks, securityTicket).Result;

                #endregion
            }


            //Notes
            ORM_TMS_PRO_Project_Notes.Query notesQuery = new ORM_TMS_PRO_Project_Notes.Query();
            notesQuery.IsDeleted    = false;
            notesQuery.Tenant_RefID = securityTicket.TenantID;
            var notes = ORM_TMS_PRO_Project_Notes.Query.Search(Connection, Transaction, notesQuery).Count;
            returnValue.Result.NotesCount = notes;

            return(returnValue);

            #endregion UserCode
        }
コード例 #2
0
        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
        }