Esempio n. 1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L6DT_ADT_1443 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Guid();

            #region InPreparationStatus

            var inPrepParam = new P_L2PR_GPSfGP_1339();
            inPrepParam.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EProjectStatus.InPreparation);

            var inPreparationStatus = cls_Get_ProjectStatuses_for_GlobalPropertyID.Invoke(Connection, Transaction, inPrepParam, securityTicket).Result;

            #endregion

            #region InPreparationFeatureStatus

            var inPrepFeatureParam = new P_L2FE_GFSfGPM_1405();
            inPrepFeatureParam.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EFeatureStatus.InPreparation);

            var inPreparationFeatureStatus = cls_Get_FeatureStatus_for_GlobalPropertyMatchigID.Invoke(Connection, Transaction, inPrepFeatureParam, securityTicket).Result;

            #endregion

            #region inPreparationBTStatus

            var inPreparationBTStatusParam = new P_L2BT_GBTfGPM_1409();
            inPreparationBTStatusParam.GlobalPropertyMatchingID = EnumUtils.GetEnumDescription(EBusinessTaskStatus.InPreparation);

            var inPreparationBTStatus = cls_Get_BusinessTask_for_GlobalPropertyMatchingID.Invoke(Connection, Transaction, inPreparationBTStatusParam, securityTicket).Result;

            #endregion

            //find old active
            P_L3DT_GADTfAU_1505 param1 = new P_L3DT_GADTfAU_1505();
            param1.IsBeingPrepared_Only = false;
            var result1 = cls_Get_ActiveDeveloperTask_for_ActiveUser.Invoke(Connection, Transaction, param1, securityTicket).Result.FirstOrDefault();

            //if active task doesn't exist
            if (result1 == null)
            {
                result1 = new L3DT_GADTfAU_1505();
            }


            //deactivate old and activate new
            P_L6DT_CADT_1453 param2 = new P_L6DT_CADT_1453();
            param2.AssignmentID_newActive = Parameter.AssignmentID_newActive;
            param2.AssignmentID_oldActive = result1.DeveloperTask_InvolvementID;

            returnValue = cls_Change_Active_DeveloperTask.Invoke(Connection, Transaction, param2, securityTicket);

            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
        }
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, P_L6DT_CADT_1453 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L6DT_CADT_1453 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Guid functionReturn = new FR_Guid();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, Parameter, securityTicket);

                #region Cleanup Connection/Transaction
                //Commit the transaction
                if (cleanupTransaction == true)
                {
                    Transaction.Commit();
                }
                //Close the connection
                if (cleanupConnection == true)
                {
                    Connection.Close();
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw new Exception("Exception occured in method cls_Change_Active_DeveloperTask", ex);
            }
            return(functionReturn);
        }
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guid Invoke(string ConnectionString, P_L6DT_CADT_1453 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }