示例#1
0
        // Json Convert Pending approvals task as list
        public List <ApprovalRequestDTO> ApprovalTasks(UserBackendrequestJsonData userBackendjsonResponse)
        {
            //creates list request details object
            List <ApprovalRequestDTO> requestsDetails = new List <ApprovalRequestDTO>();

            //Checks whether the JSON response is not null
            if (userBackendjsonResponse != null)
            {
                //Iterate json format result and bind to Model
                foreach (userBackendRequest userbackendRequestdetails in userBackendjsonResponse.userBackendRequestResults[0].userBackendRequestinfo)
                {
                    //Create ApprovalRequestDTO Model object
                    ApprovalRequestDTO requestObj = new ApprovalRequestDTO();
                    requestObj.approval = new ApprovalDTO();
                    if (userbackendRequestdetails.approvalDetails != null)
                    {
                        //Get the approval task Request ID
                        requestObj.approval.RequestId = userbackendRequestdetails.approvalDetails.RequestId;
                        //Get the approval task Request Status
                        requestObj.approval.Status             = userbackendRequestdetails.approvalDetails.Status;
                        requestObj.approval.TaskTitle          = userbackendRequestdetails.approvalDetails.TaskTitle;
                        requestObj.approval.ServiceLayerTaskID = userbackendRequestdetails.approvalDetails.ServiceLayerTaskID;
                        requestObj.approval.DueDate            = userbackendRequestdetails.approvalDetails.DueDate;
                        requestObj.approval.DecisionDate       = userbackendRequestdetails.approvalDetails.DecisionDate;
                        requestsDetails.Add(requestObj);
                    }
                }
            }
            //Return request details list
            return(requestsDetails);
        }
