コード例 #1
0
        public override void Execute()
        {
            if (users != null && users.Count > 0)
            {
                SmartBox.Console.Common.Log4NetHelper.Info("统一授权用户与本地用户比对开始!");
                foreach (SMC_User d in users)
                {
                    ServiceFactory factory = Beyondbit.BUA.Client.ServiceFactory.Instance();
                    IUserService   us      = factory.GetUserService();

                    Beyondbit.BUA.Client.User _u = null;
                    try
                    {
                        _u = us.GetUserInfo(d.U_UID);
                    }
                    catch (Exception ex)
                    {
                        SmartBox.Console.Common.Log4NetHelper.Error(ex);
                        continue;
                    }

                    if (_u != null)
                    {
                        if (d.U_UNITCODE != _u.UnitCode || d.U_NAME != _u.UserFullName)
                        {
                            d.u_need_sync = true;
                            d.u_need_sync_compare_time = DateTime.Now;
                            Bo.BoFactory.GetSMC_UserBo.Update(d);
                        }
                    }
                }
                SmartBox.Console.Common.Log4NetHelper.Info("统一授权用户与本地用户比对结束!");
            }
            else
            {
                SmartBox.Console.Common.Log4NetHelper.Info("未查询到需要比对的用户,将不执行比对任务!");
            }
        }
コード例 #2
0
        public virtual void BUAUserSyncToInside(string ids, Hashtable result)
        {
            ServiceFactory             factory          = Beyondbit.BUA.Client.ServiceFactory.Instance();
            IUserService               us               = factory.GetUserService();
            IOrgService                os               = factory.GetOrgService();
            SMC_UserDao                userDao          = new SMC_UserDao(AppConfig.statisticDBKey);
            SMC_BUAUserSyncToInsideDao buaSyncInsideDao = new SMC_BUAUserSyncToInsideDao(AppConfig.statisticDBKey);
            GlobalParamDao             globalParamDao   = new GlobalParamDao(AppConfig.statisticDBKey);
            GlobalParam                p = globalParamDao.GetGlobalParam("user_default_status");
            int batNo = 0;

            try
            {
                batNo = buaSyncInsideDao.GetMaxBatNo();
            }
            catch (Exception e)
            {
            }
            batNo += 1;

            string[] idlist = ids.Split(",".ToCharArray());
            foreach (string uid in idlist)
            {
                if (String.IsNullOrEmpty(uid))
                {
                    continue;
                }
                Beyondbit.BUA.Client.User _u = null;
                try
                {
                    _u = us.GetUserInfo(uid);
                }
                catch (Exception ex)
                {
                    result["Msg"] += uid + ex.Message;
                    continue;
                }

                SMC_BUAUserSyncToInside log = new SMC_BUAUserSyncToInside();
                log.sync_bat_no = batNo;

                try
                {
                    log.sync_status    = true;
                    log.sync_time      = DateTime.Now;
                    log.sync_user_name = "";
                    log.sync_user_uid  = "";
                    log.user_name      = _u.UserFullName;
                    log.user_uid       = _u.UserUid;
                    log.description    = "同步成功";
                    log.busi_id        = buaSyncInsideDao.GetMaxId() + 1;
                    SMC_UnitDao unitDao = new SMC_UnitDao(AppConfig.statisticDBKey);

                    SMC_User u = null;
                    u = userDao.GetUser(_u.UserUid);
                    if (u == null)
                    {
                        u            = new SMC_User();
                        u.U_NAME     = _u.UserFullName;
                        u.U_PASSWORD = _u.UserPassword;
                        u.U_UID      = _u.UserUid;
                        int id = userDao.GetMaxId() + 1;
                        u.U_ID = id;
                        string unitCode = os.GetUnitCode(ObjectType.User, u.U_UID);
                        Org    unitOrg  = os.GetOrgBaseInfo(ObjectType.Org, unitCode);
                        u.U_UNITCODE = unitCode;

                        //List<KeyValuePair<string, string>> pars = new List<KeyValuePair<string,string>>();
                        //pars.Add(new KeyValuePair<string, string>("unit_id",unitCode));
                        SMC_Unit unit = unitDao.Get(unitCode);
                        if (unit == null)
                        {
                            unit                  = new SMC_Unit();
                            unit.Unit_ID          = unitCode;
                            unit.Unit_Name        = unitOrg.OrgName;
                            unit.Unit_Sequence    = 0;
                            unit.Unit_UpdateTime  = DateTime.Now;
                            unit.Unit_CreatedTime = DateTime.Now;
                            unit.Upper_Unit_ID    = "";
                            unit.Unit_Path        = unitCode;
                            unitDao.Insert(unit);
                        }
                        u.u_unitname         = unitOrg.OrgName;
                        u.U_CREATEDDATE      = DateTime.Now;
                        u.u_enable_status    = p.ConfigValue == "1" ? UserEnabledStatus.Enabled : UserEnabledStatus.UnAuthed;
                        u.u_auth_submit_time = DateTime.Now;
                        u.u_need_sync        = false;
                        userDao.Insert(u);
                        userDao.UpdateMaxId();
                    }
                    else
                    {
                        u.U_NAME        = _u.UserFullName;
                        u.U_PASSWORD    = _u.UserPassword;
                        u.U_CREATEDDATE = DateTime.Now;
                        string unitCode = os.GetUnitCode(ObjectType.User, u.U_UID);
                        Org    unitOrg  = os.GetOrgBaseInfo(ObjectType.Org, unitCode);

                        //List<KeyValuePair<string, string>> pars = new List<KeyValuePair<string, string>>();
                        //pars.Add(new KeyValuePair<string, string>("unit_id", unitCode));
                        SMC_Unit unit = unitDao.Get(unitCode);
                        if (unit == null)
                        {
                            unit                  = new SMC_Unit();
                            unit.Unit_ID          = unitCode;
                            unit.Unit_Name        = unitOrg.OrgName;
                            unit.Unit_Sequence    = 0;
                            unit.Unit_UpdateTime  = DateTime.Now;
                            unit.Unit_CreatedTime = DateTime.Now;
                            unit.Upper_Unit_ID    = "";
                            unit.Unit_Path        = unitCode;
                            unitDao.Insert(unit);
                        }


                        u.u_unitname         = unitOrg.OrgName;
                        u.U_UNITCODE         = unitCode;
                        u.u_enable_status    = p.ConfigValue == "1" ? UserEnabledStatus.Enabled : UserEnabledStatus.UnAuthed;
                        u.u_auth_submit_time = DateTime.Now;
                        u.u_need_sync        = false;
                        u.u_update_time      = DateTime.Now;
                        userDao.Update(u);
                    }
                }
                catch (Exception ex)
                {
                    log.sync_status = false;
                    log.description = "同步失败,原因可能是:" + ex.Message + "。\r\nStackTrace:\r\n" + ex.StackTrace;
                    if (result != null)
                    {
                        result["IsSuccess"] = false;
                        result["Msg"]      += log.description;
                    }
                }

                try
                {
                    buaSyncInsideDao.Insert(log);
                    buaSyncInsideDao.UpdateMaxId();
                }
                catch (Exception ex)
                {
                }
            }
        }
コード例 #3
0
        public JsonResult AddUnitManager(string UID, string UName, string UnitCode, string UnitName, string Password, string EMail, string Phone, bool IsFromBUAUser)
        {
            Hashtable r = new Hashtable();
            r["r"] = true;
            r["d"] = "新增管理员成功!";

            if (String.IsNullOrEmpty(UnitCode))
            {
                r["r"] = false;
                r["d"] = "未选择单位!";
                return Json(r);
            }

            if (!IsFromBUAUser && String.IsNullOrEmpty(EMail))
            {
                r["r"] = false;
                r["d"] = "请填写EMail!";
                return Json(r);
            }

            if (!IsFromBUAUser && System.Text.RegularExpressions.Regex.IsMatch(EMail, "^[^@]+@[^@]+$", System.Text.RegularExpressions.RegexOptions.IgnoreCase) == false)
            {
                r["r"] = false;
                r["d"] = "请正确填写EMail!";
                return Json(r);
            }

            if (!IsFromBUAUser && String.IsNullOrEmpty(Password))
            {
                r["r"] = false;
                r["d"] = "请填写密码!";
                return Json(r);
            }

            if (!IsFromBUAUser && String.IsNullOrEmpty(Phone))
            {
                r["r"] = false;
                r["d"] = "请填写电话号码!";
                return Json(r);
            }

            if (!IsFromBUAUser && System.Text.RegularExpressions.Regex.IsMatch(Phone, "^[0-9]+$", System.Text.RegularExpressions.RegexOptions.IgnoreCase) == false)
            {
                r["r"] = false;
                r["d"] = "请正确填写电话号码!";
                return Json(r);
            }

            SmartBox.Console.Common.Entities.SMC_UserList unitManager = new Common.Entities.SMC_UserList();
            unitManager.Unit_ID = UnitCode;
            unitManager.Unit_Name = UnitName;
            unitManager.UL_Name = UName;
            unitManager.UL_UID = UID;
            unitManager.UL_PWD = Password;
            unitManager.UL_MailAddress = EMail;
            unitManager.UL_MobilePhone = Phone;

            try
            {
                IUserService us = Beyondbit.BUA.Client.ServiceFactory.Instance().GetUserService();
                IOrgService os = Beyondbit.BUA.Client.ServiceFactory.Instance().GetOrgService();
                Beyondbit.BUA.Client.User usr = null;

                bool exists = Bo.BoFactory.GetSMC_UserListBo.ExistsByUID(UID);

                try
                {
                    usr = us.GetUserInfo(unitManager.UL_UID);
                }
                catch
                {
                }

                //Beyondbit.BUA.Client.User[] _users = us.QueryUsersByObjectCode(ObjectType.User, userList.UL_UID);
                if (usr == null)
                {
                    //新增用户到统一授权
                    Beyondbit.BUA.Client.User u = new Beyondbit.BUA.Client.User();
                    u.UserUid = unitManager.UL_UID;
                    u.UserName = unitManager.UL_Name;
                    u.UserFullName = unitManager.UL_Name;
                    u.UserEmail = unitManager.UL_MailAddress == null ? "" : unitManager.UL_MailAddress;
                    u.UserPersonal = new UserPersonal();
                    u.UserPersonal.UserMobilePhone = unitManager.UL_MobilePhone;
                    u.UnitCode = unitManager.Unit_ID;
                    u.OrgCode = unitManager.Unit_ID;
                    u.UserPassword = unitManager.UL_PWD;
                    us.AddUser(u);
                }
                else
                {
                    //bua里已有用户
                    if (IsFromBUAUser)
                    {
                        unitManager.Unit_ID = UnitCode;
                        unitManager.Unit_Name = UnitName;
                        unitManager.UL_Name = usr.UserName;
                        unitManager.UL_UID = UID;
                        unitManager.UL_PWD = usr.UserPassword;
                        unitManager.UL_MailAddress = usr.UserEmail;
                        if (usr.UserPersonal != null && usr.UserPersonal.UserMobilePhone != null)
                            unitManager.UL_MobilePhone = usr.UserPersonal.UserMobilePhone;
                        else
                            unitManager.UL_MobilePhone = "";

                        if (exists)
                        {
                            r["r"] = false;
                            r["d"] = "用户已经是单位管理员!";
                            return Json(r);
                        }
                        else
                        {
                            Bo.BoFactory.GetSMC_UserListBo.InsertOrUpdate(unitManager);
                        }
                    }
                    else
                    {
                        if (exists)
                        {
                            r["r"] = false;
                            r["d"] = "用户已经是单位管理员!";
                            return Json(r);
                        }
                        else
                        {
                            Bo.BoFactory.GetSMC_UserListBo.InsertOrUpdate(unitManager);
                        }
                        return Json(r);
                    }
                }

            }
            catch (Exception ex)
            {
                r["r"] = false;
                r["d"] = ex.Message;
                return Json(r);
            }

            return Json(r);
        }
コード例 #4
0
        public virtual bool InsertOrUpdate(SMC_UserList userList)
        {
            try
            {
                IUserService us = Beyondbit.BUA.Client.ServiceFactory.Instance().GetUserService();
                IOrgService  os = Beyondbit.BUA.Client.ServiceFactory.Instance().GetOrgService();
                Beyondbit.BUA.Client.User usr = null;
                try
                {
                    usr = us.GetUserInfo(userList.UL_UID);
                }
                catch
                {
                }

                //Beyondbit.BUA.Client.User[] _users = us.QueryUsersByObjectCode(ObjectType.User, userList.UL_UID);
                if (usr == null)
                {
                    try
                    {
                        //新增用户到统一授权
                        Beyondbit.BUA.Client.User u = new Beyondbit.BUA.Client.User();
                        u.UserUid      = userList.UL_UID;
                        u.UserName     = userList.UL_Name;
                        u.UserFullName = userList.UL_Name;
                        u.UserEmail    = userList.UL_MailAddress == null ? "" : userList.UL_MailAddress;
                        u.UserPersonal = new UserPersonal();
                        u.UserPersonal.UserMobilePhone = userList.UL_MobilePhone;
                        u.UnitCode     = userList.Unit_ID;
                        u.OrgCode      = userList.Unit_ID;
                        u.UserPassword = userList.UL_PWD;
                        us.AddUser(u);
                    }
                    catch (Exception exe)
                    {
                    }
                }
                else
                {
                }


                int i = 0;
                if (SMC_UserListDao.Get(userList.UL_ID) == null)
                {
                    //i = SMC_UserListDao.Insert(userList);
                    SMC_AutoTableIDDao autoDao = new SMC_AutoTableIDDao(AppConfig.statisticDBKey);
                    if (autoDao.HasMaxID("SMC_UserList"))
                    {
                        int max_id = autoDao.GetMaxID("SMC_UserList");
                        userList.UL_ID = max_id + 1;
                    }
                    else
                    {
                        userList.UL_ID = 1;
                    }
                    i = SMC_UserListDao.Insert(userList);
                    if (true)
                    {
                        autoDao.UpdateMaxID("SMC_UserList");
                    }
                }
                else
                {
                    i = SMC_UserListDao.Update(userList);
                }

                return(true);
            }
            catch (DalException ex)
            {
                throw new BOException("调用方法InsertOrUpdate失败", ex);
            }
        }
