예제 #1
0
        public string Logout(string loginIdentifer)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2.Add("Result", false);
            obj2.Add("Message", "");
            try
            {
                LoginUser loginUser = GlobalAppModule.GetLoginUser(loginIdentifer);
                if (loginUser != null)
                {
                    GlobalAppModule.RemoveLoginUser(loginIdentifer);
                }
                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  = "";
                    SysLogModule.Add(log);
                }
                catch { }
                obj2["Result"] = true;
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string DeleteRole(string loginIdentifer, string roleId)
        {
            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 str = "删除失败";
                if (SysUserModule.GetUserListByRole(long.Parse(roleId)).Count > 0)
                {
                    str = "无法删除有用户数量的角色";
                }
                else
                {
                    if (RoleModule.DeleteRole(long.Parse(roleId)))
                    {
                        str = "删除成功";
                        MenuModule.DeleteRoleMenuByRoleId(long.Parse(roleId));
                        obj2["Result"] = true;
                    }
                }
                obj2["Message"] = str;
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.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() + "|" + roleId;
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #3
0
        public string DeleteUnitQuota(string loginIdentifer, string unitQuotaId)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2["Result"]  = false;
            obj2["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;
            CommonUtil.WaitMainLibInit();
            try
            {
                string msg = CropModule.DeleteCropInfo(long.Parse(unitQuotaId));
                if (msg == "删除成功")//msg.Result
                {
                    GlobalAppModule.IsInitMainLib = true;
                    CropModule.LoadUnitQuotaInfos();
                    GlobalAppModule.IsInitMainLib = false;
                    obj2["Result"]  = true;
                    obj2["Message"] = "成功";
                }
                else
                {
                    obj2["Message"] = msg;
                }
                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  = msg + "|" + unitQuotaId;
                    SysLogModule.Add(log);
                }
                catch { }
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #4
0
        public string DeleteUser(string loginIdentifer, string id)
        {
            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 str = SysUserModule.DeleteUser(long.Parse(id));
                if (str.Contains("删除成功"))
                {
                    obj2["Result"] = true;
                }
                obj2["Message"] = str;
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.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;
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string DeletePriceInfo(string loginIdentifer, string priceId)
        {
            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;
            CommonUtil.WaitMainLibInit();
            ResMsg msg = PriceModule.DeletePriceInfoById(priceId);

            obj2["Result"]  = msg.Result;
            obj2["Message"] = msg.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  = msg + "|" + priceId;
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #6
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));
        }
예제 #7
0
        public string AddUser(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));
                }
                if (SysUserModule.GetUserId(obj3["用户名"].ToString()) > 0)
                {
                    obj2["Message"] = "此用户已经存在!";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                try
                {
                    SysUser user = new SysUser();
                    user.UserName   = obj3["用户名"].ToString();
                    user.Password   = "******";
                    user.RegDate    = DateTime.Now;
                    user.LogonDate  = DateTime.Parse("2000-1-1");
                    user.IsAllow    = 1;
                    user.RoleId     = long.Parse(obj3["角色ID"].ToString());
                    user.DistrictId = long.Parse(obj3["管理ID"].ToString());
                    user.TrueName   = obj3["用户名"].ToString();
                    user.Sex        = "";
                    user.Mobile     = "";
                    user.Address    = "";
                    user.Remark     = "";

                    string str = SysUserModule.AddUser(user);
                    if (str.Contains("添加成功"))
                    {
                        obj2["Result"] = true;
                    }
                    obj2["Message"] = str;

                    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  = str + "|" + ModelHandler <SysUser> .ToString(user);

                        SysLogModule.Add(log);
                    }
                    catch { }
                }
                catch (Exception exception)
                {
                    obj2["Message"] = exception.Message;
                }
            }
            catch (Exception exception2)
            {
                obj2["Message"] = exception2.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #8
0
        public string LoginEx(string LoginName, string LoginPwd, string ValidateCode)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

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

            /*
             * string cookieName = CommonUtil.GetCookieName(this.context.Request, "VCode");
             * if ((base.Session[cookieName] == null) || (base.Session[cookieName].ToString() == ""))
             * {
             *  obj2["Message"] = "请刷新验证码";
             *  return JavaScriptConvert.SerializeObject(obj2);
             * }
             * if (base.Session[cookieName].ToString() != ValidateCode)
             * {
             *  obj2["Message"] = "验证码不正确,请重新输入";
             *  return JavaScriptConvert.SerializeObject(obj2);
             * }
             * */
            /*
             * if (SysInfo.IsReg && !SysInfo.IsRegSuccess)
             * {
             *  obj2["Message"] = "系统未注册";
             *  return JavaScriptConvert.SerializeObject(obj2);
             * }
             */

            if (SysInfo.IsReg)
            {
                string path = context.Server.MapPath("~/");

                SysInfo.SetFilePath(path);

                SysInfo.IsRegSuccess = false;
                string regStr = "";
                if (FileHelper.IsExists(SysInfo.fileName))
                {
                    regStr = FileHelper.ReadFile(SysInfo.fileName);
                }
                else
                {
                    regStr = "00000000000000000000000000000000";
                    FileHelper.writeFile(SysInfo.fileName, regStr);
                }

                if (regStr != SysInfo.GetRegStr2())
                {
                    myLogger.Info("注册码不对!序列号为:" + SysInfo.GetRegStr1());
                    obj2["Message"] = "系统未注册";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                else
                {
                    SysInfo.IsRegSuccess = true;
                }
            }

            try
            {
                long   userID = 0;
                string str3   = SysUserModule.Login(LoginName, LoginPwd, ToolsWeb.GetIP(context.Request), "", ref userID);
                if (str3 == "登陆成功")
                {
                    SysUserModule.OperatorLogin(userID, ToolsWeb.GetIP(context.Request), "");
                    LoginUser loginUser = new LoginUser
                    {
                        UserId         = userID,
                        LoginName      = LoginName,
                        LoginIdentifer = Guid.NewGuid().ToString()
                    };
                    GlobalAppModule.AddLoginUser(loginUser);

                    obj2["Result"] = true;
                    obj2["Guid"]   = loginUser.LoginIdentifer;
                }
                obj2["Message"] = str3;
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
            }

            try
            {
                SysLog log = new SysLog();
                log.LogUserId   = 0;
                log.LogUserName = LoginName;
                log.LogAddress  = ToolsWeb.GetIP(context.Request);
                log.LogTime     = DateTime.Now;
                log.LogType     = "登录";
                log.LogContent  = obj2["Message"].ToString();
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string SetRoleMenu(string loginIdentifer, string roleId, string menuIds)
        {
            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 str = "修改失败";

                try
                {
                    Role role = RoleModule.GetRole(long.Parse(roleId));

                    if (MenuModule.DeleteRoleMenuByRoleId(role.Id))
                    {
                        List <long> list = new List <long>();
                        string[]    strs = menuIds.Trim().Trim(',').Split(',');
                        foreach (string s in strs)
                        {
                            long id = long.Parse(s);
                            Menu m  = MenuModule.GetMenu(id);
                            if (m != null)
                            {
                                list.Add(id);

                                if (!list.Contains(m.ParentId))
                                {
                                    list.Add(m.ParentId);
                                }
                            }
                        }
                        if (strs.Length > 0)
                        {
                            if (MenuModule.AddRoleMenu(role.Id, list.ToArray()))
                            {
                                str            = "修改成功";
                                obj2["Result"] = true;
                            }
                        }
                    }
                    obj2["Message"] = str;
                }
                catch (Exception exception)
                {
                    obj2["Message"] = exception.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() + "|" + roleId + "|" + menuIds;
                    SysLogModule.Add(log);
                }
                catch { }
            }
            catch (Exception exception2)
            {
                obj2["Message"] = exception2.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string DeleteMangeNode(string loginIdentifer, string managerId)
        {
            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;
            CommonUtil.WaitMainLibInit();
            District district = DistrictModule.ReturnDistrictInfo(long.Parse(managerId));

            if (district == null)
            {
                obj2["Message"] = "传入的区域ID不存在";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if (district.ParentId == 0)
            {
                obj2["Message"] = "根节点不允许删除";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            //有设备的节点不能删除
            if (DeviceModule.GetDevicesForManageID(district.Id).Count > 0)
            {
                obj2["Message"] = "此区域下有设备,无法删除";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            string msg = DistrictModule.DeleteDistrictNode(long.Parse(managerId));

            //ResMsg msg = DevicesManager.DeleteManageNode(managerId);
            if (msg == "删除成功")//msg.Result
            {
                GlobalAppModule.IsInitMainLib = true;
                DistrictModule.UpdateDistrictInfo();
                GlobalAppModule.IsInitMainLib = false;

                Thread parameterThread = new Thread(new ParameterizedThreadStart(TcpRunThread.ParameterRun));
                parameterThread.Start(ProtocolConst.WebToGateUpdateCache + ProtocolConst.UpdateCache_District + "01" + "0".PadLeft(16, '0'));

                obj2["Result"]  = true;
                obj2["Message"] = "成功";
            }
            else
            {
                //obj2["Message"] = msg.Message;
                obj2["Message"] = msg;
            }
            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  = msg + "|" + ModelHandler <District> .ToString(district);

                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #11
0
        public string GetFileListDevice(string loginIdentifer, string LoginAddress, string RemoteStation)
        {
            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;

            try
            {
                string        rootpath  = "UploadImg/" + RemoteStation + "/";
                string        path      = Server.MapPath("~/" + rootpath);
                DirectoryInfo TheFolder = new DirectoryInfo(path);
                if (TheFolder.Exists)
                {
                    foreach (FileInfo fi in TheFolder.GetFiles())
                    {
                        JavaScriptObject obj7 = new JavaScriptObject();
                        obj7.Add("fn", fi.Name);
                        obj7.Add("fp", rootpath + fi.Name);
                        obj7.Add("fd", fi.LastWriteTime.ToString("yyyyMMddHHmmssfff"));
                        obj7.Add("fz", fi.Length);
                        //obj7.Add("fm", Encode.GetMD5HashFromFile(fi.FullName));
                        obj7.Add("fm", "");
                        objList.Add(obj7);
                    }

                    obj2["Result"]  = true;
                    obj2["Message"] = "";
                }
                else
                {
                    obj2["Result"]  = true;
                    obj2["Message"] = "";
                }
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
            }

            try
            {
                SysLog log = new SysLog();
                log.LogUserId   = loginUser.UserId;
                log.LogUserName = loginUser.LoginName;
                log.LogAddress  = ToolsWeb.GetIP(context.Request) + " | " + LoginAddress;
                log.LogTime     = DateTime.Now;
                log.LogType     = "获取水文设备可下载文件列表";
                log.LogContent  = obj2["Message"].ToString();
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #12
0
        public string Login(string LoginName, string LoginPwd, string LoginAddress)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

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

            if (SysInfo.IsReg)
            {
                string path = context.Server.MapPath("~/");

                SysInfo.SetFilePath(path);

                SysInfo.IsRegSuccess = false;
                string regStr = "";
                if (FileHelper.IsExists(SysInfo.fileName))
                {
                    regStr = FileHelper.ReadFile(SysInfo.fileName);
                }
                else
                {
                    regStr = "00000000000000000000000000000000";
                    FileHelper.writeFile(SysInfo.fileName, regStr);
                }

                if (regStr != SysInfo.GetRegStr2())
                {
                    myLogger.Info("注册码不对!序列号为:" + SysInfo.GetRegStr1());
                    obj2["Message"] = "系统未注册";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                else
                {
                    SysInfo.IsRegSuccess = true;
                }
            }

            long userID = 0;

            try
            {
                string str3 = SysUserModule.Login(LoginName, LoginPwd, ToolsWeb.GetIP(context.Request), LoginAddress, ref userID);
                if (str3 == "登陆成功")
                {
                    SysUserModule.OperatorLogin(userID, ToolsWeb.GetIP(context.Request), "");
                    LoginUser loginUser = new LoginUser
                    {
                        UserId         = userID,
                        LoginName      = LoginName,
                        LoginIdentifer = Guid.NewGuid().ToString()
                    };
                    GlobalAppModule.AddLoginUser(loginUser);

                    obj2["Result"] = true;
                    obj2["Guid"]   = loginUser.LoginIdentifer;
                }
                obj2["Message"] = str3;
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
            }

            try
            {
                SysLog log = new SysLog();
                log.LogUserId   = userID;
                log.LogUserName = LoginName;
                log.LogAddress  = ToolsWeb.GetIP(context.Request) + " | " + LoginAddress;
                log.LogTime     = DateTime.Now;
                log.LogType     = "android登录";
                log.LogContent  = obj2["Message"].ToString();
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #13
0
        public string UploadFile(string loginIdentifer, string LoginAddress, string filename, string sum, string curr)
        {
            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 fileStr = context.Request["fileStr"];

                //myLogger.Info("sum:" + sum + ",curr:" + curr + ",filename:" + filename + ",length:" + HexStringUtility.HexStringToByteArray(fileStr).Length);
                string appName = loginUser.LoginName + "_fileStrs";

                string[] fileStrs;
                if (int.Parse(curr) == 1)
                {
                    try
                    {
                        SysLog log = new SysLog();
                        log.LogUserId   = loginUser.UserId;
                        log.LogUserName = loginUser.LoginName;
                        log.LogAddress  = ToolsWeb.GetIP(context.Request) + " | " + LoginAddress;
                        log.LogTime     = DateTime.Now;
                        log.LogType     = "android上传文件";
                        log.LogContent  = "sum:" + sum + ",curr:" + curr + ",filename:" + filename;
                        SysLogModule.Add(log);
                    }
                    catch { }

                    if (Application[appName] != null)
                    {
                        //myLogger.Info("上传文件移除已存在的记录fileStrs");
                        Application.Remove(appName);
                    }
                }

                if (Application[appName] != null)
                {
                    fileStrs = (string[])Application[appName];
                }
                else
                {
                    //myLogger.Info("初始化fileStrs,长度:" + int.Parse(sum));
                    fileStrs = new string[int.Parse(sum)];
                    Application.Add(appName, fileStrs);
                }

                fileStrs[int.Parse(curr) - 1] = fileStr;

                obj2["Result"] = true;
                if (sum == curr)
                {
                    obj2["Message"] = "1";//接收完成
                    SaveFile(fileStrs, loginUser.LoginName, filename);
                    if (Application[appName] != null)
                    {
                        //myLogger.Info("接收完成移除已存在的记录fileStrs");
                        Application.Remove(appName);
                    }
                }
                else
                {
                    obj2["Message"] = "0";//继续上传
                }
            }
            catch (Exception ex)
            {
                myLogger.Error(ex.Message);
                obj2["Message"] = "上传文件出错!";
            }

            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string Recharge(string loginIdentifer, string userid1, string userid2, string n)
        {
            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;
            CommonUtil.WaitMainLibInit();

            string msg = "交易失败!";
            long   nl  = 0;

            try
            {
                nl = long.Parse(n);
            }
            catch
            {
            }
            if (nl <= 0)
            {
                msg = "交易失败!水量非法!";
            }
            else
            {
                try
                {
                    WaterUser wu1 = WaterUserModule.GetWaterUserById(long.Parse(userid1));
                    if (wu1.WaterQuota - nl > 0)
                    {
                        WaterUser wu2 = WaterUserModule.GetWaterUserById(long.Parse(userid2));

                        wu2.WaterQuota = wu2.WaterQuota + nl;
                        ResMsg r2 = WaterUserModule.ModifyWaterUser(wu2);
                        if (r2.Result)
                        {
                            wu1.WaterQuota = wu1.WaterQuota - nl;
                            ResMsg r1 = WaterUserModule.ModifyWaterUser(wu1);
                            if (r1.Result)
                            {
                                obj2["Result"] = true;
                                msg            = "交易成功!";
                            }
                            else
                            {
                                wu2            = WaterUserModule.GetWaterUserById(long.Parse(userid2));
                                wu2.WaterQuota = wu2.WaterQuota - nl;
                                WaterUserModule.ModifyWaterUser(wu2);
                                msg = "交易失败!出卖方异常!";
                            }
                        }
                        else
                        {
                            msg = "交易失败!买受方异常!";
                        }
                    }
                    else
                    {
                        msg = "交易失败!水量不足!";
                    }
                }
                catch (Exception ex)
                {
                    msg = "交易失败!" + ex.Message;
                }
            }

            obj2["Message"] = msg;
            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  = msg + "|" + userid1 + "|" + userid2 + "|" + nl;
                SysLogModule.Add(log);
            }
            catch { }

            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string AddRole(string loginIdentifer, string roleJSONString)
        {
            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(roleJSONString);
                if (obj3 == null)
                {
                    obj2["Message"] = "参数格式错误";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                if (RoleModule.GetRoleId(obj3["角色名"].ToString()) > 0)
                {
                    obj2["Message"] = "此角色已经存在!";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }
                try
                {
                    Role role = new Role();
                    role.RoleName = obj3["角色名"].ToString();
                    role.IsAllow  = 1;
                    role.Weight   = 1;

                    string str = "添加失败";
                    if (RoleModule.AddRole(role) > 0)
                    {
                        str            = "添加成功";
                        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() + "|" + roleJSONString;
                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #16
0
        public string AddUnitQuota(string loginIdentifer, string unitQuotaJson)
        {
            JavaScriptObject obj2 = new JavaScriptObject();

            obj2["Result"]  = false;
            obj2["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;
            CommonUtil.WaitMainLibInit();
            JavaScriptObject obj3 = (JavaScriptObject)JavaScriptConvert.DeserializeObject(unitQuotaJson);

            if (obj3 == null)
            {
                obj2["Message"] = "参数格式错误";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            try
            {
                Crop crop = new Crop();
                crop.CropName   = obj3["名称"].ToString();
                crop.WaterPerMu = decimal.Parse(obj3["单位定额"].ToString());
                crop.Remark     = "";

                if (CropModule.ExistsCropName(crop.CropName))
                {
                    obj2["Result"]  = false;
                    obj2["Message"] = "作物名称重复!";
                    return(JavaScriptConvert.SerializeObject(obj2));
                }

                string msg = CropModule.AddCropInfo(crop);
                if (msg == "添加成功")//msg.Result
                {
                    GlobalAppModule.IsInitMainLib = true;
                    CropModule.LoadUnitQuotaInfos();
                    GlobalAppModule.IsInitMainLib = false;
                    obj2["Result"]  = true;
                    obj2["Message"] = "成功";
                }
                else
                {
                    obj2["Message"] = msg;
                }
                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  = msg + "|" + ModelHandler <Crop> .ToString(crop);

                    SysLogModule.Add(log);
                }
                catch { }
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
            }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string ModifyPriceInfo(string loginIdentifer, string priceJson)
        {
            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;
            CommonUtil.WaitMainLibInit();
            JavaScriptObject jso = (JavaScriptObject)JavaScriptConvert.DeserializeObject(priceJson);

            if (jso == null)
            {
                obj2["Message"] = "参数priceJson格式不正确";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            if ((!jso.ContainsKey("ID") || (jso["ID"] == null)) || (jso["ID"].ToString().Trim() == ""))
            {
                obj2["Message"] = "价格ID不能为空";
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            PriceInfo pi = null;

            try
            {
                pi = this.JsonToPriceInfo(jso);
            }
            catch (Exception exception)
            {
                obj2["Message"] = exception.Message;
                return(JavaScriptConvert.SerializeObject(obj2));
            }
            ResMsg msg = PriceModule.ModifyPriceInfo(pi);

            string[]    strArray  = new string[] { "一阶名称", "二阶名称", "三阶名称", "四阶名称" };
            string[]    strArray2 = new string[4];
            string[]    strArray3 = new string[4];
            XmlDocument document  = new XmlDocument();
            string      filename  = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"App_Config\Price.config";

            document.Load(filename);
            XmlNode node  = document.GetElementsByTagName("水价").Item(0);
            XmlNode node2 = document.GetElementsByTagName("电价").Item(0);
            int     num   = int.Parse(document.SelectSingleNode("价格设置/水价/阶梯数量").InnerText);
            int     num2  = int.Parse(document.SelectSingleNode("价格设置/电价/阶梯数量").InnerText);

            for (int i = 0; (i < num) && (i < strArray.Length); i++)
            {
                XmlNode node5 = node.SelectSingleNode(strArray[i]);
                strArray2[i] = node5.InnerText;
            }
            for (int j = 0; (j < num2) && (j < strArray.Length); j++)
            {
                XmlNode node6 = node2.SelectSingleNode(strArray[j]);
                strArray3[j] = node6.InnerText;
            }
            obj2["Result"]  = msg.Result;
            obj2["Message"] = msg.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  = msg + "|" + ModelHandler <PriceInfo> .ToString(pi);

                SysLogModule.Add(log);
            }
            catch { }
            return(JavaScriptConvert.SerializeObject(obj2));
        }
        public string AddMangeNode(string loginIdentifer, string manageJSONString)
        {
            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;
            CommonUtil.WaitMainLibInit();
            JavaScriptObject obj3 = (JavaScriptObject)JavaScriptConvert.DeserializeObject(manageJSONString);

            if (obj3 == null)
            {
                obj2["Message"] = "参数格式错误";
                return(JavaScriptConvert.SerializeObject(obj2));
            }

            District district = new District();

            district.LON          = 0;
            district.LAT          = 0;
            district.ParentId     = long.Parse(obj3["上级ID"].ToString());
            district.DistrictName = obj3["名称"].ToString();
            district.DistrictType = int.Parse(obj3["级别ID"].ToString());
            district.DistrictCode = obj3["编码"].ToString();

            if (DistrictModule.ExistsDistrictName(district.ParentId, district.DistrictName))
            {
                obj2["Result"]  = false;
                obj2["Message"] = "同一级别名称重复!";
                return(JavaScriptConvert.SerializeObject(obj2));
            }

            if (DistrictModule.ExistsDistrictCode(district.ParentId, district.DistrictCode))
            {
                obj2["Result"]  = false;
                obj2["Message"] = "同一级别编码重复!";
                return(JavaScriptConvert.SerializeObject(obj2));
            }

            string msg = DistrictModule.AddDistrictInfo(district);

            //ResMsg msg = DevicesManager.AddManageNode(node);
            if (msg == "添加成功")//msg.Result
            {
                GlobalAppModule.IsInitMainLib = true;
                DistrictModule.UpdateDistrictInfo();
                GlobalAppModule.IsInitMainLib = false;

                Thread parameterThread = new Thread(new ParameterizedThreadStart(TcpRunThread.ParameterRun));
                parameterThread.Start(ProtocolConst.WebToGateUpdateCache + ProtocolConst.UpdateCache_District + "01" + "0".PadLeft(16, '0'));

                obj2["Result"]  = true;
                obj2["Message"] = "成功";
            }
            else
            {
                //obj2["Message"] = msg.Message;
                obj2["Message"] = msg;
            }

            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  = msg + "|" + ModelHandler <District> .ToString(district);

                SysLogModule.Add(log);
            }
            catch { }

            return(JavaScriptConvert.SerializeObject(obj2));
        }
예제 #19
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));
        }