예제 #1
0
        protected static FR_Guids Execute(DbConnection Connection, DbTransaction Transaction, P_L5OS_ABL_1157 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            //Leave UserCode region to enable user code saving
            #region UserCode
            var         returnValue = new FR_Guids();
            List <Guid> retVal      = new List <Guid>();

            Guid shippmentHeaderID = Guid.Empty;

            P_L5OS_GASFD_1234 param = new P_L5OS_GASFD_1234();
            param.HEC_DoctorID = Parameter.HEC_Doctor_RefID;
            var dateNow = DateTime.Now;
            param.ToDate   = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 23, 59, 59, 999);
            param.FormDate = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, 0, 0, 0, 0);

            var res = cls_Get_ActiveShippmentForDoctorID.Invoke(Connection, Transaction, param, securityTicket).Result;

            if (res != null && res.Length > 0)
            {
                shippmentHeaderID = res[0].LOG_SHP_Shipment_HeaderID;
            }

            if (shippmentHeaderID == Guid.Empty)
            {
                ORM_LOG_SHP_Shipment_Header header = new ORM_LOG_SHP_Shipment_Header();
                header.IsShipped    = false;
                header.Tenant_RefID = securityTicket.TenantID;
                header.Save(Connection, Transaction);

                shippmentHeaderID = header.LOG_SHP_Shipment_HeaderID;
            }

            for (int i = 0; i < Parameter.Count; i++)
            {
                ORM_LOG_SHP_Shipment_Position logShippmentPosition = new ORM_LOG_SHP_Shipment_Position();
                logShippmentPosition.CMN_PRO_Product_RefID         = Parameter.CMN_PRO_ProductID;
                logShippmentPosition.LOG_SHP_Shipment_Header_RefID = shippmentHeaderID;
                logShippmentPosition.Save(Connection, Transaction);

                ORM_HEC_ShippingPosition_BarcodeLabel shippmentLabel = new ORM_HEC_ShippingPosition_BarcodeLabel();
                shippmentLabel.Doctor_RefID = Parameter.HEC_Doctor_RefID;
                shippmentLabel.LOG_SHP_Shipment_Position_RefID = logShippmentPosition.LOG_SHP_Shipment_PositionID;
                shippmentLabel.R_IsSubmission_Complete         = false;
                shippmentLabel.Tenant_RefID = securityTicket.TenantID;
                List <ORM_HEC_ShippingPosition_BarcodeLabel> positionLabels;
                String barcodeLabel = "";
                do
                {
                    barcodeLabel = RandomString.Generate(9);

                    var positionLabelsQuery = new ORM_HEC_ShippingPosition_BarcodeLabel.Query();
                    positionLabelsQuery.ShippingPosition_BarcodeLabel = barcodeLabel;
                    positionLabelsQuery.Tenant_RefID = securityTicket.TenantID;
                    positionLabelsQuery.IsDeleted    = false;
                    positionLabels = ORM_HEC_ShippingPosition_BarcodeLabel.Query.Search(Connection, Transaction, positionLabelsQuery);
                } while (positionLabels != null && positionLabels.Count != 0);

                shippmentLabel.ShippingPosition_BarcodeLabel = barcodeLabel;
                shippmentLabel.Save(Connection, Transaction);

                retVal.Add(shippmentLabel.HEC_ShippingPosition_BarcodeLabelID);
            }
            returnValue.Result = retVal.ToArray();
            return(returnValue);

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

            FR_Guids functionReturn = new FR_Guids();

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