protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3DT_FDT_1646 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            #region Finished Status ID

            var Parameter_StatusFinished = new P_L2DT_GDTSfGPM_1121();
            Parameter_StatusFinished.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.Finished);
            var StatusFinished = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, Parameter_StatusFinished, securityTicket).Result;

            var Parameter_StatusStarted = new P_L2DT_GDTSfGPM_1121();
            Parameter_StatusStarted.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.Started);
            var StatusStarted = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, Parameter_StatusStarted, securityTicket).Result;

            #endregion

            #region Developer Task involvement
            ORM_TMS_PRO_DeveloperTask_Involvement DeveloperTask_Involvemnet = new ORM_TMS_PRO_DeveloperTask_Involvement();
            DeveloperTask_Involvemnet.Load(Connection, Transaction, Parameter.DeveloperTask_InvolvementID);

            DeveloperTask_Involvemnet.IsActive   = false;
            DeveloperTask_Involvemnet.IsArchived = true;
            DeveloperTask_Involvemnet.R_InvestedWorkingTime_min += Parameter.DeveloperTask_InvestedTime;

            DeveloperTask_Involvemnet.Save(Connection, Transaction);
            #endregion

            #region Developer Task

            //ORM_TMS_PRO_DeveloperTask_Involvement.Query InvolvementQuery = new ORM_TMS_PRO_DeveloperTask_Involvement.Query();
            //InvolvementQuery.DeveloperTask_RefID = DeveloperTask_Involvemnet.DeveloperTask_RefID;

            //var InvestedTime = ORM_TMS_PRO_DeveloperTask_Involvement.Query.Search(Connection, Transaction, InvolvementQuery).Sum(i => i.R_InvestedWorkingTime_min);

            ORM_TMS_PRO_DeveloperTask DeveloperTask = new ORM_TMS_PRO_DeveloperTask();
            DeveloperTask.Load(Connection, Transaction, DeveloperTask_Involvemnet.DeveloperTask_RefID);
            DeveloperTask.DeveloperTime_CurrentInvestment_min += Parameter.DeveloperTask_InvestedTime;
            DeveloperTask.Completion_Timestamp = DateTime.Now;
            DeveloperTask.PercentageComplete   = "100";
            DeveloperTask.IsComplete           = true;
            DeveloperTask.Save(Connection, Transaction);

            //Retrieve start task timestamp
            ORM_TMS_PRO_DeveloperTask_StatusHistory.Query DeveloperTask_History_Query = new ORM_TMS_PRO_DeveloperTask_StatusHistory.Query();
            DeveloperTask_History_Query.DeveloperTask_Status_RefID      = StatusStarted.TMS_PRO_DeveloperTask_StatusID;
            DeveloperTask_History_Query.DeveloperTask_RefID             = DeveloperTask.TMS_PRO_DeveloperTaskID;
            DeveloperTask_History_Query.TriggeredBy_ProjectMember_RefID = DeveloperTask_Involvemnet.ProjectMember_RefID;
            List <ORM_TMS_PRO_DeveloperTask_StatusHistory> statusHistoryResult = ORM_TMS_PRO_DeveloperTask_StatusHistory.Query.Search(Connection, Transaction, DeveloperTask_History_Query);


            //Status History
            ORM_TMS_PRO_DeveloperTask_StatusHistory DeveloperTask_StatusHistory = new ORM_TMS_PRO_DeveloperTask_StatusHistory();
            DeveloperTask_StatusHistory.DeveloperTask_RefID             = DeveloperTask.TMS_PRO_DeveloperTaskID;
            DeveloperTask_StatusHistory.DeveloperTask_Status_RefID      = StatusFinished.TMS_PRO_DeveloperTask_StatusID;
            DeveloperTask_StatusHistory.TriggeredBy_ProjectMember_RefID = DeveloperTask_Involvemnet.ProjectMember_RefID;
            DeveloperTask_StatusHistory.Comment = Parameter.DeveloperTask_Comment != ""? "Comment: " + Parameter.DeveloperTask_Comment + "</br>" + "Invested time : "
                                                  + DeveloperTask_Involvemnet.R_InvestedWorkingTime_min + " minutes":
                                                  "Invested time: " + DeveloperTask_Involvemnet.R_InvestedWorkingTime_min + " minutes";
            DeveloperTask_StatusHistory.Tenant_RefID = securityTicket.TenantID;
            DeveloperTask_StatusHistory.Save(Connection, Transaction);

            #endregion

            #region Charging Level
            ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel DefaultChargingLevel = null;
            ORM_TMS_PRO_ProjectMember GrabbedByMember = new ORM_TMS_PRO_ProjectMember();
            GrabbedByMember.Load(Connection, Transaction, DeveloperTask.GrabbedByMember_RefID);

            if (GrabbedByMember != null)
            {
                ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query ChargingLevelQuery = new ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query();
                ChargingLevelQuery.ProjectMember_Type_RefID = GrabbedByMember.ProjectMember_Type_RefID;
                ChargingLevelQuery.IsDeleted = false;

                List <ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel> AvailbaleChargingLevels =
                    ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query.Search(Connection, Transaction, ChargingLevelQuery);

                if (AvailbaleChargingLevels.Exists(acl => acl.IsDefault))
                {
                    DefaultChargingLevel = AvailbaleChargingLevels.Where(acl => acl.IsDefault).FirstOrDefault();
                }
                else if (AvailbaleChargingLevels.Count > 0)
                {
                    DefaultChargingLevel = AvailbaleChargingLevels.FirstOrDefault();
                }
            }

            #endregion

            #region Invested WorkTimes

            //User Account
            ORM_USR_Account UserAccount = new ORM_USR_Account();
            UserAccount.Load(Connection, Transaction, securityTicket.AccountID);


            ORM_CMN_BPT_InvestedWorkTime InvestedWorkTimes = new ORM_CMN_BPT_InvestedWorkTime();
            InvestedWorkTimes.BusinessParticipant_RefID   = UserAccount.BusinessParticipant_RefID;
            InvestedWorkTimes.WorkTime_Start              = statusHistoryResult.OrderBy(c => c.Creation_Timestamp).LastOrDefault().Creation_Timestamp;
            InvestedWorkTimes.WorkTime_Amount_min         = Parameter.DeveloperTask_InvestedTime;
            InvestedWorkTimes.WorkTime_InternalIdentifier = cls_Get_New_InvestedWorkTime_Identifier.Invoke(Connection, Transaction, securityTicket).Result.IWT_Identifier;
            InvestedWorkTimes.WorkTime_Source             = "DanuTask - [D" + DeveloperTask.IdentificationNumber + "] " + DeveloperTask.Name;
            InvestedWorkTimes.WorkTime_Comment.AddEntry(Parameter.LanguageID, Parameter.DeveloperTask_Comment);
            InvestedWorkTimes.ChargingLevel_RefID = DefaultChargingLevel != null ? DefaultChargingLevel.ChargingLevel_RefID : Guid.Empty;
            InvestedWorkTimes.Tenant_RefID        = securityTicket.TenantID;
            InvestedWorkTimes.Save(Connection, Transaction);
            #endregion

            #region Developer Task Involvements Invested time
            ORM_TMS_PRO_DeveloperTask_Involvements_InvestedWorkTime DeveloperTaskInvolvements_InvestedTime = new ORM_TMS_PRO_DeveloperTask_Involvements_InvestedWorkTime();
            DeveloperTaskInvolvements_InvestedTime.CMN_BPT_InvestedWorkTime_RefID          = InvestedWorkTimes.CMN_BPT_InvestedWorkTimeID;
            DeveloperTaskInvolvements_InvestedTime.TMS_PRO_DeveloperTask_Involvement_RefID = DeveloperTask_Involvemnet.TMS_PRO_DeveloperTask_InvolvementID;
            DeveloperTaskInvolvements_InvestedTime.Tenant_RefID = securityTicket.TenantID;
            DeveloperTaskInvolvements_InvestedTime.Save(Connection, Transaction);
            #endregion

            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6DT_CADT_1453 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();
            #region Activated


            var activatedParam = new P_L2DT_GDTSfGPM_1121();
            activatedParam.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.Activated);

            var activatedID = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, activatedParam, securityTicket).Result;

            #endregion

            #region Started

            var startedParam = new P_L2DT_GDTSfGPM_1121();
            startedParam.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.Started);

            var startedID = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, startedParam, securityTicket).Result;

            #endregion

            #region Deactivated

            var deactivatedParam = new P_L2DT_GDTSfGPM_1121();
            deactivatedParam.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.Deactivated);

            var deactivatedID = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, deactivatedParam, securityTicket).Result;

            #endregion

            #region ORM_TMS_PRO_DeveloperTask_2_ProjectMember

            //Load New
            ORM_TMS_PRO_DeveloperTask_Involvement newActive = new ORM_TMS_PRO_DeveloperTask_Involvement();
            if (Parameter.AssignmentID_newActive != Guid.Empty)
            {
                newActive.Load(Connection, Transaction, Parameter.AssignmentID_newActive);
            }

            //Load Old
            ORM_TMS_PRO_DeveloperTask_Involvement oldActive = new ORM_TMS_PRO_DeveloperTask_Involvement();
            if (Parameter.AssignmentID_oldActive != Guid.Empty)
            {
                oldActive.Load(Connection, Transaction, Parameter.AssignmentID_oldActive);
            }

            //Save New
            if (Parameter.AssignmentID_newActive != Guid.Empty)
            {
                newActive.IsActive      = true;
                newActive.OrderSequence = 0;

                newActive.Save(Connection, Transaction);
            }

            //Save Old
            if (Parameter.AssignmentID_oldActive != Guid.Empty)
            {
                oldActive.IsActive      = false;
                oldActive.OrderSequence = newActive.OrderSequence;
                oldActive.Save(Connection, Transaction);
            }

            #endregion ORM_TMS_PRO_DeveloperTask_2_ProjectMember

            #region ORM_TMS_PRO_DeveloperTask

            if (Parameter.AssignmentID_newActive != Guid.Empty)
            {
                ORM_TMS_PRO_DeveloperTask task = new ORM_TMS_PRO_DeveloperTask();
                task.Load(Connection, Transaction, newActive.DeveloperTask_RefID);

                if (task.IsIncompleteInformation)
                {
                    task.IsIncompleteInformation = false;
                    task.Save(Connection, Transaction);
                }
            }

            #endregion

            #region ORM_DeveloperTask_StatusHistory_newActive

            if (Parameter.AssignmentID_newActive != Guid.Empty)
            {
                //Activated
                ORM_TMS_PRO_DeveloperTask_StatusHistory newActive_history = new ORM_TMS_PRO_DeveloperTask_StatusHistory();

                newActive_history.DeveloperTask_RefID             = newActive.DeveloperTask_RefID;
                newActive_history.DeveloperTask_Status_RefID      = activatedID.TMS_PRO_DeveloperTask_StatusID;
                newActive_history.TriggeredBy_ProjectMember_RefID = newActive.ProjectMember_RefID;
                newActive_history.CreatedFor_ProjectMember_RefID  = Guid.Empty;
                newActive_history.Comment            = "Task is activated.";
                newActive_history.Tenant_RefID       = securityTicket.TenantID;
                newActive_history.Creation_Timestamp = DateTime.Now;

                newActive_history.Save(Connection, Transaction);

                //Started
                newActive_history = new ORM_TMS_PRO_DeveloperTask_StatusHistory();

                newActive_history.DeveloperTask_RefID             = newActive.DeveloperTask_RefID;
                newActive_history.DeveloperTask_Status_RefID      = startedID.TMS_PRO_DeveloperTask_StatusID;
                newActive_history.TriggeredBy_ProjectMember_RefID = newActive.ProjectMember_RefID;
                newActive_history.CreatedFor_ProjectMember_RefID  = Guid.Empty;
                newActive_history.Comment            = "Task is started.";
                newActive_history.Tenant_RefID       = securityTicket.TenantID;
                newActive_history.Creation_Timestamp = DateTime.Now.AddSeconds(2); //add 2 sec to be shure that is last one

                newActive_history.Save(Connection, Transaction);
            }


            #endregion ORM_DeveloperTask_StatusHistory_newActive

            #region ORM_DeveloperTask_StatusHistory_oldActive

            if (Parameter.AssignmentID_oldActive != Guid.Empty)
            {
                ORM_TMS_PRO_DeveloperTask_StatusHistory oldActive_history = new ORM_TMS_PRO_DeveloperTask_StatusHistory();

                //Deactivated
                oldActive_history.DeveloperTask_RefID             = oldActive.DeveloperTask_RefID;
                oldActive_history.DeveloperTask_Status_RefID      = deactivatedID.TMS_PRO_DeveloperTask_StatusID;
                oldActive_history.TriggeredBy_ProjectMember_RefID = oldActive.ProjectMember_RefID;
                oldActive_history.CreatedFor_ProjectMember_RefID  = Guid.Empty;
                oldActive_history.Comment            = "Task is deactivated.";
                oldActive_history.Tenant_RefID       = securityTicket.TenantID;
                oldActive_history.Creation_Timestamp = DateTime.Now.AddSeconds(2); //add 2 sec to be shure that is last one

                oldActive_history.Save(Connection, Transaction);
            }

            #endregion ORM_DeveloperTask_StatusHistory_oldActive
            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3DT_SDT_1808 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here
            #region StatusID's

            var Parameter_StoppedStatus = new P_L2DT_GDTSfGPM_1121();
            Parameter_StoppedStatus.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.Stopped);
            var StoppedStatus_ID = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, Parameter_StoppedStatus, securityTicket).Result;

            #endregion

            #region Involvement
            ORM_TMS_PRO_DeveloperTask_Involvement DeveloperTask_Involvement = new ORM_TMS_PRO_DeveloperTask_Involvement();
            DeveloperTask_Involvement.Load(Connection, Transaction, Parameter.DeveloperTask_InvolvementID);

            //Update invested time on involvement
            DeveloperTask_Involvement.R_InvestedWorkingTime_min += Parameter.DeveloperTask_InvestedTime;
            DeveloperTask_Involvement.Save(Connection, Transaction);

            #endregion

            #region Developer task
            ORM_TMS_PRO_DeveloperTask DeveloperTask = new ORM_TMS_PRO_DeveloperTask();
            DeveloperTask.Load(Connection, Transaction, Parameter.DeveloperTask_ID);

            DeveloperTask.IsIncompleteInformation              = Parameter.DeveloperTask_IsMissingInfo;
            DeveloperTask.PercentageComplete                   = Parameter.DeveloperTask_PercentageComplete.ToString();
            DeveloperTask.DeveloperTime_CurrentInvestment_min += Parameter.DeveloperTask_InvestedTime;

            DeveloperTask.Save(Connection, Transaction);

            #endregion

            #region Update developer task status history

            ORM_TMS_PRO_DeveloperTask_StatusHistory DeveloperTask_StatusHistory = new ORM_TMS_PRO_DeveloperTask_StatusHistory();

            DeveloperTask_StatusHistory.DeveloperTask_RefID             = Parameter.DeveloperTask_ID;
            DeveloperTask_StatusHistory.DeveloperTask_Status_RefID      = StoppedStatus_ID.TMS_PRO_DeveloperTask_StatusID;
            DeveloperTask_StatusHistory.TriggeredBy_ProjectMember_RefID = DeveloperTask_Involvement.ProjectMember_RefID;
            DeveloperTask_StatusHistory.CreatedFor_ProjectMember_RefID  = Guid.Empty;
            DeveloperTask_StatusHistory.Comment  = Parameter.DeveloperTask_StopComment != "" ? "Comment: " + Parameter.DeveloperTask_StopComment + "</br>" : "";
            DeveloperTask_StatusHistory.Comment += "Total invested time:  " + DeveloperTask_Involvement.R_InvestedWorkingTime_min +
                                                   " minutes" + "</br>" +
                                                   "Current invested time:  " + Parameter.DeveloperTask_InvestedTime +
                                                   " minutes" + "</br>" +
                                                   " Percentage complete: " + Parameter.DeveloperTask_PercentageComplete + "%\n";
            DeveloperTask_StatusHistory.Tenant_RefID = securityTicket.TenantID;
            DeveloperTask_StatusHistory.Save(Connection, Transaction);

            if (Parameter.DeveloperTask_IsMissingInfo)
            {
                //TODO: Change active developer task


                var Parameter_MissingInfoStatus = new P_L2DT_GDTSfGPM_1121();
                Parameter_MissingInfoStatus.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.MissingInfo);
                var MissingInfoStatus_ID = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, Parameter_MissingInfoStatus, securityTicket).Result;


                DeveloperTask_StatusHistory = new ORM_TMS_PRO_DeveloperTask_StatusHistory();
                DeveloperTask_StatusHistory.DeveloperTask_RefID             = Parameter.DeveloperTask_ID;
                DeveloperTask_StatusHistory.DeveloperTask_Status_RefID      = MissingInfoStatus_ID.TMS_PRO_DeveloperTask_StatusID;
                DeveloperTask_StatusHistory.TriggeredBy_ProjectMember_RefID = DeveloperTask_Involvement.ProjectMember_RefID;
                DeveloperTask_StatusHistory.CreatedFor_ProjectMember_RefID  = Guid.Empty;
                DeveloperTask_StatusHistory.Comment      = Parameter.DeveloperTask_StopComment;
                DeveloperTask_StatusHistory.Tenant_RefID = securityTicket.TenantID;
                DeveloperTask_StatusHistory.Save(Connection, Transaction);
            }


            #endregion

            #region Load user account

            ORM_USR_Account UserAccount = new ORM_USR_Account();
            UserAccount.Load(Connection, Transaction, securityTicket.AccountID);

            #endregion

            #region Default charging level
            ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel DefaultChargingLevel = null;
            ORM_TMS_PRO_ProjectMember DeveloperTask_GrabbedByMember = new ORM_TMS_PRO_ProjectMember();
            DeveloperTask_GrabbedByMember.Load(Connection, Transaction, DeveloperTask.GrabbedByMember_RefID);
            if (DeveloperTask_GrabbedByMember != null)
            {
                ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query SelectChargingLevel = new ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query();
                SelectChargingLevel.ProjectMember_Type_RefID = DeveloperTask_GrabbedByMember.ProjectMember_Type_RefID;
                SelectChargingLevel.IsDeleted = false;

                List <ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel> AvailableChargingLevels =
                    ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query.Search(Connection, Transaction, SelectChargingLevel);

                if (AvailableChargingLevels.Count > 0)
                {
                    if (AvailableChargingLevels.Exists(acl => acl.IsDefault))
                    {
                        DefaultChargingLevel = AvailableChargingLevels.Where(acl => acl.IsDefault).FirstOrDefault();
                    }
                    else
                    {
                        DefaultChargingLevel = AvailableChargingLevels.FirstOrDefault();
                    }
                }
            }
            #endregion

            #region Invested work times
            ORM_CMN_BPT_InvestedWorkTime InvestedWorkTimes = new ORM_CMN_BPT_InvestedWorkTime();
            InvestedWorkTimes.BusinessParticipant_RefID = UserAccount.BusinessParticipant_RefID;
            InvestedWorkTimes.ChargingLevel_RefID       = DefaultChargingLevel != null ? DefaultChargingLevel.ChargingLevel_RefID : Guid.Empty;
            InvestedWorkTimes.Tenant_RefID        = securityTicket.TenantID;
            InvestedWorkTimes.WorkTime_Amount_min = Parameter.DeveloperTask_InvestedTime;
            InvestedWorkTimes.WorkTime_Comment.AddEntry(Parameter.LanguageID, Parameter.DeveloperTask_StopComment);
            InvestedWorkTimes.WorkTime_Start = DateTime.Now.AddMinutes(-Parameter.DeveloperTask_InvestedTime);
            InvestedWorkTimes.WorkTime_InternalIdentifier = cls_Get_New_InvestedWorkTime_Identifier.Invoke(Connection, Transaction, securityTicket).Result.IWT_Identifier;
            InvestedWorkTimes.WorkTime_Source             = "Danutask - [D" + DeveloperTask.IdentificationNumber + "] " + DeveloperTask.Name;
            InvestedWorkTimes.Tenant_RefID = securityTicket.TenantID;
            InvestedWorkTimes.WorkTime_Comment.AddEntry(Parameter.LanguageID, Parameter.DeveloperTask_StopComment);
            InvestedWorkTimes.Save(Connection, Transaction);
            #endregion



            #region Developer task invested work times
            ORM_TMS_PRO_DeveloperTask_Involvements_InvestedWorkTime DeveloperTaskInvolvement_InvestedTime = new ORM_TMS_PRO_DeveloperTask_Involvements_InvestedWorkTime();
            DeveloperTaskInvolvement_InvestedTime.CMN_BPT_InvestedWorkTime_RefID          = InvestedWorkTimes.CMN_BPT_InvestedWorkTimeID;
            DeveloperTaskInvolvement_InvestedTime.TMS_PRO_DeveloperTask_Involvement_RefID = DeveloperTask_Involvement.TMS_PRO_DeveloperTask_InvolvementID;
            DeveloperTaskInvolvement_InvestedTime.Tenant_RefID = securityTicket.TenantID;
            DeveloperTaskInvolvement_InvestedTime.Save(Connection, Transaction);
            #endregion


            return(returnValue);

            #endregion UserCode
        }
