//Update email address private void UpdateEmail(int employeeId, string emailAdr, byte emailType) { var mailrec = db.EmployeeEmail .Where(t => t.EmployeeId.Equals(employeeId) && t.EmailTypeId == emailType).FirstOrDefault(); if (mailrec == null) { EmployeeEmail email = new EmployeeEmail(); email.EmployeeId = employeeId; email.Email = emailAdr; email.CreateDate = DateTime.Now; email.RecordStatusId = RECORDSTATUS; email.EmailTypeId = emailType; db.EmployeeEmail.Add(email); } else { mailrec.Email = emailAdr; mailrec.CreateDate = DateTime.Now; } }
private List <EmployeeEmail> GetDomainUsers() { string strUserEmail = string.Empty; string name = string.Empty; employeeEmailList = new List <EmployeeEmail>(); try { DirectoryEntry searchRoot = new DirectoryEntry(Common.AuthorizationManagerConstants.DIRECTORYSERVICE); DirectorySearcher search = new DirectorySearcher(searchRoot); //string query = "(|(objectCategory=group )(objectCategory=user))"; //string query = "(SAMAccountName=" + strUserName + ")"; string query = "(&(objectClass=user)(objectCategory=Person))"; //venkatesh : start 16-Sep, Exceed the LDAP user list more than 1000 search.PageSize = 10000; //venkatesh : start 16-Sep, Exceed the LDAP user list more than 1000 search.Filter = query; SearchResult result; SearchResultCollection resultCol = search.FindAll(); //search. if (resultCol != null) { for (int counter = 0; counter < resultCol.Count; counter++) { result = resultCol[counter]; //if (result.Properties["samaccountname"][0].ToString().Trim().ToLower() == "sachin.jadhav") //{ // name = result.Properties["displayname"][0].ToString(); // //empEmail.Name = name; //} //if (result.Properties.Contains("samaccountname")) if (result.Properties.Contains("showinaddressbook")) { EmployeeEmail empEmail = new EmployeeEmail(); //if (!result.Properties.Contains("proxyaddresses")) //strUserEmail = result.Properties["mail"][0].ToString(); //result = resultCol[counter]; //result.Properties["givenName"][0]; //result.Properties["initials"][0]; //strUserEmail = result.Properties["CN"][0].ToString(); //strUserEmail = result.Properties["samaccountname"][0].ToString(); strUserEmail = result.Properties["mail"][0].ToString(); name = result.Properties["displayname"][0].ToString(); empEmail.Name = name; empEmail.EmailID = strUserEmail; employeeEmailList.Add(empEmail); } } } employeeEmailList.Sort(delegate(EmployeeEmail e1, EmployeeEmail e2) { return(e1.Name.CompareTo(e2.Name)); }); } //catches RaveHRException exception catch (RaveHRException ex) { LogErrorMessage(ex); } catch (Exception ex) { RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, "EmployeesEmailList.aspx.cs", "GetDomainUsers", EventIDConstants.RAVE_HR_EMPLOYEE_PRESENTATION_LAYER); LogErrorMessage(objEx); } return(employeeEmailList); }