示例#1
0
 public RequestResult <string> LoginOut(MED_USERS user)
 {
     if (HttpContext.Current.Application[user.LOGIN_NAME] != null)
     {
         TransMessageManager tmm = HttpContext.Current.Application[user.LOGIN_NAME] as TransMessageManager;
         tmm.CloseConnection();
         HttpContext.Current.Application.Remove(user.LOGIN_NAME);
     }
     return(Success(""));
 }
示例#2
0
        public RequestResult <MED_USERS> OauthSide(string userJobId)
        {
            MED_USERS User = _accountService.GetUserByUserJobId(userJobId);

            if (User == null)
            {
                return(Failed <MED_USERS>("该用户不存在本系统中"));
            }
            else
            {
                if (User.IS_VALID.ToUpper() != "T")
                {
                    return(Failed <MED_USERS>("该用户未启用"));
                }
                else
                {
                    //获取用户权限信息
                    var    permission = Permission.DataServices.PermissionService.ClientInstance.GetAppPermission("AnesPlatform", User.USER_ID);
                    string user_Role  = "";
                    foreach (var item in permission.MDSD_USER_GROUP)
                    {
                        user_Role += item.GROUP_NAME + ',';
                    }
                    User.USER_ROLE = user_Role;
                    if (user_Role.Contains("主任") || user_Role.Contains("护士长"))
                    {
                        User.IsDirector = true;
                    }
                    else
                    {
                        User.IsDirector = false;
                    }

                    string menus = ""; //菜单
                    foreach (var item in permission.MDSD_APPLICATION.MENU_LIST)
                    {
                        menus += item.MENU_LABEL + ",";
                    }
                    User.Menus = menus;

                    //生成token,SecureKey是配置的web.config中,用于加密token的key,打死也不能告诉别人
                    byte[] key = Encoding.Default.GetBytes(AppSettings.SecureKey);
                    //采用HS256加密算法
                    User.Token = JWT.JsonWebToken.Encode(User, key, JWT.JwtHashAlgorithm.HS256);

                    TransMessageManager tmm = new TransMessageManager(User);
                    tmm.OpenConnection();
                    if (HttpContext.Current.Session[User.LOGIN_NAME] == null)
                    {
                        HttpContext.Current.Session[User.LOGIN_NAME] = tmm;
                    }
                    return(Success(User, ""));
                }
            }
        }
示例#3
0
        public RequestResult <Boolean> SendHeartBeatMessage(MED_USERS user)
        {
            string transmsgInfo     = string.Empty;
            TransMessageManager tmm = null;

            if (HttpContext.Current.Application[user.LOGIN_NAME] == null)
            {
                tmm = new TransMessageManager(user);
                tmm.OpenConnection();
                HttpContext.Current.Application[user.LOGIN_NAME] = tmm;
            }
            else
            {
                tmm = HttpContext.Current.Application[user.LOGIN_NAME] as TransMessageManager;
            }
            tmm.SendHeartBeatMessage();
            return(Success(tmm.GetHasReadMsg()));
        }
示例#4
0
        public RequestResult <string> TransMsgLogin(MED_USERS user)
        {
            string transmsgInfo     = string.Empty;
            TransMessageManager tmm = null;

            if (HttpContext.Current.Application[user.LOGIN_NAME] == null)
            {
                tmm = new TransMessageManager(user);
                tmm.OpenConnection();
                HttpContext.Current.Application[user.LOGIN_NAME] = tmm;
            }
            else
            {
                tmm = HttpContext.Current.Application[user.LOGIN_NAME] as TransMessageManager;
            }
            transmsgInfo = JsonConvert.SerializeObject(tmm.ChildLoginModel).Replace("\"", "\"\"\"");
            return(Success(transmsgInfo));
        }
示例#5
0
        public RequestResult <MED_USERS> Login(dynamic data)
        {
            string    loginName = data.loginName;
            string    passWord  = data.passWord;
            MED_USERS User      = null;

            if (loginName.ToLower() == "mdsd" && passWord.ToLower() == "mdsdss")
            {
                User = new MED_USERS {
                    LOGIN_NAME = loginName.ToUpper(), USER_NAME = loginName.ToUpper(), USER_JOB_ID = loginName.ToUpper(), USER_JOB = "医生", USER_ROLE = "主任,管理员", isMDSD = true
                };
                // 动态加载菜单
                GetReportMenu(data);
                User.MenuList = CheckPermission(null, data.menuList, true);
                return(Success(User, ""));
            }
            else
            {
                if (AppSettings.IsFor5)
                {
                    User = _accountService.LoginFor5(loginName, passWord);
                }
                else
                {
                    User = _accountService.Login(loginName, passWord);
                }
                if (User == null)
                {
                    return(Failed <MED_USERS>("用户名或密码错误!"));
                }
                else
                {
                    if (User.IS_VALID.ToUpper() != "T")
                    {
                        return(Failed <MED_USERS>("该用户名未启用!"));
                    }
                    else
                    {
                        if (AppSettings.IsFor5)
                        {
                            dynamic tempmenuList = new object[2];
                            foreach (var itemnew in data.menuList)
                            {
                                string name = itemnew["name"].Value;
                                if (name != "质控管理" && name != "日常查询" && name != "系统设置")
                                {
                                    continue;
                                }
                                else
                                {
                                    if (name == "日常查询")
                                    {
                                        tempmenuList[0] = itemnew;
                                    }
                                    if (name == "系统设置")
                                    {
                                        tempmenuList[1] = itemnew;
                                    }
                                }
                            }
                            User.MenuList = CheckPermission(_accountService.GetPermissionsFor5(User.USER_ID), tempmenuList);
                        }
                        else
                        {
                            //获取用户权限信息
                            var permission = Permission.DataServices.PermissionService.ClientInstance.GetAppPermission("AnesPlatform2", User.USER_ID);
                            //用户角色
                            StringBuilder sbUserRole = new StringBuilder();
                            foreach (var item in permission.MDSD_USER_GROUP)
                            {
                                sbUserRole.AppendFormat("{0},", item.GROUP_NAME);
                            }
                            User.USER_ROLE = sbUserRole.ToString().TrimEnd(',');
                            if (User.USER_ROLE.Contains("主任") || User.USER_ROLE.Contains("护士长"))
                            {
                                User.IsDirector = true;
                            }
                            else
                            {
                                User.IsDirector = false;
                            }
                            // 系统菜单
                            StringBuilder sbMenus = new StringBuilder();
                            foreach (var item in permission.MDSD_APPLICATION.MENU_LIST)
                            {
                                sbMenus.AppendFormat("{0},", item.MENU_LABEL);
                            }
                            User.Menus = sbMenus.ToString().TrimEnd(',');
                            //生成token,SecureKey是配置的web.config中,用于加密token的key,打死也不能告诉别人
                            byte[] key          = Encoding.Default.GetBytes(AppSettings.SecureKey);
                            var    userSchedule = new MED_USERS_SCHEDULE()
                            {
                                USER_ID     = User.USER_ID,
                                USER_JOB_ID = User.USER_JOB_ID,
                                LOGIN_NAME  = User.LOGIN_NAME,
                                LOGIN_PWD   = User.LOGIN_PWD,
                                USER_NAME   = User.USER_NAME,
                                IS_VALID    = User.IS_VALID,
                                Dept_Name   = User.Dept_Name,
                                USER_JOB    = User.USER_JOB,
                                USER_ROLE   = User.USER_ROLE
                            };
                            // 采用HS256加密算法
                            User.Token = JWT.JsonWebToken.Encode(userSchedule, key, JWT.JwtHashAlgorithm.HS256);
                            // 消息平台登录
                            if (HttpContext.Current.Application[User.LOGIN_NAME] == null)
                            {
                                TransMessageManager tmm = new TransMessageManager(User);
                                System.Threading.Thread.Sleep(1000);
                                tmm.OpenConnection();
                                HttpContext.Current.Application[User.LOGIN_NAME] = tmm;
                            }
                            // 动态加载菜单
                            GetReportMenu(data);
                            // 菜单权限
                            User.MenuList = CheckPermission(permission, data.menuList);
                        }
                        return(Success(User, ""));
                    }
                }
            }
        }
