public string AddEnter(DeptInfo deptInfo)
        {
            try
            {
                object o = deptInfoBll.Insert(deptInfo);

                //刷新缓存
                UserInfo user = new UserInfo();
                user = (UserInfo)Session["LoginUser"];

                new LogMessage().Save("名称:" + deptInfo.Businessdivisionname + "。");

                string cache_name = "CurUserTreeModeList_" + user.EnterId;
                if (CacheHelper.Get(cache_name) != null)
                {
                    CacheHelper.Remove(cache_name);
                }

                //刷新部门
                Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "0", "", "", "", "", "", "");
                return(o.ToString());
            }
            catch (Exception)
            {
                return("false");
            }
        }
        public string DelUser(string UserId)
        {
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            if (UserId != null && UserId.Trim() != "")
            {
                UserInfo ui = userInfoBll.GetUserInfo(UserId);
                //删除用户
                int k = userInfoBll.Delete(UserId);

                new LogMessage().Save("ID:" + UserId + "。");

                if (k > 0)
                {
                    //删除设备关联SETMANAGER
                    Transfers.ClintSendCommData(1108, "1", "7", ui.UserLname, "", "", "", "", "", "", "", "", "", "", "", "", "", "", user.UserName);
                    //刷新用户
                    Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "1", "", "", "", "", "", "");

                    return("true");
                }
                else
                {
                    return("false");
                }
            }
            else
            {
                return("false");
            }
        }
        public string ResetUser(string UserId)
        {
            UserInfo ui = new UserInfo();

            ui.UserId      = UserId;
            ui.UserPasswrd = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "md5");
            if (UserId != null && UserId.Trim() != "")
            {
                int k = userInfoBll.ResetUser(ui);
                if (k > 0)
                {
                    //刷新用户
                    Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "1", "", "", "", "", "", "");
                    return("true");
                }
                else
                {
                    return("false");
                }
            }
            else
            {
                return("false");
            }
        }
        public int DelEnter(string Businessdivisionid, string ExistChildren)
        {
            int aa = 0;

            if (ExistChildren == "false")
            {
                aa = deptInfoBll.Delete(Businessdivisionid);
            }
            else if (ExistChildren == "true")
            {
                aa = deptInfoBll.DeleteChildren(Businessdivisionid);
            }

            new LogMessage().Save("ID:" + Businessdivisionid + "。");

            //刷新缓存
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];

            string cache_name = "CurUserTreeModeList_" + user.EnterId;

            if (CacheHelper.Get(cache_name) != null)
            {
                CacheHelper.Remove(cache_name);
            }

            //刷新部门
            Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "0", "", "", "", "", "", "");
            return(aa);
        }
        public ActionResult AddUserForm(UserInfo ui)
        {
            ui.UserId = System.Guid.NewGuid().ToString();

            if (ui.RoleId == null || ui.RoleId == "")
            {
                return(JavaScript("submitFormError('用户角色不能为空');"));
            }
            if (ui.EnterId != null && ui.EnterId != "")
            {
                DeptInfo di = deptInfoBll.GetDeptInfo(ui.EnterId);
                ui.UserDeptcode = di.Businessdivisioncode;
            }
            else
            {
                return(JavaScript("submitFormError('所属企业不正确或者为空');"));
            }
            if (ui.UserPasswrd != null && ui.UserPasswrd != "")
            {
                ui.UserPasswrd = FormsAuthentication.HashPasswordForStoringInConfigFile(ui.UserPasswrd, "md5");
            }
            else
            {
                return(JavaScript("submitFormError('用户密码不能为空');"));
            }
            ui.UserFunct = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,";
            string[] arr = ui.UserFunct.Split(',');
            if (ui.UserFunct1 == "InstallCar")
            {
                arr[19] = "1";
            }
            if (ui.UserFunct2 == "SendCmd")
            {
                arr[18] = "1";
            }
            ui.UserFunct = string.Join(",", arr);
            ui.UserLname = ui.UserLname.Trim();
            int i = userInfoBll.Insert(ui);

            new LogMessage().Save("名称:" + ui.UserName + "。");

            if (i == 0)
            {
                //刷新用户
                Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "1", "", "", "", "", "", "");
                return(JavaScript("submitFormSucceed();"));
            }
            else
            {
                if (i == 2)
                {
                    return(JavaScript("submitFormError('用户名已存在');"));
                }
                else
                {
                    return(JavaScript("submitFormError();"));
                }
            }
        }
        public string Delete(string AreaId)
        {
            //int num = saBll.Delete("AREA_ID='" + AreaId + "'");
            SetArea sa = saBll.GetSetAreaDataById(AreaId);

            Transfers.ClintSendCommData(1107, "36", "", sa.Area_Terno + "&", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
            System.Threading.Thread.Sleep(1000);
            return("删除成功");
        }
        public ActionResult EditUserForm(UserInfo ui, string oldname)
        {
            if (ui.RoleId == null || ui.RoleId == "")
            {
                return(JavaScript("editFormError('用户角色不能为空');"));
            }
            if (ui.EnterId != null && ui.EnterId != "")
            {
                DeptInfo di = deptInfoBll.GetDeptInfo(ui.EnterId);
                ui.UserDeptcode = di.Businessdivisioncode;
            }
            else
            {
                return(JavaScript("editFormError('所属企业不正确或者为空');"));
            }
            ui.UserFunct = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,";
            string[] arr = ui.UserFunct.Split(',');
            if (ui.UserFunct1 == "InstallCar")
            {
                arr[19] = "1";
            }
            if (ui.UserFunct2 == "SendCmd")
            {
                arr[18] = "1";
            }
            ui.UserFunct = string.Join(",", arr);
            if (ui.UserLname != oldname)
            {
                UserInfoBLL userbll = new UserInfoBLL();
                ui.UserLname = ui.UserLname.Trim();
                UserInfo uiObj = userbll.GetUserByLName(ui, out uiObj);
                if (uiObj != null)
                {
                    return(JavaScript("editFormError('该用户名已经存在');"));
                }
            }

            int k = userInfoBll.Update(ui);

            new LogMessage().Save("ID:" + ui.UserId + "。");

            if (k > 0)
            {
                //刷新用户
                Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "1", "", "", "", "", "", "");
                return(JavaScript("editFormSucceed();"));
            }
            else
            {
                return(JavaScript("editFormError();"));
            }
        }
        public ActionResult AddTerUserForm(UserInfo ui, string userters)
        {
            ui.UserId = System.Guid.NewGuid().ToString();
            if (ui.UserPasswrd != null && ui.UserPasswrd != "")
            {
                ui.UserPasswrd = FormsAuthentication.HashPasswordForStoringInConfigFile(ui.UserPasswrd, "md5");
            }
            else
            {
                return(JavaScript("submitFormError('用户密码不能为空');"));
            }
            UserInfo user = new UserInfo();

            user             = (UserInfo)Session["LoginUser"];
            ui.UserLname     = ui.UserLname.Trim();
            ui.UserBuildcode = user.UserDeptcode;
            int i = userInfoBll.Insert(ui);

            //循环加入SETMANAGER
            string[] terno  = userters.Trim().Split(',');
            string   terstr = "";

            foreach (string ter in terno)
            {
                terstr += ter + "&";
            }
            if (i == 0)
            {
                //添加SETMANAGER表的指令
                Transfers.ClintSendCommData(1108, "1", "6", ui.UserLname, "", "", "", "", "", "", "", terstr, "", "", "", "", "", "", user.UserName);
                //刷新用户
                Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "1", "", "", "", "", "", "");
                System.Threading.Thread.Sleep(2000);
                return(JavaScript("submitFormSucceed();"));
            }
            else
            {
                if (i == 2)
                {
                    return(JavaScript("submitFormError('用户名已存在');"));
                }
                else
                {
                    return(JavaScript("submitFormError();"));
                }
            }
        }
        //无线设备的解绑
        public string DelWxLdTer(string carId, string terGuid, string DelStyle)
        {
            UserInfo     user    = (UserInfo)Session["LoginUser"];
            TerminalInfo terinfo = terbll.GetTerminalInfo(terGuid);
            CarInfo      ci      = carInfoBll.GetCarInfoByCarId(carId);

            if (DelStyle == "1")    //全部解绑
            {
                Transfers.ClintSendCommData(1107, "63", "", "", "", "", "", "", "", "", "", ci.CarNo, "", "", "", "", "", "", user.UserName);
            }
            else                    //单台解绑
            {
                Transfers.ClintSendCommData(1107, "631", "", terinfo.TerNo, "", "", "", "", "", "", "", ci.CarNo, "", "", "", "", "", "", user.UserName);
            }
            System.Threading.Thread.Sleep(2000);
            return("true");
        }
