Beispiel #1
0
        /*public JsonResult GetAPKParametersValueForGraph(int APKID, string From, string To)
         * {
         *  int id = APKContext.GetAPKList()[APKID].ID;
         *  var dateFrom = DateTime.Parse(From);
         *  var dateTo = DateTime.Parse(To);
         *  List<int> paramsID = new List<int>();
         *  Dictionary<List<DateTime>, List<double>> lst = APKContext.GetParametersValuesGraph(id, dateFrom, dateTo, ref paramsID);
         *
         *  return Json(new { dates = lst.Keys.ToList(), values = lst.Values.ToList(), paramIDs = paramsID }, JsonRequestBehavior.AllowGet);
         * }*/

        public JsonResult GetAPKParameterNamesForGraph(int APKNumber)
        {
            int id = APKContext.GetAPKList()[APKNumber].ID;
            Dictionary <int, string> lst = APKContext.GetListOfPostParametersGraph(id);

            return(Json(new { IDs = lst.Keys, Names = lst.Values }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        public ActionResult Report()
        {
            var model = (GraphValidationModel)TempData["model"];

            List <APK>         apklst = APKContext.GetAPKList();
            List <ReportModel> list   = new List <ReportModel>();

            for (int i = 0; i < apklst.Count; i++)
            {
                ReportModel rep = new ReportModel();
                rep.Description = apklst[i].Description;
                rep.Name        = apklst[i].Name;
                rep.Type        = (int)apklst[i].Type;
                if (model == null)
                {
                    rep.Day   = DateTime.Now.Day;
                    rep.Month = DateTime.Now.Month;
                    rep.Year  = DateTime.Now.Year;
                }
                else
                {
                    rep.Day   = model.DateFrom.Day;
                    rep.Month = model.DateFrom.Month;
                    rep.Year  = model.DateFrom.Year;
                }
                list.Add(rep);
            }
            return(View(list));
        }
Beispiel #3
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            GraphValidationModel model = new GraphValidationModel();

            APKContext.GenerateAPKList();
            return(View(model));
        }
Beispiel #4
0
        public JsonResult GetAPKType(int number)
        {
            APK apk  = APKContext.GetAPKList()[number];
            int type = (int)apk.Type;

            return(Json(type, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public JsonResult GetMarkers()
        {
            List <APK> lst = APKContext.GetAPKList();

            List <int>    ID     = new List <int>();
            List <double> Lat    = new List <double>();
            List <double> Lan    = new List <double>();
            List <string> Name   = new List <string>();
            List <int>    Status = new List <int>();
            List <int>    Type   = new List <int>();

            foreach (var item in lst)
            {
                ID.Add(item.ID);
                Lat.Add(item.Lat);
                Lan.Add(item.Lan);
                Name.Add(item.Name);
                Status.Add((int)(item.Status));
                Type.Add((int)(item.Type));
            }

            JsonResult jr = Json(new { id = ID, lat = Lat, lan = Lan, name = Name, status = Status, type = Type }, JsonRequestBehavior.AllowGet);

            return(jr);
        }
Beispiel #6
0
        public JsonResult GetTableValuesForGraphNoModel(List <int> PostId, string From, string To, int ParameterId, List <string> APKName)
        {
            DateTime   DateFrom = DateTime.Parse(From);
            DateTime   DateTo   = DateTime.Parse(To);
            List <int> paramsID = new List <int>();
            Dictionary <List <DateTime>, List <double> > lst = APKContext.GetParametersValuesGraph2(PostId, DateFrom, DateTo, ParameterId);

            return(Json(GetGraphValues(lst, APKName), JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
        public JsonResult GetAPKParametersForReport(int APKID, string day, string month, string year)
        {
            int id  = APKContext.GetAPKList()[APKID].ID;
            APK apk = APKContext.GetAPKList()[APKID];

            TempData["REPORTAPKTYPE"] = (int)apk.Type;
            List <List <string> > lst = APKContext.GetListOfParameterValuesReport(id, GetAPKParametersIdForReport(apk), day, month, year);

            return(Json(lst, JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        public JsonResult GetTableValuesForGraph(List <int> PostId, string From, string To, List <int> ParameterId, List <string> ParameterName)
        {
            DateTime   DateFrom = DateTime.Parse(From);
            DateTime   DateTo   = DateTime.Parse(To);
            List <int> paramsID = new List <int>();
            int        postid   = 0;

            if (PostId.Count == 1)
            {
                postid = PostId[0];
            }
            Dictionary <List <DateTime>, List <double> > lst = APKContext.GetParametersValuesGraph(postid, DateFrom, DateTo, ParameterId);

            return(Json(GetGraphValues(lst, ParameterName), JsonRequestBehavior.AllowGet));
        }
Beispiel #9
0
        public JsonResult GenerateAPK(bool all, int id)
        {
            List <APK> lst = APKContext.GenerateAPKList();
            JsonResult jr;

            if (all)
            {
                jr = Json(lst, JsonRequestBehavior.AllowGet);
            }
            else
            {
                APK tmp = lst.Where(apk => apk.ID == id).FirstOrDefault();
                if (tmp == null)
                {
                    tmp = new APK()
                    {
                        ID = -1
                    }
                }
                ;
                jr = Json(tmp, JsonRequestBehavior.AllowGet);
            }
            return(jr);
        }
Beispiel #10
0
        public JsonResult APKSearch(int byWhom, string what)
        {
            JsonResult jr   = null;
            List <APK> list = APKContext.GetAPKList();

            if (byWhom == 0) //by number
            {
                //int i = -1;
                APK apk = null;
                //if(int.TryParse(what, out i))
                apk = list.Where(item => item.Number == what).FirstOrDefault();
                if (apk == null)
                {
                    apk = new APK()
                    {
                        Number = "-1"
                    }
                }
                ;
                jr = Json(apk.Number, JsonRequestBehavior.AllowGet);
            }
            else if (byWhom == 1) //by name
            {
                APK apk = list.Where(item => item.Name.ToUpper().Contains(what.ToUpper())).FirstOrDefault();
                if (apk == null)
                {
                    apk = new APK()
                    {
                        Number = "-1"
                    }
                }
                ;
                jr = Json(apk.Number, JsonRequestBehavior.AllowGet);
            }
            return(jr);
        }
Beispiel #11
0
        public JsonResult CheckDBEConnection()
        {
            bool result = APKContext.CheckDBConnection();

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #12
0
        public JsonResult GetDOZORParameterNamesForGraph()
        {
            Dictionary <string, int> lst = APKContext.GetListOfSensorParametersGraph(1);

            return(Json(new { Name = lst.Keys, ID = lst.Values }, JsonRequestBehavior.AllowGet));
        }
Beispiel #13
0
        public FileResult CreateReportXLS(string hiddenAPKIDSelector, string hiddenPIB, string hiddenDateDay, string hiddenDateMonth, string hiddenDateYear)
        {
            /*string file = Path.Combine(Server.MapPath("~/Files"), "report.xls");
             * Workbook workbook = Workbook.Load(file);
             * Worksheet worksheet = workbook.Worksheets[0];
             *
             * worksheet.Cells[1, 1].Value = "EHUUUU";
             * worksheet.Cells[0, 1] = new Cell("1, 2");
             * workbook.Save(file);
             * return File(file, "application/vnd.ms-excel", "report.xls");*/

            int apkNumber = 0;

            Int32.TryParse(hiddenAPKIDSelector, out apkNumber);

            string file = Path.Combine(Server.MapPath("~/Files"), "report" + ((int)APKContext.GetAPKList()[apkNumber].Type).ToString() + ".xlsx");

            //видалимо попередній файл

            /*string tmp_path = (string)TempData["tmp_file"];
             * if(tmp_path != null)
             *  System.IO.File.Delete(tmp_path);*/

            foreach (string files in System.IO.Directory.EnumerateFiles(Server.MapPath("~/Files/tmp_files")))
            {
                try
                {
                    string tmp = Path.Combine(Server.MapPath("~/Files/tmp_files"), files);
                    System.IO.File.Delete(tmp);
                }
                catch (IOException ex)
                {
                }
            }
            //створимо новий файл із шаблону
            string tmp_file = Path.Combine(Server.MapPath("~/Files/tmp_files"), "report" + Guid.NewGuid() + ".xlsx");

            System.IO.File.Copy(file, tmp_file);

            var xlApp = new Excel.Application();

            try
            {
                xlApp.DisplayAlerts = false;
                Excel.Workbook  xlWorkBook  = xlApp.Workbooks.Open(tmp_file);
                int             cnt         = xlWorkBook.Sheets.Count;
                Excel.Worksheet xlWorkSheet = xlWorkBook.Sheets[1];

                xlWorkSheet.Cells[1][1]  = hiddenDateDay + "." + hiddenDateMonth + "." + hiddenDateYear;
                xlWorkSheet.Cells[17][4] = hiddenPIB;
                xlWorkSheet.Cells[17][4] = hiddenPIB;
                xlWorkSheet.Cells[1][9]  = APKContext.GetAPKList()[apkNumber].Description;
                xlWorkSheet.Cells[1][10] = "за адресою: " + APKContext.GetAPKList()[apkNumber].Name;

                int id  = APKContext.GetAPKList()[apkNumber].ID;
                APK apk = APKContext.GetAPKList()[apkNumber];
                List <List <string> > lst = APKContext.GetListOfParameterValuesReport(id, GetAPKParametersIdForReport(apk), hiddenDateDay, hiddenDateMonth, hiddenDateYear);
                for (int i = 0; i < lst.Count; i++)
                {
                    for (int j = 0; j < 24; j++)
                    {
                        xlWorkSheet.Cells[6 + j][15 + i] = "";
                    }
                }

                for (int i = 0; i < lst.Count; i++)
                {
                    for (int j = 0; j < lst[i].Count; j++)
                    {
                        xlWorkSheet.Cells[6 + j][15 + i] = lst[i][j].ToString();
                    }
                }

                xlWorkBook.SaveAs(tmp_file, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookDefault, Type.Missing, Type.Missing, false, false, Excel.XlSaveAsAccessMode.xlNoChange, Excel.XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing);
                xlWorkBook.Close(true);
                xlApp.Quit();
                Marshal.ReleaseComObject(xlApp);
            }
            catch (Exception ex)
            {
                Marshal.ReleaseComObject(xlApp);
            }

            return(File(tmp_file, "application/vnd.ms-excel", "report.xlsx"));
        }