Beispiel #1
0
        public async Task <IActionResult> Delete(int Id)
        {
            LoadsServices ls = new LoadsServices(_Context);
            bool          x  = await ls.DeleteLoad(Id);

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        /*  [HttpGet]
         * public IActionResult PeakPerDay()
         * {
         *    FactoryService fs = new FactoryService(_Context);
         *    ViewBag.factories = fs.GetAllFactoriesSimple();
         *    PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);
         *    ViewBag.Primary = ps.GetAllPrimarySources();
         *    LoadsServices ls = new LoadsServices(_Context);
         *    ViewBag.Loads = ls.GetAllLoads();
         *    return View();
         * }
         * [HttpPost]*/
        public IActionResult PeakPerDay(DateTime date, int type = -1, int primId = -1, int loadId = -1)
        {
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);

            ViewBag.Primary = ps.GetAllPrimarySources();
            LoadsServices ls = new LoadsServices(_Context);

            ViewBag.Loads = ls.GetAllLoads();
            ReportService      rs  = new ReportService(_Context);
            PowerPeakViewModel res = new PowerPeakViewModel();

            if (type == 1)
            {
                res = rs.PowerPeakPerDay(date, type, primId);
            }
            else
            {
                res = rs.PowerPeakPerDay(date, type, loadId);
            }



            return(View(res));
        }
Beispiel #3
0
        public ActionResult Edit(LoadDataModel obj)
        {
            LoadsServices ld   = new LoadsServices(_Context);
            var           load = ld.EditLoadAsyn(obj);

            return(RedirectToAction("Index"));
        }
Beispiel #4
0
        public IActionResult Edit(int Id)
        {
            LoadsServices ld   = new LoadsServices(_Context);
            var           load = ld.GetLoadById(Id);

            ViewBag.Functions = ld.GetAllFunctions();
            return(View(load));
        }
Beispiel #5
0
        public IActionResult HarmonicStat()
        {
            FactoryService fs = new FactoryService(_Context);
            LoadsServices  ls = new LoadsServices(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            ViewBag.loads     = ls.GetAllLoads();
            ViewBag.functions = ls.GetAllFunctions();
            return(View());
        }
Beispiel #6
0
        public IActionResult Instantaneous()
        {
            FactoryService fs = new FactoryService(_Context);
            LoadsServices  ls = new LoadsServices(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            ViewBag.loads     = ls.GetAllLoads();

            return(View());
        }
Beispiel #7
0
        public IActionResult homeCreate(int Id)
        {
            FactoryService fs = new FactoryService(_Context);
            LoadsServices  ls = new LoadsServices(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            ViewBag.Functions = ls.GetAllFunctions();

            return(View());
        }
Beispiel #8
0
        public IActionResult HarmonicOrder(DateTime date, int HarmOrder = -1, int loadId = -1)
        {
            RushHourViewModel res = new RushHourViewModel();
            ReportService     rs  = new ReportService(_Context);
            LoadsServices     ls  = new LoadsServices(_Context);

            ViewBag.loads = ls.GetAllLoads();
            if (HarmOrder != -1)
            {
                res = rs.HaemonicOrderForLoadId(loadId, date, HarmOrder);
                ViewBag.LoadName = (ls.GetLoadById(loadId)).name;
            }
            return(View(res));
        }
Beispiel #9
0
        public IActionResult Index(int facid = -1, int PrimOrSec = -1, int sourceid = -1)
        {
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            LoadsServices        ls = new LoadsServices(_Context);
            List <LoadDataModel> ld = ls.GetAllLoads();

            if (facid != -1)
            {
                if (sourceid != -1)
                {
                    ld = ls.MappingToLsDM(_Context.Load.Where(s => s.SourceId == sourceid).ToList());
                }
                else
                {
                    List <LoadDataModel> tmp = new List <LoadDataModel>();
                    foreach (var item in ld)
                    {
                        int fid = 0;

                        if (item.SourceId % 2 != 0)
                        {
                            fid = _Context.PrimarySource.SingleOrDefault(p => p.Code == Convert.ToString(item.SourceId)).FactoryId;
                            if (PrimOrSec == 1 && facid == fid)
                            {
                                tmp.Add(item);
                            }
                        }
                        if (item.SourceId % 2 == 0)
                        {
                            fid = _Context.secondarySource.SingleOrDefault(p => p.Code == Convert.ToString(item.SourceId)).Fac_Id;
                            if (PrimOrSec == 2 && facid == fid)
                            {
                                tmp.Add(item);
                            }
                        }

                        if (PrimOrSec == -1 && facid == fid)
                        {
                            tmp.Add(item);
                        }
                    }
                    ld = tmp;
                }
            }
            return(View(ld));
        }
Beispiel #10
0
        public List <EnergyC> EnergyConsumedAjax(int id, int sort, string val, DateTime datefrom, DateTime dateto)
        {
            List <EnergyC> res     = new List <EnergyC>();
            List <EnergyC> results = new List <EnergyC>();

            FactoryService fs = new FactoryService(_Context);

            LoadsServices ls = new LoadsServices(_Context);
            ReportService rs = new ReportService(_Context);

            var i = 0;

            ViewBag.functions = ls.GetAllFunctions();
            if (sort == 1)
            {
                while (datefrom != dateto.AddDays(1))
                {
                    res = rs.GetEnergies(id, sort, val, datefrom);
                    foreach (var item in res)
                    {
                        results.Add(item);
                    }

                    datefrom = datefrom.AddDays(1);
                }
            }
            else
            {
                while (datefrom != dateto.AddDays(1))
                {
                    var loads = _Context.Load.Where(l => l.Function == val).ToList();
                    foreach (var load in loads)
                    {
                        res = rs.GetEnergies(id, sort, Convert.ToString(load.Id), datefrom);

                        foreach (var item in res)
                        {
                            results.Add(item);
                        }
                        sort = 2;
                    }
                    datefrom = datefrom.AddDays(1);
                    i++;
                }
            }
            return(results);
        }
Beispiel #11
0
        public async Task <IActionResult> homeCreate(LoadDataModel obj)
        {
            LoadsServices ls = new LoadsServices(_Context);
            var           y  = ls.GetLoadByName(obj.name, obj.SourceId);

            if (y != null)
            {
                FactoryService fs = new FactoryService(_Context);
                ViewBag.factories = fs.GetAllFactoriesSimple();
                ModelState.AddModelError("Name", "Name is already exist");
                return(View("homecreate", obj));
            }

            bool ch = await ls.CreateLoadAsync(obj);

            return(RedirectToAction("Index"));
        }
Beispiel #12
0
        //ABDO
        public IActionResult powerpeak(int primId, int loadId, int type = -1) //type 1 -> prim , 2 -> load
        {
            ReportService        rs = new ReportService(_Context);
            PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);

            ViewBag.Primary = ps.GetAllPrimarySources();
            LoadsServices ls = new LoadsServices(_Context);

            ViewBag.loads = ls.GetAllLoads();
            PowerPeakViewModel res = new PowerPeakViewModel();

            if (type == 1)
            {
                res = rs.PowerPeakBySourceID(primId, type);
            }
            else if (type == 2)
            {
                res = rs.PowerPeakBySourceID(loadId, type);
            }

            return(View(res));
        }
Beispiel #13
0
        public LoadDataModel GetLoadDetails(int Id)
        {
            LoadsServices ls = new LoadsServices(_Context);

            return(ls.GetLoadById(Id));
        }