Exemple #1
0
        public string GetDeviceList(string loginIdentifer, string LoginAddress, string deviceNo)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");

            JavaScriptArray objList = new JavaScriptArray();

            obj2.Add("List", objList);

            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;

            SysUser user = SysUserModule.GetUser(loginUser.UserId);

            if (user != null)
            {
                List <long>   list_DistrictID = DistrictModule.GetAllDistrictID(user.DistrictId);
                List <Device> list_Device     = DeviceModule.GetAllDevice();
                foreach (Device device in list_Device)
                {
                    if (list_DistrictID.Contains(device.DistrictId))
                    {
                        if (deviceNo == "" || DeviceModule.GetFullDeviceNoByID(device.Id).Contains(deviceNo))
                        {
                            objList.Add(DeviceNodeToJson(device));
                        }
                    }
                }
                obj2["Result"]  = true;
                obj2["Message"] = "";
            }
            else
            {
                obj2["Message"] = "未查找到用户";
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string GetDeviceNodeInfosByLoginUser(string loginIdentifer)
        {
            JavaScriptObject obj2  = new JavaScriptObject();
            JavaScriptArray  array = new JavaScriptArray();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            obj2.Add("DeviceInfo", array);
            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;
            return(this.GetDeviceNodeInfosByMnId(loginIdentifer, SysUserModule.GetUser(loginUser.UserId).DistrictId.ToString(), true, false));

            /*
             * string userInfo = "";
             * if (!(UserModule.GetUserInfo(loginUser.UserId, "自定义测点") == "是"))
             * {
             *  return this.GetDeviceNodeInfosByMnId(loginIdentifer, UserModule.GetUserInfo(loginUser.UserId, "管理ID"), true, false);
             * }
             * userInfo = UserModule.GetUserInfo(loginUser.UserId, "设备ID");
             * if (userInfo != "")
             * {
             *  string[] strArray = userInfo.Split(new char[] { ',' });
             *  DeviceNode deviceNodeByID = null;
             *  for (int i = 0; i < userInfo.Length; i++)
             *  {
             *      deviceNodeByID = DevicesManager.GetDeviceNodeByID(strArray[i]);
             *      if (deviceNodeByID != null)
             *      {
             *          array.Add(this.DeviceNodeToJson(deviceNodeByID));
             *      }
             *  }
             *  obj2["Result"] = true;
             * }
             * return JavaScriptConvert.SerializeObject(obj2);
             * */
        }
        public string GetLevelInfos(string loginIdentifer)
        {
            JavaScriptObject obj2  = new JavaScriptObject();
            JavaScriptArray  array = new JavaScriptArray();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            obj2.Add("LevelNodes", array);
            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;
            CommonUtil.WaitMainLibInit();
            string levelID = DistrictModule.ReturnDistrictInfo(SysUserModule.GetUser(loginUser.UserId).DistrictId).DistrictType.ToString();

            string[] allLevelID = DistrictModule.GetAllLevelID();
            if (allLevelID != null)
            {
                for (int i = 0; i < (allLevelID.Length - 1); i++)
                {
                    try
                    {
                        if (Convert.ToInt32(allLevelID[i]) < Convert.ToInt32(levelID))
                        {
                            continue;
                        }
                    }
                    catch
                    {
                    }
                    array.Add(this.LevelInfoToJson(allLevelID[i]));
                }
                obj2["Result"] = true;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string GetSystemStateInfo(string loginIdentifer)
        {
            JavaScriptObject obj2 = new JavaScriptObject();
            JavaScriptObject obj3 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            obj2.Add("SysStateInfo", obj3);
            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;
            CommonUtil.WaitMainLibInit();
            SysUser user = SysUserModule.GetUser(loginUser.UserId);

            if (user == null)
            {
                obj2["Message"] = "ID为" + loginUser.UserId + "的用户不存在";
            }
            else
            {
                obj2["Result"] = true;
                obj3.Add("通讯服务器连接状态", isConnect ? "正常" : "中断");
                obj3.Add("当前登录操作员名称", user.UserName);
                obj3.Add("当前登录操作员管理ID", user.DistrictId);
                obj3.Add("当前登录操作员角色ID", user.RoleId);
                obj3.Add("远程客户端的IP主机地址", this.context.Request.UserHostAddress);
                obj3.Add("监测点级别名称", "设备");
                obj3.Add("监测点管理名称", "设备");
                obj3.Add("系统名称", "水资源管理平台");
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
Exemple #5
0
        public string GetUserInfosByIds(string loginIdentifer, string ids)
        {
            JavaScriptObject obj2  = new JavaScriptObject();
            JavaScriptArray  array = new JavaScriptArray();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            obj2.Add("UserNodes", new JavaScriptObject());
            string[] strArray = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            try
            {
                ResMsg msg = CommonUtil.CheckLoginState(loginIdentifer, true);
                if (!msg.Result)
                {
                    obj2["Message"] = msg.Message;
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                try
                {
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        SysUser userInfo = SysUserModule.GetUser(long.Parse(((strArray[i] == null) || (strArray[i].Trim() == "")) ? msg.Message : strArray[i]));
                        if (userInfo != null)
                        {
                            array.Add(this.UserInfoToJSON(userInfo));
                        }
                    }
                    obj2["UserNodes"] = array;
                    obj2["Result"]    = true;
                }
                catch (Exception exception)
                {
                    obj2["Message"] = exception.Message;
                }
            }
            catch (Exception exception2)
            {
                obj2["Message"] = exception2.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string GetGlobalAlarmInfos(string loginIdentifer)
        {
            if (strDisposeAlarmCookieName == "")
            {
                strDisposeAlarmCookieName = CommonUtil.GetCookieName(this.context.Request, "DisposeAlarmTime");
            }
            JavaScriptObject obj2  = new JavaScriptObject();
            JavaScriptArray  array = new JavaScriptArray();

            obj2.Add("CookieName", strDisposeAlarmCookieName);
            obj2.Add("AlarmRecords", array);

            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                return(JavaScriptConvert.SerializeObject(obj2));
            }

            string str = DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd HH:mm:ss");

            if (this.context.Session["QueryAlarmStartTime"] != null)
            {
                str = this.context.Session["QueryAlarmStartTime"].ToString();
            }
            else
            {
                string str2 = this.context.Server.UrlEncode(strDisposeAlarmCookieName);
                if (this.context.Request.Cookies[str2] != null)
                {
                    str = this.context.Server.UrlDecode(this.context.Request.Cookies[str2].Value);
                }
                this.context.Session["QueryAlarmStartTime"] = str;
            }
            DateTime now = DateTime.Now;

            if (!CommonUtil.CheckTableExiste("DeviceAlarm_" + now.Year.ToString()))
            {
                return(JavaScriptConvert.SerializeObject(obj2));
            }

            string      deviceNoFulls         = "";
            List <long> allDevicesForManageID = DeviceModule.GetAllDevicesForManageID(SysUserModule.GetUser(loginUser.UserId).DistrictId);

            for (int i = 0; i < allDevicesForManageID.Count; i++)
            {
                deviceNoFulls += "'" + DeviceModule.GetFullDeviceNoByID(allDevicesForManageID[i]) + "',";
            }

            if (deviceNoFulls == "")
            {
                return(JavaScriptConvert.SerializeObject(obj2));
            }

            string sqlstr = "select * from DeviceAlarm_" + now.Year.ToString() + " a " +
                            " where a.DeviceNo in (" + deviceNoFulls.TrimEnd(',') + ") and a.State = 'New'" +
                            " and a.StartTime > '" + str.ToString() + "' and a.StartTime <= '" + now.ToString("yyyy-MM-dd HH:mm:ss") + "'" +
                            " order by a.id";
            DataTable table = DbHelperSQL.QueryDataTable(sqlstr);

            if (table != null)
            {
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    string AlarmType      = table.Rows[i]["AlarmType"].ToString();
                    string AlarmValue     = table.Rows[i]["AlarmValue"].ToString();
                    string AlarmTypeDesc  = "";
                    string AlarmValueDesc = "";
                    bool   flag           = false;
                    if (AlarmType == "1" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "交流电充电状态";
                        AlarmValueDesc = "停电";
                        flag           = true;
                    }
                    else if (AlarmType == "2" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "蓄电池电压状态";
                        AlarmValueDesc = "电压低";
                        flag           = true;
                    }
                    else if (AlarmType == "3" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "水位超限报警状态";
                        AlarmValueDesc = "报警";
                        flag           = true;
                    }
                    else if (AlarmType == "4" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "流量超限报警状态";
                        AlarmValueDesc = "报警";
                        flag           = true;
                    }
                    else if (AlarmType == "5" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "电压状态";
                        AlarmValueDesc = "报警";
                        flag           = true;
                    }
                    else if (AlarmType == "6" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "流量仪表状态";
                        AlarmValueDesc = "故障";
                        flag           = true;
                    }
                    else if (AlarmType == "7" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "水位仪表状态";
                        AlarmValueDesc = "故障";
                        flag           = true;
                    }
                    else if (AlarmType == "9" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "存储器状态";
                        AlarmValueDesc = "异常";
                        flag           = true;
                    }
                    else if (AlarmType == "12" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "水量超采";
                        AlarmValueDesc = "异常";
                        flag           = true;
                    }
                    else if (AlarmType == "13" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "回路报警";
                        AlarmValueDesc = "报警";
                        flag           = true;
                    }
                    else if (AlarmType == "14" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "输入断相";
                        AlarmValueDesc = "断相";
                        flag           = true;
                    }
                    else if (AlarmType == "15" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "输出断相";
                        AlarmValueDesc = "断相";
                        flag           = true;
                    }
                    else if (AlarmType == "16" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "电表信号报警";
                        AlarmValueDesc = "故障";
                        flag           = true;
                    }
                    else if (AlarmType == "17" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "过载报警";
                        AlarmValueDesc = "故障";
                        flag           = true;
                    }
                    else if (AlarmType == "18" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "用户剩余水量";
                        AlarmValueDesc = "故障";
                        flag           = true;
                    }
                    else if (AlarmType == "19" && AlarmValue == "1")
                    {
                        AlarmTypeDesc  = "用户剩余电量";
                        AlarmValueDesc = "故障";
                        flag           = true;
                    }
                    if (flag)
                    {
                        JavaScriptObject item = new JavaScriptObject();
                        item.Add("单位名称", table.Rows[i]["DeviceNo"].ToString());
                        item.Add("测点名称", table.Rows[i]["DeviceNo"].ToString());
                        item.Add("报警时间", table.Rows[i]["StartTime"].ToString());
                        item.Add("报警类型", AlarmTypeDesc);
                        item.Add("报警描述", AlarmTypeDesc + ":" + AlarmValueDesc);
                        array.Add(item);
                    }
                }
            }

            this.context.Session["QueryAlarmStartTime"] = now.ToString("yyyy-MM-dd HH:mm:ss");
            return(JavaScriptConvert.SerializeObject(obj2));
        }
Exemple #7
0
        public string ModifyPassWord(string loginIdentifer, string id, string oldPwd, string newPwd)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;
            try
            {
                string message = "";

                if ((id == null) || (id.Trim() == ""))
                {
                    if (SysUserModule.GetUser(long.Parse(message)) == null)
                    {
                        obj2["Message"] = "要修改密码的用户不存在";
                        return(JavaScriptConvert.SerializeObject(obj2));
                    }
                    id = message;
                }
                try
                {
                    string str2 = SysUserModule.ModifyPassWord(long.Parse(id), oldPwd, newPwd);
                    if (str2.Contains("修改成功"))
                    {
                        obj2["Result"] = true;
                    }
                    obj2["Message"] = str2;
                }
                catch (Exception exception)
                {
                    obj2["Message"] = exception.Message;
                }
            }
            catch (Exception exception2)
            {
                obj2["Message"] = exception2.Message;
            }
            try
            {
                SysLog log = new SysLog();
                log.LogUserId   = loginUser.UserId;
                log.LogUserName = loginUser.LoginName;
                log.LogAddress  = ToolsWeb.GetIP(context.Request);
                log.LogTime     = DateTime.Now;
                log.LogType     = "修改用户密码";
                log.LogContent  = obj2["Message"].ToString() + "|" + id + "【" + oldPwd + "】【" + newPwd + "】";
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
Exemple #8
0
        public string ModifyUser(string loginIdentifer, string userJSONString)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            if (loginUser == null)
            {
                obj2["Message"] = "未登录";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (loginUser.LoginTimeout)
            {
                obj2["Message"] = "登录超时";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            loginUser.LastOperateTime = DateTime.Now;
            try
            {
                JavaScriptObject obj3 = (JavaScriptObject)JavaScriptConvert.DeserializeObject(userJSONString);
                if (obj3 == null)
                {
                    obj2["Message"] = "参数格式错误";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }

                try
                {
                    SysUser user = SysUserModule.GetUser(long.Parse(obj3["ID"].ToString()));
                    user.UserName   = obj3["用户名"].ToString();
                    user.RoleId     = long.Parse(obj3["角色ID"].ToString());
                    user.DistrictId = long.Parse(obj3["管理ID"].ToString());
                    user.TrueName   = obj3["用户名"].ToString();

                    long existsId = SysUserModule.GetUserId(user.UserName);
                    if (existsId > 0 && existsId != user.ID)
                    {
                        obj2["Message"] = "此用户已经存在!";
                        return(JavaScriptConvert.SerializeObject(obj2));
                    }

                    string str = SysUserModule.ModifyUser(user);
                    if (str.Contains("修改成功"))
                    {
                        obj2["Result"] = true;
                    }
                    obj2["Message"] = str;
                }
                catch (Exception exception)
                {
                    obj2["Message"] = exception.Message;
                }
            }
            catch (Exception exception2)
            {
                obj2["Message"] = exception2.Message;
            }

            try
            {
                SysLog log = new SysLog();
                log.LogUserId   = loginUser.UserId;
                log.LogUserName = loginUser.LoginName;
                log.LogAddress  = ToolsWeb.GetIP(context.Request);
                log.LogTime     = DateTime.Now;
                log.LogType     = "修改用户";
                log.LogContent  = obj2["Message"].ToString() + "|" + userJSONString;
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
Exemple #9
0
        //上传文件
        private string upSingleFile(HttpPostedFile file, byte typeStr, LoginUser loginUser, long DevId)
        {
            if (!SystemService.isConnect)
            {
                return("no|与通讯服务器连接中断!");
            }
            Device device = DeviceModule.GetDeviceByID(DevId);

            if (device == null)
            {
                return("no|要操作的设备不存在!");
            }

            string DeviceNo = DeviceModule.GetFullDeviceNoByID(device.Id);

            string infos  = "";
            bool   fileOK = false;
            string fileExtension;
            string fileName = System.IO.Path.GetFileName(file.FileName);

            if (fileName != "")
            {
                if (file.ContentLength >= 1024 * 1024 * 1)
                {
                    infos = "no|文件太大,目前仅支持1M以内的文档!";
                }
                else
                {
                    string theFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + DeviceNo + "_" + System.IO.Path.GetFileNameWithoutExtension(fileName);
                    if (typeStr == 0x01)
                    {
                        theFileName += ".jpg";
                    }
                    else if (typeStr == 0x02)
                    {
                        theFileName += ".bin";
                    }

                    fileExtension = System.IO.Path.GetExtension(fileName).ToLower();
                    //String[] allowedExtensions = { ".jpg", ".jpeg", ".gif", ".bmp", ".png", ".icon" };
                    String[] allowedExtensions = { };
                    if (allowedExtensions.Length > 0)
                    {
                        for (int i = 0; i < allowedExtensions.Length; i++)
                        {
                            if (fileExtension == allowedExtensions[i])
                            {
                                fileOK = true;
                                break;
                            }
                        }
                    }
                    else
                    {
                        fileOK = true;
                    }

                    if (!fileOK)
                    {
                        infos = "no|不支持上传此类型文件!目前支持的图片格式有:" + String.Join("|", allowedExtensions);
                    }
                    else
                    {
                        /**********start update by kqz 2017-3-8*****************/
                        //int packetSize = 230;
                        int packetSize = 256;
                        /**********end update by kqz 2017-3-8 20:27****************/
                        string        path = System.Web.HttpContext.Current.Request.MapPath("~/UploadFiles/User/" + loginUser.LoginName + "/");
                        DirectoryInfo dir  = new DirectoryInfo(path);
                        if (!dir.Exists)
                        {
                            dir.Create();
                        }
                        file.SaveAs(path + theFileName);

                        byte[] bsOld = new byte[file.ContentLength];
                        file.InputStream.Read(bsOld, 0, bsOld.Length);
                        file.InputStream.Seek(0, SeekOrigin.Begin);
                        //start update by kqz 2017-3-20
                        int count = 0;
                        //Debug.Print("len =========" + file.ContentLength);
                        //int count = file.ContentLength / packetSize + 1;
                        if ((file.ContentLength % packetSize) == 0)
                        {
                            count = file.ContentLength / packetSize;
                        }
                        else
                        {
                            count = file.ContentLength / packetSize + 1;
                        }
                        //end update by kqz 2017-3-20
                        //byte[] bsNew = new byte[file.ContentLength];

                        for (int i = 0; i < count; i++)
                        {
                            #region 发送数据
                            try
                            {
                                byte[] bs;
                                if (i != count - 1)
                                {
                                    bs = new byte[packetSize];
                                }
                                else
                                {
                                    bs = new byte[file.ContentLength - packetSize * i];
                                }

                                if (i == 0)
                                {
                                    bs    = new byte[packetSize + 1];
                                    bs[0] = typeStr;
                                    Array.Copy(bsOld, 0, bs, 1, bs.Length - 1);
                                    //update by kqz 2017-3-20
                                    //Array.Copy(bsOld, 0, bs, 1, bs.Length - 1);
                                    //Array.Copy(bs, 1, bsNew, 0, bs.Length - 1);
                                }
                                else
                                {
                                    Array.Copy(bsOld, packetSize * i, bs, 0, bs.Length);
                                    //}
                                    //Array.Copy(bsOld, packetSize * i - 1, bs, 0, bs.Length);
                                    //Array.Copy(bs, 0, bsNew, packetSize * i - 1, bs.Length);
                                }
                                Debug.Print("aaaaaaaaaaaaaaaaaaaaaa------------------\r\n");
                                CmdToDtuSendFile cmd = new CmdToDtuSendFile();
                                cmd.AddressField = DeviceNo.Substring(0, 12) + Convert.ToInt32(DeviceNo.Substring(12, 3)).ToString("X").PadLeft(2, '0');
                                cmd.StationType  = (byte)device.StationType;
                                cmd.StationCode  = device.StationType == 2 ? device.StationCode : 0;
                                cmd.Sum          = (short)count;
                                cmd.Curr         = (short)(i + 1);
                                cmd.Content      = bs;
                                cmd.RawDataChar  = cmd.WriteMsg();
                                cmd.RawDataStr   = HexStringUtility.ByteArrayToHexString(cmd.RawDataChar);

                                DeviceOperation op = new DeviceOperation();
                                op.DeviceNo      = DeviceNo;
                                op.DeviceName    = device.DeviceName;
                                op.OperationTime = DateTime.Now;
                                op.OperationType = "中心下发文件";
                                op.RawData       = cmd.RawDataStr;
                                op.Remark        = cmd.Sum + "|" + cmd.Curr;
                                op.UserId        = loginUser.UserId;
                                op.UserName      = SysUserModule.GetUser(loginUser.UserId).UserName;
                                op.State         = "等待发送";

                                myLogger.Info(op.OperationType + ":" + cmd.RawDataStr);
                                byte[] cmd_send = cmd.RawDataChar;
                                myLogger.Error((i + 1).ToString().PadLeft(count.ToString().Length, '0') + ":" + cmd.RawDataStr);

                                ResMsg resMsg = SendCmd(cmd_send);
                                #region 判断结果
                                if (resMsg.Result)
                                {
                                    if (resMsg.Message == BaseProtocol.DeviceOffline)
                                    {
                                        infos = "no|查询终端不在线!";
                                    }
                                    else
                                    {
                                        byte[]      cmd_receive = HexStringUtility.HexStringToByteArray(resMsg.Message);
                                        BaseMessage message     = new BaseMessage();
                                        message.RawDataChar = cmd_receive;
                                        string msg = message.ReadMsg();
                                        //myLogger.Error("------------------the id is ========= +" +cmd_receive[19] +"  ff \r\n");
                                        //if (cmd_receive[19] == 0x00)
                                        //{
                                        // op.State = "发送失败";
                                        // infos = "no|" + "终端正忙,请稍候传输数据!";
                                        //return "发送失败,终端正忙,请稍候传输数据!";
                                        // }
                                        if (msg == "")
                                        {
                                            CmdResponseToDtuSendFile res = new CmdResponseToDtuSendFile(message);
                                            string msg1 = res.ReadMsg();
                                            if (msg1 == "")
                                            {
                                                if (res.Result == 1)
                                                {
                                                    op.State = "发送成功";
                                                    //infos = "yes|结果为1,继续";
                                                }
                                                else
                                                {
                                                    op.State = "发送成功";
                                                    infos    = "no|结果为0,退出";
                                                }
                                            }
                                            else
                                            {
                                                op.State = "发送失败";
                                                infos    = "no|" + msg1;
                                            }
                                        }
                                        else
                                        {
                                            op.State = "发送失败";
                                            infos    = "no|" + msg;
                                        }

                                        if (cmd_receive[19] == 0x00)
                                        {
                                            op.State = "发送失败";
                                            infos    = "no|" + "终端正忙,请稍候传输数据!";
                                            //return "发送失败,终端正忙,请稍候传输数据!";
                                        }

                                        if (i == count - 1)
                                        {
                                            op.State = "发送成功";
                                            infos    = "no|结果为0,退出";
                                        }
                                    }
                                }
                                else
                                {
                                    return("发送失败");
                                }
                                #endregion
                                if (infos.StartsWith("no|"))
                                {
                                    op.State += "|" + infos.Split('|')[1];
                                }
                                DeviceOperationModule.AddDeviceOperation(op);
                                if (op.State.Contains("发送失败"))
                                {
                                    myLogger.Error((i + 1).ToString().PadLeft(count.ToString().Length, '0') + "-" + count + ":" + infos);
                                    return(infos);
                                }
                            }
                            catch (Exception e)
                            {
                                myLogger.Error((i + 1).ToString().PadLeft(count.ToString().Length, '0') + "-" + count + ":出错,发送失败" + e.Message + "  the trace :" + e.StackTrace);
                                //return "no|" + (i + 1);
                            }
                            #endregion
                        }


                        infos = "yes|" + theFileName.Split('_')[2];
                    }
                }
            }
            else
            {
                infos = "no|未选择文件!";
            }
            return(infos);
        }
        public string GetMainMenu(string loginIdentifer)
        {
            JavaScriptArray array     = new JavaScriptArray();
            LoginUser       loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);

            try
            {
                if (loginUser != null)
                {
                    DataTable table = new DataTable();
                    table.Columns.Add("ID");
                    table.Columns.Add("Order", typeof(int));
                    Dictionary <string, JavaScriptObject> dictionary = new Dictionary <string, JavaScriptObject>();
                    SysUser     user             = SysUserModule.GetUser(loginUser.UserId);
                    long        roleId           = user.RoleId;
                    List <Menu> menuItemByRoleID = MenuModule.GetMenuItemByRoleID(roleId);
                    foreach (Menu items in menuItemByRoleID)
                    {
                        if (items.ParentId == 0)
                        {
                            JavaScriptObject obj2   = new JavaScriptObject();
                            JavaScriptArray  array2 = new JavaScriptArray();
                            table.Rows.Add(new object[] { items.Id, Convert.ToInt32(items.OrderNumber) });
                            obj2.Add("菜单ID", items.Id);
                            obj2.Add("父菜单ID", items.ParentId);
                            obj2.Add("菜单名称", items.MenuName);
                            obj2.Add("入口URL", items.MenuUrl.Trim());
                            obj2.Add("相关文件", items.CssFile.Trim());
                            obj2.Add("子菜单", array2);
                            DataTable table2 = table.Clone();
                            Dictionary <string, JavaScriptObject> dictionary2 = new Dictionary <string, JavaScriptObject>();
                            foreach (Menu items2 in menuItemByRoleID)
                            {
                                if (items2.ParentId == items.Id)
                                {
                                    table2.Rows.Add(new object[] { items2.Id, Convert.ToInt32(items2.OrderNumber) });
                                    JavaScriptObject obj3 = new JavaScriptObject();
                                    obj3.Add("菜单ID", items2.Id);
                                    obj3.Add("父菜单ID", items2.ParentId);
                                    obj3.Add("菜单名称", items2.MenuName);
                                    obj3.Add("入口URL", items2.MenuUrl.Trim());
                                    obj3.Add("相关文件", items2.CssFile.Trim());
                                    dictionary2.Add(items2.Id.ToString(), obj3);
                                }
                            }
                            table2.DefaultView.Sort = "Order Asc";
                            table2 = table2.DefaultView.ToTable();
                            for (int j = 0; j < table2.Rows.Count; j++)
                            {
                                array2.Add(dictionary2[table2.Rows[j]["ID"].ToString()]);
                            }
                            dictionary.Add(items.Id.ToString(), obj2);
                        }
                    }
                    table.DefaultView.Sort = "Order Asc";
                    table = table.DefaultView.ToTable();
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        array.Add(dictionary[table.Rows[i]["ID"].ToString()]);
                    }
                }
            }
            catch
            {
            }
            return(JavaScriptConvert.SerializeObject(array));
        }