Beispiel #1
0
 public TreeMonitorModel GetMonitorDetail(int unitid)
 {
     using (Entities db = new Entities())
     {
         string           sql   = string.Format(@"select f.*,f2.unitname as parentname from fi_specialunits f,fi_specialunits f2 where f.unitid={0} and CONCAT('/',f.parentid,'/')=f2.path", unitid);
         TreeMonitorModel model = db.Database.SqlQuery <TreeMonitorModel>(sql).FirstOrDefault();
         return(model);
     }
 }
Beispiel #2
0
 public int EditMonitorePro(TreeMonitorModel model)
 {
     using (Entities db = new Entities())
     {
         fi_specialunits units = db.fi_specialunits.FirstOrDefault(t => t.unitid == model.unitid);
         units.unitname = model.unitname;
         return(db.SaveChanges());
     }
 }
        public HttpResponseMessage EditMonitorePro(TreeMonitorModel model)
        {
            HttpRequestBase     request  = ((HttpContextWrapper)this.Request.Properties["MS_HttpContext"]).Request;
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK);
            int success = bll.EditMonitorePro(model);

            if (success > 0)
            {
                response.Content = new StringContent("{\"success\":true}", Encoding.GetEncoding("UTF-8"), "text/html");
            }
            return(response);
        }
Beispiel #4
0
 public int AddMonitorPro(TreeMonitorModel model)
 {
     using (Entities db = new Entities())
     {
         fi_specialunits units = new fi_specialunits();
         units.parentid = model.parentid;
         units.unitname = model.unitname;
         units.path     = model.path;
         units.seq      = model.seq;
         db.fi_specialunits.Add(units);
         return(db.SaveChanges());
     }
 }
Beispiel #5
0
        public List <FI_CameraUnitsTreeModel> GetMonitoreTreeList()
        {
            using (Entities db = new Entities())
            {
                string rootsql = string.Format(@"select fi.unitname as text,fi.unitid,fi.path,fi.seq as id ,fi.parentid 
from fi_specialunits  fi where fi.parentid=0 order by fi.seq ");
                List <FI_CameraUnitsTreeModel> treelist = db.Database.SqlQuery <FI_CameraUnitsTreeModel>(rootsql).ToList();
                string           rootid   = "0";
                string           childsql = "";
                TreeMonitorModel root     = new TreeMonitorModel();
                string           rosql    = @"select fi.unitname as text,fi.unitid,fi.path,fi.seq as id ,fi.parentid  from fi_specialunits fi where fi.parentid is null";
                List <FI_CameraUnitsTreeModel> rootList = db.Database.SqlQuery <FI_CameraUnitsTreeModel>(rosql).ToList();
                for (int i = 0; i < treelist.Count; i++)
                {
                    FI_CameraUnitsTreeModel model = treelist[i];
                    if (model != null)
                    {
                        rootid   = model.id;
                        childsql = string.Format(@"select fi.unitname as text,fi.unitid,fi.path,fi.seq as id ,fi.parentid  from fi_specialunits fi where fi.parentid!=0 and fi.parentid={0} order by fi.parentid", rootid);
                        List <FI_CameraUnitsTreeModel> childList = db.Database.SqlQuery <FI_CameraUnitsTreeModel>(childsql).ToList();
                        foreach (FI_CameraUnitsTreeModel item in childList)
                        {
                            item.nodes = GetMonitoreTreeChildList(item.unitid);
                            item.leaf  = true;
                            item.text  = item.text;
                        }
                        model.nodes    = childList;
                        model.expanded = true;
                        model.leaf     = false;
                        if (childList.Count == 0)
                        {
                            model.leaf = true;
                        }
                    }
                }
                if (rootList.Count > 0)
                {
                    rootList[0].leaf     = treelist.Count > 0 ? false : true;
                    rootList[0].expanded = true;
                    rootList[0].nodes    = treelist;
                }
                return(rootList);
            }
        }
Beispiel #6
0
 public List <TreeMonitorModel> GetMonitoreTreeList()
 {
     using (Entities db = new Entities())
     {
         string rootsql = string.Format(@"select fi.unitname as text,fi.unitname as parentname,fi.* from fi_specialunits  fi where fi.parentid=0 order by fi.seq; ");
         List <TreeMonitorModel> treelist = db.Database.SqlQuery <TreeMonitorModel>(rootsql).ToList();
         int?                    rootid   = 0;
         string                  childsql = "";
         TreeMonitorModel        root     = new TreeMonitorModel();
         string                  rosql    = @"select fi.unitname as text,fi.unitname as parentname,fi.* from fi_specialunits fi where fi.parentid is null";
         List <TreeMonitorModel> rootList = db.Database.SqlQuery <TreeMonitorModel>(rosql).ToList();
         for (int i = 0; i < treelist.Count; i++)
         {
             TreeMonitorModel model = treelist[i];
             if (model != null)
             {
                 rootid   = model.seq;
                 childsql = string.Format(@"select fi.unitname as text ,fi.* from fi_specialunits fi where fi.parentid!=0 and fi.parentid={0} order by fi.parentid;", rootid);
                 List <TreeMonitorModel> childList = db.Database.SqlQuery <TreeMonitorModel>(childsql).ToList();
                 foreach (TreeMonitorModel item in childList)
                 {
                     item.children   = new List <TreeMonitorModel>();
                     item.leaf       = true;
                     item.parentname = model.parentname;
                 }
                 model.children = childList;
                 model.expanded = true;
                 model.leaf     = false;
                 if (childList.Count == 0)
                 {
                     model.leaf = true;
                 }
             }
         }
         if (rootList.Count > 0)
         {
             rootList[0].leaf     = treelist.Count > 0 ? false : true;
             rootList[0].expanded = true;
             rootList[0].children = treelist;
         }
         return(rootList);
     }
 }
Beispiel #7
0
 public int EditMonitorePro(TreeMonitorModel model)
 {
     return(dal.EditMonitorePro(model));
 }
Beispiel #8
0
 public int AddMonitorPro(TreeMonitorModel model)
 {
     return(dal.AddMonitorPro(model));
 }