Exemplo n.º 10
0
        public ActionResult EditPWD(UserInfo clsUserInfo)
        {
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];

            if (FormsAuthentication.HashPasswordForStoringInConfigFile(clsUserInfo.OldPasswrd.Trim(), "md5") != user.UserPasswrd)
            {
                return(JavaScript("editFormError('修改失败,旧密码不正确!');"));
            }
            else if (clsUserInfo.UserPasswrd.Trim() != clsUserInfo.UserRePasswrd.Trim())
            {
                return(JavaScript("editFormError('修改失败,新密码不一致!');"));
            }
            else
            {
                UserInfo Userobj = new UserInfo();

                Userobj.UserPasswrd = FormsAuthentication.HashPasswordForStoringInConfigFile(clsUserInfo.UserPasswrd, "md5");
                Userobj.UserLname   = clsUserInfo.UserLname;
                ResultState result = userInfoBll.ModifyUserPWD(Userobj);

                new LogMessage().Save("用户:" + user.UserLname + "修改密码;");

                switch (result)
                {
                case ResultState.SUCCEED:
                    //刷新用户
                    Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "1", "", "", "", "", "", "");
                    return(JavaScript("editFormSucceed();"));

                case ResultState.ERROR:
                    return(JavaScript("editFormError('');"));

                case ResultState.EXIST:
                    return(JavaScript("editFormExist();"));

                default:
                    return(JavaScript("editFormSucceed();"));
                }
            }
        }
