Пример #1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L3QT_SQT_0905 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

            var item = new ORM_TMS_QuickTask();
            if (Parameter.TMS_QuickTaskID != Guid.Empty)
            {
                var result = item.Load(Connection, Transaction, Parameter.TMS_QuickTaskID);
                if (result.Status != FR_Status.Success || item.TMS_QuickTaskID == Guid.Empty)
                {
                    var error = new FR_Guid();
                    error.ErrorMessage = "No Such ID";
                    error.Status       = FR_Status.Error_Internal;
                    return(error);
                }
            }

            if (Parameter.IsDeleted == true)
            {
                #region Delete ORM_CMN_BPT_InvestedWorkTime

                var qtinv_query = new ORM_TMS_QuickTask_InvestedWorkTime.Query();
                qtinv_query.TMS_QuickTasks_RefID = item.TMS_QuickTaskID;
                qtinv_query.IsDeleted            = false;

                var qtinv = ORM_TMS_QuickTask_InvestedWorkTime.Query.Search(Connection, Transaction, qtinv_query);

                foreach (var qt in qtinv)
                {
                    qt.IsDeleted = true;
                    qt.Save(Connection, Transaction);

                    var inv_query = new ORM_CMN_BPT_InvestedWorkTime.Query();
                    inv_query.CMN_BPT_InvestedWorkTimeID = qt.CMN_BPT_InvestedWorkTime_RefID;
                    inv_query.IsDeleted = false;

                    ORM_CMN_BPT_InvestedWorkTime.Query.SoftDelete(Connection, Transaction, inv_query);
                }

                #endregion

                item.IsDeleted = true;
                return(new FR_Guid(item.Save(Connection, Transaction), item.TMS_QuickTaskID));
            }

            //Creation specific parameters (Tenant, Account ... )
            if (Parameter.TMS_QuickTaskID == Guid.Empty)
            {
                item.QuickTask_CreatedByAccount_RefID = securityTicket.AccountID;
                item.Tenant_RefID = securityTicket.TenantID;

                #region Define IdentificationNumber

                ORM_TMS_QuickTask.Query query = new ORM_TMS_QuickTask.Query();
                query.Tenant_RefID = securityTicket.TenantID;
                var    count      = ORM_TMS_QuickTask.Query.Search(Connection, Transaction, query).Count() + 1;
                String identifier = "000000" + count.ToString();
                item.IdentificationNumber = identifier.Substring(identifier.Length - 6);

                #endregion


                #region Define DocumentsL3FE_GFIfF_1455

                var structureHeader = new ORM_DOC_Structure_Header();
                structureHeader.DOC_Structure_HeaderID = Guid.NewGuid();

                structureHeader.Label = Parameter.QuickTask_Title.GetContent(Parameter.LanguageID);

                structureHeader.Tenant_RefID = securityTicket.TenantID;
                var structureStatusSave = structureHeader.Save(Connection, Transaction);

                item.QuickTask_DocumentStructureHeader_RefID = structureHeader.DOC_Structure_HeaderID;

                #endregion

                #region BusinessParticipient

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

                #endregion

                #region Invested work times

                ORM_CMN_BPT_InvestedWorkTime iwt = new ORM_CMN_BPT_InvestedWorkTime();
                iwt.BusinessParticipant_RefID = userAcc.BusinessParticipant_RefID;
                iwt.WorkTime_Source           = "DanuTask - [W" + item.IdentificationNumber + "] " + Parameter.QuickTask_Title.GetContent(Parameter.LanguageID);

                iwt.CMN_BPT_InvestedWorkTimeID  = Guid.NewGuid();
                iwt.WorkTime_Start              = Parameter.QuickTask_StartTime;
                iwt.WorkTime_Amount_min         = (long)Parameter.R_QuickTask_InvestedTime_min;
                iwt.WorkTime_InternalIdentifier = cls_Get_NewInvestedWTimeIdentifier.Invoke(Connection, Transaction, securityTicket).Result.Identifier;
                iwt.Tenant_RefID = securityTicket.TenantID;
                iwt.Save(Connection, Transaction);

                ORM_TMS_QuickTask_InvestedWorkTime qtiwt = new ORM_TMS_QuickTask_InvestedWorkTime();
                qtiwt.CMN_BPT_InvestedWorkTime_RefID = iwt.CMN_BPT_InvestedWorkTimeID;
                qtiwt.Creation_Timestamp             = DateTime.Now;
                qtiwt.Tenant_RefID = securityTicket.TenantID;
                qtiwt.TMS_QuickTask_InvestedWorkTimeID = Guid.NewGuid();
                qtiwt.TMS_QuickTasks_RefID             = item.TMS_QuickTaskID;
                qtiwt.Save(Connection, Transaction);

                #endregion
            }
            else
            {
                var query = new ORM_TMS_QuickTask_InvestedWorkTime.Query();
                query.TMS_QuickTasks_RefID = item.TMS_QuickTaskID;
                query.IsDeleted            = false;

                var result = ORM_TMS_QuickTask_InvestedWorkTime.Query.Search(Connection, Transaction, query).ToArray();

                if (result.Count() == 1)
                {
                    ORM_CMN_BPT_InvestedWorkTime iwt = new ORM_CMN_BPT_InvestedWorkTime();
                    iwt.Load(Connection, Transaction, result[0].CMN_BPT_InvestedWorkTime_RefID);
                    iwt.WorkTime_Source             = "DanuTask - [W" + item.IdentificationNumber + "] " + Parameter.QuickTask_Title.GetContent(Parameter.LanguageID);
                    iwt.WorkTime_Start              = Parameter.QuickTask_StartTime;
                    iwt.WorkTime_Amount_min         = (long)Parameter.R_QuickTask_InvestedTime_min;
                    iwt.WorkTime_InternalIdentifier = cls_Get_NewInvestedWTimeIdentifier.Invoke(Connection, Transaction, securityTicket).Result.Identifier;
                    iwt.Save(Connection, Transaction);
                }
            }

            if (item.QuickTask_StartTime != Parameter.QuickTask_StartTime)
            {
                item.IsManuallyEntered = true;
            }

            if (item.R_QuickTask_InvestedTime_min != Parameter.R_QuickTask_InvestedTime_min)
            {
                item.IsManuallyEntered = true;
            }

            item.QuickTask_Title                = Parameter.QuickTask_Title;
            item.QuickTask_Description          = Parameter.QuickTask_Description;
            item.QuickTask_Type_RefID           = Parameter.QuickTask_Type_RefID;
            item.R_QuickTask_InvestedTime_min   = Parameter.R_QuickTask_InvestedTime_min;
            item.AssignedTo_Project_RefID       = Parameter.AssignedTo_Project_RefID;
            item.AssignedTo_BusinessTask_RefID  = Parameter.AssignedTo_BusinessTask_RefID;
            item.AssignedTo_Feature_RefID       = Parameter.AssignedTo_Feature_RefID;
            item.AssignedTo_DeveloperTask_RefID = Parameter.AssignedTo_DeveloperTask_RefID;
            item.QuickTask_StartTime            = Parameter.QuickTask_StartTime;

            return(new FR_Guid(item.Save(Connection, Transaction), item.TMS_QuickTaskID));

            #endregion UserCode
        }
Пример #2
0
 ///<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_L3QT_SQT_0905 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Пример #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L3QT_SQT_0905 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_Save_TMS_QuickTask", ex);
            }
            return(functionReturn);
        }
Пример #4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_Guid Invoke(string ConnectionString, P_L3QT_SQT_0905 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }