Пример #1
0
        ///<summary>
        /// Method Invocation of wrapper classes
        ///<summary>
        protected static FR_L5OD_GDfT_1126_Array Invoke(DbConnection Connection, DbTransaction Transaction, string ConnectionString, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            bool cleanupConnection  = Connection == null;
            bool cleanupTransaction = Transaction == null;

            FR_L5OD_GDfT_1126_Array functionReturn = new FR_L5OD_GDfT_1126_Array();

            try
            {
                if (cleanupConnection == true)
                {
                    Connection = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }
                if (cleanupTransaction == true)
                {
                    Transaction = Connection.BeginTransaction();
                }

                functionReturn = Execute(Connection, Transaction, 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_Get_OphthalDoctors_For_Tenant", ex);
            }
            return(functionReturn);
        }
Пример #2
0
        protected static FR_L5OD_GDfT_1126_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null)
        {
            #region UserCode
            var returnValue = new FR_L5OD_GDfT_1126_Array();

            var basicInfos   = cls_Get_Doctor_BaseInfo_withPractice_forTenant.Invoke(Connection, Transaction, securityTicket).Result;
            var allPractices = cls_Get_Practice_For_Tenant.Invoke(Connection, Transaction, securityTicket).Result;
            var accs         = cls_Retrive_Account_Code_Details_forTenant.Invoke(Connection, Transaction, securityTicket).Result;

            var customerQuery = new ORM_CMN_BPT_CTM_Customer.Query();
            customerQuery.Tenant_RefID = securityTicket.TenantID;
            var customers = ORM_CMN_BPT_CTM_Customer.Query.Search(Connection, Transaction, customerQuery);

            var customer2SRQuery = new ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query();
            customer2SRQuery.Tenant_RefID = securityTicket.TenantID;
            var customer2SRs = ORM_CMN_BPT_CTM_Customer_2_SalesRepresentative.Query.Search(Connection, Transaction, customer2SRQuery);

            List <L5OD_GDfT_1126> retVal = new List <L5OD_GDfT_1126>();
            foreach (var item in basicInfos)
            {
                var doc = new L5OD_GDfT_1126();
                doc.BaseInfo     = item;
                doc.FirstName    = item.FirstName;
                doc.LastName     = item.LastName;
                doc.HEC_DoctorID = item.HEC_DoctorID;
                doc.Title        = item.Title;
                if (item.AllPractices != null)
                {
                    var practices       = item.AllPractices.OrderBy(p => p.Creation_Timestamp);
                    var doctorsPractice = practices.FirstOrDefault();
                    if (doctorsPractice != null)
                    {
                        var practicesForDoctor = allPractices.FirstOrDefault(p => p.BaseInfo.HEC_MedicalPractiseID == doctorsPractice.PracticeID);
                        if (practicesForDoctor != null)
                        {
                            L5OD_GDfT_1126_Practice practice = new L5OD_GDfT_1126_Practice();
                            practice.AssociatedParticipant_FunctionName = doctorsPractice.AssociatedParticipant_FunctionName;
                            practice.CMN_BPT_BusinessParticipantID      = doctorsPractice.CMN_BPT_BusinessParticipantID;
                            if (practicesForDoctor.OtherOphthal_PracticeData != null)
                            {
                                practice.HealthAssociation_Name = practicesForDoctor.OtherOphthal_PracticeData.HealthAssociation_Name;
                            }
                            practice.PracticeID    = practicesForDoctor.BaseInfo.HEC_MedicalPractiseID;
                            practice.PracticeName  = practicesForDoctor.BaseInfo.PracticeName;
                            practice.Region_Name   = practicesForDoctor.BaseInfo.Region_Name;
                            practice.Street_Name   = practicesForDoctor.BaseInfo.Street_Name;
                            practice.Street_Number = practicesForDoctor.BaseInfo.Street_Number;
                            practice.Town          = practicesForDoctor.BaseInfo.Town;
                            practice.ZIP           = practicesForDoctor.BaseInfo.ZIP;
                            doc.Practice           = practice;
                        }
                    }

                    var customer = customers.FirstOrDefault(c => c.Ext_BusinessParticipant_RefID == item.Doctor_CMN_BPT_BusinessParticipantID);
                    if (customer != null)
                    {
                        var c2sr = customer2SRs.FirstOrDefault(c => c.Customer_RefID == customer.CMN_BPT_CTM_CustomerID);
                        if (c2sr != null)
                        {
                            doc.SalesRepresentative = new L5OD_GDfT_1126_SalesRepresentative();
                            doc.SalesRepresentative.SalesRepresentative_RefID = c2sr.SalesRepresentative_RefID;
                        }
                    }

                    var accountInfo = accs.FirstOrDefault(a => a.BusinessParticipant_RefID == item.Doctor_CMN_BPT_BusinessParticipantID);
                    if (accountInfo != null)
                    {
                        doc.AccountInfo = new L5OD_GDfT_1126_AccountInfo();
                        doc.AccountInfo.AccountCode_Value = accountInfo.AccountCode_Value;
                    }
                }
                retVal.Add(doc);
            }
            returnValue.Result = retVal.ToArray();
            return(returnValue);

            #endregion UserCode
        }