public ActionResult Edit(BatchDetailDTO model) { //if (model.CycleId == 1 || model.CycleId == 2) // timeley //{ // model.BegginingTime = "09:00"; // model.EndTime = "09:00"; //} //else if (model.CycleId == 3)//intrs day 1 //{ // model.BegginingTime = "14:00"; // model.EndTime = "09:00"; //} //else if (model.CycleId == 4)//intrs day 2 //{ // model.BegginingTime = "18:00"; // model.EndTime = "09:00"; //} //else if (model.CycleId == 5)//intrs day 3 //{ // model.BegginingTime = "22:00"; // model.EndTime = "09:00"; //} //var StartTime = TimeSpan.Parse(model.BegginingTime); //var EndTime = TimeSpan.Parse(model.EndTime); // model.StartDateTime = model.StartDateTime.Add(StartTime); // model.EndDateTime = model.EndDateTime.Add(EndTime); model.ShowZeroCheck = true; model.RankingCheck = true; model.PakageCheck = true; model.UpDnContractCheck = false; model.ShowZeroUp = true; model.ShowZeroDn = true; model.UpDnPkgCheck = false; model.ScheduleDate = DateTime.MaxValue; model.SubmittedDate = DateTime.MaxValue; //TODO: var identity = (ClaimsPrincipal)Thread.CurrentPrincipal; string shipperDuns = identity.Claims.Where(c => c.Type == "ShipperDuns") .Select(c => c.Value).SingleOrDefault(); var UserKey = Guid.Parse(identity.Claims.Where(c => c.Type == "UserId") .Select(c => c.Value).SingleOrDefault()); model.StatusId = Convert.ToInt32(NomStatus.Draft); model.CreatedBy = UserKey.ToString(); model.CreatedDateTime = DateTime.Now; model.ShiperDuns = shipperDuns; Guid?transactionId = pntNominationService.UpdatePNTBatch(model); //SaveAndUpdatePNTBatchDetail(model, true);//.SaveAndUpdateBatchWithDetail(model, true); return(RedirectToAction("Index", new { pipelineDuns = model.Duns })); }
public ActionResult Edit(string pipelineDuns, Guid batchId) { BatchDetailDTO model = new BatchDetailDTO(); model = pntNominationService.GetNomDetail(batchId, pipelineDuns); model.Duns = pipelineDuns; var CycleIndicator = ICycleIndicator.GetCycles(); ViewBag.Cycles = new SelectList(CycleIndicator.AsEnumerable(), "Id", "Name", model.CycleId); model.EndDateTime = model.EndDateTime; // in DB,Stored One day more than actual date of End date. //NomType modelType = pipelineService.GetPathTypeByPipelineDuns(pipelineService.GetDunsByPipelineID(pipelineId)); // model.PipelineModelType = modelType; var pipes = GetPipelines(); var pipe = pipes.Count > 0 ? pipes.Where(a => a.DUNSNo == pipelineDuns).FirstOrDefault() : new PipelineDTO(); model.PipelineModelType = GetPathTypeByPipelineType(pipe.ModelTypeID); return(this.PartialView(model)); }
public ActionResult Save(string pipelineDuns) { BatchDetailDTO model = new BatchDetailDTO(); model.Duns = pipelineDuns; model.Description = string.Empty; model.StartDateTime = DateTime.Now.Date; model.EndDateTime = DateTime.Now.Date; model.CycleId = 1; var CycleIndicator = ICycleIndicator.GetCycles(); ViewBag.Cycles = new SelectList(CycleIndicator.AsEnumerable(), "Id", "Name", 1); var pipes = GetPipelines(); var pipe = pipes.Count > 0 ? pipes.Where(a => a.DUNSNo == pipelineDuns).FirstOrDefault() : new PipelineDTO(); // NomType modelType = pipelineService.GetPathTypeByPipelineDuns(pipelineService.GetDunsByPipelineID(pipelineId)); model.PipelineModelType = GetPathTypeByPipelineType(pipe.ModelTypeID); return(this.View(model)); }
public void SavePNTBulkUpload(BatchDetailDTO batch, bool IsSave) { PNTNominationService.SaveBulkUpload(batch, true); }
protected BatchDetailDTO UpdateCounterPartyNameAndLocNameInBatchDetail(BatchDetailDTO batchDetail) { try { bool cpExist = false; bool locExist = false; List <PathedNomDetailsDTO> newList = new List <PathedNomDetailsDTO>(); var pathCP = Path.Combine(HostingEnvironment.MapPath("~/App_Data"), "CounterParty.xml"); FileInfo fileInfoCP = new FileInfo(pathCP); var pathLoc = Path.Combine(HostingEnvironment.MapPath("~/App_Data"), "Location.xml"); FileInfo fileInfoLoc = new FileInfo(pathLoc); if (System.IO.File.Exists(pathCP) && !IsFileLocked(fileInfoCP)) { cpExist = true; } if (System.IO.File.Exists(pathLoc) && !IsFileLocked(fileInfoLoc)) { locExist = true; } if (cpExist || locExist) { XmlNodeList nodeListLoc = null; XmlNodeList nodeListCP = null; XmlDocument xmlCP = new XmlDocument(); XmlDocument xmlLoc = new XmlDocument(); if (cpExist) { xmlCP.Load(pathCP); nodeListCP = xmlCP.GetElementsByTagName("CounterPartiesDTO"); } if (locExist) { xmlLoc.Load(pathLoc); nodeListLoc = xmlLoc.GetElementsByTagName("LocationsDTO"); } List <BatchDetailContractDTO> listCon = new List <BatchDetailContractDTO>(); foreach (var item in batchDetail.Contract) { if (locExist) { string recLoc = nodeListLoc.Cast <XmlNode>().Where(node => node.SelectSingleNode("Identifier").InnerText == item.RecLocation) .Select(n => n.SelectSingleNode("Name").InnerText).FirstOrDefault(); string delLoc = nodeListLoc.Cast <XmlNode>().Where(node => node.SelectSingleNode("Identifier").InnerText == item.DelLocation) .Select(n => n.SelectSingleNode("Name").InnerText).FirstOrDefault(); item.RecLocationName = !string.IsNullOrEmpty(recLoc) ? recLoc : item.RecLocation; item.DelLocationName = !string.IsNullOrEmpty(delLoc) ? delLoc : item.DelLocation; } listCon.Add(item); } List <BatchDetailSupplyDTO> listSup = new List <BatchDetailSupplyDTO>(); foreach (var item in batchDetail.SupplyList) { if (cpExist) { string UpName = nodeListCP.Cast <XmlNode>().Where(node => node.SelectSingleNode("Identifier").InnerText == item.UpstreamID) .Select(n => n.SelectSingleNode("Name").InnerText).FirstOrDefault(); item.UpstreamIDName = !string.IsNullOrEmpty(UpName) ? UpName : item.UpstreamID; } if (locExist) { string recLoc = nodeListLoc.Cast <XmlNode>().Where(node => node.SelectSingleNode("Identifier").InnerText == item.Location) .Select(n => n.SelectSingleNode("Name").InnerText).FirstOrDefault(); item.LocationName = !string.IsNullOrEmpty(recLoc) ? recLoc : item.Location; } listSup.Add(item); } List <BatchDetailMarketDTO> listMar = new List <BatchDetailMarketDTO>(); foreach (var item in batchDetail.MarketList) { if (cpExist) { string DwName = nodeListCP.Cast <XmlNode>().Where(node => node.SelectSingleNode("Identifier").InnerText == item.DownstreamID) .Select(n => n.SelectSingleNode("Name").InnerText).FirstOrDefault(); item.DownstreamIDName = !string.IsNullOrEmpty(DwName) ? DwName : item.DownstreamID; } if (locExist) { string delLoc = nodeListLoc.Cast <XmlNode>().Where(node => node.SelectSingleNode("Identifier").InnerText == item.Location) .Select(n => n.SelectSingleNode("Name").InnerText).FirstOrDefault(); item.LocationName = !string.IsNullOrEmpty(delLoc) ? delLoc : item.Location; } listMar.Add(item); } batchDetail.Contract = listCon; batchDetail.SupplyList = listSup; batchDetail.MarketList = listMar; } return(batchDetail); } catch (Exception ex) { return(batchDetail); } }
public bool ValidateNomination(Guid transactioId, int pipeId) { var SONAT = "006900518"; bool reqFields = true; bool pathComplete = true; BatchDetailDTO batchDetail = servicePNTNomnation.GetNomDetail(transactioId, pipeId);//GetNominationDetailByBatchID(transactioId); if ((batchDetail.StatusId == 11) && (batchDetail.MarketList != null && batchDetail.MarketList.Count > 0) && (batchDetail.SupplyList != null && batchDetail.SupplyList.Count > 0)) { int marketRows, supplyRows, transportRows, transportPathRows; marketRows = batchDetail.MarketList.Count; supplyRows = batchDetail.SupplyList.Count; transportRows = batchDetail.Contract.Count; transportPathRows = batchDetail.ContractPath.Count; #region Mandatory fields validation #region Market do { if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].Location)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].LocationProp)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].DownstreamID)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].DownstreamIDProp)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].ServiceRequestNo)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].TransactionType)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].DnstreamRank)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].ReceiptQuantityGross + "")) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.MarketList[marketRows - 1].DeliveryQuantityNet + "")) { reqFields = false; break; } marketRows--; } while (marketRows > 0); #endregion #region Supply do { if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].Location)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].LocationProp)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].UpstreamID)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].UpstreamIDProp)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].ServiceRequestNo)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].TransactionType)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].UpstreamRank)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].ReceiptQuantityGross + "")) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.SupplyList[supplyRows - 1].DeliveryQuantityNet + "")) { reqFields = false; break; } supplyRows--; } while (supplyRows > 0); #endregion #region contract if ((batchDetail.ContractPath != null && batchDetail.ContractPath.Count > 0) && (batchDetail.Contract != null && batchDetail.Contract.Count > 0)) { #region Transport do { if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].RecLocation)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].RecLocationProp)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].DelLocation)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].DelLocationProp)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].ServiceRequestNo)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].TransactionType)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].RecRank)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].DelRank)) { reqFields = false; break; } //if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].PackageID)) //{ // reqFields = false; // break; //} if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].PathRank)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].ReceiptDth)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].DeliveryDth)) { reqFields = false; break; } if (string.IsNullOrEmpty(batchDetail.Contract[transportRows - 1].Route) && batchDetail.Duns == SONAT) { reqFields = false; break; } transportRows--; } while (transportRows > 0); #endregion #region TransportPath do { if (string.IsNullOrEmpty(batchDetail.ContractPath[transportPathRows - 1].ServiceRequestNo)) { reqFields = false; break; } //if (string.IsNullOrEmpty(batchDetail.ContractPath[transportPathRows - 1].FuelPercentage)) //{ // reqFields = false; // break; //} transportPathRows--; } while (transportPathRows > 0); #endregion } #endregion #endregion #region Nom Matrix Path validation if (reqFields) { if (batchDetail.Contract != null && batchDetail.Contract.Count > 0) { foreach (var item in batchDetail.Contract) { if (!batchDetail.SupplyList.Any(a => a.Location == item.RecLocation)) { pathComplete = false; break; } if (!batchDetail.MarketList.Any(a => a.Location == item.DelLocation)) { pathComplete = false; break; } if (!batchDetail.ContractPath.Any(a => a.ServiceRequestNo == item.ServiceRequestNo)) { pathComplete = false; break; } } } else { foreach (var supply in batchDetail.SupplyList) { if (!batchDetail.MarketList.Any(a => a.LocationProp == supply.LocationProp)) { pathComplete = false; break; } } } } else { return(false); } #endregion } else { return(false); } if (reqFields && pathComplete) { return(true); } else { return(false); } }