コード例 #5
0
        public JsonResult AddUnitManager(string UID, string UName, string UnitCode, string UnitName, string Password, string EMail, string Phone, bool IsFromBUAUser)
        {
            Hashtable r = new Hashtable();

            r["r"] = true;
            r["d"] = "新增管理员成功!";

            if (String.IsNullOrEmpty(UnitCode))
            {
                r["r"] = false;
                r["d"] = "未选择单位!";
                return(Json(r));
            }

            if (!IsFromBUAUser && String.IsNullOrEmpty(EMail))
            {
                r["r"] = false;
                r["d"] = "请填写EMail!";
                return(Json(r));
            }

            if (!IsFromBUAUser && System.Text.RegularExpressions.Regex.IsMatch(EMail, "^[^@]+@[^@]+$", System.Text.RegularExpressions.RegexOptions.IgnoreCase) == false)
            {
                r["r"] = false;
                r["d"] = "请正确填写EMail!";
                return(Json(r));
            }

            if (!IsFromBUAUser && String.IsNullOrEmpty(Password))
            {
                r["r"] = false;
                r["d"] = "请填写密码!";
                return(Json(r));
            }

            if (!IsFromBUAUser && String.IsNullOrEmpty(Phone))
            {
                r["r"] = false;
                r["d"] = "请填写电话号码!";
                return(Json(r));
            }

            if (!IsFromBUAUser && System.Text.RegularExpressions.Regex.IsMatch(Phone, "^[0-9]+$", System.Text.RegularExpressions.RegexOptions.IgnoreCase) == false)
            {
                r["r"] = false;
                r["d"] = "请正确填写电话号码!";
                return(Json(r));
            }

            SmartBox.Console.Common.Entities.SMC_UserList unitManager = new Common.Entities.SMC_UserList();
            unitManager.Unit_ID        = UnitCode;
            unitManager.Unit_Name      = UnitName;
            unitManager.UL_Name        = UName;
            unitManager.UL_UID         = UID;
            unitManager.UL_PWD         = Password;
            unitManager.UL_MailAddress = EMail;
            unitManager.UL_MobilePhone = Phone;

            try
            {
                IUserService us = Beyondbit.BUA.Client.ServiceFactory.Instance().GetUserService();
                IOrgService  os = Beyondbit.BUA.Client.ServiceFactory.Instance().GetOrgService();
                Beyondbit.BUA.Client.User usr = null;

                bool exists = Bo.BoFactory.GetSMC_UserListBo.ExistsByUID(UID);

                try
                {
                    usr = us.GetUserInfo(unitManager.UL_UID);
                }
                catch
                {
                }

                //Beyondbit.BUA.Client.User[] _users = us.QueryUsersByObjectCode(ObjectType.User, userList.UL_UID);
                if (usr == null)
                {
                    //新增用户到统一授权
                    Beyondbit.BUA.Client.User u = new Beyondbit.BUA.Client.User();
                    u.UserUid      = unitManager.UL_UID;
                    u.UserName     = unitManager.UL_Name;
                    u.UserFullName = unitManager.UL_Name;
                    u.UserEmail    = unitManager.UL_MailAddress == null ? "" : unitManager.UL_MailAddress;
                    u.UserPersonal = new UserPersonal();
                    u.UserPersonal.UserMobilePhone = unitManager.UL_MobilePhone;
                    u.UnitCode     = unitManager.Unit_ID;
                    u.OrgCode      = unitManager.Unit_ID;
                    u.UserPassword = unitManager.UL_PWD;
                    us.AddUser(u);
                }
                else
                {
                    //bua里已有用户
                    if (IsFromBUAUser)
                    {
                        unitManager.Unit_ID        = UnitCode;
                        unitManager.Unit_Name      = UnitName;
                        unitManager.UL_Name        = usr.UserName;
                        unitManager.UL_UID         = UID;
                        unitManager.UL_PWD         = usr.UserPassword;
                        unitManager.UL_MailAddress = usr.UserEmail;
                        if (usr.UserPersonal != null && usr.UserPersonal.UserMobilePhone != null)
                        {
                            unitManager.UL_MobilePhone = usr.UserPersonal.UserMobilePhone;
                        }
                        else
                        {
                            unitManager.UL_MobilePhone = "";
                        }

                        if (exists)
                        {
                            r["r"] = false;
                            r["d"] = "用户已经是单位管理员!";
                            return(Json(r));
                        }
                        else
                        {
                            Bo.BoFactory.GetSMC_UserListBo.InsertOrUpdate(unitManager);
                        }
                    }
                    else
                    {
                        if (exists)
                        {
                            r["r"] = false;
                            r["d"] = "用户已经是单位管理员!";
                            return(Json(r));
                        }
                        else
                        {
                            Bo.BoFactory.GetSMC_UserListBo.InsertOrUpdate(unitManager);
                        }
                        return(Json(r));
                    }
                }
            }
            catch (Exception ex)
            {
                r["r"] = false;
                r["d"] = ex.Message;
                return(Json(r));
            }

            return(Json(r));
        }
