Example #1
0
        /// <summary>
        /// method to get all userbackends
        /// </summary>
        /// <param name="UserID">takes userid as input</param>
        /// <returns>returns list of user backend</returns>
        public IEnumerable <UserBackendDTO> GetUserAllBackends(string UserID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                UserBackendDAL userbackenddal = new UserBackendDAL();
                //calling data access layer method to get user backends
                List <UserBackendEntity> alluserbackends = userbackenddal.GetUserAllBackends(UserID);
                //calling data access layer method to get user backend synch
                List <SynchEntity>    allbackendsynch     = userbackenddal.GetAllUserBackendsSynch(UserID);
                List <UserBackendDTO> userbackendsdtolist = new List <UserBackendDTO>();
                //check for null
                if (alluserbackends != null && alluserbackends.Count > 0)
                {
                    //converting userdevice entity to userdevice data transfer object
                    foreach (UserBackendEntity userbackendentity in alluserbackends)
                    {
                        UserBackendDTO userbackenddto = UserBackendEntityDTOMapper(userbackendentity);
                        SynchEntity    synchentity    = allbackendsynch.Where(m => m.RowKey.Equals(userbackendentity.BackendID)).FirstOrDefault();
                        //if user backend synch available then convert to dto
                        if (synchentity != null)
                        {
                            SynchDTO synchdto = DataProvider.ResponseObjectMapper <SynchDTO, SynchEntity>(synchentity);
                            userbackenddto.synch = synchdto;
                        }

                        userbackendsdtolist.Add(userbackenddto);
                    }
                }
                else
                {
                    userbackendsdtolist = null;
                }

                return((IEnumerable <UserBackendDTO>)userbackendsdtolist);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while retreiving userbackends : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Example #2
0
        /// <summary>
        /// method to add or update userbackend synch
        /// </summary>
        /// <param name="userbackend"></param>

        public void AddUpdateBackendSynch(UserBackendEntity userbackend)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                SynchDAL    synchDAL     = new SynchDAL();
                SynchEntity backendsynch = synchDAL.GetUserBackendSynch(userbackend.UserID, userbackend.BackendID);
                //backend synch available then update
                if (backendsynch != null)
                {
                    //last synch frequency
                    backendsynch.lastSynchFreq = (backendsynch.LastSynch.Value - DateTime.Now).Days;
                    //update best synch frequency
                    if (backendsynch.lastSynchFreq < backendsynch.bestSynchFreq)
                    {
                        backendsynch.bestSynchFreq = backendsynch.lastSynchFreq;
                    }
                    backendsynch.avgSynchFreq = (backendsynch.lastSynchFreq + (backendsynch.SynchCount * backendsynch.avgSynchFreq)) / (backendsynch.SynchCount + 1);
                    backendsynch.SynchCount   = backendsynch.SynchCount + 1;
                    backendsynch.LastSynch    = DateTime.Now;
                    //calling data access layer method
                    synchDAL.AddUpdateBackendSynch(backendsynch);
                }
                else
                {
                    SynchEntity newbackendsynch = new SynchEntity();
                    newbackendsynch.PartitionKey = string.Concat(CoreConstants.AzureTables.BackendSynchPK, userbackend.UserID);
                    newbackendsynch.RowKey       = string.Concat(CoreConstants.AzureTables.BackendSynchPK, userbackend.BackendID);
                    newbackendsynch.LastSynch    = DateTime.Now;
                    newbackendsynch.SynchCount   = 1;
                    //calling data access layer method
                    synchDAL.AddUpdateBackendSynch(newbackendsynch);
                }
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while adding userbackend synch  : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Example #3
0
        /// <summary>
        /// method to get single userbackend
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <param name="userBackendID">takes user backend id as input</param>
        /// <returns>returns user backend with id associated to user in the form of personalization response</returns>
        public PersonalizationResponseDTO <UserBackendDTO> GetUserBackend(string userID, string userBackendID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                UserBackendDAL    userbackenddal    = new UserBackendDAL();
                UserBackendEntity userbackendentity = userbackenddal.GetUserBackend(userID, userBackendID);
                SynchEntity       synch             = userbackenddal.GetBackendSynch(userID, userBackendID);
                //converting userbackend entity to Response data transfer object
                var ResponseUserBackend = new PersonalizationResponseDTO <UserBackendDTO>();
                ///check for null
                if (userbackendentity != null)
                {
                    UserBackendDTO userbackenddto = UserBackendEntityDTOMapper(userbackendentity);
                    //adding synch to user backend
                    if (synch != null)
                    {
                        SynchDTO synchdto = DataProvider.ResponseObjectMapper <SynchDTO, SynchEntity>(synch);
                        userbackenddto.synch = synchdto;
                    }
                    ResponseUserBackend.result = userbackenddto;
                }
                else
                {
                    ResponseUserBackend.result = null;
                }
                return(ResponseUserBackend);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while retreiving single userbackend : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Example #4
0
        /// <summary>
        /// method to add/upadte Request entity to azure table
        /// </summary>
        /// <param name="synch">takes userbackend synch entity as input</param>
        public void AddUpdateBackendSynch(SynchEntity synch)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //call dataprovider method to insert entity into azure table
                DataProvider.InsertReplaceEntity <SynchEntity>(CoreConstants.AzureTables.UserDeviceConfiguration, synch);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error while inserting userbackend synch into requestTransactions azure table in DAL : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new DataAccessException();
            }
        }
Example #5
0
        /// <summary>
        /// method to get user backend synch
        /// </summary>
        /// <param name="UserID">takes user id as input</param>
        /// /// <param name="UserBackendID">takes user backend id as input</param>
        /// <returns>returns backend synch entity for user</returns>
        public SynchEntity GetBackendSynch(string UserID, string UserBackendID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //call dataprovider method to get entities from azure table
                SynchEntity synchentity = DataProvider.Retrieveentity <SynchEntity>(CoreConstants.AzureTables.UserDeviceConfiguration, (string.Concat(CoreConstants.AzureTables.BackendSynchPK, UserID)), UserBackendID);
                return(synchentity);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error while retrieving userbackendsynch from userdeviceconfig azure table in DAL : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new DataAccessException();
            }
        }
Example #6
0
        ///<summary>a general function to reduce the amount of code for uploading</summary>
        private static void SynchGeneric(List <long> PKNumList, SynchEntity entity, double totalCount, ref double currentVal)
        {
            //Dennis: a try catch block here has been avoid on purpose.
            List <long> BlockPKNumList = null;
            int         localBatchSize = BatchSize;

            if (IsTroubleshootMode)
            {
                localBatchSize = 1;
            }
            string AtoZpath = ImageStore.GetPreferredAtoZpath();

            for (int start = 0; start < PKNumList.Count; start += localBatchSize)
            {
                if ((start + localBatchSize) > PKNumList.Count)
                {
                    localBatchSize = PKNumList.Count - start;
                }
                try{
                    BlockPKNumList = PKNumList.GetRange(start, localBatchSize);
                    switch (entity)
                    {
                    case SynchEntity.patient:
                        List <Patientm> changedPatientmList = Patientms.GetMultPats(BlockPKNumList);
                        mb.SynchPatients(PrefC.GetString(PrefName.RegistrationKey), changedPatientmList.ToArray());
                        break;

                    case SynchEntity.appointment:
                        List <Appointmentm> changedAppointmentmList = Appointmentms.GetMultApts(BlockPKNumList);
                        mb.SynchAppointments(PrefC.GetString(PrefName.RegistrationKey), changedAppointmentmList.ToArray());
                        break;

                    case SynchEntity.prescription:
                        List <RxPatm> changedRxList = RxPatms.GetMultRxPats(BlockPKNumList);
                        mb.SynchPrescriptions(PrefC.GetString(PrefName.RegistrationKey), changedRxList.ToArray());
                        break;

                    case SynchEntity.provider:
                        List <Providerm> changedProvList = Providerms.GetMultProviderms(BlockPKNumList);
                        mb.SynchProviders(PrefC.GetString(PrefName.RegistrationKey), changedProvList.ToArray());
                        break;

                    case SynchEntity.pharmacy:
                        List <Pharmacym> changedPharmacyList = Pharmacyms.GetMultPharmacyms(BlockPKNumList);
                        mb.SynchPharmacies(PrefC.GetString(PrefName.RegistrationKey), changedPharmacyList.ToArray());
                        break;

                    case SynchEntity.labpanel:
                        List <LabPanelm> ChangedLabPanelList = LabPanelms.GetMultLabPanelms(BlockPKNumList);
                        mb.SynchLabPanels(PrefC.GetString(PrefName.RegistrationKey), ChangedLabPanelList.ToArray());
                        break;

                    case SynchEntity.labresult:
                        List <LabResultm> ChangedLabResultList = LabResultms.GetMultLabResultms(BlockPKNumList);
                        mb.SynchLabResults(PrefC.GetString(PrefName.RegistrationKey), ChangedLabResultList.ToArray());
                        break;

                    case SynchEntity.medication:
                        List <Medicationm> ChangedMedicationList = Medicationms.GetMultMedicationms(BlockPKNumList);
                        mb.SynchMedications(PrefC.GetString(PrefName.RegistrationKey), ChangedMedicationList.ToArray());
                        break;

                    case SynchEntity.medicationpat:
                        List <MedicationPatm> ChangedMedicationPatList = MedicationPatms.GetMultMedicationPatms(BlockPKNumList);
                        mb.SynchMedicationPats(PrefC.GetString(PrefName.RegistrationKey), ChangedMedicationPatList.ToArray());
                        break;

                    case SynchEntity.allergy:
                        List <Allergym> ChangedAllergyList = Allergyms.GetMultAllergyms(BlockPKNumList);
                        mb.SynchAllergies(PrefC.GetString(PrefName.RegistrationKey), ChangedAllergyList.ToArray());
                        break;

                    case SynchEntity.allergydef:
                        List <AllergyDefm> ChangedAllergyDefList = AllergyDefms.GetMultAllergyDefms(BlockPKNumList);
                        mb.SynchAllergyDefs(PrefC.GetString(PrefName.RegistrationKey), ChangedAllergyDefList.ToArray());
                        break;

                    case SynchEntity.disease:
                        List <Diseasem> ChangedDiseaseList = Diseasems.GetMultDiseasems(BlockPKNumList);
                        mb.SynchDiseases(PrefC.GetString(PrefName.RegistrationKey), ChangedDiseaseList.ToArray());
                        break;

                    case SynchEntity.diseasedef:
                        List <DiseaseDefm> ChangedDiseaseDefList = DiseaseDefms.GetMultDiseaseDefms(BlockPKNumList);
                        mb.SynchDiseaseDefs(PrefC.GetString(PrefName.RegistrationKey), ChangedDiseaseDefList.ToArray());
                        break;

                    case SynchEntity.icd9:
                        List <ICD9m> ChangedICD9List = ICD9ms.GetMultICD9ms(BlockPKNumList);
                        mb.SynchICD9s(PrefC.GetString(PrefName.RegistrationKey), ChangedICD9List.ToArray());
                        break;

                    case SynchEntity.statement:
                        List <Statementm> ChangedStatementList = Statementms.GetMultStatementms(BlockPKNumList);
                        mb.SynchStatements(PrefC.GetString(PrefName.RegistrationKey), ChangedStatementList.ToArray());
                        break;

                    case SynchEntity.document:
                        List <Documentm> ChangedDocumentList = Documentms.GetMultDocumentms(BlockPKNumList, AtoZpath);
                        mb.SynchDocuments(PrefC.GetString(PrefName.RegistrationKey), ChangedDocumentList.ToArray());
                        break;

                    case SynchEntity.recall:
                        List <Recallm> ChangedRecallList = Recallms.GetMultRecallms(BlockPKNumList);
                        mb.SynchRecalls(PrefC.GetString(PrefName.RegistrationKey), ChangedRecallList.ToArray());
                        break;

                    case SynchEntity.deletedobject:
                        List <DeletedObject> ChangedDeleteObjectList = DeletedObjects.GetMultDeletedObjects(BlockPKNumList);
                        mb.DeleteObjects(PrefC.GetString(PrefName.RegistrationKey), ChangedDeleteObjectList.ToArray());
                        break;

                    case SynchEntity.patientdel:
                        mb.DeletePatientsRecords(PrefC.GetString(PrefName.RegistrationKey), BlockPKNumList.ToArray());
                        break;
                    }
                    //progressIndicator.CurrentVal+=LocalBatchSize;//not allowed
                    currentVal += localBatchSize;
                    if (Application.OpenForms["FormProgress"] != null)                   // without this line the following error is thrown: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." or a null pointer exception is thrown when an automatic synch is done by the system.
                    {
                        FormP.Invoke(new PassProgressDelegate(PassProgressToDialog),
                                     new object[] { currentVal, "?currentVal of ?maxVal records uploaded", totalCount, "" });
                    }
                }
                catch (Exception e) {
                    if (IsTroubleshootMode)
                    {
                        string errorMessage = entity + " with Primary Key = " + BlockPKNumList.First() + " failed to synch. " + "\n" + e.Message;
                        throw new Exception(errorMessage);
                    }
                    else
                    {
                        throw e;
                    }
                }
            }            //for loop ends here
        }
