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

            var item = new ORM_CMN_PPS_ShiftTemplate();
            item.Load(Connection, Transaction, Parameter.CMN_PPS_ShiftTemplateID);
            item.Remove(Connection, Transaction);

            ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query workDetailQuery = new ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query();
            workDetailQuery.IsDeleted    = false;
            workDetailQuery.Tenant_RefID = securityTicket.TenantID;
            workDetailQuery.CMN_PPS_ShiftTemplate_RefID = item.CMN_PPS_ShiftTemplateID;
            List <ORM_CMN_PPS_ShiftTemplate_WorkDetail> workDetailsList = ORM_CMN_PPS_ShiftTemplate_WorkDetail.Query.Search(Connection, Transaction, workDetailQuery);
            if (workDetailsList != null && workDetailsList.Count != 0)
            {
                foreach (var workDetail in workDetailsList)
                {
                    workDetail.Remove(Connection, Transaction);
                    ORM_CMN_STR_PPS_WorkDetail_Activity.Query activityDetailQuery = new ORM_CMN_STR_PPS_WorkDetail_Activity.Query();
                    activityDetailQuery.IsDeleted    = false;
                    activityDetailQuery.Tenant_RefID = securityTicket.TenantID;
                    activityDetailQuery.CMN_PPS_ShiftTemplate_WorkDetail_RefID = workDetail.CMN_PPS_ShiftTemplate_WorkDetailID;
                    List <ORM_CMN_STR_PPS_WorkDetail_Activity> activityDetails = ORM_CMN_STR_PPS_WorkDetail_Activity.Query.Search(Connection, Transaction, activityDetailQuery);
                    if (activityDetails != null && activityDetails.Count != 0)
                    {
                        ORM_CMN_STR_PPS_WorkDetail_Activity activityDetail = activityDetails.FirstOrDefault();
                        activityDetail.Remove(Connection, Transaction);

                        if (activityDetail.CMN_STR_PPS_Activity_RefID != Guid.Empty)
                        {
                            ORM_CMN_STR_PPS_Activity activity = new ORM_CMN_STR_PPS_Activity();
                            activity.Load(Connection, Transaction, activityDetail.CMN_STR_PPS_Activity_RefID);
                            activity.Remove(Connection, Transaction);
                        }
                    }
                }
            }
            //Put your code here
            return(returnValue);

            #endregion UserCode
        }
示例#2
0
 ///<summary>
 /// Ivokes the method with the given Connection, leaving it open if no exceptions occured
 ///<summary>
 public static FR_Base Invoke(DbConnection Connection, P_L5ST_DST_0917 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, null, null, Parameter, securityTicket));
 }
示例#3
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_Base Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5ST_DST_0917 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Base functionReturn = new FR_Base();

            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_Delete_ShiftTemplate", ex);
            }
            return(functionReturn);
        }