Пример #1
0
 public ActionResult Edit([Bind(Include = "id,type,settable")] dev_dict dev_dict)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dev_dict).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dev_dict));
 }
Пример #2
0
        public ActionResult UpdateGB(FormCollection formcollection, device device)    //[Bind(Include = "alias, site, dev_type, dev_model, uuid, rtsp_url, account, password")
        {
            gensysEntities gensysdb = new gensysEntities();

            if (ModelState.IsValid)
            {
                device device_old = gensysdb.device.Find(device.uuid);
                if (device == null)
                {
                    return(HttpNotFound());
                }
                gensysdb.device.Remove(device_old);
                gensysdb.device.Add(device);
            }

            string camuuid1 = formcollection["cam_uuid1"];
            string algo1    = formcollection["algo1"];
            string cpunum1  = formcollection["cpu_num1"];

            string camuuid2 = formcollection["cam_uuid2"];
            string algo2    = formcollection["algo2"];
            string cpunum2  = formcollection["cpu_num2"];

            string camuuid3 = formcollection["cam_uuid3"];
            string algo3    = formcollection["algo3"];
            string cpunum3  = formcollection["cpu_num3"];

            device availableuuid1 = gensysdb.device.Find(camuuid1);
            device availableuuid2 = gensysdb.device.Find(camuuid2);
            device availableuuid3 = gensysdb.device.Find(camuuid3);

            ipcam cam1, cam2, cam3;

            //判断,如果三个输入的uuid不是空,且查询device表,不存在这个uuid或者不是ipcam的话就不添加
            if (camuuid1 != "" && (availableuuid1 == null || availableuuid1.dev_type == "GenBox" || availableuuid1.dev_type == "声波盾") ||
                camuuid2 != "" && (availableuuid2 == null || availableuuid2.dev_type == "GenBox" || availableuuid2.dev_type == "声波盾") ||
                camuuid3 != "" && (availableuuid3 == null || availableuuid3.dev_type == "GenBox" || availableuuid3.dev_type == "声波盾"))
            {
                var script = string.Format("<script>alert('添加的uuid有问题,请检查后重新输入!');location.href='{0}'</script>", Url.Action("Index", "DeviceMana"));
                //Url.Action()用于指定跳转的路径
                return(Content(script, "text/html"));
            }
            else
            {
                if (camuuid1 != "" && cpunum1 != "")
                {
                    genbox_cpu add1 = new genbox_cpu();
                    add1.ipcam_uuid  = camuuid1;
                    add1.genbox_uuid = device.uuid;
                    add1.algo_value  = algo1;
                    add1.cpu_num     = cpunum1;
                    gensysdb.genbox_cpu.Add(add1);

                    cam1 = gensysdb.ipcam.Find(camuuid1);   //要和数据库字段的类型一致
                    if (cam1 == null)
                    {
                        return(HttpNotFound());
                    }
                    switch (algo1)
                    {
                    case "ebd":
                        cam1.ebd_cpu = int.Parse(cpunum1); break;

                    case "fsd":
                        cam1.fsd_cpu = int.Parse(cpunum1); break;

                    case "opa4t":
                        cam1.opa4t_cpu = int.Parse(cpunum1); break;

                    case "pfr":
                        cam1.pfr_cpu = int.Parse(cpunum1); break;

                    case "ssc":
                        cam1.ssc_cpu = int.Parse(cpunum1); break;

                    case "wca":
                        cam1.wca_cpu = int.Parse(cpunum1); break;
                    }
                    gensysdb.Entry(cam1).State = System.Data.Entity.EntityState.Modified;
                    gensysdb.SaveChanges();
                }
                else if (camuuid1 == "" && cpunum1 == "")
                {
                }
                else
                {
                    var script = string.Format("<script>alert('有表格项未填写完整!');location.href='{0}'</script>", Url.Action("Index", "DeviceMana"));
                    //Url.Action()用于指定跳转的路径
                    return(Content(script, "text/html"));
                }
                if (camuuid2 != "" && cpunum2 != "")
                {
                    genbox_cpu add2 = new genbox_cpu();
                    add2.ipcam_uuid  = camuuid2;
                    add2.genbox_uuid = device.uuid;
                    add2.algo_value  = algo2;
                    add2.cpu_num     = cpunum2;
                    gensysdb.genbox_cpu.Add(add2);

                    cam2 = gensysdb.ipcam.Find(camuuid2);   //要和数据库字段的类型一致
                    if (cam2 == null)
                    {
                        return(HttpNotFound());
                    }
                    switch (algo2)
                    {
                    case "ebd":
                        cam2.ebd_cpu = int.Parse(cpunum2); break;

                    case "fsd":
                        cam2.fsd_cpu = int.Parse(cpunum2); break;

                    case "opa4t":
                        cam2.opa4t_cpu = int.Parse(cpunum2); break;

                    case "pfr":
                        cam2.pfr_cpu = int.Parse(cpunum2); break;

                    case "ssc":
                        cam2.ssc_cpu = int.Parse(cpunum2); break;

                    case "wca":
                        cam2.wca_cpu = int.Parse(cpunum2); break;
                    }
                    //gensysdb.Entry(cam2).State = System.Data.Entity.EntityState.Modified;
                    gensysdb.SaveChanges();
                }
                else if (camuuid2 == "" && cpunum2 == "")
                {
                }
                else
                {
                    var script = string.Format("<script>alert('有表格项未填写完整!');location.href='{0}'</script>", Url.Action("Index", "DeviceMana"));
                    //Url.Action()用于指定跳转的路径
                    return(Content(script, "text/html"));
                }
                if (camuuid3 != "" && cpunum3 != "")
                {
                    genbox_cpu add3 = new genbox_cpu();
                    add3.ipcam_uuid  = camuuid3;
                    add3.genbox_uuid = device.uuid;
                    add3.algo_value  = algo3;
                    add3.cpu_num     = cpunum3;
                    gensysdb.genbox_cpu.Add(add3);

                    cam3 = gensysdb.ipcam.Find(camuuid3);   //要和数据库字段的类型一致
                    if (cam3 == null)
                    {
                        return(HttpNotFound());
                    }
                    switch (algo3)
                    {
                    case "ebd":
                        cam3.ebd_cpu = int.Parse(cpunum3); break;

                    case "fsd":
                        cam3.fsd_cpu = int.Parse(cpunum3); break;

                    case "opa4t":
                        cam3.opa4t_cpu = int.Parse(cpunum3); break;

                    case "pfr":
                        cam3.pfr_cpu = int.Parse(cpunum3); break;

                    case "ssc":
                        cam3.ssc_cpu = int.Parse(cpunum3); break;

                    case "wca":
                        cam3.wca_cpu = int.Parse(cpunum3); break;
                    }
                    //gensysdb.Entry(cam3).State = System.Data.Entity.EntityState.Modified;
                    gensysdb.SaveChanges();
                }
                else if (camuuid3 == "" && cpunum3 == "")
                {
                }
                else
                {
                    var script = string.Format("<script>alert('有表格项未填写完整!');location.href='{0}'</script>", Url.Action("Index", "DeviceMana"));
                    //Url.Action()用于指定跳转的路径
                    return(Content(script, "text/html"));
                }
            }
            gensysdb.SaveChanges();

            GenboxHelper.ipcam_setup_set(db, device);

            return(RedirectToAction("Index"));//return Redirect("index");//return Json("fsdfds");// return JavaScript("location.reload()");
        }
Пример #3
0
        public ActionResult EditTrg(FormCollection collection)
        {
            //生成repeat
            var Mon  = collection["Mon"];
            var Tues = collection["Tues"];
            var Wed  = collection["Wed"];
            var Thur = collection["Thur"];
            var Fri  = collection["Fri"];
            var Sat  = collection["Sat"];
            var Sun  = collection["Sun"];
            //过滤 hidden false
            var repeat = "";

            if (Mon.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Tues.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Wed.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Thur.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Fri.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Sat.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }
            if (Sun.Contains("true"))
            {
                repeat += "1";
            }
            else
            {
                repeat += "0";
            }

            linkage_trigger trg = new linkage_trigger();

            trg.id      = int.Parse(collection["id2"]);
            trg.delay   = int.Parse(collection["delay2"]);
            trg.repeat  = repeat;
            trg.trigger = collection["trigger2"];

            db.Entry <linkage_trigger>(trg).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }