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) { } } }
public virtual bool Update(SMC_BUAUserSyncToInside unit) { try { int i = SMC_BUAUserSyncToInsideDao.Update(unit); return i > 0; } catch (DalException ex) { throw new BOException("调用方法Update失败", ex); } }
public virtual bool Insert(SMC_BUAUserSyncToInside unit) { try { SMC_AutoTableIDDao autoDao = new SMC_AutoTableIDDao(AppConfig.statisticDBKey); if (autoDao.HasMaxID("SMC_BUAUserSyncToInside")) { int max_id = autoDao.GetMaxID("SMC_BUAUserSyncToInside"); unit.busi_id = max_id + 1; } else { unit.busi_id = 1; } int i = SMC_BUAUserSyncToInsideDao.Insert(unit); autoDao.UpdateMaxID("SMC_BUAUserSyncToInside"); return i > 0; } catch (DalException ex) { throw new BOException("调用方法Insert失败", ex); } }
public virtual bool InsertOrUpdate(SMC_BUAUserSyncToInside unit) { try { int i = 0; if (SMC_BUAUserSyncToInsideDao.Get(unit.busi_id) == null) { //i = SMC_UnitDao.Insert(unit); SMC_AutoTableIDDao autoDao = new SMC_AutoTableIDDao(AppConfig.statisticDBKey); if (autoDao.HasMaxID("SMC_BUAUserSyncToInside")) { int max_id = autoDao.GetMaxID("SMC_BUAUserSyncToInside"); unit.busi_id = max_id + 1; } else { unit.busi_id = 1; } i = SMC_BUAUserSyncToInsideDao.Insert(unit); if (true) { autoDao.UpdateMaxID("SMC_BUAUserSyncToInside"); } } else { i = SMC_BUAUserSyncToInsideDao.Update(unit); } return true; } catch (DalException ex) { throw new BOException("调用方法InsertOrUpdate失败", ex); } }
public virtual void Delete(SMC_BUAUserSyncToInside entity) { try { SMC_BUAUserSyncToInsideDao.Delete(entity); } catch (DalException ex) { throw new BOException("????????????", ex); } }