Example #1
0
        protected static FR_L5MHC_SD_1351 Execute(DbConnection Connection, DbTransaction Transaction, P_L5MHC_SD_1351 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5MHC_SD_1351();
            //Put your code here

            returnValue.Result = new L5MHC_SD_1351();

            Guid DeviceId = Guid.Empty;
            if (!Parameter.BaseData.IsDelete)
            {
                DeviceId = cls_Save_DeviceOnly.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result;
            }
            else
            {
                List <ORM_PPS_DEV_Device_Instance> existingDeviceInstance = ORM_PPS_DEV_Device_Instance.Query.Search(Connection, Transaction, new ORM_PPS_DEV_Device_Instance.Query
                {
                    IsDeleted    = false,
                    Tenant_RefID = securityTicket.TenantID,
                    Device_RefID = Parameter.BaseData.PPS_DEV_DeviceID
                }).ToList();

                if (existingDeviceInstance.Count > 0) //cannot delete
                {
                    List <L5MHC_SD_1351_UsedInDeviceInstance> usedDeviceInstanceList = new List <L5MHC_SD_1351_UsedInDeviceInstance>();

                    foreach (var deviceInstance in existingDeviceInstance)
                    {
                        usedDeviceInstanceList.Add(new L5MHC_SD_1351_UsedInDeviceInstance {
                            DeviceInstanceName = deviceInstance.DeviceInventoryNumber
                        });
                    }

                    returnValue.Result.UsedInDeviceInstance = usedDeviceInstanceList.ToArray();
                }

                List <ORM_PPS_TSK_Task_Template_RequiredDevice> existingAppointmentType = ORM_PPS_TSK_Task_Template_RequiredDevice.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_Template_RequiredDevice.Query
                {
                    IsDeleted        = false,
                    Tenant_RefID     = securityTicket.TenantID,
                    DEV_Device_RefID = Parameter.BaseData.PPS_DEV_DeviceID
                }).ToList();

                if (existingAppointmentType.Count > 0) //cannot delete
                {
                    List <L5MHC_SD_1351_UsedInAppointmentType> usedAppointmentTypeList = new List <L5MHC_SD_1351_UsedInAppointmentType>();

                    foreach (var appointmentType in existingAppointmentType)
                    {
                        ORM_PPS_TSK_Task_Template appointmentTypeName = ORM_PPS_TSK_Task_Template.Query.Search(Connection, Transaction, new ORM_PPS_TSK_Task_Template.Query
                        {
                            IsDeleted               = false,
                            Tenant_RefID            = securityTicket.TenantID,
                            PPS_TSK_Task_TemplateID = appointmentType.TaskTemplate_RefID
                        }).Single();
                        usedAppointmentTypeList.Add(new L5MHC_SD_1351_UsedInAppointmentType {
                            AppointmentTypeName = appointmentTypeName.TaskTemplateName
                        });
                    }
                    returnValue.Result.UsedInAppointmentType = usedAppointmentTypeList.ToArray();
                }

                if (existingDeviceInstance.Count == 0 && existingAppointmentType.Count == 0)
                {
                    DeviceId = cls_Save_DeviceOnly.Invoke(Connection, Transaction, Parameter.BaseData, securityTicket).Result;
                }
            }
            returnValue.Result.ID = DeviceId;

            return(returnValue);

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

            FR_L5MHC_SD_1351 functionReturn = new FR_L5MHC_SD_1351();

            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_Device", ex);
            }
            return(functionReturn);
        }
Example #4
0
 ///<summary>
 /// Opens the connection/transaction for the given connectionString, and closes them when complete
 ///<summary>
 public static FR_L5MHC_SD_1351 Invoke(string ConnectionString, P_L5MHC_SD_1351 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
 {
     return(Invoke(null, null, ConnectionString, Parameter, securityTicket));
 }