Exemple #1
0
        protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5BR_SBM_1545 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_Guid();

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

            breakTimeTemplate.BreakTimeTemplate_Name  = Parameter.BreakTimeTemplate_Name_DictID;
            breakTimeTemplate.Tenant_RefID            = securityTicket.TenantID;
            breakTimeTemplate.BoundTo_Office_RefID    = Parameter.Office_RefID;
            breakTimeTemplate.BoundTo_Workarea_RefID  = Parameter.Workarea_RefID;
            breakTimeTemplate.BoundTo_Workplace_RefID = Parameter.Workplace_RefID;
            breakTimeTemplate.Save(Connection, Transaction);


            ORM_CMN_PPS_BreakTime_Template_Assignment.Query breakeTimeAssigmentQuery = new ORM_CMN_PPS_BreakTime_Template_Assignment.Query();
            breakeTimeAssigmentQuery.IsDeleted                = false;
            breakeTimeAssigmentQuery.Tenant_RefID             = securityTicket.TenantID;
            breakeTimeAssigmentQuery.BreakTime_Template_RefID = breakTimeTemplate.CMN_PPS_BreakTime_TemplateID;
            List <ORM_CMN_PPS_BreakTime_Template_Assignment> breakTimeAssignemnts = ORM_CMN_PPS_BreakTime_Template_Assignment.Query.Search(Connection, Transaction, breakeTimeAssigmentQuery);

            List <ORM_CMN_PPS_BreakTime> breakTimes = new List <ORM_CMN_PPS_BreakTime>();
            if (breakTimeAssignemnts != null)
            {
                foreach (var breakTimeAssignment in breakTimeAssignemnts)
                {
                    ORM_CMN_PPS_BreakTime breakTime = new ORM_CMN_PPS_BreakTime();
                    breakTime.Load(Connection, Transaction, breakTimeAssignment.BreakTime_RefID);
                    breakTimes.Add(breakTime);
                }
            }

            if (Parameter.BreakfestDuration != 0)
            {
                if (breakTimes.Any(i => i.IsBreakfastBreak))
                {
                    ORM_CMN_PPS_BreakTime breakTime = breakTimes.FirstOrDefault(i => i.IsBreakfastBreak);
                    breakTime.Default_Duration_in_sec = Parameter.BreakfestDuration;
                    breakTime.Save(Connection, Transaction);
                }
                else
                {
                    ORM_CMN_PPS_BreakTime breakTime = new ORM_CMN_PPS_BreakTime();
                    breakTime.Default_Duration_in_sec = Parameter.BreakfestDuration;
                    breakTime.IsBreakfastBreak        = true;
                    breakTime.Tenant_RefID            = securityTicket.TenantID;
                    breakTime.Save(Connection, Transaction);

                    ORM_CMN_PPS_BreakTime_Template_Assignment newAssignment = new ORM_CMN_PPS_BreakTime_Template_Assignment();
                    newAssignment.BreakTime_RefID          = breakTime.CMN_PPS_BreakTimeID;
                    newAssignment.BreakTime_Template_RefID = breakTimeTemplate.CMN_PPS_BreakTime_TemplateID;
                    newAssignment.Tenant_RefID             = securityTicket.TenantID;
                    newAssignment.Save(Connection, Transaction);
                }
            }
            else
            {
                if (breakTimes.Any(i => i.IsBreakfastBreak))
                {
                    ORM_CMN_PPS_BreakTime breakTime = breakTimes.FirstOrDefault(i => i.IsBreakfastBreak);
                    breakTime.Remove(Connection, Transaction);
                }
            }


            if (Parameter.DinnerDuration != 0)
            {
                if (breakTimes.Any(i => i.IsDinnerBreak))
                {
                    ORM_CMN_PPS_BreakTime breakTime = breakTimes.FirstOrDefault(i => i.IsDinnerBreak);
                    breakTime.Default_Duration_in_sec = Parameter.DinnerDuration;
                    breakTime.Save(Connection, Transaction);
                }
                else
                {
                    ORM_CMN_PPS_BreakTime breakTime = new ORM_CMN_PPS_BreakTime();
                    breakTime.Default_Duration_in_sec = Parameter.DinnerDuration;
                    breakTime.IsDinnerBreak           = true;
                    breakTime.Tenant_RefID            = securityTicket.TenantID;
                    breakTime.Save(Connection, Transaction);

                    ORM_CMN_PPS_BreakTime_Template_Assignment newAssignment = new ORM_CMN_PPS_BreakTime_Template_Assignment();
                    newAssignment.BreakTime_RefID          = breakTime.CMN_PPS_BreakTimeID;
                    newAssignment.BreakTime_Template_RefID = breakTimeTemplate.CMN_PPS_BreakTime_TemplateID;
                    newAssignment.Tenant_RefID             = securityTicket.TenantID;
                    newAssignment.Save(Connection, Transaction);
                }
            }
            else
            {
                if (breakTimes.Any(i => i.IsDinnerBreak))
                {
                    ORM_CMN_PPS_BreakTime breakTime = breakTimes.FirstOrDefault(i => i.IsDinnerBreak);
                    breakTime.Remove(Connection, Transaction);
                }
            }

            if (Parameter.LunchDuration != 0)
            {
                if (breakTimes.Any(i => i.IsLunchBreak))
                {
                    ORM_CMN_PPS_BreakTime breakTime = breakTimes.FirstOrDefault(i => i.IsLunchBreak);
                    breakTime.Default_Duration_in_sec = Parameter.LunchDuration;
                    breakTime.Save(Connection, Transaction);
                }
                else
                {
                    ORM_CMN_PPS_BreakTime breakTime = new ORM_CMN_PPS_BreakTime();
                    breakTime.Default_Duration_in_sec = Parameter.LunchDuration;
                    breakTime.IsLunchBreak            = true;
                    breakTime.Tenant_RefID            = securityTicket.TenantID;
                    breakTime.Save(Connection, Transaction);

                    ORM_CMN_PPS_BreakTime_Template_Assignment newAssignment = new ORM_CMN_PPS_BreakTime_Template_Assignment();
                    newAssignment.BreakTime_RefID          = breakTime.CMN_PPS_BreakTimeID;
                    newAssignment.BreakTime_Template_RefID = breakTimeTemplate.CMN_PPS_BreakTime_TemplateID;
                    newAssignment.Tenant_RefID             = securityTicket.TenantID;
                    newAssignment.Save(Connection, Transaction);
                }
            }
            else
            {
                if (breakTimes.Any(i => i.IsLunchBreak))
                {
                    ORM_CMN_PPS_BreakTime breakTime = breakTimes.FirstOrDefault(i => i.IsLunchBreak);
                    breakTime.Remove(Connection, Transaction);
                }
            }

            if (Parameter.Duration != 0)
            {
                if (breakTimes.Any(i => !i.IsLunchBreak && !i.IsBreakfastBreak && !i.IsDinnerBreak))
                {
                    ORM_CMN_PPS_BreakTime breakTime = breakTimes.FirstOrDefault(i => !i.IsLunchBreak && !i.IsBreakfastBreak && !i.IsDinnerBreak);
                    breakTime.Default_Duration_in_sec = Parameter.Duration;
                    breakTime.Save(Connection, Transaction);
                }
                else
                {
                    ORM_CMN_PPS_BreakTime breakTime = new ORM_CMN_PPS_BreakTime();
                    breakTime.Default_Duration_in_sec = Parameter.Duration;
                    breakTime.Tenant_RefID            = securityTicket.TenantID;
                    breakTime.Save(Connection, Transaction);

                    ORM_CMN_PPS_BreakTime_Template_Assignment newAssignment = new ORM_CMN_PPS_BreakTime_Template_Assignment();
                    newAssignment.BreakTime_RefID          = breakTime.CMN_PPS_BreakTimeID;
                    newAssignment.BreakTime_Template_RefID = breakTimeTemplate.CMN_PPS_BreakTime_TemplateID;
                    newAssignment.Tenant_RefID             = securityTicket.TenantID;
                    newAssignment.Save(Connection, Transaction);
                }
            }
            else
            {
                if (breakTimes.Any(i => !i.IsLunchBreak && !i.IsBreakfastBreak && !i.IsDinnerBreak))
                {
                    ORM_CMN_PPS_BreakTime breakTime = breakTimes.FirstOrDefault(i => !i.IsLunchBreak && !i.IsBreakfastBreak && !i.IsDinnerBreak);
                    breakTime.Remove(Connection, Transaction);
                }
            }

            returnValue.Result = breakTimeTemplate.CMN_PPS_BreakTime_TemplateID;


            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
Exemple #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_L5BR_SBM_1545 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }
Exemple #3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5BR_SBM_1545 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 { }

                Guid errorID = Guid.NewGuid();
                ServerLog.Instance.Fatal("Application error occured. ErrorID = " + errorID, ex);
                throw new Exception("Exception occured in method cls_Save_BreakModel", ex);
            }
            return(functionReturn);
        }
Exemple #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_L5BR_SBM_1545 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }