Exemplo n.º 1
0
        public virtual Dictionary <string, string> GetUnitByUL_UID(string UL_UID)
        {
            Dictionary <string, string> unitInfo = new Dictionary <string, string>();
            string      unitId  = SMC_UserListDao.GetUnitIdByUID(UL_UID);
            SMC_UnitDao unitDao = new SMC_UnitDao(AppConfig.statisticDBKey);

            SMC_Unit unit = unitDao.Get(unitId);

            if (unit != null)
            {
                unitInfo.Add(unit.Unit_Name, unit.Unit_ID);
            }
            return(unitInfo);
        }
        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)
                {
                }
            }
        }
Exemplo n.º 3
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)
                {
                }
            }
        }
Exemplo n.º 4
0
        public virtual Hashtable QueryPersonsTreeDataByUnit(string Unit_ID, int Role_ID)
        {
            try
            {
                Hashtable       result  = new Hashtable();
                SMC_UserListDao ulDao   = new SMC_UserListDao(AppConfig.statisticDBKey);
                SMC_UnitDao     unitDao = new SMC_UnitDao(AppConfig.statisticDBKey);

                IList <SMC_UserList> ulList = ulDao.QueryUserListByUnitID(Unit_ID);
                SMC_Unit             tunit  = null;
                if (!String.IsNullOrEmpty(Unit_ID))
                {
                    tunit = unitDao.Get(Unit_ID);
                }

                List <Hashtable> hashs = new List <Hashtable>();
                if (ulList.Count > 0)
                {
                    List <Hashtable> objs = new List <Hashtable>();
                    foreach (SMC_UserList u in ulList)
                    {
                        Hashtable uhash = new Hashtable();
                        uhash["id"]      = "u_" + u.UL_ID;
                        uhash["name"]    = u.UL_Name;
                        uhash["tp"]      = "user";
                        uhash["checked"] = ulDao.IsUserListInRole(u.UL_ID, Role_ID);
                        hashs.Add(uhash);
                    }
                    //hash["children"] = objs;
                }

                IList <SMC_Unit> units = unitDao.QueryChildUnitsByUnitID(Unit_ID, 0);


                result["children"] = hashs;
                if (units != null && units.Count > 0)
                {
                    foreach (SMC_Unit unit in units)
                    {
                        Hashtable hash = new Hashtable();
                        //bool isFnInRole = frDao.IsUserInRole(fn.FN_ID, Role_ID);
                        hash["id"]   = unit.Unit_ID;
                        hash["name"] = unit.Unit_Name;
                        hash["open"] = true;
                        //hash["checked"] = isFnInRole;
                        List <Hashtable> objs = new List <Hashtable>();
                        parseChildTreeData(hash, unit, unitDao, ulDao, objs, Role_ID);
                        hashs.Add(hash);
                    }
                }

                //if (tunit != null)
                {
                    result["id"]   = String.IsNullOrEmpty(Unit_ID) ? Unit_ID : tunit.Unit_ID;
                    result["name"] = String.IsNullOrEmpty(Unit_ID) ? "全局" : tunit.Unit_Name;
                    result["open"] = true;
                }

                return(result);
            }
            catch (DalException ex)
            {
                throw new BOException("QueryFunctionsByUnitID", ex);
            }
        }
Exemplo n.º 5
0
        public virtual Hashtable QueryPersonsTreeDataByUnit(string Unit_ID, int Role_ID)
        {
            try
            {
                Hashtable result = new Hashtable();
                SMC_UserListDao ulDao = new SMC_UserListDao(AppConfig.statisticDBKey);
                SMC_UnitDao unitDao = new SMC_UnitDao(AppConfig.statisticDBKey);

                IList<SMC_UserList> ulList = ulDao.QueryUserListByUnitID(Unit_ID);
                SMC_Unit tunit = null;
                if (!String.IsNullOrEmpty(Unit_ID))
                    tunit = unitDao.Get(Unit_ID);

                List<Hashtable> hashs = new List<Hashtable>();
                if (ulList.Count > 0)
                {
                    List<Hashtable> objs = new List<Hashtable>();
                    foreach (SMC_UserList u in ulList)
                    {
                        Hashtable uhash = new Hashtable();
                        uhash["id"] = "u_" + u.UL_ID;
                        uhash["name"] = u.UL_Name;
                        uhash["tp"] = "user";
                        uhash["checked"] = ulDao.IsUserListInRole(u.UL_ID, Role_ID);
                        hashs.Add(uhash);
                    }
                    //hash["children"] = objs;
                }

                IList<SMC_Unit> units = unitDao.QueryChildUnitsByUnitID(Unit_ID, 0);

                result["children"] = hashs;
                if (units != null && units.Count > 0)
                    foreach (SMC_Unit unit in units)
                    {
                        Hashtable hash = new Hashtable();
                        //bool isFnInRole = frDao.IsUserInRole(fn.FN_ID, Role_ID);
                        hash["id"] = unit.Unit_ID;
                        hash["name"] = unit.Unit_Name;
                        hash["open"] = true;
                        //hash["checked"] = isFnInRole;
                        List<Hashtable> objs = new List<Hashtable>();
                        parseChildTreeData(hash, unit, unitDao, ulDao, objs, Role_ID);
                        hashs.Add(hash);
                    }

                //if (tunit != null)
                {
                    result["id"] = String.IsNullOrEmpty(Unit_ID) ? Unit_ID : tunit.Unit_ID;
                    result["name"] = String.IsNullOrEmpty(Unit_ID) ? "ȫ��" : tunit.Unit_Name;
                    result["open"] = true;

                }

                return result;
            }
            catch (DalException ex)
            {
                throw new BOException("QueryFunctionsByUnitID", ex);
            }
        }
Exemplo n.º 6
0
        public virtual Dictionary<string, string> GetUnitByUL_UID(string UL_UID)
        {
            Dictionary<string, string> unitInfo = new Dictionary<string, string>();
             string unitId = SMC_UserListDao.GetUnitIdByUID(UL_UID);
             SMC_UnitDao unitDao = new SMC_UnitDao(AppConfig.statisticDBKey);

             SMC_Unit unit = unitDao.Get(unitId);
             if (unit != null)
             {
                 unitInfo.Add(unit.Unit_Name, unit.Unit_ID);
             }
             return unitInfo;
        }