Ejemplo n.º 1
0
 public ForecastViewConext(IDBContext db)
 {
     this.menuitempoint = menuitemgeop;
     this.Regim         = REGIM.INIT;
     if (!Helper.GetListPetrochemicalType(db, ref petrochemicaltypelist))
     {
         this.Regim = REGIM.RUNERROR;
     }
     this.incidenttypelist = new EGH01DB.Types.IncidentTypeList(db);
     if (this.incidenttypelist == null)
     {
         this.Regim = REGIM.RUNERROR;
     }
 }
Ejemplo n.º 2
0
        public ActionResult IncidentType()
        {
            ViewBag.EGHLayout = "RGE.IncidentType";
            RGEContext   db       = null;
            ActionResult view     = View("Index");
            string       menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";

            try
            {
                db = new RGEContext();
                //ViewBag.msg = "Соединение с базой данных установлено";  // debug
                view = View("IncidentType", db);
                if (menuitem.Equals("IncidentType.Create"))
                {
                    view = View("IncidentTypeCreate");
                }
                else if (menuitem.Equals("IncidentType.Delete"))
                {
                    string type_code_item = this.HttpContext.Request.Params["type_code"];
                    if (type_code_item != null)
                    {
                        int c = 0;
                        if (int.TryParse(type_code_item, out c))
                        {
                            IncidentType it = new IncidentType();
                            if (EGH01DB.Types.IncidentType.GetByCode(db, c, out it))
                            {
                                view = View("IncidentTypeDelete", it);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("IncidentType.Update"))
                {
                    string type_code_item = this.HttpContext.Request.Params["type_code"];
                    if (type_code_item != null)
                    {
                        int c = 0;
                        if (int.TryParse(type_code_item, out c))
                        {
                            IncidentType it = new IncidentType();
                            if (EGH01DB.Types.IncidentType.GetByCode(db, c, out it))
                            {
                                view = View("IncidentTypeUpdate", it);
                            }
                        }
                    }
                }
                else if (menuitem.Equals("IncidentType.Excel"))
                {
                    EGH01DB.Types.IncidentTypeList list = new IncidentTypeList(db);
                    XmlNode     node  = list.toXmlNode();
                    XmlDocument doc   = new XmlDocument();
                    XmlNode     nnode = doc.ImportNode(node, true);
                    doc.AppendChild(nnode);
                    doc.Save(Server.MapPath("~/App_Data/IncidentType.xml"));
                    view = View("Index");

                    view = File(Server.MapPath("~/App_Data/IncidentType.xml"), "text/plain", "Типы инцидентов.xml");
                }
            }
            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }