Ejemplo n.º 1
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L5MHC_SDIwDC_1040 Invoke(string ConnectionString, P_L5MHC_SDIwDC_1040 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }
Ejemplo n.º 2
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5MHC_SDIwDC_1040 Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5MHC_SDIwDC_1040 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5MHC_SDIwDC_1040 functionReturn = new FR_L5MHC_SDIwDC_1040();

            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_DeviceInstance_withDeleteCheck", ex);
            }
            return(functionReturn);
        }
Ejemplo n.º 3
0
        protected static FR_L5MHC_SDIwDC_1040 Execute(DbConnection Connection, DbTransaction Transaction, P_L5MHC_SDIwDC_1040 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5MHC_SDIwDC_1040();
            //Put your code here

            returnValue.Result = new L5MHC_SDIwDC_1040();

            Guid DeviceInstanceId = Guid.Empty;
            if (!Parameter.BaseData.IsDelete)
            {
                DeviceInstanceId = cls_Save_DeviceInstance.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result;
            }
            else
            {
                List <ORM_PPS_TSK_Task_DeviceBooking> existingAppointment = ORM_PPS_TSK_Task_DeviceBooking.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_DeviceBooking.Query
                {
                    IsDeleted    = false,
                    Tenant_RefID = securityTicket.TenantID,
                    PPS_DEV_Device_Instance_RefID = Parameter.BaseData.PPS_DEV_Device_InstanceID
                }).ToList();

                if (existingAppointment.Count > 0) //cannot delete
                {
                    List <L5MHC_SDIwDC_1040_UsedInAppointment> usedAppointmentList = new List <L5MHC_SDIwDC_1040_UsedInAppointment>();

                    foreach (var appointment in existingAppointment)
                    {
                        ORM_PPS_TSK_Task appointmentName = ORM_PPS_TSK_Task.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task.Query
                        {
                            IsDeleted      = false,
                            Tenant_RefID   = securityTicket.TenantID,
                            PPS_TSK_TaskID = appointment.PPS_TSK_Task_RefID
                        }).Single();
                        usedAppointmentList.Add(new L5MHC_SDIwDC_1040_UsedInAppointment {
                            AppointmentName = appointmentName.DisplayName
                        });
                    }
                    returnValue.Result.UsedInAppointment = usedAppointmentList.ToArray();
                }

                if (existingAppointment.Count == 0)
                {
                    DeviceInstanceId = cls_Save_DeviceInstance.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result;
                }
            }
            returnValue.Result.ID = DeviceInstanceId;

            return(returnValue);

            #endregion UserCode
        }
Ejemplo n.º 4
0
 ///<summary>
 /// Invokes the method for the given Connection, and Transaction, leaving them open/not commited if no exceptions occured
 ///<summary>
 public static FR_L5MHC_SDIwDC_1040 Invoke(DbConnection Connection, DbTransaction Transaction, P_L5MHC_SDIwDC_1040 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(Connection, Transaction, null, Parameter, securityTicket));
 }