Example #4
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6DT_ADTbD_1314 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();

            #region Assigned

            var assignedParam = new P_L2DT_GDTSfGPM_1121();
            assignedParam.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.Assigned);

            var assignedID = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, assignedParam, securityTicket).Result;

            #endregion

            #region GetProjectMemeberID and AssignmentID
            P_L3DT_GPMaAfDTaA_1326 param1 = new P_L3DT_GPMaAfDTaA_1326();
            param1.DTaskID = Parameter.DeveloperTask_RefID;

            L3DT_GPMaAfDTaA_1326 result1 = cls_Get_ProjectMemberID_and_AssignmentID_for_DTaskID_and_AccountID.Invoke(Connection, Transaction, param1, securityTicket).Result;
            #endregion

            #region ORM_DeveloperTask_2_ProjectMember

            #region cls_Get_AssignedTaskCount_for_Account

            L3DT_GATCfA_1333 result2 = cls_Get_AssignedTaskCount_for_Account.Invoke(Connection, Transaction, securityTicket).Result;

            if (result2 == null)
            {
                result2           = new L3DT_GATCfA_1333();
                result2.TaskCount = 0;
            }

            #endregion

            var assignItem = new ORM_TMS_PRO_DeveloperTask_Involvement();
            if (result1.TMS_PRO_DeveloperTask_InvolvementID != Guid.Empty)
            {
                assignItem.Load(Connection, Transaction, result1.TMS_PRO_DeveloperTask_InvolvementID);
            }
            else
            {
                assignItem.TMS_PRO_DeveloperTask_InvolvementID = Guid.NewGuid();
                assignItem.Tenant_RefID = securityTicket.TenantID;
            }
            assignItem.ProjectMember_RefID = result1.TMS_PRO_ProjectMemberID;
            assignItem.DeveloperTask_RefID = Parameter.DeveloperTask_RefID;
            assignItem.OrderSequence       = result2.TaskCount + 1;
            assignItem.IsActive            = false;
            assignItem.IsArchived          = false;
            assignItem.IsDeleted           = false;
            assignItem.Developer_CompletionTimeEstimation_min = Parameter.Developer_TimeEstimation_min;

            assignItem.Save(Connection, Transaction);

            #endregion

            #region ORM_TMS_PRO_DeveloperTask

            var developerTask = new ORM_TMS_PRO_DeveloperTask();
            if (Parameter.DeveloperTask_RefID != Guid.Empty)
            {
                developerTask.Load(Connection, Transaction, Parameter.DeveloperTask_RefID);
            }

            developerTask.GrabbedByMember_RefID = result1.TMS_PRO_ProjectMemberID;

            developerTask.Save(Connection, Transaction);

            #endregion

            #region ORM_DeveloperTask_StatusHistory

            ORM_TMS_PRO_DeveloperTask_StatusHistory statusHistory = new ORM_TMS_PRO_DeveloperTask_StatusHistory();

            statusHistory.DeveloperTask_RefID             = Parameter.DeveloperTask_RefID;
            statusHistory.DeveloperTask_Status_RefID      = assignedID.TMS_PRO_DeveloperTask_StatusID;
            statusHistory.TriggeredBy_ProjectMember_RefID = result1.TMS_PRO_ProjectMemberID;
            statusHistory.CreatedFor_ProjectMember_RefID  = Guid.Empty;
            statusHistory.Comment      = "Estimated time: " + Parameter.Developer_TimeEstimation_min + "[min]";
            statusHistory.Tenant_RefID = securityTicket.TenantID;

            statusHistory.Save(Connection, Transaction);

            #endregion ORM_DeveloperTask_StatusHistory

            #region projectInfo

            var project = new ORM_TMS_PRO_Project();
            project.Load(Connection, Transaction, developerTask.Project_RefID);

            ORM_TMS_PRO_Project_Status ProjectStatus = new ORM_TMS_PRO_Project_Status();
            ProjectStatus.Load(Connection, Transaction, project.Status_RefID);

            Guid   language    = Parameter.LanguageID;
            String statusLabel = ProjectStatus.Label.GetContent(language);
            String projectName = project.Name.GetContent(language);

            #endregion

            returnValue.Result = assignItem.TMS_PRO_DeveloperTask_InvolvementID;

            #region MailSandout

            //try
            //{


            //    L3US_GAAPI_1057 userInfo = cls_Get_ActiveAccount_PersonalInformation.Invoke(Connection, Transaction, securityTicket).Result;
            //    String frontHost = WebConfigurationManager.AppSettings["FrontHost"].ToString();
            //    String seeDetailsLink = String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_br_and_link"), frontHost, "DTask", developerTask.TMS_PRO_DeveloperTaskID);
            //    String unsubscribeLink = String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_Unsubscribe_Link"), frontHost, "dtask", developerTask.TMS_PRO_DeveloperTaskID.ToString());
            //    String subject = String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_AssignDeveloperTaskByDeveloper_subject"), projectName, statusLabel, developerTask.IdentificationNumber, developerTask.Name);

            //    P_L3DT_GPfDT_1659 prm = new P_L3DT_GPfDT_1659();
            //    prm.DTaskID = developerTask.TMS_PRO_DeveloperTaskID;

            //    List<L3DT_GPfDT_1659> ress = cls_Get_Peers_for_DTaskID.Invoke(Connection, Transaction, prm, securityTicket).Result.ToList();

            //    P_L3US_GUIfA_1241 usParameter = new P_L3US_GUIfA_1241();
            //    usParameter.UserAccountID = securityTicket.AccountID;
            //    L3US_GUIfA_1241 emailInfo = cls_Get_UserInformation_for_AccountID.Invoke(Connection, Transaction, usParameter, securityTicket).Result;

            //    MailMessage mail = DanuTaskMailGenerator.formatMailMessage(false, false, EnumMailTypes.DTask);

            //    foreach (var x in ress.Select(s => s.PrimaryEmail).Distinct())
            //    {
            //        if (!mail.To.Contains(new MailAddress(x)))
            //            mail.To.Add(x);
            //    }

            //    mail.Subject = subject;
            //    mail.Body = mail.Body.Replace("{ProjectName}", projectName);
            //    mail.Body = mail.Body.Replace("{Role}", String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Developer")));
            //    mail.Body = mail.Body.Replace("{status}", statusLabel);
            //    mail.Body = mail.Body.Replace("{DTaskNumber}", "D" + developerTask.IdentificationNumber);
            //    mail.Body = mail.Body.Replace("{DTaskName}", developerTask.Name);
            //    mail.Body = mail.Body.Replace("{action}", String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_DTask_AssignedbyDeveloper")));
            //    mail.Body = mail.Body.Replace("{FirstName}", userInfo.FirstName);
            //    mail.Body = mail.Body.Replace("{LastName}", userInfo.LastName);
            //    mail.Body = mail.Body.Replace("{userName}", userInfo.Username);
            //    mail.Body = mail.Body.Replace("{UserFullName}", userInfo.FirstName + " " + userInfo.LastName);
            //    mail.Body = mail.Body.Replace("{bodyText}", String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_DTask_AssignedDTask")) + " " + developerTask.Name + String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_inProject")) + " " + projectName + String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_DTaskAssignedToHimself")));
            //    DateTime dateToDisplay = DateTime.Now;
            //    mail.Body = mail.Body.Replace("{date}", dateToDisplay.ToShortDateString());
            //    mail.Body = mail.Body.Replace("{time}", dateToDisplay.ToShortTimeString());
            //    mail.Body = mail.Body.Replace("{itemType}", String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_DeveloperTask")));
            //    mail.Body = mail.Body.Replace("{ItemName}", developerTask.Name);
            //    mail.Body = mail.Body.Replace("$$$seeDetailsLink$$$", seeDetailsLink);
            //    mail.Body = mail.Body.Replace("$$$unsubscribeLink$$$", unsubscribeLink);
            //    if (mail.To.Count > 0)
            //    {
            //        SmtpClient smtpClient = new SmtpClient();
            //        smtpClient.Send(mail);
            //    }
            //}
            //catch
            //{

            //}

            #endregion

            return(returnValue);

            #endregion UserCode
        }
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6DT_DDTbD_0958 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();
            //Put your code here

            #region Deassigned

            var deassignedParam = new P_L2DT_GDTSfGPM_1121();
            deassignedParam.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EDeveloperTaskHistory.Deassigned);

            var deassignedID = cls_Get_DeveloperTaskStatus_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, deassignedParam, securityTicket).Result;

            #endregion

            #region Delete Assignement

            ORM_TMS_PRO_DeveloperTask_Involvement assignment = new ORM_TMS_PRO_DeveloperTask_Involvement();
            assignment.Load(Connection, Transaction, Parameter.AssigmentID);
            assignment.IsActive  = false;
            assignment.IsDeleted = true;

            assignment.Save(Connection, Transaction);

            #endregion

            #region Update Developer Task

            ORM_TMS_PRO_DeveloperTask task = new ORM_TMS_PRO_DeveloperTask();
            task.Load(Connection, Transaction, assignment.DeveloperTask_RefID);

            task.GrabbedByMember_RefID = Guid.Empty;

            task.Save(Connection, Transaction);

            #endregion

            #region Create Developer Task Status History

            ORM_TMS_PRO_DeveloperTask_StatusHistory statusHistory = new ORM_TMS_PRO_DeveloperTask_StatusHistory();

            statusHistory.TMS_PRO_DeveloperTask_StatusHistoryID = Guid.NewGuid();
            statusHistory.DeveloperTask_RefID             = assignment.DeveloperTask_RefID;
            statusHistory.DeveloperTask_Status_RefID      = deassignedID.TMS_PRO_DeveloperTask_StatusID;
            statusHistory.TriggeredBy_ProjectMember_RefID = assignment.ProjectMember_RefID;
            statusHistory.CreatedFor_ProjectMember_RefID  = Guid.Empty;
            statusHistory.Comment            = "Task has been deasigned.";
            statusHistory.Creation_Timestamp = DateTime.Now.AddSeconds(6);
            statusHistory.Tenant_RefID       = securityTicket.TenantID;

            statusHistory.Save(Connection, Transaction);

            #endregion

            #region projectInfo

            var project = new ORM_TMS_PRO_Project();
            project.Load(Connection, Transaction, task.Project_RefID);

            ORM_TMS_PRO_Project_Status ProjectStatus = new ORM_TMS_PRO_Project_Status();
            ProjectStatus.Load(Connection, Transaction, project.Status_RefID);

            Guid   language    = Parameter.LanguageID;
            String statusLabel = ProjectStatus.Label.GetContent(language);
            String projectName = project.Name.GetContent(language);


            #endregion
            //TO DO:
            #region MailSandout

            //try
            //{


            //    var dt2pm = new ORM_TMS_PRO_DeveloperTask_Involvement();
            //    dt2pm.Load(Connection, Transaction, Parameter.AssigmentID);

            //    var projectMember = new ORM_TMS_PRO_ProjectMember();
            //    projectMember.Load(Connection, Transaction, dt2pm.ProjectMember_RefID);

            //    P_L3US_GUIfA_1241 userParam = new P_L3US_GUIfA_1241();
            //    userParam.UserAccountID = projectMember.USR_Account_RefID;

            //    L3US_GUIfA_1241 devInfo = cls_Get_UserInformation_for_AccountID.Invoke(Connection, Transaction, userParam, securityTicket).Result;

            //    String frontHost = WebConfigurationManager.AppSettings["FrontHost"].ToString();
            //    String unsubscribeLink = String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_Unsubscribe_Link"), frontHost, "dtask", task.TMS_PRO_DeveloperTaskID.ToString());
            //    String seeDetailsLink = String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_br_and_link"), frontHost, "DTask", task.TMS_PRO_DeveloperTaskID);
            //    String subject = String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_DeasignDeveloperTask_subject"), projectName, statusLabel, task.IdentificationNumber, task.Name);
            //    P_L3DT_GPfDT_1659 prm = new P_L3DT_GPfDT_1659();
            //    prm.DTaskID = task.TMS_PRO_DeveloperTaskID;


            //    List<L3DT_GPfDT_1659> ress = cls_Get_Peers_for_DTaskID.Invoke(Connection, Transaction, prm, securityTicket).Result.ToList();

            //    P_L3US_GUIfA_1241 usParameter = new P_L3US_GUIfA_1241();
            //    usParameter.UserAccountID = securityTicket.AccountID;
            //    L3US_GUIfA_1241 emailInfo = cls_Get_UserInformation_for_AccountID.Invoke(Connection, Transaction, usParameter, securityTicket).Result;

            //    MailMessage mail = DanuTaskMailGenerator.formatMailMessage(true, false, EnumMailTypes.DTask);

            //    foreach (var x in ress.Select(s => s.PrimaryEmail).Distinct())
            //    {
            //        if (!mail.To.Contains(new MailAddress(x)))
            //            mail.To.Add(x);
            //    }

            //    mail.Subject = subject;
            //    mail.Body = mail.Body.Replace("{ProjectName}", projectName);
            //    mail.Body = mail.Body.Replace("{Role}", String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Developer")));
            //    mail.Body = mail.Body.Replace("{status}", statusLabel);
            //    mail.Body = mail.Body.Replace("{DTaskNumber}", "D" + task.IdentificationNumber);
            //    mail.Body = mail.Body.Replace("{DTaskName}", task.Name);
            //    mail.Body = mail.Body.Replace("{action}", String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_DTask_Deassigned")));
            //    mail.Body = mail.Body.Replace("{FirstName}", devInfo.FirstName);
            //    mail.Body = mail.Body.Replace("{LastName}", devInfo.LastName);
            //    mail.Body = mail.Body.Replace("{userName}", devInfo.Username);
            //    mail.Body = mail.Body.Replace("{bodyText}", String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_DTask_DeassignedDTask")) + " " + task.Name + String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_inProject")) + " " + projectName + " " + String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_Dtask_Deassigned_to")));
            //    mail.Body = mail.Body.Replace("{UserFullName}", devInfo.FirstName + " " + devInfo.LastName);
            //    DateTime dateToDisplay = DateTime.Now;
            //    mail.Body = mail.Body.Replace("{date}", dateToDisplay.ToShortDateString());
            //    mail.Body = mail.Body.Replace("{time}", dateToDisplay.ToShortTimeString());
            //    mail.Body = mail.Body.Replace("{itemType}", String.Format((String)HttpContext.GetGlobalResourceObject("Global", "Mail_DeveloperTask")));
            //    mail.Body = mail.Body.Replace("{ItemName}", task.Name);
            //    mail.Body = mail.Body.Replace("{commentText}", "Task has been deasigned.");
            //    mail.Body = mail.Body.Replace("$$$seeDetailsLink$$$", seeDetailsLink);
            //    mail.Body = mail.Body.Replace("$$$unsubscribeLink$$$", unsubscribeLink);
            //    if (mail.To.Count > 0)
            //    {
            //        SmtpClient smtpClient = new SmtpClient();
            //        smtpClient.Send(mail);
            //    }
            //}
            //catch
            //{

            //}

            #endregion

            return(returnValue);

            #endregion UserCode
        }