private void UpdateRequest(int requestor, int reqId, UserMgrCommandType cmd, bool success, string errMsg, ref string err) { m_dataAccess.UpdateRequestQueue(requestor, cmd.ToString(), ref reqId, success, errMsg, ref err); }
/// <summary> /// update AD /// </summary> /// <param name="dicIDs"></param> private void UpdateAD(Dictionary <int, int> dicIDs, UserMgrCommandType uType) { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient service = sm.StartServiceClient()) { UpdateADUserRequest uReq; UpdateADUserResponse uResponse; ReqHdr hdr; Dictionary <string, string> dicFailed = new Dictionary <string, string>(); foreach (KeyValuePair <int, int> kvp in dicIDs) { hdr = new ReqHdr(); hdr.UserId = kvp.Value; uReq = new UpdateADUserRequest(); uReq.hdr = hdr; uReq.Command = uType; uReq.AD_OU_Filter = this.hiPrefix.Value; uReq.AD_User = new LP_Service.User(); uReq.AD_User.Username = gridUserList.DataKeys[kvp.Key]["Username"].ToString(); uReq.AD_User.Firstname = gridUserList.DataKeys[kvp.Key]["FirstName"].ToString(); uReq.AD_User.Lastname = gridUserList.DataKeys[kvp.Key]["LastName"].ToString(); uReq.AD_User.Email = gridUserList.DataKeys[kvp.Key]["EmailAddress"].ToString(); try { uResponse = service.UpdateADUser(uReq); if (!uResponse.hdr.Successful) { dicFailed.Add(gridUserList.DataKeys[kvp.Key]["Username"].ToString(), uResponse.hdr.StatusInfo); } } catch (System.ServiceModel.EndpointNotFoundException ee) { dicFailed.Add(gridUserList.DataKeys[kvp.Key]["Username"].ToString(), ee.Message); } catch (Exception ex) { dicFailed.Add(gridUserList.DataKeys[kvp.Key]["Username"].ToString(), ex.Message); } } if (dicFailed.Count > 0) { StringBuilder sbErrorMsg = new StringBuilder(); StringBuilder sbErrorLog = new StringBuilder(); foreach (KeyValuePair <string, string> kvp in dicFailed) { if (sbErrorMsg.Length > 0) { sbErrorMsg.Append(","); } sbErrorMsg.Append(kvp.Key); if (sbErrorLog.Length > 0) { sbErrorLog.Append(","); } sbErrorLog.Append(string.Format("{0}:{1}", kvp.Key, kvp.Value)); } // get UserMgrCommandType string string strType = ""; switch (uType) { case UserMgrCommandType.DisableUser: strType = "disable"; break; case UserMgrCommandType.DeleteUser: strType = "delete"; break; default: strType = ""; break; } ClientFun(this.updatePanel, "failedtodeleteuserinad", string.Format("alert('Failed to {0} the selected user account(s), username = {1}, please try it again.');", strType, sbErrorMsg.ToString())); //PageCommon.AlertMsg(this, string.Format("Failed to {0} the selected user account(s), username = {1}", strType, sbErrorMsg.ToString())); LPLog.LogMessage(LogType.Logerror, string.Format("Failed to {0} the selected user account(s): {1}", strType, sbErrorLog.ToString())); } } }