public void Login()
        {
            try
            {
                string strUsertitle = FormData["txtUserName"];
                string strPassWord = FormData["txtUserPWD"];
                string strIP = FormData["txtUserIP"];
                string strMac = FormData["txtMac"];

                User user = NewObject<User>();
                bool islogin = user.UserLogin(strUsertitle, strPassWord);


                if (islogin)
                {

                    BaseUser EbaseUser = user.GetUser(strUsertitle);
                    SysLoginRight right = new SysLoginRight();
                    right.UserId = EbaseUser.UserId;
                    right.EmpId = EbaseUser.EmpId;
                    right.WorkId = EbaseUser.WorkId;
                    oleDb.WorkId = EbaseUser.WorkId;

                    Dept dept = NewObject<Dept>();
                    BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId);
                    if (EbaseDept != null)
                    {
                        right.DeptId = EbaseDept.DeptId;
                        right.DeptName = EbaseDept.Name;
                    }

                    BaseEmployee EbaseEmp = (BaseEmployee)NewObject<BaseEmployee>().getmodel(EbaseUser.EmpId);
                    right.EmpName = EbaseEmp.Name;

                    BaseWorkers EbaseWork = (BaseWorkers)NewObject<BaseWorkers>().getmodel(EbaseUser.WorkId);
                    right.WorkName = EbaseWork.WorkName;

                    if (EbaseWork.DelFlag == 0)
                    {
                        string regkey = EbaseWork.RegKey;
                        DESEncryptor des = new DESEncryptor();
                        des.InputString = regkey;
                        des.DesDecrypt();
                        string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' });
                        if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now)
                        {
                            if (PutOutData.ContainsKey("RoleUser")) PutOutData.Remove("RoleUser");
                            PutOutData.Add("RoleUser", right);
                            if (PutOutData.ContainsKey("WorkId")) PutOutData.Remove("WorkId");
                            PutOutData.Add("WorkId", right.WorkId);

                            DataTable ListModeules = ConvertExtend.ToDataTable(NewObject<Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList());
                            List<BaseMenu> listM = NewObject<Menu>().GetMenuList(right.UserId);
                            //给菜单url后面绑定MenuId参数
                            for (int i = 0; i < listM.Count; i++)
                            {
                                listM[i].UrlName = ConvertExtend.UrlAddParams(listM[i].UrlName, "MenuId", listM[i].MenuId.ToString());
                            }
                            DataTable ListMenus = ConvertExtend.ToDataTable(listM);
                            DataTable ListDepts = ConvertExtend.ToDataTable(NewObject<Dept>().GetHaveDept(right.EmpId));
                            DataTable ListGroups = ConvertExtend.ToDataTable(NewObject<Group>().GetGroupList(right.UserId));

                            if (PutOutData.ContainsKey("ListModeules")) PutOutData.Remove("ListModeules");
                            PutOutData.Add("ListModeules", ListModeules);
                            if (PutOutData.ContainsKey("ListMenus")) PutOutData.Remove("ListMenus");
                            PutOutData.Add("ListMenus", ListMenus);
                            if (PutOutData.ContainsKey("ListDepts")) PutOutData.Remove("ListDepts");
                            PutOutData.Add("ListDepts", ListDepts);
                            if (PutOutData.ContainsKey("ListGroups")) PutOutData.Remove("ListGroups");
                            PutOutData.Add("ListGroups", ListGroups);

                            JsonResult = RetSuccess("");
                        }
                        else
                        {
                            //throw new Exception("登录用户的当前机构注册码不正确!");
                            JsonResult = RetError("登录用户的当前机构注册码不正确!");
                        }
                    }
                    else
                    {
                        //throw new Exception("登录用户的当前机构还未启用!");
                        JsonResult = RetError("登录用户的当前机构还未启用!");
                    }
                }
                else
                {
                    //throw new Exception("输入的用户名密码不正确!");
                    JsonResult = RetError("输入的用户名密码不正确!");
                }
                //JsonResult = RetSuccess("");
            }
            catch (Exception err)
            {
                //ZhyContainer.CreateException().HandleException(err, "HISPolicy");
                JsonResult = RetError("登录失败,请联系系统管理员!" + err.Message);
            }
        }
        public string BalancePres(string visitNO)
        {
            try
            {
                //  string visitNO = "34";
                int           empid  = 100;
                int           deptid = 1048;
                SysLoginRight sys    = new EFWCoreLib.CoreFrame.Business.SysLoginRight();
                sys.WorkId = 1;
                //获取病人信息
                Action <ClientRequestData> requestAction = ((ClientRequestData request) =>
                {
                    request.LoginRight = sys;
                    request.AddData(6);
                    request.AddData(visitNO);
                });
                ServiceResponseData retdata = InvokeWcfService("OPProject.Service", "BalanceController", "GetRegPatListByCardNo", requestAction);
                List <OP_PatList>   patlist = retdata.GetData <List <OP_PatList> >(0);
                if (patlist.Count == 0)
                {
                    return("Falg:1");
                }
                OP_PatList curPatlist = patlist[0];
                //获取处方
                requestAction = ((ClientRequestData request) =>
                {
                    request.LoginRight = sys;
                    request.AddData(curPatlist.PatListID);
                    request.AddData(OP_Enum.PresStatus.未收费);
                });
                retdata = InvokeWcfService("OPProject.Service", "BalanceController", "GetPatPrescription", requestAction);
                DataTable dtPresc = retdata.GetData <DataTable>(0);
                //预算
                List <Prescription> budgePres     = new List <Prescription>();
                List <int>          budgeNums     = new List <int>();
                List <Prescription> prescriptions = EFWCoreLib.CoreFrame.Common.ConvertExtend.ToList <Prescription>(dtPresc);
                budgeNums = GetBudgePrescriptionAmbitList(prescriptions);
                if (budgeNums.Count == 0)
                {
                    throw new Exception("没有选中的处方需要收费");
                }
                budgePres = prescriptions.Where(p => p.Selected == 1 && p.SubTotalFlag == 0).ToList();

                requestAction = ((ClientRequestData request) =>
                {
                    request.LoginRight = sys;
                    request.AddData(budgePres);            //处方
                    request.AddData(empid);                //操作员ID
                    request.AddData(curPatlist);           //当前病人对象
                    request.AddData(curPatlist.PatTypeID); //结算病人类型
                    request.AddData(budgeNums);            //选中的处方张数
                });
                retdata = InvokeWcfService("OPProject.Service", "BalanceController", "BudgeBalance", requestAction);
                List <ChargeInfo> budgeInfo = retdata.GetData <List <ChargeInfo> >(0);
                //正式结算
                List <OP_CostPayMentInfo> paylist = new List <OP_CostPayMentInfo>();

                OP_CostPayMentInfo payment = new OP_CostPayMentInfo();
                payment.PayMentID    = 1002;
                payment.PayMentMoney = 600;
                paylist.Add(payment);

                budgeInfo[0].PayInfoList       = paylist;
                budgeInfo[0].PayTotalFee       = 600;
                budgeInfo[0].FavorableTotalFee = 0;
                budgeInfo[0].PosFee            = 0;
                budgeInfo[0].CashFee           = 600;//现金
                budgeInfo[0].RoundFee          = 0;
                budgeInfo[0].ChangeFee         = 0;
                requestAction = ((ClientRequestData request) =>
                {
                    request.LoginRight = sys;
                    request.AddData(budgePres);  //费用明细对象
                    request.AddData(empid);      //操作员ID
                    request.AddData(curPatlist); //当前病人对象
                    request.AddData(budgeInfo);  //预算对象
                    request.AddData(1);
                    request.AddData(empid);
                    request.AddData(deptid);
                });
                retdata = InvokeWcfService("OPProject.Service", "BalanceController", "Balance", requestAction);
                return("Falg:0");
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }
        }
        public string UserLogin()
        {
            //UseDb("SQL20052");
            //string strsql = @"select count(*) from appcenter";
            //object o = oleDb.GetDataResult(strsql);
            //UseDb();

            string usercode = ToArray(ParamJsonData)[0].ToString();
            string password = ToArray(ParamJsonData)[1].ToString();

            User user = NewObject<User>();
            bool islogin = user.UserLogin(usercode, password);

            if (islogin)
            {
                BaseUser EbaseUser = user.GetUser(usercode);
                SysLoginRight right = new SysLoginRight();
                right.UserId = EbaseUser.UserId;
                right.EmpId = EbaseUser.EmpId;
                right.WorkId = EbaseUser.WorkId;

                Dept dept = NewObject<Dept>();
                BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId);
                if (EbaseDept != null)
                {
                    right.DeptId = EbaseDept.DeptId;
                    right.DeptName = EbaseDept.Name;
                }

                BaseEmployee EbaseEmp = (BaseEmployee)NewObject<BaseEmployee>().getmodel(EbaseUser.EmpId);
                right.EmpName = EbaseEmp.Name;

                BaseWorkers EbaseWork = (BaseWorkers)NewObject<BaseWorkers>().getmodel(EbaseUser.WorkId);
                right.WorkName = EbaseWork.WorkName;

                if (EbaseWork.DelFlag == 0)
                {
                    string regkey = EbaseWork.RegKey;
                    DESEncryptor des = new DESEncryptor();
                    des.InputString = regkey;
                    des.DesDecrypt();
                    string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' });
                    if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now)
                    {
                        ClientInfo.LoginRight = right;//缓存登录用户信息

                        Object[] retObjs = new Object[]{
                            right.EmpName,right.DeptName,right.WorkName
                            ,NewObject<Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList()
                            ,NewObject<Menu>().GetMenuList(right.UserId)
                            ,NewObject<Dept>().GetHaveDept(right.EmpId)
                            ,right
                        };
                        return ToJson(retObjs);
                    }
                    else
                    {
                        throw new Exception("登录用户的当前机构注册码不正确!");
                    }
                }
                else
                {
                    throw new Exception("登录用户的当前机构还未启用!");
                }
            }
            else
            {
                throw new Exception("输入的用户名密码不正确!");
            }
        }
        //调试免登录
        private void DebugLogin()
        {
            #region 进入调试模式

            if (AppPluginManage.getbaseinfoDataValue(_pluginName, "isdebug") == "true")
            {
                //进入调试模式
                DefaultView = frmmain as IBaseViewBusiness;

                SysLoginRight right = new SysLoginRight();
                right.UserId = 1;
                right.EmpId = 1;
                right.WorkId = 1;
                right.DeptId = 1;
                right.DeptName = "调试科室";
                right.EmpName = "调试用户";
                right.WorkName = "调试机构";
                AppGlobal.cache.Add("RoleUser", right);

                frmmain.UserName = right.EmpName;
                frmmain.DeptName = right.DeptName;
                frmmain.WorkName = right.WorkName;
                if (AppPluginManage.getbaseinfoDataValue(_pluginName, "menuconfig") != null)
                {
                    string filepath = AppPluginManage.getbaseinfoDataValue(_pluginName, "menuconfig");
                    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                    xmlDoc.Load(filepath);

                    XmlNodeList nl = xmlDoc.DocumentElement.SelectNodes("modules/module");
                    List<BaseModule> mdlist = new List<BaseModule>();
                    foreach (XmlNode n in nl)
                    {
                        BaseModule bmd = new BaseModule();
                        bmd.ModuleId = Convert.ToInt32(n.Attributes["ModuleId"].Value);
                        bmd.Name = n.Attributes["Name"].Value;
                        mdlist.Add(bmd);
                    }
                    nl = xmlDoc.DocumentElement.SelectNodes("menus/menu");
                    List<BaseMenu> menulist = new List<BaseMenu>();
                    foreach (XmlNode n in nl)
                    {
                        BaseMenu bmenu = new BaseMenu();
                        bmenu.MenuId = Convert.ToInt32(n.Attributes["MenuId"].Value);
                        bmenu.ModuleId = Convert.ToInt32(n.Attributes["ModuleId"].Value);
                        bmenu.PMenuId = Convert.ToInt32(n.Attributes["PMenuId"].Value);
                        bmenu.Name = n.Attributes["Name"].Value;
                        bmenu.Image = n.Attributes["Image"].Value;
                        bmenu.DllName = n.Attributes["DllName"].Value;
                        bmenu.FunName = n.Attributes["FunName"].Value;
                        menulist.Add(bmenu);
                    }
                    frmmain.modules = mdlist;
                    frmmain.menus = menulist;
                    //frmmain.depts = NewObject<Dept>().GetHaveDept(right.EmpId);
                }
                frmmain.showSysMenu();
                ShowWeclomeForm();

                ((System.Windows.Forms.Form)frmmain).ShowIcon = true;
                ((System.Windows.Forms.Form)frmmain).Icon = System.Drawing.Icon.ExtractAssociatedIcon(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"images\msn.ico");
            }
            #endregion
        }
        public void UserLogin()
        {
            User user = NewObject<User>();
            bool islogin = user.UserLogin(frmlogin.usercode, frmlogin.password);

            if (islogin)
            {
                BaseUser EbaseUser = user.GetUser(frmlogin.usercode);
                SysLoginRight right = new SysLoginRight();
                right.UserId = EbaseUser.UserId;
                right.EmpId = EbaseUser.EmpId;
                right.WorkId = EbaseUser.WorkId;

                Dept dept = NewObject<Dept>();
                BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId);
                if (EbaseDept != null)
                {
                    right.DeptId = EbaseDept.DeptId;
                    right.DeptName = EbaseDept.Name;
                }

                BaseEmployee EbaseEmp = (BaseEmployee)NewObject<BaseEmployee>().getmodel(EbaseUser.EmpId);
                right.EmpName = EbaseEmp.Name;

                BaseWorkers EbaseWork = (BaseWorkers)NewObject<BaseWorkers>().getmodel(EbaseUser.WorkId);
                right.WorkName = EbaseWork.WorkName;

                if (EbaseWork.DelFlag == 0)
                {
                    string regkey = EbaseWork.RegKey;
                    DESEncryptor des = new DESEncryptor();
                    des.InputString = regkey;
                    des.DesDecrypt();
                    string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' });
                    if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now)
                    {
                        AppGlobal.cache.Add("RoleUser", right);

                        //调用单点登录
                        //Guid TokenKey;
                        //EFWCoreLib.CoreFrame.SSO.SsoHelper.SignIn(right.UserId.ToString(), right.EmpName, out TokenKey);
                        //AppGlobal.cache.Add("TokenKey", TokenKey);

                        frmmain.UserName = right.EmpName;
                        frmmain.DeptName = right.DeptName;
                        frmmain.WorkName = right.WorkName;

                        frmmain.modules = NewObject<Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList();
                        frmmain.menus = NewObject<WinMainUIFrame.ObjectModel.RightManager.Menu>().GetMenuList(right.UserId);
                        frmmain.depts = NewObject<Dept>().GetHaveDept(right.EmpId);

                        frmmain.showSysMenu();
                        ShowWeclomeForm();
                        ((System.Windows.Forms.Form)frmmain).ShowIcon = true;
                        ((System.Windows.Forms.Form)frmmain).Icon = System.Drawing.Icon.ExtractAssociatedIcon(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"images\msn.ico");
                        ((System.Windows.Forms.Form)frmmain).Show();

                        AppGlobal.winfromMain.MainForm = (System.Windows.Forms.Form)frmmain;
                        //InitMessageForm();//?

                        //登录完成后执行扩展的插件方法
                        string val= AppPluginManage.getbaseinfoDataValue(_pluginName, "LoginCompleted");
                        if (val != null && val.Split('@').Length==3)
                        {
                            string pluginName=val.Split('@')[0];
                            string controllerName=val.Split('@')[1];
                            string methodName=val.Split('@')[2];
                            InvokeController(pluginName, controllerName, methodName, right);
                        }

                        CustomConfigManager.xmlDoc = null;
                    }
                    else
                    {
                        throw new Exception("登录用户的当前机构注册码不正确!");
                    }
                }
                else
                {
                    throw new Exception("登录用户的当前机构还未启用!");
                }
            }
            else
            {
                throw new Exception("输入的用户名密码不正确!");
            }
        }