Esempio n. 1
0
        public void SetDataOnPechInExcelTest()
        {
            OptZRM opz = new OptZRM();

            opz.nachDataPech = Convert.ToDateTime("01.12.2014");
            opz.nomerPech    = 1;
            string path =
                @"C:\Users\Александр\Documents\учебка\диплом\web\calcOptimalZRM\calcOptimalZRM\Content\Оптимальная доменная шихта 2010_.xlt";

            opz.SetDataOnPechInExcel(path);
            Thread.Sleep(5000);
            ExcelReport exp = new ExcelReport(path, true);

            exp.ChangeWorkSheet("Ввод составов (база)");
            string g = exp.GetValue("B7");
            double c = Convert.ToDouble(g);

            Assert.AreEqual(12.80, c, 1);
        }
        public ActionResult ResultCalcZRM(VvodOgranicheniy vvod, FormCollection frm)
        {
            int targetType;
            int influence;
            var d = vvod.vzskkonshlakmax;

            try
            {
                targetType = Convert.ToInt32(frm["target"].ToString());
                influence  = Convert.ToInt32(frm["vozdeistv"].ToString());
            }
            catch (Exception ex)
            {
                ViewBag.Error = ex.ToString();
                return(View("Error"));
            }
            string[] conclusion =
            {
                frm["first_concl"], frm["second_concl"], frm["third_concl"], frm["fourth_concl"], frm["fifth_concl"]
            };
            bool[] b = new bool[conclusion.Length];
            for (int i = 0; i < conclusion.Length; i++)
            {
                if (conclusion[i].Contains("true"))
                {
                    b[i] = true;
                }
                else
                {
                    b[i] = false;
                }
            }
            string excelPath = Server.MapPath("~/Content/" + "Оптимальная доменная шихта 2010_2.xlsm");

            //string excelPath = Server.MapPath("~/Content/" + "Оптимальная доменная шихта 2010_.xlt");

            OptZRM opz = new OptZRM();

            opz.CalcOptZRM(b, targetType, influence, excelPath);
            Okatishi okatishi = new Okatishi();

            okatishi.okatSsgokModel        = Convert.ToDouble(opz.okatSsgok);
            ResOkatSsgok                   = okatishi.okatSsgokModel;
            okatishi.okatLebedinskModel    = Convert.ToDouble(opz.okatLebedinsk);
            ResOkatLebedinsk               = okatishi.okatLebedinskModel;
            okatishi.okatKachanarskieModel = Convert.ToDouble(opz.okatKachanarskie);
            ResOkatKachanarsk              = okatishi.okatKachanarskieModel;
            okatishi.okatMihailovskModel   = Convert.ToDouble(opz.okatMihailovsk);
            ResOkatMihailovsk              = okatishi.okatMihailovskModel;
            ParamShlakAfterCalc psac = new ParamShlakAfterCalc();

            psac.summdoleyzrmnow  = opz.summdoleyzrmnow;
            ResSummDoleyZrm       = psac.summdoleyzrmnow;
            psac.vzskkonshlak     = opz.vzskkonshlak;
            ResVyazkKonShlak      = psac.vzskkonshlak;
            psac.vzskkonshlak1450 = opz.vzskkonshlak1450;
            ResVyazkKonShlak14    = psac.vzskkonshlak1450;
            psac.aglmmknow        = opz.aglmmknow;
            ResAglomMmk           = psac.aglmmknow;
            psac.osnkonshlack     = opz.osnkonshlack;
            ResOsnovKonShlak      = psac.osnkonshlack;
            psac.grdvzkkkonshlak  = opz.grdvzkkkonshlak;
            ResGradVyazkShlak     = psac.grdvzkkkonshlak;
            ViewBag.Result        = psac;
            ViewBag.Vihod         = vvod;
            ViewBag.Okatish       = okatishi;
            killDOZER("excel");
            return(View());
        }
        public ActionResult CalcZHRM(int Monthes, int PechType, string YearPick)
        {
            if (YearPick.IsNullOrWhiteSpace())
            {
                return(View("Error"));
            }

            DateTime pickDateTime;
            string   excelPath = Server.MapPath("~/Content/" + "Оптимальная доменная шихта 2010_2.xlsm");

            try
            {
                pickDateTime = DateTime.Parse("01." + Convert.ToString(Monthes) + "." + YearPick);
            }
            catch (Exception e)
            {
                ViewBag.Error = e.ToString();
                return(View("Error"));
            }

            int npech = PechType;

            FirstDateTime = pickDateTime;
            NomerPech     = Convert.ToByte(npech);
            List <OptShihtDC_Param_Load_Result> opShihtParam = new List <OptShihtDC_Param_Load_Result>();
            List <PechParams> paramsPechList = new List <PechParams>();

            //testReportEntities test = new testReportEntities();
            test.Database.Connection.Open();
            var shihtaParam = test.OptShihtDC_Param_Load(pickDateTime, 0);

            foreach (var p in shihtaParam)
            {
                PechParams pp = new PechParams();
                if (PechType == 1)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP1;
                }
                if (PechType == 2)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP2;
                }
                if (PechType == 3)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP3;
                }
                if (PechType == 4)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP4;
                }
                if (PechType == 5)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP5;
                }
                if (PechType == 6)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP6;
                }
                if (PechType == 7)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP7;
                }
                if (PechType == 8)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP8;
                }
                if (PechType == 9)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP9;
                }
                if (PechType == 10)
                {
                    pp.Pechdate = p.dtFirstDay;
                    pp.Descr    = p.Descr;
                    pp.Val      = p.sDP10;
                }
                paramsPechList.Add(pp);
            }

            ViewBag.ParamsPech = paramsPechList;
            OptZRM opz = new OptZRM();

            opz.nachDataPech = pickDateTime;
            opz.nomerPech    = Convert.ToByte(npech);
            opz.SetDataOnPechInExcel(excelPath);
            DomCehParameter domCehParameter = new DomCehParameter();

            domCehParameter.proizvDomPechModel   = Convert.ToDouble(opz.proizvDomPechModel);
            domCehParameter.summUdRashKoksModel  = Convert.ToDouble(opz.summUdRashKoksModel);
            domCehParameter.sodSeraChugunModel   = Convert.ToDouble(opz.sodSeraChugunModel);
            domCehParameter.dolAglomeratMmkModel = Convert.ToDouble(opz.dolAglomeratMmkModel);
            domCehParameter.Al2O3ShlakModel      = Convert.ToDouble(opz.Al2O3ShlakModel);
            domCehParameter.MgOShlakModel        = Convert.ToDouble(opz.MgOShlakModel);
            ViewBag.DomCehPar = domCehParameter;
            VvodOgranicheniy vvod = new VvodOgranicheniy();

            vvod.aglmmkmax = opz.aglmmkmax;
            vvod.aglmmkmin = opz.aglmmkmin;
            vvod.aglmmknow = opz.aglmmknow;

            vvod.grdvzkkkonshlak    = opz.grdvzkkkonshlak;
            vvod.grdvzkkkonshlakmax = opz.grdvzkkkonshlakmax;
            vvod.grdvzkkkonshlakmin = opz.grdvzkkkonshlakmin;

            vvod.onskonshlakkzad     = opz.onskonshlakkzad;
            vvod.onskonshlakmin      = opz.onskonshlakmin;
            vvod.osnkonshlack        = opz.osnkonshlack;
            vvod.osnkonshlakmax      = opz.osnkonshlakmax;
            vvod.summdoleyzrmnow     = opz.summdoleyzrmnow;
            vvod.vzskkonshlak        = opz.vzskkonshlak;
            vvod.vzskkonshlak1450    = opz.vzskkonshlak1450;
            vvod.vzskkonshlakmax     = opz.vzskkonshlakmax;
            vvod.vzskkonshlakmax1450 = opz.vzskkonshlakmax1450;
            vvod.vzskkonshlakmin     = opz.vzskkonshlakmin;
            vvod.vzskkonshlakmin1450 = opz.vzskkonshlakmin1450;

            ViewBag.Vvod = vvod;
            test.Database.Connection.Close();
            return(View());
        }