Example #7
0
		///<summary>a general function to reduce the amount of code for uploading</summary>
		private static void SynchGeneric(List<long> PKNumList,SynchEntity entity,double totalCount,ref double currentVal) {
			//Dennis: a try catch block here has been avoid on purpose.
			List<long> BlockPKNumList=null;
			int localBatchSize=BatchSize;
			if(IsTroubleshootMode) {
				localBatchSize=1;
			}
			string AtoZpath=ImageStore.GetPreferredAtoZpath();
			for(int start=0;start<PKNumList.Count;start+=localBatchSize) {
				if((start+localBatchSize)>PKNumList.Count) {
					localBatchSize=PKNumList.Count-start;
				}
				try{
					BlockPKNumList=PKNumList.GetRange(start,localBatchSize);
					switch(entity) {
						case SynchEntity.patient:
							List<Patientm> changedPatientmList=Patientms.GetMultPats(BlockPKNumList);
							mb.SynchPatients(PrefC.GetString(PrefName.RegistrationKey),changedPatientmList.ToArray());
						break;
						case SynchEntity.appointment:
							List<Appointmentm> changedAppointmentmList=Appointmentms.GetMultApts(BlockPKNumList);
							mb.SynchAppointments(PrefC.GetString(PrefName.RegistrationKey),changedAppointmentmList.ToArray());
						break;
						case SynchEntity.prescription:
							List<RxPatm> changedRxList=RxPatms.GetMultRxPats(BlockPKNumList);
							mb.SynchPrescriptions(PrefC.GetString(PrefName.RegistrationKey),changedRxList.ToArray());
						break;
						case SynchEntity.provider:
							List<Providerm> changedProvList=Providerms.GetMultProviderms(BlockPKNumList);
							mb.SynchProviders(PrefC.GetString(PrefName.RegistrationKey),changedProvList.ToArray());
						break;
						case SynchEntity.pharmacy:
						List<Pharmacym> changedPharmacyList=Pharmacyms.GetMultPharmacyms(BlockPKNumList);
						mb.SynchPharmacies(PrefC.GetString(PrefName.RegistrationKey),changedPharmacyList.ToArray());
						break;
						case SynchEntity.labpanel:
							List<LabPanelm> ChangedLabPanelList=LabPanelms.GetMultLabPanelms(BlockPKNumList);
							mb.SynchLabPanels(PrefC.GetString(PrefName.RegistrationKey),ChangedLabPanelList.ToArray());
						break;
						case SynchEntity.labresult:
							List<LabResultm> ChangedLabResultList=LabResultms.GetMultLabResultms(BlockPKNumList);
							mb.SynchLabResults(PrefC.GetString(PrefName.RegistrationKey),ChangedLabResultList.ToArray());
						break;
						case SynchEntity.medication:
							List<Medicationm> ChangedMedicationList=Medicationms.GetMultMedicationms(BlockPKNumList);
							mb.SynchMedications(PrefC.GetString(PrefName.RegistrationKey),ChangedMedicationList.ToArray());
						break;
						case SynchEntity.medicationpat:
							List<MedicationPatm> ChangedMedicationPatList=MedicationPatms.GetMultMedicationPatms(BlockPKNumList);
							mb.SynchMedicationPats(PrefC.GetString(PrefName.RegistrationKey),ChangedMedicationPatList.ToArray());
						break;
						case SynchEntity.allergy:
							List<Allergym> ChangedAllergyList=Allergyms.GetMultAllergyms(BlockPKNumList);
							mb.SynchAllergies(PrefC.GetString(PrefName.RegistrationKey),ChangedAllergyList.ToArray());
						break;
						case SynchEntity.allergydef:
							List<AllergyDefm> ChangedAllergyDefList=AllergyDefms.GetMultAllergyDefms(BlockPKNumList);
							mb.SynchAllergyDefs(PrefC.GetString(PrefName.RegistrationKey),ChangedAllergyDefList.ToArray());
						break;
						case SynchEntity.disease:
							List<Diseasem> ChangedDiseaseList=Diseasems.GetMultDiseasems(BlockPKNumList);
							mb.SynchDiseases(PrefC.GetString(PrefName.RegistrationKey),ChangedDiseaseList.ToArray());
						break;
						case SynchEntity.diseasedef:
							List<DiseaseDefm> ChangedDiseaseDefList=DiseaseDefms.GetMultDiseaseDefms(BlockPKNumList);
							mb.SynchDiseaseDefs(PrefC.GetString(PrefName.RegistrationKey),ChangedDiseaseDefList.ToArray());
						break;
						case SynchEntity.icd9:
							List<ICD9m> ChangedICD9List=ICD9ms.GetMultICD9ms(BlockPKNumList);
							mb.SynchICD9s(PrefC.GetString(PrefName.RegistrationKey),ChangedICD9List.ToArray());
						break;
						case SynchEntity.statement:
						List<Statementm> ChangedStatementList=Statementms.GetMultStatementms(BlockPKNumList);
						mb.SynchStatements(PrefC.GetString(PrefName.RegistrationKey),ChangedStatementList.ToArray());
						break;
						case SynchEntity.document:
						List<Documentm> ChangedDocumentList=Documentms.GetMultDocumentms(BlockPKNumList,AtoZpath);
						mb.SynchDocuments(PrefC.GetString(PrefName.RegistrationKey),ChangedDocumentList.ToArray());
						break;
						case SynchEntity.recall:
						List<Recallm> ChangedRecallList=Recallms.GetMultRecallms(BlockPKNumList);
						mb.SynchRecalls(PrefC.GetString(PrefName.RegistrationKey),ChangedRecallList.ToArray());
						break;
						case SynchEntity.deletedobject:
						List<DeletedObject> ChangedDeleteObjectList=DeletedObjects.GetMultDeletedObjects(BlockPKNumList);
						mb.DeleteObjects(PrefC.GetString(PrefName.RegistrationKey),ChangedDeleteObjectList.ToArray());
						break;
						case SynchEntity.patientdel:
						mb.DeletePatientsRecords(PrefC.GetString(PrefName.RegistrationKey),BlockPKNumList.ToArray());
						break;
					}
					//progressIndicator.CurrentVal+=LocalBatchSize;//not allowed
					currentVal+=localBatchSize;
					if(Application.OpenForms["FormProgress"]!=null) {// without this line the following error is thrown: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created." or a null pointer exception is thrown when an automatic synch is done by the system.
						FormP.Invoke(new PassProgressDelegate(PassProgressToDialog),
							new object[] {currentVal,"?currentVal of ?maxVal records uploaded",totalCount,"" });
					}
				}
				catch(Exception e) {
					if(IsTroubleshootMode) {
						string errorMessage=entity+ " with Primary Key = "+BlockPKNumList.First() + " failed to synch. " +  "\n" + e.Message;
						throw new Exception(errorMessage);
					}
					else {
						throw e;
					}
				}
			}//for loop ends here
		}