コード例 #1
0
ファイル: SynchDAL.cs プロジェクト: mkbiltek2019/MyProjs
        /// <summary>
        /// method to add/upadte Request synch entity to azure table
        /// </summary>
        /// <param name="synch">takes request synch entity as input</param>
        public void AddUpdateRequestSynch(RequestSynchEntity 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 <RequestSynchEntity>(CoreConstants.AzureTables.UserDeviceConfiguration, synch);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error while inserting request synch into requestTransactions azure table in DAL : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new DataAccessException();
            }
        }
コード例 #2
0
ファイル: SynchDAL.cs プロジェクト: mkbiltek2019/MyProjs
        /// <summary>
        /// method to get request synch
        /// </summary>
        /// <param name="requestsynchpk">takes request synch partitionkey as input</param>
        /// /// <param name="requestid">takes request id as input</param>
        /// <returns>returns backend synch entity for user</returns>
        public RequestSynchEntity GetRequestSynch(string requestsynchpk, string requestid)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //call dataprovider method to get entities from azure table
                RequestSynchEntity synchentity = DataProvider.Retrieveentity <RequestSynchEntity>(CoreConstants.AzureTables.UserDeviceConfiguration, requestsynchpk, requestid);
                return(synchentity);
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error while retrieving request synch from userdeviceconfig azure table in DAL : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new DataAccessException();
            }
        }
コード例 #3
0
ファイル: Synch.cs プロジェクト: mkbiltek2019/MyProjs
        /// <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();
            }
        }
コード例 #4
0
ファイル: Synch.cs プロジェクト: mkbiltek2019/MyProjs
        // <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();
            }
        }
コード例 #5
0
ファイル: Synch.cs プロジェクト: mkbiltek2019/MyProjs
        public UserBackendDTO AddRequsetsTasksCountToSynchResponse(List <RequestEntity> userbackendrequestslist, List <ApprovalEntity> userbackendapprovalslist, UserBackendEntity userbackend, SynchRequestDTO query, UserBackendDTO userbackenddto)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                List <ApprovalRequestDTO> approvalrequestlist = new List <ApprovalRequestDTO>();
                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: Loop through all requests in backend");
                //loop through each request in the userbackend
                foreach (RequestEntity request in userbackendrequestslist)
                {
                    ApprovalRequestDTO approvalrequest = new ApprovalRequestDTO();
                    RequestDTO         requestdto      = new RequestDTO();
                    //get approval associated to request
                    ApprovalEntity approval = userbackendapprovalslist.Find(x => x.RequestId == request.ID);
                    if (approval != null)
                    {
                        ApprovalDTO approvaldto = new ApprovalDTO();
                        approvaldto = DataProvider.ResponseObjectMapper <ApprovalDTO, ApprovalEntity>(approval);
                        approvalrequest.approval            = approvaldto;
                        userbackenddto.approvalsCount.Count = userbackenddto.approvalsCount.Count + 1;
                        //if request is updated
                        if (Rules.IsRequestUpdated(request, userbackend.DefaultUpdateFrequency))
                        {
                            InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: check request update, response: true");
                            //get request synch entity
                            RequestSynchEntity requestsynch = GetRequestSynch(request);
                            //check if requests which have changed since the last synch need to send in response or all requests.
                            if (Rules.IsTargetRequest(query, request, approval, requestsynch))
                            {
                                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: Target request, response: true");
                                requestdto = DataProvider.ResponseObjectMapper <RequestDTO, RequestEntity>(request);
                                approvalrequest.request = requestdto;
                                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: add request header to response, response: success");
                                //code here to populate extended depth
                                //code here to update request synch time stamp
                                AddUpdateRequestSynch(request, requestsynch, query.userId);
                                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: Update request synch timestamp, response: success");
                                //requestsfulfilled = true;
                            }
                        }
                        else
                        {
                            InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: check request update, response: false");
                            //check if request update is in progress in service layer then send the latency in response
                            if (Rules.IsRequestUpdateInProgress(request))
                            {
                                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: update in-progress, response: true");
                                approvalrequest.retryAfter = request.ExpectedLatency;
                                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: Add expected request latancy to resposne as retry time, response: Success");
                            }
                            else
                            {
                                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: update in-progress, response: false");
                                TriggerRequestUpdate(request, query.userId);
                                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: trigger a Request update, response: success");
                                approvalrequest.retryAfter = Convert.ToInt32(Rules.RequestRetryTime(userbackend));
                                InsightLogger.TrackEvent("SyncAPIController :: endpoint - api/synch/users/{userID}/backends, action: Add request retrytime to response, response: success");
                            }
                            //requestsunfulfilled = true;
                        }
                        //add approval request to list which will be added to corresponding backend
                        approvalrequestlist.Add(approvalrequest);
                    }
                }
                userbackenddto.requests = approvalrequestlist;
                return(userbackenddto);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while adding all approvals count to response  : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
コード例 #6
0
 /// <summary>
 /// method to filter out the requests changed/updated since the Last synch
 /// </summary>
 /// <param name="query">takes qury as input</param>
 /// <param name="request">takes request as input</param>
 /// <returns>returns whether request is changed after last synch</returns>
 public static Boolean IsRequestATarget(SynchRequestDTO query, RequestEntity request, RequestSynchEntity requestsynch)
 {
     if (requestsynch != null)
     {
         return((query.parameters.filters.onlyChangedReq && request.LastUpdate != null && (request.LastUpdate > requestsynch.LastChange)) || (!query.parameters.filters.onlyChangedReq));
     }
     else
     {
         return(true);
     }
 }
コード例 #7
0
        /// <summary>
        /// method to deicede only the filtered requests are sent back or all
        /// </summary>
        /// <param name="query">takes qury as input</param>
        /// <param name="request">takes request as input</param>
        /// <param name="approvalStatus">takes approvalStatus as input</param>
        /// <param name="requestsynch">takes requestsynch as input</param>
        /// <returns>returns whether filtered requests are sent back or all</returns>
        public static Boolean IsTargetRequest(SynchRequestDTO query, RequestEntity request, ApprovalEntity approval, RequestSynchEntity requestsynch)
        {
            string QueryRequestStatus  = query.parameters.filters.reqStatus;
            string QueryApprovalStatus = query.parameters.filters.apprStatus;
            string approvalStatus      = null;

            if (approval != null)
            {
                approvalStatus = approval.Status;
            }
            if (requestsynch != null)
            {
                return(((string.IsNullOrEmpty(QueryRequestStatus) && (request.Status == QueryRequestStatus)) || (!string.IsNullOrEmpty(QueryRequestStatus))) &&
                       ((string.IsNullOrEmpty(QueryApprovalStatus) && (approvalStatus == QueryApprovalStatus)) || (!string.IsNullOrEmpty(QueryApprovalStatus))) &&
                       ((query.parameters.filters.onlyChangedReq && request.LastUpdate != null && (request.LastUpdate > requestsynch.LastChange)) || (!query.parameters.filters.onlyChangedReq)));
            }
            else
            {
                return(((string.IsNullOrEmpty(QueryRequestStatus) && (request.Status == QueryRequestStatus)) || (!string.IsNullOrEmpty(QueryRequestStatus))) &&
                       ((string.IsNullOrEmpty(QueryApprovalStatus) && (approvalStatus == QueryApprovalStatus)) || (!string.IsNullOrEmpty(QueryApprovalStatus))));
            }
        }