private void uxSave_Click(object sender, EventArgs e)
        {
            production          = IWellFactories.GetFactory(IWellType.Production).CreateIWell();
            production.Id       = Convert.ToInt32(uxProductionID.Text);
            production.SpudDate = uxDate.Value.Date;
            ProductionWell prod = production as ProductionWell;

            prod.DailyProduction = new List <IOilProduction>();

            var ID      = Convert.ToInt32(uxWellPad.SelectedValue);
            var WellPad = FacilityManager.FacilityMng.FindWell(ID);

            WellPad.Wells.Add(production);
            FacilityManager.FacilityMng.SaveData();
            RefreshGridData();
        }
Exemplo n.º 2
0
        private void PopulateListView(TreeNode node)
        {
            uxListView.Items.Clear();
            switch (node.Level)
            {
            case 0:
                List <wellpad_listview> wells_list = node.Tag as List <wellpad_listview>;
                int producwellcount = 0, injectcount = 0;
                foreach (wellpad_listview wellpads in wells_list)
                {
                    foreach (WellPads Well in wellpads.wells)
                    {
                        injectcount = Well.Wells
                                      .Where(o => o.GetType() == typeof(InjectionWell))
                                      .Count();
                        producwellcount = Well.Wells
                                          .Where(o => o.GetType() == typeof(ProductionWell))
                                          .Count();
                    }
                    string[] datas =
                        new string[] { wellpads.Province.ToString(), producwellcount.ToString(), injectcount.ToString() };
                    ListViewItem items = new ListViewItem(datas);
                    uxListView.Items.Add(items);
                }
                break;

            case 1:
                wellpad_listview locations = node.Tag as wellpad_listview;
                foreach (WellPads Well in locations.wells)
                {
                    var productionCount = Well.Wells
                                          .Where(o => o.GetType() == typeof(ProductionWell))
                                          .Count()
                                          .ToString();
                    var injectionCount = Well.Wells
                                         .Where(o => o.GetType() == typeof(InjectionWell))
                                         .Count()
                                         .ToString();
                    string[]     datas = new string[] { Well.Location, productionCount, injectionCount };
                    ListViewItem items = new ListViewItem(datas);
                    uxListView.Items.Add(items);
                }
                break;

            case 2:
                WellPads well            = node.Tag as WellPads;
                var      productionWells = well.Wells
                                           .OrderByDescending(o => o.SpudDate)
                                           .Where(o => o.GetType() == typeof(ProductionWell))
                                           .ToList();
                var InjectionWells = well.Wells
                                     .OrderByDescending(o => o.SpudDate)
                                     .Where(o => o.GetType() == typeof(InjectionWell))
                                     .ToList();
                foreach (ProductionWell productionWell in productionWells)
                {
                    string[] Datas = new string[] { productionWell.SpudDate.ToShortDateString(), productionWell.DailyProduction
                                                    .Select(o => o.BarrelsProduced)
                                                    .Sum()
                                                    .ToString() };
                    ListViewItem Items = new ListViewItem(Datas);
                    uxListView.Items.Add(Items);
                }
                foreach (InjectionWell injectionWell in InjectionWells)
                {
                    string[]     Datas = new string[] { injectionWell.SpudDate.ToShortDateString(), "0 barrels (Injection Well)" };
                    ListViewItem Items = new ListViewItem(Datas);
                    uxListView.Items.Add(Items);
                }
                break;

            case 3:
                IWell          iwells       = node.Tag as IWell;
                ProductionWell productwells = iwells as ProductionWell;
                try
                {    //get a collection of oil production from production wells (with production dates sorted in descending order)
                    var Production = productwells.DailyProduction.OrderByDescending(o => o.ProductionDate).ToList();
                    foreach (OilProduction production in Production)
                    {
                        string[] productions =
                            new string[] { production.ProductionDate.ToShortDateString(), production.BarrelsProduced.ToString() };
                        ListViewItem producItems = new ListViewItem(productions);
                        uxListView.Items.Add(producItems);
                    }
                }
                catch
                {
                    string[]     InjectionData = new string[] { "N/A", "0 barrels" };
                    ListViewItem items         = new ListViewItem(InjectionData);
                    uxListView.Items.Add(items);
                    return;
                }
                break;
            }
        }