示例#6
0
        public ActionResult Create(MED_VER_INFO verInfo, HttpPostedFileBase postFileBase)
        {
            DapperContext dapper  = new DapperContext("docareConnString");
            string        erroMsg = string.Empty;

            try
            {
                //检测应用程序最大版本号,是否为测试版,如果为测试版又未回退,就不能发布新版
                if (!string.IsNullOrEmpty(verInfo.APP_ID))
                {
                    MED_VER_INFO maxNoVerInfo = dapper.Set <MED_VER_INFO>().Select(x => x.APP_ID.Equals(verInfo.APP_ID)).OrderByDescending(x => x.VER_NO).FirstOrDefault();
                    if (maxNoVerInfo == null || maxNoVerInfo.IS_TEST != 1 || (maxNoVerInfo.IS_TEST == 1 && maxNoVerInfo.ROLL_BACK == 1))
                    {
                        if (Request.Files.Count > 0)
                        {
                            MED_APP_INFO appInfo = dapper.Set <MED_APP_INFO>().Single(x => x.APP_ID.Equals(verInfo.APP_ID));
                            postFileBase = Request.Files[0];
                            //文件上传,一次上传1M的数据,防止出现大文件无法上传
                            uploadStream = postFileBase.InputStream;
                            int    bufferLen  = 1024;
                            byte[] buffer     = new byte[bufferLen];
                            int    contentLen = 0;

                            string fileName = Path.GetFileName(postFileBase.FileName);
                            //判断扩展名
                            string[] extens = new string[] { ".zip" };
                            if (Array.Exists(extens, p => p.ToUpper() == System.IO.Path.GetExtension(fileName).ToUpper()))
                            {
                                string baseUrl    = Server.MapPath("/");
                                string uploadPath = "UpdateFile" + @"\" + appInfo.APP_KEY + @"\";
                                //创建文件夹
                                string[] folderFile = uploadPath.Split(new String[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);
                                String   l          = folderFile.LastOrDefault();
                                string   cPath      = baseUrl;
                                foreach (var item in folderFile)
                                {
                                    if (!item.Contains(":"))
                                    {
                                        cPath += @"\" + item;
                                        if (!Directory.Exists(cPath))
                                        {
                                            Directory.CreateDirectory(cPath);
                                        }
                                    }
                                }
                                //保存文件
                                string newFilename = verInfo.VER_NO + Path.GetExtension(fileName);
                                string newFilePath = baseUrl + @"\" + uploadPath + newFilename;
                                fs = new FileStream(newFilePath, FileMode.Create, FileAccess.ReadWrite);
                                while ((contentLen = uploadStream.Read(buffer, 0, bufferLen)) != 0)
                                {
                                    fs.Write(buffer, 0, bufferLen);
                                    fs.Flush();
                                }
                                fs.Close();
                                verInfo.FILE_PATH = uploadPath + newFilename;
                                //保存数据
                                verInfo.VER_ID      = Guid.NewGuid().ToString();
                                verInfo.CREATE_TIME = DateTime.Now;
                                verInfo.ModelStatus = ModelStatus.Add;
                                bool rest = dapper.Set <MED_VER_INFO>().Save(verInfo);
                                dapper.SaveChanges();
                                MedicalSystem.Services.Logger.Info("上传完成");
                                if (!rest)
                                {
                                    //删除文件
                                    System.IO.File.Delete(newFilePath);
                                    erroMsg = "数据保存失败";
                                }
                                else
                                {
                                    MedicalSystem.Services.Logger.Info("发消息给客户端");
                                    // 发布消息给客户端
                                    MED_USERS user = new MED_USERS {
                                        LOGIN_NAME = "admin", USER_NAME = "admin", USER_JOB_ID = "admin", USER_JOB = "医生", USER_ROLE = "主任,管理员", isMDSD = true
                                    };

                                    if (System.Web.HttpContext.Current.Application["admin"] == null)
                                    {
                                        try
                                        {
                                            MedicalSystem.Services.Logger.Info("消息平台连接");
                                            TransMessageManager tmm = new TransMessageManager(user);
                                            tmm.OpenConnection();
                                            System.Web.HttpContext.Current.Application["admin"] = tmm;
                                            MedicalSystem.Services.Logger.Info("消息平台连接成功");
                                            // 设置消息体
                                            TransMessageModel tm = new TransMessageModel()
                                            {
                                                TargetClientEnumAppType = EnumAppType.AnesWorkStation,
                                                CurEnumMessageType      = EnumMessageType.Broadcase,
                                                CurEnumFunctionType     = EnumFunctionType.HasNewVersion,
                                                SourceClientEnumAppType = EnumAppType.Platform,
                                                MessageContent          = appInfo.APP_KEY
                                            };
                                            MedicalSystem.Services.Logger.Info("发送消息");
                                            tmm.SendMsg(tm);
                                            MedicalSystem.Services.Logger.Info("发送消息完");
                                        }
                                        catch (Exception ex)
                                        {
                                            MedicalSystem.Services.Logger.Info("消息平台错误:" + ex.Message);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                erroMsg = "扩展名必须为zip";
                            }
                        }
                        else
                        {
                            erroMsg = "未选择要上传文件!";
                        }
                    }
                    else
                    {
                        erroMsg = "版本号" + maxNoVerInfo.VER_NO + "是测试版并没有回退版本!";
                    }
                }
                else
                {
                    erroMsg = "没有选择应用程序!";
                }
                if (!string.IsNullOrEmpty(erroMsg))
                {
                    return(Json(erroMsg, "text/html"));
                }
                else
                {
                    return(Json(true, "text/html"));
                }
            }
            catch (Exception ex)
            {
                erroMsg = ex.Message;
                return(Json(erroMsg, "text/html"));
            }
            finally
            {
                if (System.Web.HttpContext.Current.Application["admin"] != null)
                {
                    TransMessageManager tmm = System.Web.HttpContext.Current.Application["admin"] as TransMessageManager;
                    tmm.CloseConnection();
                    System.Web.HttpContext.Current.Application.Remove("admin");
                }
            }
        }