Exemplo n.º 11
0
        public string AddCarAndTer(TerminalBind tb)
        {
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            if (user != null)
            {
                if (tb.DeptId != null && tb.DeptId.Trim() == "")
                {
                    tb.DeptId = user.EnterId;
                }
                DeptInfoBLL deptInfoBll = new DeptInfoBLL();
                DeptInfo    di          = deptInfoBll.GetDeptInfo(tb.DeptId);
                string      deptcode    = di.Businessdivisioncode;
                tb.Businessdivisioncode = deptcode;
                string     carinfostr = "";
                CarTypeBLL cartypebll = new CarTypeBLL();
                CarType    ct         = cartypebll.GetCarType(tb.TypeId);
                if (ct != null)
                {
                    carinfostr = ct.TypeName + "||||||||||||||||||||||||||||||";
                }
                string result = tib.AddCarAndTer(tb);

                new LogMessage().Save("TerNo:" + tb.TerNo + "。");

                if (result == "true")
                {
                    //绑车接口
                    Transfers.ClintSendCommData(1107, "50", "", tb.CarNo, "", "", "", "", "", "", "", deptcode, tb.CarNo, carinfostr, "", "", "", "", user.UserName);

                    //刷新车辆
                    Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "2", "", "", "", "", "", "");
                }
                return(result);
            }
            else
            {
                return("false");
            }
        }
