public ActionResult GetProductions2(int queryId) { if (queryId < 1) { return(Json(new List <ProductionObject>(), JsonRequestBehavior.AllowGet)); } var query = new ProductionQueryBuilderServices().GetProductionQuery(queryId); if (query == null || query.ProductionQueryId < 1) { return(Json(new List <ProductionObject>(), JsonRequestBehavior.AllowGet)); } var productionList = new ProductionServices().GetOrderedProductionReportObjects(query) ?? new List <ProductionObject>(); if (!productionList.Any()) { return(Json(new List <ProductionObject>(), JsonRequestBehavior.AllowGet)); } var jsonResult = Json(productionList, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); }
public List <Production> GetProducttionsBySearchDate(GenericSearch search) { try { var productions = new ProductionServices().GetAllOrderedProductionsByMonth(search.Month, search.Year); if (!productions.Any()) { return(new List <Production>()); } productions.ForEach(m => { m.FieldName = m.Field.Name; m.ProductName = m.Product.Name; m.MonthName = Enum.GetName(typeof(MonthList), m.Month); m.Quantity = Convert.ToDecimal(m.Quantity).ToString("#,##0"); }); return(productions); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(new List <Production>()); } }
public ActionResult GetProductions(ProductionQuery queryBuilder) { if (queryBuilder == null) { return(Json(new List <ProductionObject>(), JsonRequestBehavior.AllowGet)); } if (queryBuilder.BlockId < 1 && queryBuilder.CompanyId < 1 && ((queryBuilder.StartDate != null && queryBuilder.StartDate.Value.Year == 0001) || (queryBuilder.StartDate == null)) && ((queryBuilder.EndDate != null && queryBuilder.EndDate.Value.Year == 0001) || (queryBuilder.EndDate == null)) && queryBuilder.FieldId < 1 && queryBuilder.ProductId < 1 && queryBuilder.TerrainId < 1 && queryBuilder.ZoneId < 1) { return(Json(new List <ProductionObject>(), JsonRequestBehavior.AllowGet)); } var productionList = new ProductionServices().GetOrderedProductionReportObjects(queryBuilder) ?? new List <ProductionObject>(); if (!productionList.Any()) { return(Json(new List <ProductionObject>(), JsonRequestBehavior.AllowGet)); } Session["_successfulProductionQuery"] = queryBuilder; var jsonResult = Json(productionList, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); }
private List <ProductionObject> GetProductionObjects(int pageNumber, int itemsPerPage, GenericSearch search) { try { var productionObjects = new ProductionServices().GetProductionStaticReportByPeriod(itemsPerPage, pageNumber, search.Month, search.Year); if (!productionObjects.Any()) { return(new List <ProductionObject>()); } return(productionObjects); } catch (Exception ex) { return(new List <ProductionObject>()); } }
private List <ProductionObject> GetWellComletionObjects(int itemsPerPage, int pageNumber) { try { var wellCompletions = new ProductionServices().GetMoreProductionObjects(itemsPerPage, pageNumber); if (!wellCompletions.Any()) { return(new List <ProductionObject>()); } return(wellCompletions); } catch (Exception ex) { return(new List <ProductionObject>()); } }
private List <DocObject> GetYears() { var jxs = new ProductionServices().GetProductionYears(); if (!jxs.Any()) { return(new List <DocObject>()); } var tdv = new List <DocObject>(); jxs.ForEach(m => { if (!tdv.Exists(t => t.DocId == m)) { tdv.Add(new DocObject { DocName = m.ToString(CultureInfo.InvariantCulture), DocId = m }); } }); return(tdv.OrderByDescending(m => m.DocName).ToList()); }
private List <Production> GetProductions(int itemsPerPage, int pageNumber, out int dataCount) { try { var productionList = new ProductionServices().GetAllOrderedProductions(itemsPerPage, pageNumber, out dataCount); ViewBag.PrDataCount = dataCount.ToString(CultureInfo.InvariantCulture); var totalPages = dataCount / itemsPerPage; // Counting the last page if (dataCount % itemsPerPage != 0) { totalPages++; } ViewBag.PrTotalPages = totalPages; ViewBag.PrPage = pageNumber; if (!productionList.Any()) { return(new List <Production>()); } productionList.ForEach(m => { m.FieldName = m.Field.Name; m.ProductName = m.Product.Name; m.Quantity = Convert.ToDecimal(m.Quantity).ToString("#,##0"); m.MonthName = Enum.GetName(typeof(MonthList), m.Month); }); return(productionList); } catch (Exception ex) { dataCount = 0; ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(new List <Production>()); } }
public ActionResult GetProductionsByField(int fieldId) { try { if (fieldId < 1) { return(Json(new List <Field>(), JsonRequestBehavior.AllowGet)); } var productionList = new ProductionServices().GetAllOrderedProductionsByFieldId(fieldId); if (!productionList.Any()) { return(Json(new List <Production>(), JsonRequestBehavior.AllowGet)); } return(Json(productionList, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(Json(new List <Production>(), JsonRequestBehavior.AllowGet)); } }
public ActionResult GetProductionsByQueryDateDate(GenericSearch search) { try { if (search.Year < 1) { ViewBag.ErrorCode = -1; ViewBag.ErrorMessage = "Please provide a valid Report Year"; return(View("Report", new ProductionViewModel { Products = new List <Product>(), Fields = new List <Field>(), YearList = GetYears(), MonthList = GetMonths(), ProductionObjects = new List <ProductionObject>() })); } if (search.Month > 0) { ViewBag.SearchPeriod = Enum.GetName(typeof(MonthList), search.Month) + "/" + search.Year; } else { ViewBag.SearchPeriod = search.Year; } var txd = new ProductionServices().GetProductionStaticReportByPeriod(PageNumber, ItemsPerPage, search.Month, search.Year); if (!txd.Any()) { ViewBag.ErrorMessage = "No record found"; ViewBag.ErrorCode = -1; return(View("Report", new ProductionViewModel { Products = new List <Product>(), Fields = new List <Field>(), YearList = GetYears(), MonthList = GetMonths(), ProductionObjects = new List <ProductionObject>() })); } var txx = new ProductionViewModel { Products = new List <Product>(), Fields = new List <Field>(), YearList = GetYears(), MonthList = GetMonths(), ProductionObjects = txd }; Session["_prodRepoPage"] = 1; Session["_prodRepoGenSearch"] = search; return(View("Report", txx)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); ViewBag.ErrorMessage = "No record found"; ViewBag.ErrorCode = -1; return(View("Report", new ProductionViewModel { Products = new List <Product>(), Fields = new List <Field>(), YearList = GetYears(), MonthList = GetMonths(), Productions = new List <Production>() })); } }