/// <summary> /// method to check user availability /// </summary> /// <param name="UserID">takes userid as input</param> /// <returns>returns true if user exists else false</returns> public Boolean CheckUser(string UserID) { string callerMethodName = string.Empty; try { //Get Caller Method name from CallerInformation class callerMethodName = CallerInformation.TrackCallerMethodName(); PersonalizationDAL personalizationdal = new PersonalizationDAL(); //calling data access layer method UserEntity user = personalizationdal.GetUser(UserID); //if user exists return true if (user != null) { return(true); } else { return(false); } } catch (Exception exception) { InsightLogger.Exception(exception.Message, exception, callerMethodName); //LoggerHelper.WriteToLog(exception + " - Error in BL while checking user existance : " //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error); throw new BusinessLogicException(); } }
/// <summary> /// method to delete user details /// </summary> /// <param name="UserID">takes userid as input</param> /// <returns>returns deleted user entity</returns> public UserEntity DeleteUser(string UserID) { string callerMethodName = string.Empty; try { //Get Caller Method name from CallerInformation class callerMethodName = CallerInformation.TrackCallerMethodName(); PersonalizationDAL personalizationdal = new PersonalizationDAL(); //calling data access layer method UserEntity deleteuser = personalizationdal.DeleteUser(UserID); return(deleteuser); } catch (DataAccessException DALexception) { throw DALexception; } catch (Exception exception) { InsightLogger.Exception(exception.Message, exception, callerMethodName); //LoggerHelper.WriteToLog(exception + " - Error in BL while deleting user : " //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error); throw new BusinessLogicException(); } }
/// <summary> /// method to add message to queue to trigger userbackend update /// </summary> /// <param name="userbackend">takes userbackend as input</param> public void TriggerUserBackendUpdate(UserBackendEntity userbackend, bool isForceUpdate) { string callerMethodName = string.Empty; try { //Get Caller Method name from CallerInformation class callerMethodName = CallerInformation.TrackCallerMethodName(); UpdateTriggeringMessage updateTriggerMessage = new UpdateTriggeringMessage(); UserUpdateMsg usermsg = new UserUpdateMsg(); usermsg.UserID = userbackend.UserID; List <UpdateTriggerBackend> updatetriggerbackendlist = new List <UpdateTriggerBackend>(); //adding backend to message object UpdateTriggerBackend triggerbackend = new UpdateTriggerBackend(); triggerbackend.BackendID = userbackend.BackendID; updateTriggerMessage.ChangeAfter = userbackend.LastUpdate; updatetriggerbackendlist.Add(triggerbackend); usermsg.Backends = updatetriggerbackendlist; //creating list to add users List <UserUpdateMsg> usermsglist = new List <UserUpdateMsg>(); usermsglist.Add(usermsg); updateTriggerMessage.Users = usermsglist; //calling data access layer method to add message to queue PersonalizationDAL personalizationdal = new PersonalizationDAL(); if (isForceUpdate) { personalizationdal.ForceUpdate_AddUpdateTriggerMessageToQueue(updateTriggerMessage); } else { personalizationdal.AddUpdateTriggerMessageToQueue(updateTriggerMessage); } } catch (DataAccessException DALexception) { throw DALexception; } catch (Exception exception) { InsightLogger.Exception(exception.Message, exception, callerMethodName); //LoggerHelper.WriteToLog(exception + " - Error in BL while formatting updatetriggering message : " //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error); throw new BusinessLogicException(); } }
/// <summary> /// method to get user details /// </summary> /// <param name="UserID">takes user id as input</param> /// <returns> returns user along with associated devices and backends </returns> public UserDTO GetUser(string UserID) { string callerMethodName = string.Empty; try { //Get Caller Method name from CallerInformation class callerMethodName = CallerInformation.TrackCallerMethodName(); PersonalizationDAL personalizationdal = new PersonalizationDAL(); UserEntity user = personalizationdal.GetUser(UserID); if (user != null) { //converting userentity to user data transfer object UserDTO userdto = DataProvider.ResponseObjectMapper <UserDTO, UserEntity>(user); //getting devices and backends associated to that user UserBackend userbackend = new UserBackend(); UserDevice userdevice = new UserDevice(); ///getting devices and backends associated to that user IEnumerable <UserDeviceDTO> userdevices = userdevice.GetUserAllDevices(UserID); IEnumerable <UserBackendDTO> userbackends = userbackend.GetUserAllBackends(UserID); userdto.userbackends = userbackends; userdto.userdevices = userdevices; return(userdto); } else { return(null); } } catch (DataAccessException DALexception) { throw DALexception; } catch (Exception exception) { InsightLogger.Exception(exception.Message, exception, callerMethodName); //LoggerHelper.WriteToLog(exception + " - Error in BL while retrieving user : " //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error); throw new BusinessLogicException(); } }
//// <summary> /// method to trigger user requsets update /// </summary> /// <param name="UserID">takes userid as input</param> /// <param name="userbackendslist">takes userbackends list as input</param> public void TriggerUserRequests(string userID, IEnumerable <UserBackendDTO> userbackendslist) { string callerMethodName = string.Empty; try { //Get Caller Method name from CallerInformation class callerMethodName = CallerInformation.TrackCallerMethodName(); UpdateTriggeringMessage updateTriggerMessage = new UpdateTriggeringMessage(); UserUpdateMsg usermsg = new UserUpdateMsg(); usermsg.UserID = userID; List <UpdateTriggerBackend> updatetriggerbackendlist = new List <UpdateTriggerBackend>(); //adding each user backend details to list for adding to message foreach (UserBackendDTO userbackend in userbackendslist) { UpdateTriggerBackend triggerbackend = new UpdateTriggerBackend(); triggerbackend.BackendID = userbackend.backend.BackendID; updatetriggerbackendlist.Add(triggerbackend); } usermsg.Backends = updatetriggerbackendlist; //creating list to add users List <UserUpdateMsg> usermsglist = new List <UserUpdateMsg>(); usermsglist.Add(usermsg); updateTriggerMessage.Users = usermsglist; updateTriggerMessage.GetPDFs = Convert.ToBoolean(ConfigurationManager.AppSettings[CoreConstants.Config.GetPDFs]); //calling data access layer method to add message to queue PersonalizationDAL personalizationdal = new PersonalizationDAL(); personalizationdal.AddUpdateTriggerMessageToQueue(updateTriggerMessage); } catch (DataAccessException DALexception) { throw DALexception; } catch (Exception exception) { InsightLogger.Exception(exception.Message, exception, callerMethodName); //LoggerHelper.WriteToLog(exception + " - Error in BL while formatting updatetriggering message : " //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error); throw new BusinessLogicException(); } }
/// <summary> /// method to add message to queue to trigger request update /// </summary> /// <param name="request">takes request as input</param> public void TriggerRequestUpdate(RequestEntity request, string UserID) { string callerMethodName = string.Empty; try { //Get Caller Method name from CallerInformation class callerMethodName = CallerInformation.TrackCallerMethodName(); UpdateTriggeringMessage updateTriggerMessage = new UpdateTriggeringMessage(); List <RequestUpdateMsg> updatetriggerrequestlist = new List <RequestUpdateMsg>(); RequestUpdateMsg triggerrequset = new RequestUpdateMsg(); //adding request to message object Request requestobj = new Request(); requestobj.ID = request.ID; requestobj.UserID = UserID; triggerrequset.request = requestobj; //adding backend to queue message UpdateTriggerBackend backendobj = new UpdateTriggerBackend(); backendobj.BackendID = request.BackendID; triggerrequset.request.Backend = backendobj; //add requests to list which will be added to message updatetriggerrequestlist.Add(triggerrequset); updateTriggerMessage.Requests = updatetriggerrequestlist; updateTriggerMessage.GetPDFs = Convert.ToBoolean(ConfigurationManager.AppSettings[CoreConstants.Config.GetPDFs]); //calling data access layer method to add message to queue PersonalizationDAL personalizationdal = new PersonalizationDAL(); personalizationdal.AddUpdateTriggerMessageToQueue(updateTriggerMessage); } catch (DataAccessException DALexception) { throw DALexception; } catch (Exception exception) { InsightLogger.Exception(exception.Message, exception, callerMethodName); //LoggerHelper.WriteToLog(exception + " - Error in BL while formatting updatetriggering message : " //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error); throw new BusinessLogicException(); } }