Exemplo n.º 12
0
        public ActionResult EditTerUserForm(UserInfo ui, string oldname, string userters)
        {
            if (ui.UserLname != oldname)
            {
                UserInfoBLL userbll = new UserInfoBLL();
                ui.UserLname = ui.UserLname.Trim();
                UserInfo uiObj = userbll.GetUserByLName(ui, out uiObj);
                if (uiObj != null)
                {
                    return(JavaScript("editFormError('该用户名已经存在');"));
                }
            }
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            string[] terno  = userters.Trim().Split(',');
            string   terstr = "";

            foreach (string ter in terno)
            {
                terstr += ter + "&";
            }
            int k = userInfoBll.Update(ui);

            new LogMessage().Save("ID:" + ui.UserId + "。");

            if (k > 0)
            {
                //修改SETMANAGER表的指令
                Transfers.ClintSendCommData(1108, "1", "6", ui.UserLname, "", "", "", "", "", "", "", terstr, "", "", "", "", "", "", user.UserName);
                //刷新用户
                Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "1", "", "", "", "", "", "");
                System.Threading.Thread.Sleep(2000);
                return(JavaScript("editFormSucceed();"));
            }
            else
            {
                return(JavaScript("editFormError();"));
            }
        }
        public string DelCarInfo(string carId, string terGuid)
        {
            new LogMessage().Save("CarNo:" + carId + ";");
            UserInfo     user    = (UserInfo)Session["LoginUser"];
            TerminalInfo terinfo = terbll.GetTerminalInfo(terGuid);
            string       result  = "";
            int          cnt     = terbll.GetTerminalCountByCarId(carId);

            if (cnt > 1)
            {
                result = carInfoBll.Delete(terGuid, true);
            }
            else
            {
                result = carInfoBll.Delete(carId, false);
            }

            //解绑接口
            if (terGuid != "")
            {
                Transfers.ClintSendCommData(1107, "501", "", terinfo.TerNo, "", "", "", "", "", "", "", "", "", "", "", "", "", "", user.UserName);
            }
            return(result);
        }
Exemplo n.º 14
0
        public ActionResult UpLoadForm(string DeptId, HttpPostedFileBase file)
        {
            //CreateExcel();
            if (file != null && file.ContentLength > 0 && DeptId != null && DeptId.Trim() != "")
            {
                string filePath = Path.Combine(HttpContext.Server.MapPath("../Files"), System.Guid.NewGuid().ToString() + Path.GetExtension(file.FileName));
                file.SaveAs(filePath);

                new LogMessage().Save("文件:" + filePath + "。");

                string               val = "";
                ExcelUpLoad          eu  = new ExcelUpLoad();
                string               msg = "";
                List <UpLoadTerBind> lut = eu.ReadExcel(filePath, ref msg);

                if (lut != null && lut.Count > 0)
                {
                    val = tib.InsertExcelData(DeptId, lut);
                    DeptInfoBLL deptInfoBll = new DeptInfoBLL();
                    DeptInfo    di          = deptInfoBll.GetDeptInfo(DeptId);
                    string      deptcode    = di.Businessdivisioncode;
                    UserInfo    user        = (UserInfo)Session["LoginUser"];
                    for (int m = 0; m < lut.Count; m++)
                    {
                        if (!val.Contains(lut[m].TerNo) && val != "false")
                        {
                            string tertype = "";
                            if (lut[m].TerType == "一代无线GPS")
                            {
                                tertype = "104";
                            }
                            else if (lut[m].TerType == "二代无线GPS")
                            {
                                tertype = "102";
                            }
                            else if (lut[m].TerType == "Homer3M" || lut[m].TerType == "Homer3B-2")
                            {
                                tertype = "101";
                            }
                            else if (lut[m].TerType == "五代无线GPS")
                            {
                                tertype = "112";
                            }
                            else if (lut[m].TerType == "五代有线GPS")
                            {
                                tertype = "111";
                            }
                            //添加终端的接口
                            Transfers.ClintSendCommData(1108, "2", "1", lut[m].TerNo, "", "", "", lut[m].TerInnettime.ToString("yyyy-MM-dd HH:mm:ss"), "", "", "", deptcode, lut[m].SimCard, tertype, "", "", "", "", user.UserName);
                        }
                    }

                    ViewBag.ReturnVal = val.Trim(',');
                }
                else if (msg.Trim() != "")
                {
                    ViewBag.ReturnVal = msg;
                }
                else
                {
                    ViewBag.ReturnVal = "false";
                }
            }
            else if (DeptId == null || DeptId.Trim() == "")
            {
                ViewBag.ReturnVal = "请选择导入终端的企业";
            }
            else if (file == null || file.ContentLength <= 0)
            {
                ViewBag.ReturnVal = "请选择导入的文件!";
            }
            return(View());
        }
