public DirectoryModel() { //Company subdomain BambooAPIClient bambooClient = new BambooAPIClient("Infragistics"); //Api Key, shush it is secret bambooClient.setSecretKey("SECRET"); //Setup the fields to be requested string[] fields = { "firstName", "lastName", "jobTitle", "WorkEmail", "department", "division", "location", "supervisor", "nickname", "mobilePhone", "workPhone", "workPhoneExtension", "sms\text", "id" }; //Create the directroy so it is ready to fill Directory = new List <DirectoryEntryModel>(); BambooHTTPResponse resp; //Get string of employees resp = bambooClient.getEmployeesReport("csv", "Report", fields); string list = resp.getContentString(); //Remove escape characters/sequance from the string list = list.Replace("\"", ""); //Split the string by employees char[] splitEmployees = { '\n' }; string[] employees = list.Split(splitEmployees); for (int i = 1; i < employees.Length - 1; i++) { //Split out the fields by comma "," as long as it is not follow by a space string[] splitDetails = { ",(?!\\s)" }; string[] employee = Regex.Split(employees[i], ",(?!\\s)"); DirectoryEntryModel entry = new DirectoryEntryModel(); entry.FirstName = employee[0]; entry.LastName = employee[1]; entry.Title = employee[2]; entry.WorkEmail = employee[3]; entry.Department = employee[4]; entry.Division = employee[5]; entry.Location = employee[6]; entry.ReportingTo = employee[7]; entry.Nickname = employee[8]; entry.CellPhone = employee[9]; entry.WorkPhone = employee[10]; entry.WorkExt = employee[11]; entry.SMS = false; entry.ID = int.Parse(employee[12]); entry.Photo = GetImage(bambooClient.baseUrl, entry); //Add the entry to the directory Directory.Add(entry); } Directory.Sort(new DirectoryEntryModelComparer()); }
public DirectoryModel() { //Company subdomain BambooAPIClient bambooClient = new BambooAPIClient("Infragistics"); //Api Key, shush it is secret bambooClient.setSecretKey("SECRET"); //Setup the fields to be requested string[] fields = { "firstName", "lastName", "jobTitle", "WorkEmail", "department", "division", "location", "supervisor", "nickname", "mobilePhone", "workPhone", "workPhoneExtension", "sms\text","id" }; //Create the directroy so it is ready to fill Directory = new List<DirectoryEntryModel>(); BambooHTTPResponse resp; //Get string of employees resp = bambooClient.getEmployeesReport("csv", "Report", fields); string list = resp.getContentString(); //Remove escape characters/sequance from the string list = list.Replace("\"", ""); //Split the string by employees char[] splitEmployees = { '\n' }; string[] employees = list.Split(splitEmployees); for (int i = 1; i < employees.Length - 1; i++) { //Split out the fields by comma "," as long as it is not follow by a space string[] splitDetails = { ",(?!\\s)" }; string[] employee = Regex.Split(employees[i], ",(?!\\s)"); DirectoryEntryModel entry = new DirectoryEntryModel(); entry.FirstName = employee[0]; entry.LastName = employee[1]; entry.Title = employee[2]; entry.WorkEmail = employee[3]; entry.Department = employee[4]; entry.Division = employee[5]; entry.Location = employee[6]; entry.ReportingTo = employee[7]; entry.Nickname = employee[8]; entry.CellPhone = employee[9]; entry.WorkPhone = employee[10]; entry.WorkExt = employee[11]; entry.SMS = false; entry.ID = int.Parse(employee[12]); entry.Photo = GetImage(bambooClient.baseUrl, entry); //Add the entry to the directory Directory.Add(entry); } Directory.Sort(new DirectoryEntryModelComparer()); }
public BambooHRController() { __API = new BambooAPIClient(__DQSUBDOMAIN); __API.setSecretKey(__APIKEY); }