public CustomerResult Get(int size = 100, int page = 0) { serviceCaller.size = size; serviceCaller.from = page; CustomerResult result = new CustomerResult(); var lstResult = new List <GetCustomerResult>(); var response = serviceCaller.SearchForGivenInput(); var objResult = JsonConvert.DeserializeObject <PurchaseOrderResult>(response.Result); if (objResult != null && objResult.hits != null & objResult.hits.hits != null) { var group = (from p in objResult.hits.hits.ToList() group p by new { p._source.ThreadID, p._source.PONumber } into g select new { ThreadId = g.Key.ThreadID, PONumber = g.Key.PONumber, POResult = g.ToList() }).ToList(); foreach (var item in group) { var lstOfSteps = purchaseOrderStatusRetriever.GetSteps(item.POResult.ToList()); var identity = item.POResult.First()._source.Identity; lstResult.Add(new GetCustomerResult { ProfileID = identity, lstOfSteps = lstOfSteps, PONumber = item.PONumber, ThreadID = item.ThreadId }); } result.Total = objResult.hits.total; result.lst = lstResult; } return(result); }
public PurchaseOrderWithTotal Get(string id) { PurchaseOrderWithTotal result = new PurchaseOrderWithTotal(); PurchaseOrderStatusRetriever pos = new PurchaseOrderStatusRetriever(); var lstresult = new List <PurchaseOrderProgressSteps>(); var allResults = serviceCaller.SearchForGivenInput(id, "PONumber"); var objResult = JsonConvert.DeserializeObject <PurchaseOrderResult>(allResults.Result); if (objResult != null && objResult.hits != null & objResult.hits.hits != null) { int total = objResult.hits.total; allResults = serviceCaller.SearchForGivenInput(id, "PONumber", total); objResult = JsonConvert.DeserializeObject <PurchaseOrderResult>(allResults.Result); if (objResult != null && objResult.hits != null & objResult.hits.hits != null) { var threadGroup = (from p in objResult.hits.hits.ToList() where p._source.PONumber == id group p by p._source.ThreadID into g select new { threadid = g.Key, POResult = g.ToList() }).ToList(); foreach (var item in threadGroup) { var lstOfItems = item.POResult; var localResult = pos.GetServiceStatus(id, item.threadid, lstOfItems); lstresult.Add(localResult); } lstresult.Where(x => x.ThreadID != null).ToList(); result.lst = lstresult; result.total = objResult.hits.total; } } return(result); }
private List <AdditionalDetails> GetAdditionalDetails(string threadId, string poNum, string step) { var result = new List <AdditionalDetails>(); var response = serviceCaller.SearchForGivenInput(poNum, "PONumber"); var objResult = JsonConvert.DeserializeObject <PurchaseOrderResult>(response.Result); foreach (var item in objResult.hits.hits.Where(x => x._source.ThreadID == threadId)) { result.Add(new AdditionalDetails { threadID = item._source.ThreadID, PONumber = item._source.PONumber, description = item._source.description, POStatus = item._source.POStatus, ProfileDescription = item._source.ProfileDescription, Type = item._type, ManufacturePartNum = item._source.ManufacturePartNum, BuyerPartNum = item._source.BuyerPartNum, ItemDescription = item._source.ItemDescription, Currency = item._source.Currency, BuyerExpectedPrice = item._source.BuyerExpectedPrice, UnitOfMeasure = item._source.UnitOfMeasure, }); } return(result); }
public ExcelResult Post(ExportToExcelInput input) { try { string startDate = input.StartDate; string endDate = input.EndDate; string customerNumber = input.CustomerNumber; int size = input.Size == 0 ? 100 : input.Size; int page = input.Page; string threadID = !(string.IsNullOrEmpty(input.ThreadId)) ? input.ThreadId : ""; string poNumber = !(string.IsNullOrEmpty(input.PONumber)) ? input.PONumber : ""; serviceCaller.size = size; serviceCaller.from = page; ExcelResult result = new ExcelResult(); var lstResult = new List <GetExcelResult>(); var pos = serviceCaller.GetPOS(input); var poNumbersSource = JsonConvert.DeserializeObject <PurchaseOrderResult>(pos.Result); var poNumbers = poNumbersSource.hits.hits.Where(x => x._source.ThreadID != null).Select(x => x._source.ThreadID).ToList(); result.Total = poNumbersSource.hits.total; var response = serviceCaller.SearchForGivenInput(startDate, endDate, customerNumber, poNumbers, threadID: threadID); var objResult = JsonConvert.DeserializeObject <PurchaseOrderResult>(response.Result); if (objResult != null && objResult.hits != null & objResult.hits.hits != null) { //int total = objResult.hits.total; //response = serviceCaller.SearchForGivenInput(startDate, endDate, customerNumber, poNumbers, total); //objResult = JsonConvert.DeserializeObject<PurchaseOrderResult>(response.Result); if (objResult != null && objResult.hits != null & objResult.hits.hits != null) { var group = (from p in objResult.hits.hits.ToList() //where string.IsNullOrEmpty(id) || p._source.Identity.Contains(id) group p by new { p._source.ThreadID, p._source.PONumber } into g select new { ThreadId = g.Key.ThreadID, PONumber = g.Key.PONumber, POResult = g.ToList() }).ToList(); foreach (var item in group) { if (!string.IsNullOrEmpty(input.PONumber)) { if (!item.PONumber.Equals(input.PONumber, StringComparison.OrdinalIgnoreCase)) { break; } } var selectedSendPurchaseOrder = item.POResult.Where(x => x._type == CONSTANTS.sendPurchaseOrderstatus).ToList(); var date = item.POResult.Max(x => x._source.Date); if (selectedSendPurchaseOrder != null && selectedSendPurchaseOrder.Count > 0) { foreach (var sendPO in selectedSendPurchaseOrder) { var lstOfSteps = purchaseOrderStatusRetriever.GetStepsForExcel(item.POResult.ToList(), sendPO); lstResult.Add(new GetExcelResult { lstOfSteps = lstOfSteps, PONumber = item.PONumber, ThreadID = item.ThreadId, Date = date }); } } else { var lstOfSteps = purchaseOrderStatusRetriever.GetStepsForExcel(item.POResult.ToList(), null); lstResult.Add(new GetExcelResult { lstOfSteps = lstOfSteps, PONumber = item.PONumber, ThreadID = item.ThreadId, Date = date }); } } //result.Total = objResult.hits.total; result.lst = lstResult; } } return(result); } catch (Exception ex) { return(new ExcelResult { Message = ex.Message + Environment.NewLine + ex.StackTrace }); //System.IO.File.AppendAllText(@"E:\inetpub\wwwroot\b2bdiceapiprod\bin\\ErrorText.txt", ex.Message + DateTime.Now + Environment.NewLine); // throw; } }