コード例 #6
0
        public virtual bool InsertOrUpdate(SMC_UserList userList)
        {
            try
            {
                IUserService us = Beyondbit.BUA.Client.ServiceFactory.Instance().GetUserService();
                IOrgService os = Beyondbit.BUA.Client.ServiceFactory.Instance().GetOrgService();
                Beyondbit.BUA.Client.User usr = null;
                try
                {
                    usr = us.GetUserInfo(userList.UL_UID);
                }
                catch
                {
                }

                //Beyondbit.BUA.Client.User[] _users = us.QueryUsersByObjectCode(ObjectType.User, userList.UL_UID);
                if (usr == null)
                {
                    try
                    {
                        //�����û���ͳһ��Ȩ
                        Beyondbit.BUA.Client.User u = new Beyondbit.BUA.Client.User();
                        u.UserUid = userList.UL_UID;
                        u.UserName = userList.UL_Name;
                        u.UserFullName = userList.UL_Name;
                        u.UserEmail = userList.UL_MailAddress == null ? "" : userList.UL_MailAddress;
                        u.UserPersonal = new UserPersonal();
                        u.UserPersonal.UserMobilePhone = userList.UL_MobilePhone;
                        u.UnitCode = userList.Unit_ID;
                        u.OrgCode = userList.Unit_ID;
                        u.UserPassword = userList.UL_PWD;
                        us.AddUser(u);
                    }
                    catch (Exception exe)
                    {
                    }
                }
                else
                {
                }

                int i = 0;
                if (SMC_UserListDao.Get(userList.UL_ID) == null)
                {
                    //i = SMC_UserListDao.Insert(userList);
                    SMC_AutoTableIDDao autoDao = new SMC_AutoTableIDDao(AppConfig.statisticDBKey);
                    if (autoDao.HasMaxID("SMC_UserList"))
                    {
                        int max_id = autoDao.GetMaxID("SMC_UserList");
                        userList.UL_ID = max_id + 1;
                    }
                    else
                    {
                        userList.UL_ID = 1;
                    }
                    i = SMC_UserListDao.Insert(userList);
                    if (true)
                    {
                        autoDao.UpdateMaxID("SMC_UserList");
                    }
                }
                else
                {
                    i = SMC_UserListDao.Update(userList);
                }

                return true;
            }
            catch (DalException ex)
            {
                throw new BOException("���÷���InsertOrUpdateʧ��", ex);
            }
        }