public List <WellCompletion> GetCompletionsBySearchDate(GenericSearch search)
        {
            try
            {
                var wellCompletions = new WellCompletionServices().GetAllOrderedCompletionsByMonth(search.Month, search.Year);

                if (!wellCompletions.Any())
                {
                    return(new List <WellCompletion>());
                }

                wellCompletions.ForEach(m =>
                {
                    m.EquipmentName          = m.Equipment.Name;
                    m.WellName               = m.Well.Name;
                    m.WellCompletionTypeName = m.WellCompletionType.Type;
                    m.EquipmentName          = m.Equipment.Name;
                });
                return(wellCompletions);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(new List <WellCompletion>());
            }
        }
        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>());
            }
        }
Ejemplo n.º 3
0
        private void AddButtonSearch(Control control, ComponentItemDto componentDto, ConfigurationColumnFillDto config_fill, ref int position_y, ref int position_x)
        {
            Button btn = new Button();

            btn.Parent   = control;
            btn.Name     = $"btn_search_{componentDto.Group}";
            btn.Text     = "...";
            btn.Location = new System.Drawing.Point(position_x + 20, position_y);

            var code   = componentDto.ConfigurationColumns.FirstOrDefault(fi => fi.Id == config_fill.ConfigurationColumnSourceId);
            var val    = componentDto.ConfigurationColumns.FirstOrDefault(fi => fi.Id == config_fill.ConfigurationColumnDestinationId);
            var search = new SearchDto()
            {
                LabelDescriptionName  = val.Title,
                LabelIdName           = code.Title,
                SearchItems           = code.EnableValues,
                ColumnSourceName      = $"{code.Name}_{code.Id}",
                ColumnDestinationName = $"{val.Name}_{val.Id}",
            };

            btn.Click += (object sender, EventArgs e) =>
            {
                var form = new GenericSearch(search, this);
                form.Show();
            };
            position_y += 40;
            position_x += btn.Width;
        }
Ejemplo n.º 4
0
        public GenericSearchedDataDto MapGenericSearchedDataToDto(GenericSearch genericSearchObj, string tableName)
        {
            GenericSearchedDataDto genericSearchedDataDto = new GenericSearchedDataDto();

            genericSearchedDataDto.TableName             = tableName;
            genericSearchedDataDto.RetrievedDataKey      = genericSearchObj.RetrievedDataKey;
            genericSearchedDataDto.RetrievedDataName     = genericSearchObj.RetrievedDataName;
            genericSearchedDataDto.RetrievedDataClientId = genericSearchObj.RetrievedDataClientId;

            return(genericSearchedDataDto);
        }
Ejemplo n.º 5
0
        public void Search_NullSearchProperty_Throws()
        {
            var request = CreateRequest();

            request.Text = null;

            var search = new GenericSearch(CreateProvider(), null);

            search.Invoking(x => x.Search(Query, request))
            .Should()
            .ThrowExactly <NullReferenceException>();
        }
Ejemplo n.º 6
0
        public void Paginate_NoRows_Throws()
        {
            var request = CreateRequest();

            request.Page = 1;
            var provider = CreateProvider(x => x.RowsDefinition = new RowsExpression <Request, Result>("Something"));

            var search = new GenericSearch(provider, null);

            search.Invoking(x => x.Paginate(Query, request))
            .Should()
            .ThrowExactly <NullReferenceException>();
        }
Ejemplo n.º 7
0
        public void Paginate_ZeroRows_Throws()
        {
            var request = CreateRequest();

            request.Page = 1;

            var provider = CreateProvider();

            var search = new GenericSearch(provider, null);

            search.Invoking(x => x.Paginate(Query, request))
            .Should()
            .ThrowExactly <ArgumentOutOfRangeException>();
        }
Ejemplo n.º 8
0
        public void Missing_Configuration_Throws()
        {
            var configurationProvider = new Mock <IListConfigurationProvider>();

            configurationProvider.Setup(x => x.GetConfiguration(It.IsAny <Type>())).Returns((ListConfiguration)null);

            var request = CreateRequest();

            var search = new GenericSearch(configurationProvider.Object, null);

            search.Invoking(x => x.Search(Query, request))
            .Should()
            .ThrowExactly <MissingConfigurationException>();
        }
Ejemplo n.º 9
0
        public void Search_Succeeds()
        {
            var search = new GenericSearch(CreateProvider(), null);

            var request = CreateRequest();

            request.Text.Is   = TextSearch.Comparer.Contains;
            request.Text.Term = "ir";

            var result = Query.Search(search, request).ToArray();

            result.Length.Should().Be(2);
            result[0].Id.Should().Be(1);
            result[1].Id.Should().Be(3);
        }
        public ActionResult GetProductionsByMonth(GenericSearch search)
        {
            try
            {
                if (search.Year < 1)
                {
                    ViewBag.ErrorCode    = -1;
                    ViewBag.ErrorMessage = "Please provide a valid Report Year";
                    return(View("Productions", new ProductionViewModel
                    {
                        Products = GetProducts(),
                        Fields = GetFields(),
                        YearList = GetYears(),
                        MonthList = GetMonths(),
                        Productions = new List <Production>()
                    }));
                }

                var productions = GetProducttionsBySearchDate(search);
                ViewBag.Title        = "Manage Productions";
                ViewBag.ErrorCode    = 5;
                ViewBag.ErrorMessage = "";

                return(View("Productions", new ProductionViewModel
                {
                    Products = GetProducts(),
                    Fields = GetFields(),
                    YearList = GetYears(),
                    MonthList = GetMonths(),
                    Productions = productions
                }));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                ViewBag.ErrorCode    = -1;
                ViewBag.ErrorMessage = "An error was encountered, the seach operation could not be completed.";
                return(View("Productions", new ProductionViewModel
                {
                    Products = GetProducts(),
                    Fields = GetFields(),
                    YearList = GetYears(),
                    MonthList = GetMonths(),
                    Productions = new List <Production>()
                }));
            }
        }
Ejemplo n.º 11
0
        public void Paginate_Succeeds()
        {
            var search = new GenericSearch(CreateProvider(), null);

            var request = CreateRequest();

            request.Page = 2;
            request.Rows = 3;

            var result = Query.Paginate(search, request).ToArray();

            result.Length.Should().Be(3);

            result[0].Id.Should().Be(4);
            result[1].Id.Should().Be(5);
            result[2].Id.Should().Be(6);
        }
Ejemplo n.º 12
0
        public void Search_ModelCache_Succeeds()
        {
            var request = CreateRequest();

            request.Text.Is   = TextSearch.Comparer.Contains;
            request.Text.Term = "ir";

            var modelCache = new Mock <IRequestModelProvider>();

            modelCache.Setup(x => x.GetCurrentRequestModel()).Returns(request);

            var search = new GenericSearch(CreateProvider(), modelCache.Object);

            var result = Query.Search(search).ToArray();

            result.Length.Should().Be(2);
            result[0].Id.Should().Be(1);
            result[1].Id.Should().Be(3);
        }
Ejemplo n.º 13
0
        public void Sort_Succeeds()
        {
            var search = new GenericSearch(CreateProvider(), null);

            var request = CreateRequest();

            request.Ordx = nameof(Item.Text);
            request.Ordd = Direction.Descending;

            var result = Query.Sort(search, request).ToArray();

            result[0].Id.Should().Be(3);
            result[1].Id.Should().Be(6);
            result[2].Id.Should().Be(7);
            result[3].Id.Should().Be(2);
            result[4].Id.Should().Be(4);
            result[5].Id.Should().Be(1);
            result[6].Id.Should().Be(5);
        }
Ejemplo n.º 14
0
        public void Paginate_ModelCache_Succeeds()
        {
            var request = CreateRequest();

            request.Page = 2;
            request.Rows = 3;

            var modelCache = new Mock <IRequestModelProvider>();

            modelCache.Setup(x => x.GetCurrentRequestModel()).Returns(request);

            var search = new GenericSearch(CreateProvider(), modelCache.Object);

            var result = Query.Paginate(search).ToArray();

            result.Length.Should().Be(3);

            result[0].Id.Should().Be(4);
            result[1].Id.Should().Be(5);
            result[2].Id.Should().Be(6);
        }
        private List <WellCompletion> GetWellComletionReportByQueryPeriods(GenericSearch search)
        {
            try
            {
                var wellCompletions = new WellCompletionServices().GetAllOrderedWellCompletionReportByPeriod(search.Month, search.Year);

                if (!wellCompletions.Any())
                {
                    return(new List <WellCompletion>());
                }

                return(wellCompletions);
            }
            catch (Exception ex)
            {
                //dataCount = 0;
                //ViewBag.TotalPages = 0;
                //ViewBag.Page = 1;
                return(new List <WellCompletion>());
            }
        }
Ejemplo n.º 16
0
        public void Sort_NullDirection_Succeeds()
        {
            var request = CreateRequest();

            request.Ordx = nameof(Item.Text);

            var modelCache = new Mock <IRequestModelProvider>();

            modelCache.Setup(x => x.GetCurrentRequestModel()).Returns(request);

            var search = new GenericSearch(CreateProvider(), modelCache.Object);

            var result = Query.Sort(search, request).ToArray();

            result[0].Id.Should().Be(1);
            result[1].Id.Should().Be(2);
            result[2].Id.Should().Be(3);
            result[3].Id.Should().Be(4);
            result[4].Id.Should().Be(5);
            result[5].Id.Should().Be(6);
            result[6].Id.Should().Be(7);
        }
Ejemplo n.º 17
0
        public IEnumerable <ISearchEngine> GetEngineList()
        {
            var enginesConfig = this.config["engines"];

            if (string.IsNullOrWhiteSpace(enginesConfig))
            {
                return(new List <ISearchEngine>());
            }

            var engines = enginesConfig.Split(',');

            if (engines == null || engines.Length <= 0)
            {
                return(new List <ISearchEngine>());
            }

            return(engines.Select(engine =>
            {
                var strs = engine.Split(':');
                engine = strs[0];
                var searchEngine = this.searcherConfig?.GetSearchEngine(engine);
                if (searchEngine == null)
                {
                    searchEngine = new GenericSearch(this.config, engine);
                }

                if (strs.Length > 1 && float.TryParse(strs[1], out float weight))
                {
                    searchEngine.Weight = weight;
                }
                else
                {
                    searchEngine.Weight = 1.0f;
                }
                return searchEngine;
            }));
        }
        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>()
                }));
            }
        }
