日期:2014-05-18 浏览次数:20829 次
public string SyncUserInfor(HttpResponse Response) { GC.Collect(); string jsBlock; StringBuilder sbLog = new StringBuilder(); sbLog.Append(" 开始时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm")+ ";"); DBOperator db = new DBOperator(); //jsBlock = "<script>SetPorgressBar('开始读取数据库数据 ','0'); </script>"; //Response.Write(jsBlock); //Response.Flush(); int begin = Environment.TickCount; DataTable HRUserInfor = db.GetHRUserInfor(); int end = Environment.TickCount; sbLog.Append(string.Format(" 获取数据库:{0}毫秒",end-begin)); //jsBlock = "<script>SetPorgressBar('开始读域数据 ','0'); </script>"; //Response.Write(jsBlock); //Response.Flush(); begin = Environment.TickCount; ArrayList XMLUserInfor = xmlOperate.GetXMLInfor("0"); end = Environment.TickCount; sbLog.Append(string.Format(" 获取域中所有信息:{0}毫秒", end - begin)); ArrayList userProhibited = new ArrayList(); ArrayList userModify = new ArrayList(); ArrayList userModifyLog = new ArrayList(); DataTable userAddTable = HRUserInfor; ArrayList MoveOUList = new ArrayList(); DBOperator.SyncLog sl = new DBOperator.SyncLog(); string UpdateNo = db.GetUpdateNo(); int ModifyCount, AddCount, LeaveCount, totalCount, dataCount; totalCount = XMLUserInfor.Count; dataCount = HRUserInfor.Rows.Count; sl.UpdateNo = UpdateNo; if (XMLUserInfor != null) { for (int i = 0; i < XMLUserInfor.Count; i++) { userProhibited.Add((userInfor)XMLUserInfor[i]); } int count = XMLUserInfor.Count; for (int i = 0; i < count; i++) { userInfor user = (userInfor)XMLUserInfor[i]; DataRow[] drlist = HRUserInfor.Select(string.Format("samAccountName='{0}'", user.samAccountName)); DataRow dr = null; if (drlist.Length < 1) continue; dr = drlist[0]; userProhibited.Remove(user); } if (userProhibited.Count != 0) { for (int i = 0; i < userProhibited.Count; i++) { userInfor user = (userInfor)userProhibited[i]; if (!user.samAccountName.EndsWith("_tmp")) { LeaveCount += 1; op.ProhibitedUser(user.samAccountName); DBOperator.SyncLog log = new DBOperator.SyncLog(); log.UpdateLevel = DBOperator.UpdateLevel.Hint; log.UpdateType = DBOperator.UpdateType.Prohibit; WriteLog(log, user); } } } sbLog.Append("离职个数:" + LeaveCount + ";"); }