示例#2
0
        public async Task <ActionResult> GetRequestDetails(RequestDetails requestInfo)
        {
            try
            {
                //Assign UI synch request details to SynchRequestDTO model
                SynchRequestDTO syncRequest = requestInfo.syncRequest;
                //Assign user id to SynchRequestDTO model
                syncRequest.userId = userid;
                //Api Controller object initialization
                APIController apiControllerObj = new APIController();
                //Get request details from Synch API
                string stApprovalrequest = await apiControllerObj.GetRequestInfo(syncRequest, requestInfo.requestID);

                //Get Approval List details from Synch API
                string strApproverList = await apiControllerObj.GetApprovers(syncRequest, requestInfo.requestID);

                //Deseralize the result returned by the API
                UserRequestJsonData  userBackendjsonResponse  = JsonConvert.DeserializeObject <UserRequestJsonData>(stApprovalrequest);
                UserApprovalJsonData userApprovaljsonResponse = JsonConvert.DeserializeObject <UserApprovalJsonData>(strApproverList);
                //creates list request details object
                List <ApprovalRequestDTO> requestsDetails = new List <ApprovalRequestDTO>();
                //Checks whether the JSON response is not null
                if (userBackendjsonResponse != null && userApprovaljsonResponse != null)
                {
                    //Create ApprovalRequestDTO Model object
                    ApprovalRequestDTO requestObj = new ApprovalRequestDTO();
                    //Iterate json format result and bind to Model
                    foreach (userBackendRequest userbackendRequestdetails in userBackendjsonResponse.userBackendRequestinfo)
                    {
                        //Create ApprovalDTO Model object
                        requestObj.approval = new ApprovalDTO();
                        //Create RequestDTO Model object
                        requestObj.request = new RequestDTO();
                        if (userbackendRequestdetails.requestDetails != null)
                        {
                            //Get Request ID from Json reuslt
                            requestObj.request.ID = userbackendRequestdetails.requestDetails.ID;
                            //Get Request Title from Json reuslt
                            requestObj.request.Title = userbackendRequestdetails.requestDetails.Title;
                            //Get Request Status from Json reuslt
                            requestObj.request.Status = userbackendRequestdetails.requestDetails.Status;
                            //Get Request Created from Json reuslt
                            DateTime?created = userbackendRequestdetails.requestDetails.Created;
                            if (created != null)
                            {
                                requestObj.request.Created = created.Value;
                            }
                            //Get Request Requester details from Json reuslt
                            requestObj.request.Requester = new RequesterDTO();
                            //Get Requester UserID from Json reuslt
                            if (requestObj.request.Requester.UserID == null)
                            {
                                requestObj.request.Requester.UserID = userbackendRequestdetails.requestDetails.Requester.UserID;
                            }
                            //Get Requester UserID from Json reuslt
                            if (requestObj.request.Requester.Name == null)
                            {
                                requestObj.request.Requester.Name = userbackendRequestdetails.requestDetails.Requester.Name;
                            }
                            //Creates list request fields object
                            List <FieldDTO> requestFields = new List <FieldDTO>();
                            //Checks whether the JSON response is not null
                            if (userbackendRequestdetails.requestDetails.Fields.Overview != null && userbackendRequestdetails.requestDetails.Fields.Overview.Count > 0)
                            {
                                //Iterate json format result and bind to Model
                                foreach (FieldDTO field in userbackendRequestdetails.requestDetails.Fields.Overview)
                                {
                                    //Create FieldDTO Model object for Overview fields
                                    FieldDTO overviewFields = new FieldDTO();
                                    //Get Overview fields Name from Json reuslt
                                    overviewFields.Name = field.Name;
                                    //Get Overview fields Value from Json reuslt
                                    overviewFields.Value = field.Value;
                                    //Get Overview fields Group from Json reuslt
                                    overviewFields.Group = field.Group;
                                    //Add to FieldDTO Model object
                                    requestFields.Add(overviewFields);
                                }
                            }
                            //Checks whether the JSON response is not null
                            if (userbackendRequestdetails.requestDetails.Fields.GenericInfo != null && userbackendRequestdetails.requestDetails.Fields.Overview.Count > 0)
                            {
                                //Iterate json format result and bind to Model
                                foreach (FieldDTO field in userbackendRequestdetails.requestDetails.Fields.GenericInfo)
                                {
                                    //Create FieldDTO Model object for Generic fields
                                    FieldDTO genericInfoFields = new FieldDTO();
                                    //Get Generic fields Name/Value pair from Json reuslt
                                    genericInfoFields.Name  = field.Name;
                                    genericInfoFields.Value = field.Value;
                                    //Get Generic fields Group from Json reuslt
                                    genericInfoFields.Group = field.Group;
                                    //Add to FieldDTO Model object
                                    requestFields.Add(genericInfoFields);
                                }
                            }
                            //Creates list approval list object
                            List <Approvers> approverList = new List <Approvers>();
                            //Iterate json format result and bind to Model
                            foreach (ApproversJson userApprovalJsondetails in userApprovaljsonResponse.userApprovalinfo)
                            {
                                //Create Approvers Model object for Approval details
                                Approvers userApprovaldetails = new Approvers();
                                //Get Approval Order info
                                userApprovaldetails.Order = userApprovalJsondetails.Order;
                                //Get Approval Order UserID
                                userApprovaldetails.UserID = userApprovalJsondetails.UserID;
                                //Get Approval Order UserName
                                userApprovaldetails.UserName = userApprovalJsondetails.UserName;
                                //Get Approval Order Status
                                userApprovaldetails.Status = userApprovalJsondetails.Status;
                                //Get Approval Order Created
                                userApprovaldetails.Created = userApprovalJsondetails.Created;
                                //Get Approval Order DueDate
                                userApprovaldetails.DueDate = userApprovalJsondetails.DueDate;
                                //Get Approval Order DecisionDate
                                userApprovaldetails.DecisionDate = userApprovalJsondetails.DecisionDate;
                                //getting Approver Comment
                                userApprovaldetails.Comment = userApprovalJsondetails.Comment;
                                //Add to Approvers Model object for Approval details
                                approverList.Add(userApprovaldetails);
                            }
                            //Add approval list to ApprovalRequestDTO Model object
                            requestObj.request.Approvers = approverList;
                            //Add Overview /Generic fields to ApprovalRequestDTO Model object
                            requestObj.request.Fields = requestFields;
                        }
                        else
                        {
                            requestObj.request    = null;
                            requestObj.approval   = null;
                            requestObj.retryAfter = userbackendRequestdetails.retryAfter;
                        }
                        //Add all info to ApprovalRequestDTO Model object List
                        requestsDetails.Add(requestObj);
                    }
                }
                // Return Json formate object and pass to UI
                return(Json(requestsDetails, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exception)
            {
                LoggerHelper.WriteToLog(exception + " - Error while creating client context : "
                                        + exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                return(View("Error"));
            }
        }
示例#3
0
文件: Reference.cs 项目: unicloud/FRP
 public void AddToApprovalRequests(ApprovalRequestDTO approvalRequestDTO)
 {
     base.AddObject("ApprovalRequests", approvalRequestDTO);
 }
示例#4
0
        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();
            }
        }
示例#5
0
文件: Reference.cs 项目: unicloud/FRP
 public static ApprovalRequestDTO CreateApprovalRequestDTO(global::System.Guid ID, int status, global::System.Collections.ObjectModel.ObservableCollection<ApprovalHistoryDTO> approvalHistories)
 {
     ApprovalRequestDTO approvalRequestDTO = new ApprovalRequestDTO();
     approvalRequestDTO.Id = ID;
     approvalRequestDTO.Status = status;
     if ((approvalHistories == null))
     {
         throw new global::System.ArgumentNullException("approvalHistories");
     }
     approvalRequestDTO.ApprovalHistories = approvalHistories;
     return approvalRequestDTO;
 }