Ejemplo n.º 1
0
        public ActionResult Day(int day, int month, int year)
        {
            string DB    = string.Empty;
            string table = string.Empty;
            int    cfNum = 1;

            foreach (string key in Session.Keys)
            {
                if (key.Contains("dbName"))
                {
                    DB = Session[key].ToString();
                }
                if (key.Contains("tableName"))
                {
                    table = Session[key].ToString();
                }
                if (key.Contains("congirationNumber"))
                {
                    cfNum = int.Parse(Session[key].ToString());
                }
            }
            DateTime       from  = new DateTime(year, month, day);
            DateTime       to    = new DateTime(year, month, day + 1);
            ReportDBHelper db    = new ReportDBHelper(DB, 2);
            ReportDosing   model = new ReportDosing();

            model       = db.GetReportDosing(from, to, table);
            model.Day   = day;
            model.Month = month;
            model.Year  = year;
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult GetNextBatch(int id)
        {
            ReportDBHelper db      = new ReportDBHelper(Session["ReportDB"].ToString(), 2);
            int            BatchNo = db.SelectNextBatchNo(id, Session["ReportTable"].ToString());

            if (BatchNo == 0)
            {
                Session["tempforview"] = "You have reached the maximum batch";
                return(RedirectToAction("Detail", new { id = id }));
            }
            DataReportModel data = db.SelectSteps(BatchNo, Session["ReportTable"].ToString());

            ViewBag.BatchNo = BatchNo;
            int dest = int.Parse(data.Data[0].Destination);

            if (tankNames.Keys.Contains(dest))
            {
                ViewBag.Destination = tankNames[dest];
            }
            else
            {
                Session["tempforview"] = "Check configuration of report config";
            }

            return(View("Detail", data.Data));
        }
Ejemplo n.º 3
0
        // GET: ReportOverview
        public ActionResult Index()
        {
            const int startDay = 1;

            int      month          = DateTime.Now.Month;
            int      year           = DateTime.Now.Year;
            DateTime thisMonthStart = new DateTime(year, month, startDay, 0, 0, 0);
            DateTime thisMontEnd    = new DateTime(year, month + 1, startDay, 0, 0, 0);

            foreach (string key in Session.Keys)
            {
                if (key.Contains("dbName" + Request.QueryString["name"] + Request.QueryString["plc"]))
                {
                    DB = Session[key].ToString();
                }
                if (key.Contains("tableName" + Request.QueryString["name"] + Request.QueryString["plc"]))
                {
                    table = Session[key].ToString();
                }
                if (key.Contains("congirationNumber" + Request.QueryString["name"] + Request.QueryString["plc"]))
                {
                    configrationNumber = int.Parse(Session[key].ToString());
                }
            }

            ReportDBHelper      db   = new ReportDBHelper(DB, 2);
            OverviewReportModel data = db.SelectConsumption(thisMonthStart, thisMontEnd, table);

            ViewBag.month = month;
            ViewBag.year  = year;

            return(View(data));
        }
Ejemplo n.º 4
0
        public ActionResult Month(int year, int month)
        {
            const int startDay = 1;

            DateTime thisMonthStart = new DateTime(year, month, startDay, 0, 0, 0);
            DateTime thisMontEnd    = new DateTime(year, month + 1, startDay, 0, 0, 0);

            ReportDBHelper      db   = new ReportDBHelper(DB, 2);
            OverviewReportModel data = db.SelectConsumption(thisMonthStart, thisMontEnd, table);

            ViewBag.month = month;
            ViewBag.year  = year;

            return(View("Index", data));
        }
Ejemplo n.º 5
0
        public async Task <JsonResult> getEventsHeader()
        {
            int          batchStart  = 0;
            int          batchEnd    = 0;
            StreamReader stream      = new StreamReader(Request.InputStream);
            string       json        = stream.ReadToEnd();
            DataRequest  dataRequest = new JavaScriptSerializer().Deserialize <DataRequest>(json);
            string       DB          = string.Empty;
            string       table       = string.Empty;

            foreach (string key in Session.Keys)
            {
                if (key.Contains("dbName") && key.Contains(Request.QueryString["plc"].ToString()))
                {
                    DB = Session[key].ToString();
                }
                if (key.Contains("tableName") && key.Contains(Request.QueryString["plc"].ToString()))
                {
                    table = Session[key].ToString();
                }
            }
            ReportDBHelper  db   = new ReportDBHelper(DB, 2);
            GraphEventsData data = await db.SelectGraphDataAsync(dataRequest.beginTime, dataRequest.beginTime + dataRequest.timeAxisLength, table);

            foreach (ColumnGraphModel CGM in data.events)
            {
                if (CGM.RecordType == 10 || CGM.RecordType == 14)
                {
                    if (data.events.Exists(p => (int)p.RecordType == 10 && p.BatchNo == CGM.BatchNo))
                    {
                        batchStart = data.events.Single(p => (int)p.RecordType == 10 && p.BatchNo == CGM.BatchNo).TimeStart;
                    }
                    if (data.events.Exists(p => (int)p.RecordType == 14 && p.BatchNo == CGM.BatchNo))
                    {
                        batchEnd = (data.events.Single(p => (int)p.RecordType == 14 && p.BatchNo == CGM.BatchNo).TimeStart);
                    }
                    if (data.events.Exists(p => (int)p.RecordType == 10 && p.BatchNo == CGM.BatchNo) && data.events.Exists(p => (int)p.RecordType == 14 && p.BatchNo == CGM.BatchNo))
                    {
                        CGM.Variant3 = batchEnd - batchStart;
                    }
                    //Duration is for George graphs in recordType 10 and 14
                }
            }

            return(Json(data)); //it add data in the reguested shape to client
        }
Ejemplo n.º 6
0
        public ActionResult Month(int month, int year)
        {
            int       monthAdded = 1;
            int       yearAdded  = 1;
            const int startDay   = 1;

            if (month == 12)
            {
                monthAdded = 1;
                yearAdded  = year + 1;
            }
            else
            {
                monthAdded = month + 1;
                yearAdded  = year;
            }
            //int month = DateTime.Now.Month;
            //int year = DateTime.Now.Year;
            DateTime      thisMonthStart = new DateTime(year, month, startDay, 0, 0, 0);
            DateTime      thisMontEnd    = new DateTime(year, monthAdded, startDay, 0, 0, 0);
            ReportHandler RH             = new ReportHandler();

            ReportDBHelper           db       = new ReportDBHelper(Session["ReportDB"].ToString(), 2);
            DataReportModel          model    = db.SelectHeaderData(thisMonthStart, thisMontEnd, Session["ReportTable"].ToString());
            List <ColumnReportModel> cleaning = model.Data.Where(p => p.RecordType == Operations.PipWorkCleaning || p.RecordType == Operations.YeastCleaning).ToList();

            foreach (var report in model.Data)
            {
                int dest = int.Parse(report.Destination);
                if (tankNames.Keys.Contains(dest))
                {
                    report.Destination = tankNames[dest];
                }
                else
                {
                    Session["tempforview"] = "Check configuration of report config";
                }
                //report.Destination = tankNames[int.Parse(report.Destination)];
            }
            ViewBag.month = month;
            ViewBag.year  = year;
            return(View("calender", model));
        }
Ejemplo n.º 7
0
        public ActionResult Detail(int id)
        {
            ReportDBHelper  db   = new ReportDBHelper(Session["ReportDB"].ToString(), 2);
            DataReportModel data = db.SelectSteps(id, Session["ReportTable"].ToString());

            //if (data.Data.Exists(p => p.RecordType == Operations.Interrupt))
            ViewBag.AmntTotal = data.Data.First(p => p.RecordType == Operations.RecipeStart).Need;
            //if (data.Data.Exists(p => p.RecordType == Operations.Interrupt))
            ViewBag.InteruptedCounts = data.Data.Where(p => p.RecordType == Operations.Interrupt).Count();
            //if (data.Data.Exists(p=> p.RecordType == Operations.StepSkip))
            ViewBag.NumberOfStepsSkipped = data.Data.Where(p => p.RecordType == Operations.StepSkip).Count();
            ViewBag.BatchNo = id;
            int dest = int.Parse(data.Data[0].Destination);

            if (tankNames.Keys.Contains(dest))
            {
                ViewBag.Destination = tankNames[dest];
            }
            else
            {
                Session["tempforview"] = "Check configuration of report config";
            }
            return(View(data.Data));
        }
Ejemplo n.º 8
0
        public async Task <JsonResult> getEventsHeader()
        {
            int          batchStart  = 0;
            int          batchEnd    = 0;
            StreamReader stream      = new StreamReader(Request.InputStream);
            string       json        = stream.ReadToEnd();
            DataRequest  dataRequest = new JavaScriptSerializer().Deserialize <DataRequest>(json);
            string       DB          = string.Empty;
            string       table       = string.Empty;

            foreach (string key in Session.Keys)
            {
                if (key.Contains("dbName") && key.Contains(Request.QueryString["plc"].ToString()))
                {
                    DB = Session[key].ToString();
                }
                if (key.Contains("tableName") && key.Contains(Request.QueryString["plc"].ToString()))
                {
                    table = Session[key].ToString();
                }
            }
            ReportDBHelper  db   = new ReportDBHelper(DB, 2);
            DataReportModel data = await db.SelectHeaderDataAsync(dataRequest.beginTime, dataRequest.beginTime + dataRequest.timeAxisLength, table);

            GraphEventsData GED = new GraphEventsData();

            GED.events = new List <ColumnGraphModel>();
            foreach (ColumnReportModel CRM in data.Data)
            {
                ColumnGraphModel CGM = new ColumnGraphModel();

                CGM.RecordNo   = CRM.RecordNo;
                CGM.RecordType = (int)CRM.RecordType;

                CGM.TimeStart   = AlarmHelper.DateTimeTopkTime(CRM.TimeStart);
                CGM.TimeEnd     = AlarmHelper.DateTimeTopkTime(CRM.TimeEnd);
                CGM.BatchNo     = CRM.BatchNo;
                CGM.Destination = CRM.Destination;
                CGM.Need        = CRM.Need;
                CGM.Actual      = CRM.Actual;

                CGM.Variant1 = CRM.Variant1;
                CGM.Variant2 = CRM.Variant2;
                CGM.Variant3 = CRM.Variant3;
                if (CGM.RecordType == 10 || CGM.RecordType == 14)
                {
                    if (data.Data.Exists(p => (int)p.RecordType == 10 && p.BatchNo == CGM.BatchNo))
                    {
                        batchStart = AlarmHelper.DateTimeTopkTime(data.Data.Single(p => (int)p.RecordType == 10 && p.BatchNo == CGM.BatchNo).TimeStart);
                    }
                    if (data.Data.Exists(p => (int)p.RecordType == 14 && p.BatchNo == CGM.BatchNo))
                    {
                        batchEnd = AlarmHelper.DateTimeTopkTime(data.Data.Single(p => (int)p.RecordType == 14 && p.BatchNo == CGM.BatchNo).TimeEnd);
                    }
                    if (data.Data.Exists(p => (int)p.RecordType == 10 && p.BatchNo == CGM.BatchNo) && data.Data.Exists(p => (int)p.RecordType == 14 && p.BatchNo == CGM.BatchNo))
                    {
                        CGM.Variant3 = batchEnd - batchStart;
                    }
                    //Duration is for George graphs in recordType 10 and 14
                }
                CGM.Variant4 = CRM.Variant4;

                GED.events.Add(CGM);
            }

            return(Json(GED)); //it add data in the reguested shape to client
        }
Ejemplo n.º 9
0
        // GET: ReportCalender
        public ActionResult Index()
        {
            int       monthAdded = 1;
            int       yearAdded  = 1;
            const int startDay   = 1;

            tankNames = new Dictionary <int, string>();
            string DB    = string.Empty;
            string table = string.Empty;
            int    cfNum = 1;

            foreach (string key in Session.Keys)
            {
                if (key.Contains("dbName" + Request.QueryString["name"] + Request.QueryString["plc"]))
                {
                    DB = Session[key].ToString();
                }
                if (key.Contains("tableName" + Request.QueryString["name"] + Request.QueryString["plc"]))
                {
                    table = Session[key].ToString();
                }
                if (key.Contains("congirationNumber" + Request.QueryString["name"] + Request.QueryString["plc"]))
                {
                    cfNum = int.Parse(Session[key].ToString());
                }
            }
            Session["ReportDB"]    = DB;
            Session["ReportTable"] = table;
            Session["ReportConfigrationNumber"] = cfNum;
            int month = DateTime.Now.Month;
            int year  = DateTime.Now.Year;

            if (month == 12)
            {
                monthAdded = 1;
                yearAdded  = year + 1;
            }
            else
            {
                monthAdded = month + 1;
                yearAdded  = year;
            }
            DateTime      thisMonthStart = new DateTime(year, month, startDay, 0, 0, 0);
            DateTime      thisMontEnd    = new DateTime(yearAdded, monthAdded, startDay, 0, 0, 0);
            ReportHandler RH             = new ReportHandler();

            if (cfNum != 0)
            {
                tankNames = RH.getTanknames(cfNum);
            }
            else
            {
                tankNames = RH.getTanknames();
            }

            ReportDBHelper  db    = new ReportDBHelper(Session["ReportDB"].ToString(), 2);
            DataReportModel model = db.SelectHeaderData(thisMonthStart, thisMontEnd, Session["ReportTable"].ToString());

            foreach (var report in model.Data)
            {
                int dest = int.Parse(report.Destination);
                if (tankNames.Keys.Contains(dest))
                {
                    report.Destination = tankNames[dest];
                }
                else
                {
                    Session["tempforview"] = "Check configuration of report config";
                }
            }
            ViewBag.month = month;
            ViewBag.year  = year;
            return(View("calender", model));
        }