Exemplo n.º 15
0
        public ActionResult EditNode(DeptInfo Dept)
        {
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];

            if (Dept.Businessdivisionid == user.EnterId) //"52c96c61-8532-4ace-ab6e-2be214289280"
            {
                ModelState.AddModelError("", "修改失败");
                return(JavaScript("editFormError('不能修改根企业');"));
            }
            if (Dept.Fatherid == "" || Dept.Fatherid == null)
            {
                ModelState.AddModelError("", "修改失败");
                return(JavaScript("editFormError('上级企业不能为空');"));
            }
            else
            {
                DeptInfo di = deptInfoBll.GetDeptInfo(Dept.Fatherid);
                if (di.Businessdivisioncode.StartsWith(Dept.Businessdivisioncode))
                {
                    ModelState.AddModelError("", "修改失败");
                    return(JavaScript("editFormError('所选企业不能把自己的子企业修改为父企业');"));
                }
            }

            if (string.IsNullOrEmpty(Dept.Businessdivisionname))
            {
                ModelState.AddModelError("", "修改失败");
                return(JavaScript("editFormError('企业名称不能为空');"));
            }
            else
            {
                List <string> OldDeptCode = new List <string>();
                List <string> NewDeptCode = new List <string>();
                int           k           = deptInfoBll.Update(Dept, OldDeptCode, NewDeptCode);
                if (k > 0)
                {
                    UpdateState();

                    new LogMessage().Save("ID:" + Dept.Businessdivisionid + "。");

                    string cache_name = "CurUserTreeModeList_" + user.EnterId;
                    if (CacheHelper.Get(cache_name) != null)
                    {
                        CacheHelper.Remove(cache_name);
                    }
                    if (OldDeptCode.Count > 0 && NewDeptCode.Count > 0)
                    {
                        for (int i = 0; i < OldDeptCode.Count; i++)
                        {
                            //部门流转修改终端部门
                            Transfers.ClintSendCommData(1108, "0", "3", "", "", "", "", "", "", "", "", OldDeptCode[i], NewDeptCode[i], "", "", "", "", "", user.UserName);
                        }
                    }
                    //刷新部门
                    Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "0", "", "", "", "", "", "");
                    ModelState.AddModelError("", "修改成功");
                    return(JavaScript("editFormSucceed();"));
                }
                else
                {
                    ModelState.AddModelError("", "修改失败");
                    return(JavaScript("editFormError();"));
                }
            }
        }
        public string AddCarIdstr(string SelectTerNoStr, string AreaType, string AreaData, string AreaMaptype, string CenterloglatZoom)
        {
            string   result = "";
            UserInfo user   = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            var DeptCode = "";
            var UserName = "";

            if (user != null)
            {
                UserName = user.UserName;
                DeptCode = user.UserDeptcode;
            }

            string[]        TerNoStr = SelectTerNoStr.Trim(',').Split(',');
            Regex           regex    = new Regex("(?<=\\()[^\\(\\)]*(?=\\))");
            MatchCollection m        = regex.Matches(AreaData);
            StringBuilder   sb       = new StringBuilder();

            if (AreaType == "0") //方形
            {
                if (m.Count == 2)
                {
                    string[] str = m[0].ToString().Split(',');
                    sb.Append(str[1].Trim() + "," + str[0].Trim() + "|");
                    str = m[1].ToString().Split(',');
                    sb.Append(str[1].Trim() + "," + str[0].Trim());
                }
            }
            else if (AreaType == "1") //圆形
            {
                string[] strdata = AreaData.Split('$');
                if (m.Count > 0)
                {
                    string[] str = m[0].ToString().Split(',');
                    sb.Append(str[1].Trim() + "," + str[0].Trim() + "|" + strdata[1].Trim());
                }
            }
            else if (AreaType == "2") //多边
            {
                for (int i = 0; i < m.Count; i++)
                {
                    string[] str = m[i].ToString().Split(',');
                    if (i != m.Count - 1)
                    {
                        sb.Append(str[1].Trim() + "," + str[0].Trim() + "|");
                    }
                    else
                    {
                        sb.Append(str[1].Trim() + "," + str[0].Trim());
                    }
                }
            }
            foreach (var terno in TerNoStr)
            {
                result += terno + "&";
            }
            if (result != "")
            {
                Transfers.ClintSendCommData(1107, "35", "", result, AreaMaptype, AreaType, "", "", "", "", "", DeptCode, UserName, sb.ToString(), CenterloglatZoom, "", "", "", "");
                System.Threading.Thread.Sleep(1000);
                return("成功");
            }
            else
            {
                return("未选择设备!");
            }
        }
        public ActionResult CarInfoForm(CarInfo carInfo, string Hid_FieldsVal, string TerGuid, string TypeName)
        {
            if (carInfo.CarNo != null && carInfo.CarNo.Trim() != "")
            {
                new LogMessage().Save("CarNo:" + carInfo.CarNo + ";");

                ArrayList arr = new ArrayList();
                carInfo.CarId = System.Guid.NewGuid().ToString();
                if (carInfo.Businessdivisionid != null || carInfo.Businessdivisionid.Trim() != "")
                {
                    DeptInfo di = deptInfoBll.GetDeptInfo(carInfo.Businessdivisionid);
                    carInfo.CarDeptcode = di.Businessdivisioncode;
                }
                else
                {
                    ViewBag.Result = "所属企业不正确或者为空";
                    return(View());
                }
                arr.Add(carInfo);

                if (TerGuid != null && TerGuid.Trim() != "")
                {
                    arr.Add(TerGuid);
                }
                else
                {
                    ViewBag.Result = "终端号不正确或者为空";
                    return(View());
                }

                string kku = carInfoBll.InsertCarInfo(arr, TypeName);
                ViewBag.Result = kku;

                //绑定车辆终端
                UserInfo user      = (UserInfo)Session["LoginUser"];
                string   carhbinfo = "";
                if (carInfo.CarColor != "" || TypeName != "")
                {
                    string cartypename = "";
                    if (TypeName.Split('-').Length == 3)
                    {
                        cartypename = TypeName.Split('-')[2];
                    }
                    else
                    {
                        cartypename = TypeName;
                    }

                    carhbinfo = cartypename + "|" + carInfo.CarColor + "|||||||||||||||||||||||||||||";
                }
                string[] terguids = TerGuid.Split(',');
                foreach (string terguid in terguids)
                {
                    TerminalInfoBLL terbll  = new TerminalInfoBLL();
                    TerminalInfo    terinfo = terbll.GetTerminalInfo(terguid);
                    if (terinfo != null && terinfo.TerNo != "")
                    {
                        Transfers.ClintSendCommData(1107, "50", "", terinfo.TerNo, "", "", "", "", "", "", "", carInfo.CarDeptcode, carInfo.CarNo, carhbinfo, carInfo.CarAdminName, carInfo.CarFrame, "", "", user.UserName);
                    }
                }
                //刷新车辆
                //Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "2", "", "", "", "", "", "");
                return(View());
            }
            else
            {
                ViewBag.Result = "false";
                return(View());
            }
        }
        public ActionResult EditCarInfoForm(CarInfo carInfo, string Hid_TerNo, string Hid_OldCarno, string TypeName, string flag)
        {
            new LogMessage().Save("CarNo:" + carInfo.CarNo + ";");
            UserInfo user = (UserInfo)Session["LoginUser"];

            if (carInfo.Businessdivisionid != null || carInfo.Businessdivisionid.Trim() != "")
            {
                DeptInfo di = deptInfoBll.GetDeptInfo(carInfo.Businessdivisionid);
                carInfo.CarDeptcode = di.Businessdivisioncode;
            }
            carInfo.Description = carInfo.Description.Trim();

            string carhbinfo = "";

            if (carInfo.CarColor != "" || TypeName != "")
            {
                string cartypename = "";
                if (TypeName.Split('-').Length == 1)
                {
                    cartypename = TypeName.Split('-')[0];
                }
                else
                {
                    cartypename = TypeName.Split('-')[2] == null ? "" : TypeName.Split('-')[2];
                }
                carhbinfo = cartypename + "|" + carInfo.CarColor + "|||||||||||||||||||||||||||||";
            }

            RealtimeData rdinfo = realtimedatabll.GetRealtimeData(Hid_TerNo);

            if (rdinfo.Rawdataid != null && rdinfo.Rawdataid != "")
            {
                string NewCarno = carInfo.CarNo;
                carInfo.CarNo = Hid_OldCarno;
                string kku = carInfoBll.UpdateCarType(carInfo, TypeName);
                ViewBag.Result = kku;

                //修改联动车辆发送的指令
                Transfers.ClintSendCommData(1107, "551", "", Hid_OldCarno, "", "", "", "", "", "", "", carInfo.CarDeptcode, NewCarno, carhbinfo, carInfo.CarAdminName, carInfo.CarFrame, "", "", user.UserName);
                System.Threading.Thread.Sleep(2000);
            }
            else
            {
                ArrayList arr = new ArrayList();
                arr.Add(carInfo);
                string kku = carInfoBll.UpdateCarInfo(arr, TypeName);
                ViewBag.Result = kku;
                //修改普通车辆发送的指令
                TerminalInfoBLL      terbll      = new TerminalInfoBLL();
                IList <TerminalInfo> terinfolist = terbll.GetTerminalInfoByCarId(carInfo.CarId);
                foreach (TerminalInfo terinfo in terinfolist)
                {
                    if (terinfo != null && terinfo.TerNo != "")
                    {
                        Transfers.ClintSendCommData(1107, "50", "", terinfo.TerNo, "", "", "", "", "", "", "", carInfo.CarDeptcode, carInfo.CarNo, carhbinfo, carInfo.CarAdminName, carInfo.CarFrame, "", "", user.UserName);
                    }
                }
            }
            ViewBag.flag = flag;
            return(View());
        }
        public ActionResult UpLoadCarInfoForm(string DeptId, HttpPostedFileBase file)
        {
            UserInfo user = new UserInfo();

            user = (UserInfo)Session["LoginUser"];
            if (file != null && file.ContentLength > 0 && DeptId != null && DeptId.Trim() != "")
            {
                string filePath = Path.Combine(HttpContext.Server.MapPath("../Files"), System.Guid.NewGuid().ToString() + Path.GetExtension(file.FileName));

                file.SaveAs(filePath);

                new LogMessage().Save("文件:" + filePath + ";");

                string val = "";
                string msg = "";

                ExcelUpLoad eu = new ExcelUpLoad();

                List <UpLoadTerBind> lut = eu.ReadCarInfo_ZNX(filePath, ref msg);
                if (lut != null && lut.Count > 0)
                {
                    val = carInfoBll.insertCarInfoMul(DeptId, lut);
                    if (val.LastIndexOf(",") > 0)
                    {
                        val = val.Substring(0, val.Length - 1);
                    }
                    ViewBag.ReturnVal = val;

                    //绑车接口
                    for (int i = 0; i < lut.Count; i++)
                    {
                        string CarDeptcode = "";
                        string TypeName    = "";
                        if (lut[i].BusinessDivisionId != "" && lut[i].BusinessDivisionId != null)
                        {
                            DeptInfo di = deptInfoBll.GetDeptInfo(lut[i].BusinessDivisionId);
                            CarDeptcode = di.Businessdivisioncode;
                        }
                        if (lut[i].CarType != "" && lut[i].CarType != null)
                        {
                            CarTypeBLL cartypebll = new CarTypeBLL();
                            CarType    ct         = cartypebll.GetCarType(lut[i].CarType);
                            if (ct != null)
                            {
                                TypeName = ct.TypeName;
                            }
                        }

                        string carinfostr = TypeName + "|" + lut[i].CarColor + "|||||||||||||||||||||||||||||";

                        Transfers.ClintSendCommData(1107, "50", "", lut[i].TerNo, "", "", "", "", "", "", "", CarDeptcode, lut[i].CarNo, carinfostr, lut[i].CarAdminName, lut[i].CarFrame, "", "", user.UserName);
                    }
                }
                else if (msg.Trim() != "")
                {
                    if (msg.LastIndexOf(",") > 0)
                    {
                        msg = msg.Substring(0, msg.Length - 1);
                    }
                    ViewBag.ReturnVal = msg;
                }
                else
                {
                    ViewBag.ReturnVal = "false";
                }
            }
            else if (DeptId == null || DeptId.Trim() == "")
            {
                ViewBag.ReturnVal = "请选择导入车辆的所属企业!";
            }
            else if (file == null || file.ContentLength <= 0)
            {
                ViewBag.ReturnVal = "请选择要导入的文件!";
            }
            //刷新车辆
            Transfers.ClintSendCommData(1160, "1108", "", "", "", "", "", "", "", "", "", "1", "2", "", "", "", "", "", "");
            return(View());
        }