コード例 #1
0
        public BatchDocumentCommandRoutingResponse GetNextBatcDocumentCommand(Guid costCentreApplicationId, Guid costCentreId, List<long> lastDeliveredCommandRouteItemIds, int batchSize)
        {

            if (lastDeliveredCommandRouteItemIds!=null && lastDeliveredCommandRouteItemIds.Count>0)
                _commandRoutingOnRequestRepository.MarkBatchAsDelivered(lastDeliveredCommandRouteItemIds, costCentreApplicationId);

            List<CommandRouteOnRequest> criList = _commandRoutingOnRequestRepository
                .GetUnexecutedBatchByDestinationCostCentreApplicationId(costCentreApplicationId, costCentreId, batchSize,true);
            BatchDocumentCommandRoutingResponse responce = new BatchDocumentCommandRoutingResponse();
            if (criList == null || criList.Count()==0)
            {
                responce.RoutingCommands = null;
                responce.CommandRoutingCount = 0;
                responce.ErrorInfo = "No Pending Download";
                responce.LastCommandRouteItemId = 0;
            }
            foreach (CommandRouteOnRequest cri in criList)
            {
                //CommandType ct = (CommandType) Enum.Parse(typeof (CommandType), cri.CommandType);

                DocumentCommandRoutingResponse commandResponse=new DocumentCommandRoutingResponse
                           {
                               CommandRouteItemId = cri.Id,
                               CommandType = cri.CommandType,
                               ErrorInfo = "",
                               Command = JsonConvert.DeserializeObject<DocumentCommand>(cri.JsonCommand)
                           };

                responce.RoutingCommands.Add(commandResponse);
                responce.LastCommandRouteItemId = cri.Id;
            }
            responce.CommandRoutingCount = criList.Count;
            responce.ErrorInfo = "Success";
            return responce;
        }
コード例 #2
0
        public ActionResult GetNextBatchDocumentCommand(Guid costCentreApplicationId, long lastDeliveredCommandRouteItemId, int batchSize, string  batchIdsJson)
        {
            _log.InfoFormat("GetNextBatchDocumentCommand of Batch Size {2} from CCAPPId : {0} with lastDeliveredCommandRouteItemId : {1}", costCentreApplicationId, lastDeliveredCommandRouteItemId, batchSize);
            Guid ccid = _costCentreApplicationService.GetCostCentreFromCostCentreApplicationId(costCentreApplicationId);
            BatchDocumentCommandRoutingResponse response = null;
            List<long> LastBatchIds = JsonConvert.DeserializeObject<List<long>> (batchIdsJson);
            try
            {
                if (_costCentreApplicationService.IsCostCentreActive(costCentreApplicationId))
                {
                    response = _commandRouterResponseBuilder.GetNextBatcDocumentCommand(costCentreApplicationId,ccid,
                                                                                LastBatchIds, batchSize);
                }
                else
                {
                    response = new BatchDocumentCommandRoutingResponse { ErrorInfo = "Inactive CostCentre Application Id" };
                }
              
            }
            catch (Exception ex)
            {
                response = new BatchDocumentCommandRoutingResponse { ErrorInfo = "Failed to get next document command" };
                _log.InfoFormat("ERROR GetNextBatchDocumentCommand of Batch Size {2}  from CCAPPId : {0} with lastDeliveredCommandRouteItemId : {1}", costCentreApplicationId, lastDeliveredCommandRouteItemId,batchSize);
                _log.Error(ex);
            }
            ContentResult result = new ContentResult
                                       {
                                           Content = JsonConvert.SerializeObject(response),
                                           ContentType = "application/json",
                                           ContentEncoding = Encoding.UTF8
                                       };
            AuditCCHit(ccid, "GetNextBatchDocumentCommand", result.Content, "OK");

            return result;
        }
コード例 #3
0
        public HttpResponseMessage GetNextDocumentCommand(Guid costCentreApplicationId,
                                                          long lastDeliveredCommandRouteItemId, int batchSize, string batchIdsJson)
        {
            _log.InfoFormat("GetNextBatchDocumentCommand of Batch Size {2} from CCAPPId : {0} with lastDeliveredCommandRouteItemId : {1}", costCentreApplicationId, lastDeliveredCommandRouteItemId, batchSize);
            Guid ccid = _costCentreApplicationService.GetCostCentreFromCostCentreApplicationId(costCentreApplicationId);
            BatchDocumentCommandRoutingResponse response = null;
            List<long> LastBatchIds = JsonConvert.DeserializeObject<List<long>>(batchIdsJson);
            try
            {
                if (_costCentreApplicationService.IsCostCentreActive(costCentreApplicationId))
                {
                    response = _commandRouterResponseBuilder.GetNextBatcDocumentCommand(costCentreApplicationId, ccid,
                                                                                LastBatchIds, batchSize);
                }
                else
                {
                    response = new BatchDocumentCommandRoutingResponse { ErrorInfo = "Inactive CostCentre Application Id" };
                }

            }
            catch (Exception ex)
            {
                response = new BatchDocumentCommandRoutingResponse { ErrorInfo = "Failed to get next document command" };
                _log.InfoFormat("ERROR GetNextBatchDocumentCommand of Batch Size {2}  from CCAPPId : {0} with lastDeliveredCommandRouteItemId : {1}", costCentreApplicationId, lastDeliveredCommandRouteItemId, batchSize);
                _log.Error(ex);
            }
            
            AuditCCHit(ccid, "GetNextBatchDocumentCommand", JsonConvert.SerializeObject(response), "OK");

            
            return Request.CreateResponse(HttpStatusCode.OK, response);
        }
コード例 #4
0
ファイル: DeserializeJson.cs プロジェクト: asanyaga/BuildTest
        public BatchDocumentCommandRoutingResponse DeserializeBatchDocumentCommandRoutingResponse(string jsonString)
        {
            BatchDocumentCommandRoutingResponse responce = new BatchDocumentCommandRoutingResponse();
            JObject jo = JObject.Parse(jsonString);
            string RoutingResponse = (jo["RoutingCommands"]).ToString();
           
            if (RoutingResponse!="null")
            {
                foreach (JObject j in jo["RoutingCommands"])
                {
                    responce.RoutingCommands.Add(DeserializeDocumentCommandRoutingResponse(j.ToString()));
                }
            }
            string commandCount =(jo["CommandRoutingCount"]).ToString();
            string LastcommandRouteItemId = (jo["LastCommandRouteItemId"]).ToString();
            responce.LastCommandRouteItemId = long.Parse(LastcommandRouteItemId);
            responce.CommandRoutingCount = int.Parse(commandCount);
            responce.ErrorInfo = (jo["ErrorInfo"]).ToString();
            return responce;

        }