Пример #1
0
        protected static FR_Base Execute(DbConnection Connection, DbTransaction Transaction, P_L6PG_DMCL_1304 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var returnValue = new FR_Base();

            var item = new CL1_CMN_BPT.ORM_CMN_BPT_InvestedWorkTime_ChargingLevel();

            foreach (var cl in Parameter.ChargingLevelsToDelete)
            {
                if (cl != Guid.Empty)
                {
                    var result = item.Load(Connection, Transaction, cl);

                    if (result.Status != FR_Status.Success || item.CMN_BPT_InvestedWorkTime_ChargingLevelID == Guid.Empty)
                    {
                        var error = new FR_Base();
                        error.ErrorMessage = "No Such ID";
                        error.Status       = FR_Status.Error_Internal;
                        return(error);
                    }
                }

                #region Update project member type charging level

                CL1_TMP_PRO.ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query searchQuery = new CL1_TMP_PRO.ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query();
                searchQuery.ChargingLevel_RefID = Parameter.ChargingLevelToReplace;
                searchQuery.IsDeleted           = false;

                CL1_TMP_PRO.ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query updateQuery = new CL1_TMP_PRO.ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query();
                updateQuery.ChargingLevel_RefID = Parameter.ChargingLevelToReplace;

                CL1_TMP_PRO.ORM_TMP_PRO_ProjectMember_Type_AvailableChargingLevel.Query.Update(Connection, Transaction, searchQuery, updateQuery);

                #endregion

                #region Delete charging level

                CL1_CMN_BPT.ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query query2 = new CL1_CMN_BPT.ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query();
                query2.CMN_BPT_InvestedWorkTime_ChargingLevelID = cl;
                CL1_CMN_BPT.ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query.SoftDelete(Connection, Transaction, query2);

                #endregion
            }


            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_L6PG_DMCL_1304 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_L6PG_DMCL_1304 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 { }

                throw new Exception("Exception occured in method cls_Delete_MultipleChargingLevels", ex);
            }
            return(functionReturn);
        }