Exemple #1
0
        /// <summary>
        /// method to get fields for request
        /// </summary>
        /// <param name="requestID">takes requestid as input</param>
        /// <returns>returns list of fields</returns>
        public List <FieldDTO> GetFields(string requestID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                SynchDAL synchDAL = new SynchDAL();
                //calling data access layer method
                List <FieldEntity> fieldsentitylist = synchDAL.GetFields(requestID);
                List <FieldDTO>    fileds           = new List <FieldDTO>();
                //loop through fields list entity to convert to fields dto
                foreach (FieldEntity field in fieldsentitylist)
                {
                    FieldDTO fielddto = DataProvider.ResponseObjectMapper <FieldDTO, FieldEntity>(field);
                    fileds.Add(fielddto);
                }
                return(fileds);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting fields per request : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #2
0
        /// <summary>
        /// method to get all approvals of user
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <returns>reurns list of requests for user</returns>
        public List <ApprovalEntity> GetUserApprovalsForCount(string userID, string approvalstatus)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //if requeststatus is null, get requests with defaultstatus inprogress.
                if (string.IsNullOrEmpty(approvalstatus))
                {
                    approvalstatus = CoreConstants.AzureTables.Waiting;
                }
                SynchDAL synchDAL = new SynchDAL();
                //calling data access layer method
                return(synchDAL.GetUserApprovalsForCount(userID, approvalstatus));
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting all approvals count per user  : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #3
0
        /// <summary>
        /// method to get list of backends associated to user
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <returns>returns list of userbackends</returns>
        public List <UserBackendEntity> GetUserBackendsList(string userID, List <string> userbackends)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //if userbackendid's not provided get all associated backends to user by default
                if (userbackends != null)
                {
                    SynchDAL synchdDAL = new SynchDAL();
                    //calling data access layer method
                    return(synchdDAL.GetUserAllBackends(userID, userbackends));
                }
                else
                {
                    UserBackendDAL userbackenddal = new UserBackendDAL();
                    return(userbackenddal.GetUserAllBackends(userID));
                }
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting userbackend list per user : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #4
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();
            }
        }
Exemple #5
0
        /// <summary>
        /// method add or update request synch
        /// </summary>
        /// <param name="request"></param>
        public void AddUpdateRequestSynch(RequestEntity request, RequestSynchEntity requestsynch, string userid)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                SynchDAL synchDAL = new SynchDAL();
                if (requestsynch != null)
                {
                    //last synch frequency
                    requestsynch.LastChange = DateTime.Now;
                    //calling data access layer method
                    synchDAL.AddUpdateRequestSynch(requestsynch);
                }
                else
                {
                    RequestSynchEntity newrequestsynch = new RequestSynchEntity();
                    newrequestsynch.PartitionKey = CoreConstants.AzureTables.RequestSynchPK;
                    newrequestsynch.RowKey       = request.ID;
                    newrequestsynch.LastChange   = DateTime.Now;
                    newrequestsynch.BackendID    = request.BackendID;
                    newrequestsynch.UserID       = userid;
                    //calling data access layer method
                    synchDAL.AddUpdateRequestSynch(newrequestsynch);
                }
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while adding/updating request synch  : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #6
0
        // <summary>
        /// method add or get request synch
        /// </summary>
        /// <param name="request"></param>
        public RequestSynchEntity GetRequestSynch(RequestEntity request)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                SynchDAL           synchDAL     = new SynchDAL();
                RequestSynchEntity requestsynch = synchDAL.GetRequestSynch(CoreConstants.AzureTables.RequestSynchPK, request.ID);
                return(requestsynch);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting request synch  : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Exemple #7
0
        /// <summary>
        /// method to get shared access service pdf uri with id
        /// </summary>
        /// <param name="pdfuri">takes pdfuri as input</param>
        /// <returns>returns sas pdf uri</returns>
        public Uri GetSASPdfUri(string pdfuri)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                SynchDAL synchDAL = new SynchDAL();
                //calling data access layer method
                return(synchDAL.GetSASPdfUri(pdfuri));
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting shared access service pdf uri : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }