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

            Guid           accounrRefID = Guid.Empty;
            var            doctorQuery  = new ORM_HEC_Doctor.Query();
            ORM_HEC_Doctor doctor;
            if (Parameter.HEC_DoctorID != Guid.Empty)
            {
                doctorQuery.HEC_DoctorID = Parameter.HEC_DoctorID;
                doctor       = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).First();
                accounrRefID = doctor.Account_RefID;
            }

            P_L3MD_SDBI_1349 sbdParam = new P_L3MD_SDBI_1349();
            sbdParam.DoctorID      = Parameter.HEC_DoctorID;
            sbdParam.Account_RefID = accounrRefID;
            sbdParam.FirstName     = Parameter.FirstName;
            sbdParam.LastName      = Parameter.LastName;
            sbdParam.isOphthalSave = true;
            sbdParam.ifOphthal_Salutation_General = Parameter.Salutation_General;
            sbdParam.ifOphthal_Salutation_Letter  = Parameter.Salutation_Letter;
            sbdParam.Title = Parameter.Title;

            List <P_L3MD_SDBI_1349_Contacts> contactsParams = new List <P_L3MD_SDBI_1349_Contacts>();
            if (Parameter.Contacts != null)
            {
                foreach (var item in Parameter.Contacts)
                {
                    var c = new P_L3MD_SDBI_1349_Contacts();
                    c.CMN_PER_CommunicationContact_TypeID = item.CMN_PER_CommunicationContact_TypeID;
                    c.Content = item.Content;
                    contactsParams.Add(c);
                }
            }
            sbdParam.Contacts = contactsParams.ToArray();

            List <P_L3MD_SDBI_1349_Practice> practicesParams = new List <P_L3MD_SDBI_1349_Practice>();
            if (Parameter.Practices != null)
            {
                foreach (var item in Parameter.Practices)
                {
                    var p = new P_L3MD_SDBI_1349_Practice();
                    p.PracticeID = item.PracticeID;
                    p.isDeleted  = item.isDeleted;
                    p.AssociatedParticipant_FunctionName = item.AssociatedParticipant_FunctionName;
                    practicesParams.Add(p);
                }
            }
            sbdParam.Practices = practicesParams.ToArray();

            var docID = cls_Save_Doctor_BaseInfo.Invoke(Connection, Transaction, sbdParam, securityTicket).Result;

            doctorQuery = new ORM_HEC_Doctor.Query();
            doctorQuery.HEC_DoctorID = docID;

            doctor = ORM_HEC_Doctor.Query.Search(Connection, Transaction, doctorQuery).First();
            var bParticipantQuery = new ORM_CMN_BPT_BusinessParticipant.Query();
            bParticipantQuery.CMN_BPT_BusinessParticipantID = doctor.BusinessParticipant_RefID;
            var bParticipant = ORM_CMN_BPT_BusinessParticipant.Query.Search(Connection, Transaction, bParticipantQuery).First();

            ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative SalesRepresentative;
            var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query();
            customerQuery.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID;
            var customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).FirstOrDefault();
            if (customer == null)
            {
                customer = new ORM_CMN_BPT_CTM_Customer();
                customer.CMN_BPT_CTM_CustomerID        = Guid.NewGuid();
                customer.Tenant_RefID                  = securityTicket.TenantID;
                SalesRepresentative                    = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative();
                SalesRepresentative.AssignmentID       = Guid.NewGuid();
                SalesRepresentative.Customer_RefID     = customer.CMN_BPT_CTM_CustomerID;
                SalesRepresentative.Tenant_RefID       = securityTicket.TenantID;
                customer.Ext_BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID;
            }
            else
            {
                customer = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery).First();
                var SalesRepresentativeQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query();
                SalesRepresentativeQuery.Customer_RefID = customer.CMN_BPT_CTM_CustomerID;
                SalesRepresentative = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, SalesRepresentativeQuery).First();
            }
            SalesRepresentative.SalesRepresentative_RefID = Parameter.CMN_BPT_SalesRepresentativeID;

            var sRepresentativeQuery = new ORM_CMN_BPT_SalesRepresentative.Query();
            sRepresentativeQuery.CMN_BPT_SalesRepresentativeID = Parameter.CMN_BPT_SalesRepresentativeID;
            sRepresentativeQuery.IsDeleted = false;
            var sRepresentative = ORM_CMN_BPT_SalesRepresentative.Query.Search(Connection, Transaction, sRepresentativeQuery).FirstOrDefault();
            if (sRepresentative == null)
            {
                sRepresentative = new ORM_CMN_BPT_SalesRepresentative();
                sRepresentative.CMN_BPT_SalesRepresentativeID = Parameter.CMN_BPT_SalesRepresentativeID;
                sRepresentative.Save(Connection, Transaction);
            }

            customer.Save(Connection, Transaction);
            SalesRepresentative.Save(Connection, Transaction);

            ORM_USR_Account            account;
            ORM_USR_Device_AccountCode code;
            ORM_USR_Device_AccountCode_StatusHistory codeStatus;
            var accountQuery = new ORM_USR_Account.Query();
            accountQuery.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID;
            accountQuery.AccountType = 3;
            var accountQueryRes = ORM_USR_Account.Query.Search(Connection, Transaction, accountQuery);
            if (accountQueryRes.Count == 0)
            {
                account = new ORM_USR_Account();
                account.USR_AccountID             = Guid.NewGuid();
                account.Tenant_RefID              = securityTicket.TenantID;
                account.AccountType               = 3;
                account.BusinessParticipant_RefID = bParticipant.CMN_BPT_BusinessParticipantID;
                account.Save(Connection, Transaction);

                code = new ORM_USR_Device_AccountCode();
                code.Tenant_RefID             = securityTicket.TenantID;
                code.USR_Device_AccountCodeID = Guid.NewGuid();
                code.Account_RefID            = account.USR_AccountID;
                code.AccountCode_ValidFrom    = DateTime.Now;

                codeStatus = new ORM_USR_Device_AccountCode_StatusHistory();
                codeStatus.USR_Device_AccountCode_StatusHistoryID = Guid.NewGuid();
                codeStatus.Device_AccountCode_RefID = code.USR_Device_AccountCodeID;
                codeStatus.Tenant_RefID             = securityTicket.TenantID;
                codeStatus.IsAccountCode_Active     = true;
                codeStatus.Save(Connection, Transaction);

                code.AccountCode_CurrentStatus_RefID = codeStatus.USR_Device_AccountCode_StatusHistoryID;

                L3DAC_GDACFTCV_1616   checkCodeValue;
                P_L3DAC_GDACFTCV_1616 codeParam = new P_L3DAC_GDACFTCV_1616();
                string codeValue;
                do
                {
                    codeValue           = RandomString.Generate(8);
                    codeParam.CodeValue = codeValue;
                    checkCodeValue      = cls_GetDeviceAccountCodeForTenantAndCodeValue.Invoke(Connection, Transaction, codeParam, securityTicket).Result;
                } while (checkCodeValue != null);

                code.AccountCode_Value = codeValue;
                code.Save(Connection, Transaction);
            }

            returnValue.Result = docID;
            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_Guid Invoke(DbConnection Connection, DbTransaction Transaction, P_L5OD_SD_1130 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_Guid Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, P_L5OD_SD_1130 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_Guid functionReturn = new FR_Guid();

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