Example #1
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));
        }
Example #2
0
        public IActionResult Details()
        {
            FactoryService fs = new FactoryService(_con);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            return(View());
        }
Example #3
0
        public IActionResult Create()
        {
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            return(View());
        }
        public IActionResult homeCreate(int Id)
        {
            FactoryService         fs = new FactoryService(_Context);
            SecoundrySourceService ss = new SecoundrySourceService(_Context);

            ViewBag.factories   = fs.GetAllFactoriesSimple();
            ViewBag.secondaries = ss.GetAllSecoundrySources();
            return(View());
        }
Example #5
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());
        }
Example #6
0
        public IActionResult LoadDashBoard()
        {
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            DashboardViewModel res = new DashboardViewModel();

            res.datetime = DateTime.Now;
            return(View(res));
        }
Example #7
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());
        }
Example #8
0
        public IActionResult Instantaneous()
        {
            FactoryService fs = new FactoryService(_Context);
            LoadsServices  ls = new LoadsServices(_Context);

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

            return(View());
        }
Example #9
0
        public IActionResult Index(int Id = -1)
        {
            ProductionService ps = new ProductionService(_Context);
            FactoryService    fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            List <ProductionViewModel> res = new List <ProductionViewModel>();

            if (Id != -1)
            {
                res = ps.GetallProduction(Id);
            }
            return(View(res));
        }
Example #10
0
        public IActionResult Production(DateTime fromdate, DateTime todate, int Id = -1) // 1 -> for primaries
        {
            ReportService  ps = new ReportService(_Context);
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            List <ProductionViewModel> res = new List <ProductionViewModel>();

            if (Id != -1)
            {
                res = ps.ProductionReport(fromdate, todate, Id, 1);
            }
            return(View(res));
        }
Example #11
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));
        }
Example #12
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"));
        }
        public async Task <IActionResult> Create(PrimarySourceDataModel obj)
        {
            PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);
            var y = ps.GetPrimaryByName(obj.Name, obj.FacId);

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


            bool created = await ps.CreatePrimarySourceAsync(obj);

            return(RedirectToAction("Index", "PrimarySource"));
        }
        public IActionResult Index(int Id = -1)
        {
            PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);

            List <PrimarySourceDataModel> Model = null;
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            if (Id != -1)
            {
                Model = ps.GetAllPrimarySourcesbyfacId(Id);
            }
            else
            {
                Model = ps.GetAllPrimarySources();
            }
            return(View(Model));
        }
        public IActionResult Index(int facid = -1, int primary = -1)
        {
            List <SecoundrySouresDataModelSim> allsec;
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories = fs.GetAllFactoriesSimple();
            SecoundrySourceService ss = new SecoundrySourceService(_Context);

            if (facid != -1)
            {
                allsec = ss.GetSpecificSecondary(facid, primary);
            }
            else
            {
                allsec = ss.GetAllSecoundrySources();
            }


            return(View(allsec));
        }
        public async Task <IActionResult> homeCreate(SecoundrySouresDataModelSim obj)
        {
            SecoundrySourceService ss = new SecoundrySourceService(_Context);

            var y = ss.GetSecondaryByName(obj.Name, obj.PS_Id);

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



            bool created = await ss.CreateSecoundrySourceAsync(obj);

            return(RedirectToAction("Index"));
        }
        public IActionResult Create(int Id)
        {
            if (Id != -1)
            {
                PrimarySourceDataModel viewModel = new PrimarySourceDataModel()
                {
                    FacId = Id
                };
                return(View(viewModel));
            }
            else
            {
                FactoryService       fs = new FactoryService(_Context);
                PrimarySourceSerivce ps = new PrimarySourceSerivce(_Context);
                ViewBag.factories = fs.GetAllFactoriesSimple();
                ViewBag.primaries = ps.GetAllPrimarySources();


                return(View("homeCreate"));
            }
        }
Example #18
0
        /*
         *
         *  sort equal sort by values :
         *  1 -> sort by load
         *  2-> sort by type
         *
         *
         *    if sortValue equal 1 val will be value of load
         *
         * if sortValue equal 2 val will be value of type
         *  type:  1-> current
         * type:2->voltage
         *  type:3->powerFactor
         *
         */


        public List <querySource> AveragePerDayfromajax(int id, int sort, string val, DateTime date)
        {
            FactoryService fs = new FactoryService(_Context);

            ViewBag.factories   = fs.GetAllFactoriesSimple();
            ViewBag.factoryname = fs.GetFactoryNameById(id);
            ViewBag.date        = date.ToString("yyyy/MM/dd hh");
            ReportService      r   = new ReportService(_Context);
            List <querySource> res = new List <querySource>();

            int i = 0;


            if (sort == 1)
            {
                var           load = _Context.Load.FirstOrDefault(l => l.Id == Convert.ToInt32(val));
                SourceReading src;
                src = _Context.SourceReading.LastOrDefault(s => s.PrimarySourceId == load.SourceId && s.TimeStamp.Day == date.Day && s.Fac_Id == id);
                if (src != null)
                {
                    res.Add(new querySource());
                    r.GetAveragePerDay(id, date, ref res[i].CurrentAvg, ref res[i].HarmAvg, ref res[i].VoltageAvg, ref res[i].PowerFactorAvg, load.SourceId);
                    res[i].name      = load.name;
                    res[i].sourceid  = load.SourceId;
                    res[i].id        = load.Id;
                    res[i].facid     = id;
                    res[i].Timestamp = date;
                }
            }
            else
            {
                var loads = _Context.Load.Where(l => l.Function == val).ToList();



                foreach (var x in loads)
                {
                    SourceReading src;
                    if (x.SourceId % 2 == 0)
                    {
                        // src = _Context.SourceReading.Last(s => s.SecondarySourceId == x.SourceId && s.TimeStamp.Day == date.Day && s.Fac_Id == id);
                        src = _Context.SourceReading.LastOrDefault(s => s.SecondarySourceId == x.SourceId && s.TimeStamp.Day == date.Day && s.Fac_Id == id);
                    }

                    else
                    {
                        src = _Context.SourceReading.LastOrDefault(s => s.PrimarySourceId == x.SourceId && s.TimeStamp.Day == date.Day && s.Fac_Id == id);
                    }
                    if (src != null)
                    {
                        res.Add(new querySource());
                        r.GetAveragePerDay(id, date, ref res[i].CurrentAvg, ref res[i].HarmAvg, ref res[i].VoltageAvg, ref res[i].PowerFactorAvg, x.SourceId);
                        res[i].name      = x.name;
                        res[i].sourceid  = x.SourceId;
                        res[i].id        = x.Id;
                        res[i].facid     = id;
                        res[i].Timestamp = date;
                        i++;
                    }
                    else
                    {
                        continue;
                    }
                }
            }

            return(res);
        }