Ejemplo n.º 19
0
        public GenericSearchedDataDto MapObjectToDto(Object iGenericSearchObj, string tableName)
        {
            GenericSearch genericSearchObj = (GenericSearch)iGenericSearchObj;

            return(MapGenericSearchedDataToDto(genericSearchObj, tableName));
        }
        private List <WellWorkoverReportObject> GetWorkoverObjects(int pageNumber, int itemsPerPage, GenericSearch search)
        {
            try
            {
                var wellWorkoverObjects = new WellWorkoverServices().GetMoreWellWorkoverReport(itemsPerPage, pageNumber, search.Month, search.Year);

                if (!wellWorkoverObjects.Any())
                {
                    return(new List <WellWorkoverReportObject>());
                }

                return(wellWorkoverObjects);
            }
            catch (Exception ex)
            {
                return(new List <WellWorkoverReportObject>());
            }
        }
        public ActionResult GetWorkoversByQueryDate(GenericSearch search)
        {
            try
            {
                if (search.Year < 1)
                {
                    ViewBag.ErrorCode    = -1;
                    ViewBag.ErrorMessage = "Please provide a valid Report Year";
                    return(View("Report", new WellWorkoverViewModel
                    {
                        WellWorkOverReasons = new List <WellWorkOverReason>(),
                        Equipments = new List <Equipment>(),
                        Wells = new List <Well>(),
                        WellWorkOvers = new List <WellWorkover>(),
                        WellWorkoverReportObjects = new List <WellWorkoverReportObject>(),
                        YearList = GetYears(),
                        MonthList = GetMonths()
                    }));
                }

                if (search.Month > 0)
                {
                    ViewBag.SearchPeriod = Enum.GetName(typeof(MonthList), search.Month) + "/" + search.Year;
                }

                else
                {
                    ViewBag.SearchPeriod = search.Year;
                }

                var txd = GetWorkoverObjects(PageNumber, ItemsPerPage, search);
                if (!txd.Any())
                {
                    return(View("Report", new WellWorkoverViewModel
                    {
                        WellWorkOverReasons = new List <WellWorkOverReason>(),
                        Equipments = new List <Equipment>(),
                        Wells = new List <Well>(),
                        WellWorkOvers = new List <WellWorkover>(),
                        WellWorkoverReportObjects = new List <WellWorkoverReportObject>(),
                        YearList = GetYears(),
                        MonthList = GetMonths()
                    }));
                }

                var txx = new WellWorkoverViewModel
                {
                    WellWorkOverReasons = new List <WellWorkOverReason>(),
                    Equipments          = new List <Equipment>(),
                    Wells                     = new List <Well>(),
                    WellWorkOvers             = new List <WellWorkover>(),
                    WellWorkoverReportObjects = txd,
                    YearList                  = GetYears(),
                    MonthList                 = GetMonths()
                };
                Session["_workRepoPage"]          = 1;
                Session["_workoverRepoGenSearch"] = 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 WellWorkoverViewModel
                {
                    WellWorkOverReasons = new List <WellWorkOverReason>(),
                    Equipments = new List <Equipment>(),
                    Wells = new List <Well>(),
                    WellWorkOvers = new List <WellWorkover>(),
                    YearList = GetYears(),
                    MonthList = GetMonths()
                }));
            }
        }
        public ActionResult GetWellWorkoversByMonth(GenericSearch search)
        {
            try
            {
                if (search.Month < 1)
                {
                    ViewBag.ErrorCode    = -1;
                    ViewBag.ErrorMessage = "Please provide a valid Report Month";
                    return(View("WellWorkovers", new WellWorkoverViewModel
                    {
                        WellWorkOverReasons = new List <WellWorkOverReason>(),
                        Equipments = new List <Equipment>(),
                        Wells = new List <Well>(),
                        WellWorkOvers = new List <WellWorkover>(),
                        YearList = GetYears(),
                        MonthList = GetMonths()
                    }));
                }
                if (search.Year < 1)
                {
                    ViewBag.ErrorCode    = -1;
                    ViewBag.ErrorMessage = "Please provide a valid Search Year";
                    return(View("WellWorkovers", new WellWorkoverViewModel
                    {
                        WellWorkOverReasons = new List <WellWorkOverReason>(),
                        Equipments = new List <Equipment>(),
                        Wells = new List <Well>(),
                        WellWorkOvers = new List <WellWorkover>(),
                        YearList = GetYears(),
                        MonthList = GetMonths()
                    }));
                }
                var wellWorkOvers = GetWorkoversBySearchDate(search.Month, search.Year);
                ViewBag.SearchPeriod = Enum.GetName(typeof(MonthList), search.Month) + "/" + search.Year;
                ViewBag.Title        = "Manage Well Workovers";
                if (!wellWorkOvers.Any())
                {
                    ViewBag.ErrorCode    = -1;
                    ViewBag.ErrorMessage = "No record found";

                    return(View("WellWorkovers", new WellWorkoverViewModel
                    {
                        WellWorkOverReasons = GetWellWorkoverReasons(),
                        Equipments = GetEquipmets(),
                        WellObjects = GetWells(),
                        WellWorkOvers = new List <WellWorkover>(),
                        YearList = GetYears(),
                        MonthList = GetMonths()
                    }));
                }


                ViewBag.ErrorCode    = 5;
                ViewBag.ErrorMessage = "";

                return(View("~/Views/WellWorkOver/WellWorkovers.cshtml", new WellWorkoverViewModel
                {
                    WellWorkOverReasons = GetWellWorkoverReasons(),
                    Equipments = GetEquipmets(),
                    WellObjects = GetWells(),
                    WellWorkOvers = wellWorkOvers,
                    YearList = GetYears(),
                    MonthList = GetMonths()
                }));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                ViewBag.ErrorCode    = -1;
                ViewBag.ErrorMessage = "An error was encountered, the seach operation could not be completed.";
                return(View("~/Views/WellWorkOver/WellWorkovers.cshtml", new WellWorkoverViewModel
                {
                    WellWorkOverReasons = GetWellWorkoverReasons(),
                    Equipments = GetEquipmets(),
                    WellObjects = GetWells(),
                    WellWorkOvers = new List <WellWorkover>(),
                    YearList = GetYears(),
                    MonthList = GetMonths()
                }));
            }
        }
        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>());
            }
        }
        public ActionResult GetWellCompletionsByQueryDateDate(GenericSearch search)
        {
            try
            {
                if (search.Year < 1)
                {
                    ViewBag.ErrorCode    = -1;
                    ViewBag.ErrorMessage = "Please provide a valid Report Year";
                    return(View("Report", new WellCompletionViewModel
                    {
                        WellCompletionTypes = new List <WellCompletionType>(),
                        Wells = new List <Well>(),
                        Equipments = new List <Equipment>(),
                        WellCompletions = new List <WellCompletion>(),
                        WellCompletionReportObjects = new List <WellCompletionReportObject>(),
                        MonthList = GetMonths(),
                        YearList = GetYears()
                    }));
                }

                var txd = GetWellCompletionStaticReports(ItemsPerPage, PageNumber, search);
                if (!txd.Any())
                {
                    ViewBag.ErrorMessage = "No record found";
                    ViewBag.ErrorCode    = -1;

                    if (search.Month < 1)
                    {
                        ViewBag.SearchPeriod = search.Year;
                    }
                    if (search.Month > 0)
                    {
                        ViewBag.SearchPeriod = Enum.GetName(typeof(MonthList), search.Month) + "/" + search.Year;
                    }

                    return(View("Report", new WellCompletionViewModel
                    {
                        WellCompletionTypes = new List <WellCompletionType>(),
                        Wells = new List <Well>(),
                        Equipments = new List <Equipment>(),
                        WellCompletions = new List <WellCompletion>(),
                        WellCompletionReportObjects = new List <WellCompletionReportObject>(),
                        MonthList = GetMonths(),
                        YearList = GetYears()
                    }));
                }
                ViewBag.SearchPeriod = Enum.GetName(typeof(MonthList), search.Month) + "/" + search.Year;
                var txx = new WellCompletionViewModel
                {
                    WellCompletionTypes = new List <WellCompletionType>(),
                    Wells                       = new List <Well>(),
                    Equipments                  = new List <Equipment>(),
                    WellCompletions             = new List <WellCompletion>(),
                    WellCompletionReportObjects = txd,
                    MonthList                   = GetMonths(),
                    YearList                    = GetYears()
                };
                Session["_wellCompRepoGenSearch"] = search;
                Session["_wellCompRepoPage"]      = 1;
                return(View("Report", txx));
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "No record found";
                ViewBag.ErrorCode    = -1;
                ViewBag.SearchPeriod = Enum.GetName(typeof(MonthList), search.Month) + "/" + search.Year;
                return(View("Report", new WellCompletionViewModel
                {
                    WellCompletionTypes = new List <WellCompletionType>(),
                    Wells = new List <Well>(),
                    Equipments = new List <Equipment>(),
                    WellCompletions = new List <WellCompletion>(),
                    WellCompletionReportObjects = new List <WellCompletionReportObject>(),
                    MonthList = GetMonths(),
                    YearList = GetYears()
                }));
            }
        }
        private List <WellCompletionReportObject> GetWellCompletionStaticReports(int itemsPerPage, int pageNumber, GenericSearch search)
        {
            try
            {
                var wellCompletions = new WellCompletionServices().GetWellStaticCompletionReport(itemsPerPage, pageNumber, search.Month, search.Year);

                if (!wellCompletions.Any())
                {
                    return(new List <WellCompletionReportObject>());
                }


                return(wellCompletions);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                return(new List <WellCompletionReportObject>());
            }
        }