Ejemplo n.º 1
0
        public string GetJSON(double forecast_time)
        {
            List <Forecast_data> list = new List <Forecast_data>();

            Forecast_data current   = null;
            int           timestamp = Convert.ToInt32(DateTime.UtcNow.AddHours(8).Subtract(new DateTime(1970, 1, 1)).TotalSeconds);


            for (int i = 0; i < Results.Count; i += 3)
            {
                current = new Forecast_data();
                IS8Result itemB = Results[i];
                IS8Result itemW = Results[i + 1];
                IS8Result itemI = Results[i + 2];

                current.Hospital_ID   = itemB.Name.Substring(1, 2);
                current.Forecast_Time = forecast_time;
                current.Basetime      = timestamp;

                current.HpF_BED  = new double[] { itemB.Mean, itemB.get_ConfLimit(-95), itemB.get_ConfLimit(95) };
                current.HpF_WARN = new double[] { itemW.Mean, itemW.get_ConfLimit(-95), itemW.get_ConfLimit(95) };
                current.HpF_ICU  = new double[] { itemI.Mean, itemI.get_ConfLimit(-95), itemI.get_ConfLimit(95) };

                list.Add(current);
            }

            return(JsonConvert.SerializeObject(list));
        }
Ejemplo n.º 2
0
        public List <Forecast_data> GetHospitals(double forecast_time)
        {
            List <Forecast_data> list = new List <Forecast_data>();

            Forecast_data current   = null;
            int           timestamp = Convert.ToInt32(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);


            for (int i = 0; i < Results.Count; i += 3)
            {
                current = new Forecast_data();
                IS8Result itemB = Results[i];
                IS8Result itemW = Results[i + 1];
                IS8Result itemI = Results[i + 2];

                int length = itemB.Name.IndexOf('B') - 1;
                current.Hospital_ID   = itemB.Name.Substring(1, length);
                current.Forecast_Time = forecast_time;
                current.Basetime      = timestamp;

                current.HpF_BED  = new double[] { itemB.Mean, itemB.get_ConfLimit(-95), itemB.get_ConfLimit(95) };
                current.HpF_WARN = new double[] { itemW.Mean, itemW.get_ConfLimit(-95), itemW.get_ConfLimit(95) };
                current.HpF_ICU  = new double[] { itemI.Mean, itemI.get_ConfLimit(-95), itemI.get_ConfLimit(95) };

                list.Add(current);
            }

            return(list);
        }
Ejemplo n.º 3
0
        public List <Forecast_data> Forcasting(string time)
        {
            //StringBuilder strReturnValue = new StringBuilder();
            // return username prefixed as shown below
            //strReturnValue.Append(string.Format("You have entered userName as {0}", time));
            //return strReturnValue.ToString();

            //StreamReader sr = new StreamReader(data);
            //string stringData = sr.ReadToEnd();

            //string path = @"c:\MyTest.txt";
            int replicationnum = 5;
            int timestamp      = Convert.ToInt32(DateTime.UtcNow.AddHours(8).Subtract(new DateTime(1970, 1, 1)).TotalSeconds);

            //string MyID = OperationContext.Current.SessionId;
            string filename = @"~/XML/ERPModel_SS.XML";
            //string datafilename = @"~/XML/H_ER.xlsx";
            //string datafilename = @"~/XML/" + timestamp + ".xlsx";

            List <Forecast_data> RTNValue = null;

            //string RTNTag = "";


            RTNValue = new List <Forecast_data>();

            //Forecast_data current = null;
            int timestamp1 = Convert.ToInt32(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);

            string path1 = System.Web.Hosting.HostingEnvironment.MapPath(filename);
            //string path2 = System.Web.Hosting.HostingEnvironment.MapPath(datafilename);

            //RTNTag = "'" + MyID + "'";
            //Excel.Workbook wb = null;
            //bool S8LoadFlag = false;
            //string filename = path1 + "TableTest1.XML";
            ERFSIMUL MySim = null;

            try
            {
                //string ans = run_cmd("E:/Project/OpenSrcData/data/createModelData.py", "1");
                //ScriptEngine engine = Python.CreateEngine();
                //xlApp = new Excel.Application();
                //engine.ExecuteFile("E:/Project/OpenSrcData/data/createModelData.py");
                //run_cmd("E:/Project/OpenSrcData/data/createModelData.py", "1");

                run_cmd("E:/Project/OpenSrcData/data/createModelDataSS.py", "-o " + xmlBase);

                //StreamWriter sw = new StreamWriter(
                //    System.Web.Hosting.HostingEnvironment.MapPath(@"~/XML/Result2.csv"));

                //RTNValue = "' >>"+ans+">> '";
                //sw.WriteLine("name,value,mean,sd-,sd+");
                /////////////////////////////////////////////////////
                //wb = xlApp.Workbooks.Open(path2);
                S8Machine.getSIMU8().Open(path1);
                //S8LoadFlag = true;
                MySim = new ERFSIMUL(S8Machine);
                MySim.Load(path1);
                //MySim.SetInputVariable(value);
                //sw.WriteLine(inputText[1]);
                List <S8Spreadsheet> NewSS = LoadSpreadsheet(MySim.InputVariables);
                MySim.SetTimesAnsLength(replicationnum, Double.Parse(time));
                MySim.SetSSInputVariable(NewSS);
                MySim.Run();
                RTNValue = MySim.GetHospitals(Double.Parse(time));
                MySim.Reset();
                //Forecast_data tmp = new Forecast_data();
                //tmp.Hospital_ID = "OK";
                //RTNValue.Add(tmp);
            }
            catch (Exception ex)
            {
                Forecast_data Err = new Forecast_data();
                Err.Hospital_ID = ex.ToString();

                RTNValue.Add(Err);
            }
            finally
            {
                //S8Machine.getSIMU8().Close();
                if (MySim != null)
                {
                    MySim.close();
                }
            }

            //RTNValue = ;

            //return RTNValue;
            return(RTNValue);
        }