Пример #1
0
        public async Task <IActionResult> _IndexPlc(string dataFrom, string dataTo)
        {
            // Modific datele de afisat in functie de selectie din View
            if (dataFrom == null)
            {
                dataFrom = _auxiliar.GetOneMonthBeforeDate();
            }
            if (dataTo == null)
            {
                dataTo = _auxiliar.GetTomorrowDate();
            }
            IEnumerable <PlcModel> ListaDeAfisat = await _context.Plcs.ToListAsync();

            return(PartialView(ListaDeAfisat.Where(item => _auxiliar.IsDateBetween(item.DataCreation.ToString("dd.MM.yyyy HH:mm:ss"), dataFrom, dataTo))));
            // return View(await _context.ProbaModels.ToListAsync());
        }
Пример #2
0
        public async Task <IActionResult> _Index(DateProbaDeAfisat selectieAfisareDate, string dataFrom, string dataTo, string ecranMic)
        {
            ViewBag.IsMallScreen = ecranMic;
            // Salvez in ViewBag userName si Rol pentru a folosi in View
            ViewBag.UserName = HttpContext.Session.GetString("UserName");
            ViewBag.Rol      = HttpContext.Session.GetString("Rol");
            // Daca nu e logat redirectionez la Pagina de Login
            if (ViewBag.UserName == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            // Modific datele de afisat in functie de selectie din View
            if (dataFrom == null)
            {
                dataFrom = Auxiliar.GetOneMonthBeforeDate();
            }
            if (dataTo == null)
            {
                dataTo = Auxiliar.GetTomorrowDate();
            }
            IEnumerable <ProbaModel> ListaDeAfisat = await _context.ProbaModels.ToListAsync();

            switch (selectieAfisareDate)
            {
            // Afiseaza toate datele
            case DateProbaDeAfisat.Toate:
                ListaDeAfisat = await _context.ProbaModels.ToListAsync();

                break;

            // Afiseaza doar datele introduse de operator
            case DateProbaDeAfisat.ProbaIntrodusa:
                ListaDeAfisat = _context.ProbaModels.Where(item => item.DataPreluare == "-" && item.DataRaspunsCalitate == "-");
                break;

            // Afiseaza doar datele cu probele prelevate de operator calitate
            case DateProbaDeAfisat.ProbaPreluata:
                ListaDeAfisat = _context.ProbaModels.Where(item => item.DataPreluare != "-" && item.DataRaspunsCalitate == "-");
                break;

            // Afiseaza doar datele cu rezultat la calitate
            case DateProbaDeAfisat.ProbaRezultat:
                ListaDeAfisat = _context.ProbaModels.Where(item => item.DataPreluare != "-" && item.DataRaspunsCalitate != "-");
                break;

            // Afiseaza doar datele cu RNC
            case DateProbaDeAfisat.ProbaRNC:
                ListaDeAfisat = _context.ProbaModels.Where(item => item.RezultatProba == Rezultat.RNC);
                break;

            default:
                break;
            }
            return(PartialView(ListaDeAfisat.Where(item => Auxiliar.IsDateBetween(item.DataPrelevare, dataFrom, dataTo))));
            // return View(await _context.ProbaModels.ToListAsync());
        }
Пример #3
0
        // Functie exportare data to excel file
        public async Task <IActionResult> ExportToExcelAsync(string dataFrom, string dataTo)
        {
            //return Content(dataFrom + "<==>" + dataTo);
            List <IndexModel> listaSql = await _context.IndexModels.ToListAsync();

            IEnumerable <IndexModel> listaExcel = listaSql.Where(model => model.PlcName == "PlcCuptor");

            // Extrage datele cuprinse intre limitele date de operator
            IEnumerable <IndexModel> listaDeAfisat = listaExcel.Where(model => Auxiliar.IsDateBetween(model.Data, dataFrom, dataTo));

            var stream = new MemoryStream();

            using (var pck = new ExcelPackage(stream))
            {
                ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Cuptor");
                ws.Cells["A1:Z1"].Style.Font.Bold = true;

                ws.Cells["A1"].Value = "Id";
                ws.Cells["B1"].Value = "Data";
                ws.Cells["C1"].Value = "Nume Plc";
                ws.Cells["D1"].Value = "Index gaz";
                ws.Cells["E1"].Value = "Consum gaz";

                int rowStart = 2;
                foreach (var elem in listaDeAfisat)
                {
                    ws.Cells[string.Format("A{0}", rowStart)].Value = elem.Id;
                    ws.Cells[string.Format("B{0}", rowStart)].Value = elem.Data;
                    ws.Cells[string.Format("C{0}", rowStart)].Value = elem.PlcName;
                    ws.Cells[string.Format("D{0}", rowStart)].Value = elem.IndexValue;
                    ws.Cells[string.Format("E{0}", rowStart)].Value = elem.GazValue;
                    rowStart++;
                }

                ws.Cells["A:AZ"].AutoFitColumns();

                pck.Save();
            }
            stream.Position = 0;
            string excelName = "RaportGazCuptor.xlsx";

            return(File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", excelName));
        }
Пример #4
0
        public async Task <IActionResult> Index()
        {
            // Salvez in ViewBag userName si Rol pentru a folosi in View
            ViewBag.UserName = HttpContext.Session.GetString("UserName");
            ViewBag.Rol      = HttpContext.Session.GetString("Rol");
            // Daca nu e logat redirectionez la Pagina de Login
            if (ViewBag.UserName == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            // Logiga afisare date doar pt o luna inainte
            ViewBag.dataFrom = Auxiliar.GetOneMonthBeforeDate();
            ViewBag.dataTo   = Auxiliar.GetTomorrowDate();
            List <ProbaModel> ListaSql = await _context.ProbaModels.ToListAsync();

            IEnumerable <ProbaModel> ListaDeAfisat = ListaSql.Where(item => Auxiliar.IsDateBetween(item.DataPrelevare, ViewBag.dataFrom, ViewBag.dataTo));

            return(View(ListaDeAfisat));
        }
Пример #5
0
        // Functie exportare data to excel file
        public async Task <IActionResult> ExportToExcelAsync(string dataFrom, string dataTo)
        {
            //return Content(dataFrom + "<==>" + dataTo);
            List <ProbaModel> listaExcel = await _context.ProbaModels.ToListAsync();

            // Extrage datele cuprinse intre limitele date de operator
            IEnumerable <ProbaModel> listaDeAfisat = listaExcel.Where(model => Auxiliar.IsDateBetween(model.DataPrelevare, dataFrom, dataTo));

            var stream = new MemoryStream();

            using (var pck = new ExcelPackage(stream))
            {
                ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Sheet1");
                ws.Cells["A1:Z1"].Style.Font.Bold = true;

                ws.Cells["A1"].Value = "Id";
                ws.Cells["B1"].Value = "Data prelevare";
                ws.Cells["C1"].Value = "Sigla furnizor";
                ws.Cells["D1"].Value = "Sarja";
                ws.Cells["E1"].Value = "Diametru";
                ws.Cells["F1"].Value = "Calitate";
                ws.Cells["G1"].Value = "Nr cuptor";
                ws.Cells["H1"].Value = "Tip Tratament Termic";
                ws.Cells["I1"].Value = "Cap bara";
                ws.Cells["J1"].Value = "Tip proba";
                ws.Cells["K1"].Value = "User name";
                ws.Cells["L1"].Value = "Obs operator";
                ws.Cells["M1"].Value = "Data preluare";
                ws.Cells["N1"].Value = "Data raspuns";
                ws.Cells["O1"].Value = "User name calitate";
                ws.Cells["P1"].Value = "Rezultat proba";
                ws.Cells["Q1"].Value = "KV1";
                ws.Cells["R1"].Value = "KV2";
                ws.Cells["S1"].Value = "KV3";
                ws.Cells["T1"].Value = "Temperatura";
                ws.Cells["U1"].Value = "Duritate HB";
                ws.Cells["V1"].Value = "Obs Calitate";

                int rowStart = 2;
                foreach (var elem in listaDeAfisat)
                {
                    ws.Cells[string.Format("A{0}", rowStart)].Value = elem.ProbaModelId;
                    ws.Cells[string.Format("B{0}", rowStart)].Value = elem.DataPrelevare;
                    ws.Cells[string.Format("C{0}", rowStart)].Value = elem.SiglaFurnizor;
                    ws.Cells[string.Format("D{0}", rowStart)].Value = elem.Sarja;
                    ws.Cells[string.Format("E{0}", rowStart)].Value = elem.Diametru;
                    ws.Cells[string.Format("F{0}", rowStart)].Value = elem.Calitate;
                    ws.Cells[string.Format("G{0}", rowStart)].Value = elem.NumarCuptor;
                    ws.Cells[string.Format("H{0}", rowStart)].Value = elem.TipTratamentTermic;
                    ws.Cells[string.Format("I{0}", rowStart)].Value = elem.TipCapBara;
                    ws.Cells[string.Format("J{0}", rowStart)].Value = elem.Tipproba;
                    ws.Cells[string.Format("K{0}", rowStart)].Value = elem.UserName;
                    ws.Cells[string.Format("L{0}", rowStart)].Value = elem.ObservatiiOperator;
                    ws.Cells[string.Format("M{0}", rowStart)].Value = elem.DataPreluare;
                    ws.Cells[string.Format("N{0}", rowStart)].Value = elem.DataRaspunsCalitate;
                    ws.Cells[string.Format("O{0}", rowStart)].Value = elem.NumeUtilizatorCalitate;
                    ws.Cells[string.Format("P{0}", rowStart)].Value = elem.RezultatProba;
                    ws.Cells[string.Format("Q{0}", rowStart)].Value = elem.KV1;
                    ws.Cells[string.Format("R{0}", rowStart)].Value = elem.KV2;
                    ws.Cells[string.Format("S{0}", rowStart)].Value = elem.KV3;
                    ws.Cells[string.Format("T{0}", rowStart)].Value = elem.Temperatura;
                    ws.Cells[string.Format("U{0}", rowStart)].Value = elem.DuritateHB;
                    ws.Cells[string.Format("V{0}", rowStart)].Value = elem.ObservatiiCalitate;

                    rowStart++;
                }

                ws.Cells["A:AZ"].AutoFitColumns();

                pck.Save();
            }
            stream.Position = 0;
            string excelName = "RaportTrackingMostre.xlsx";

            return(File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", excelName));
        }