public XmlNode SearchPersonData(string id = null, string startingKey = null, PersonState state = PersonState.All) { var xo = new XmlOutput() .XmlDeclaration() .Node("NETBOX-API").Attribute("sessionid", SessionID).Within() .Node("COMMAND").Attribute("name", "SearchPersonData").Attribute("num", "1").Within() .Node("PARAMS").Within() .Node("ALLPARTITIONS").InnerText("TRUE"); if (!string.IsNullOrEmpty(id)) { xo.Node("PERSONID").InnerText(id); } if (!string.IsNullOrEmpty(startingKey)) { xo.Node("STARTFROMKEY").InnerText(startingKey); } var deleted = "ALL"; if (state == PersonState.Deleted) { deleted = "TRUE"; } else if (state == PersonState.NotDeleted) { deleted = "FALSE"; } xo.Node("DELETED").InnerText(deleted); var sw = new StringWriter(); var tx = new XmlTextWriter(sw); xo.GetXmlDocument().WriteTo(tx); var doc = HttpPost(xo); if (CallWasSuccessful(doc)) { XmlNode details = doc["NETBOX"]["RESPONSE"]["DETAILS"]; return(details); } return(null); }
public XmlDocument GetXml() { XmlOutput xo = new XmlOutput() .XmlDeclaration() .Node("package").Attribute("xmlns", "http://soap.sforce.com/2006/04/metadata").Within(); foreach (var salesForceChange in Types) { XmlOutput xmlOutput = xo.Node("types").Within(); foreach (var member in salesForceChange.Members) { xmlOutput.Node("members").InnerText(member); } xmlOutput.Node("name").InnerText(salesForceChange.Name) .EndWithin(); } xo.EndWithin() .Node("version").InnerText(this.Version); return(xo.GetXmlDocument()); }
public XmlNode GetAccessHistory(DateTime from, string nextId = null, string startFromId = null) { var xo = new XmlOutput() .XmlDeclaration() .Node("NETBOX-API").Attribute("sessionid", SessionID).Within() .Node("COMMAND").Attribute("name", "GetAccessHistory").Attribute("num", "1").Within(); var param = xo.Node("PARAMS").Within(); param.Node("OLDESTDTTM").InnerText(from.ToString(DateFormat)); //optional NEWESTDTTM if (nextId != null || startFromId != null) { if (!string.IsNullOrEmpty(nextId)) { param.Node("STARTLOGID").InnerText(nextId); } if (!string.IsNullOrEmpty(startFromId)) { param.Node("AFTERLOGID").InnerText(startFromId); } } var sw = new StringWriter(); var tx = new XmlTextWriter(sw); xo.GetXmlDocument().WriteTo(tx); var doc = HttpPost(xo); var code = doc.SelectSingleNode("NETBOX/RESPONSE/CODE"); if (code != null && (code.InnerXml == "SUCCESS" || code.InnerXml == "NOT FOUND")) { return(code.InnerXml == "SUCCESS" ? doc["NETBOX"]["RESPONSE"]["DETAILS"] : code); } return(null); }
public XmlDocument GetXml() { XmlOutput xo = new XmlOutput() .XmlDeclaration() .Node("package").Attribute("xmlns", "http://soap.sforce.com/2006/04/metadata").Within(); foreach (var salesForceChange in Types) { XmlOutput xmlOutput = xo.Node("types").Within(); foreach (var member in salesForceChange.Members) { xmlOutput.Node("members").InnerText(member); } xmlOutput.Node("name").InnerText(salesForceChange.Name) .EndWithin(); } xo.EndWithin() .Node("version").InnerText(this.Version); return xo.GetXmlDocument(); }
public bool ModifyPerson(Person person) { var db = new RSMDataModelDataContext(); string personDispCredentials; string jobDisplayDescription; string jobDescription; try { personDispCredentials = person.DisplayCredentials; if (personDispCredentials == " ") { personDispCredentials = string.Empty; } } catch (Exception) { personDispCredentials = string.Empty; } try { jobDescription = person.Job.JobDescription; } catch (Exception) { jobDescription = string.Empty; } try { jobDisplayDescription = person.Job.DisplayDescription; if (jobDisplayDescription.Length < 1) { jobDisplayDescription = jobDescription; } } catch (Exception) { jobDisplayDescription = jobDescription; } var jobDescr = personDispCredentials.Length > 0 ? string.Format("{0}, {1}", jobDisplayDescription, personDispCredentials) : jobDisplayDescription; XmlOutput xo; try { xo = new XmlOutput() .XmlDeclaration() .Node("NETBOX-API").Attribute("sessionid", SessionID).Within() .Node("COMMAND").Attribute("name", "ModifyPerson").Attribute("num", "1").Within() .Node("PARAMS").Within() .Node("PERSONID").InnerText(person.PersonID.ToString()) .Node("LASTNAME").InnerText(person.LastName) .Node("FIRSTNAME").InnerText(person.NickFirst) .Node("MIDDLENAME").InnerText(person.MiddleName) .Node("CONTACTLOCATION").InnerText(person.Facility) //.Node("DELETED").InnerText((person.Active == true ? "FALSE" : "TRUE")) .Node("DELETED").InnerText("FALSE") .Node("UDF1").InnerText(person.JobCode) .Node("UDF2").InnerText(jobDescr) .Node("UDF3").InnerText(person.DeptID) .Node("UDF4").InnerText(person.DeptDescr) .Node("UDF5").InnerText(person.Facility) .Node("UDF6").InnerText(person.BadgeNumber) .Node("UDF7").InnerText(person.JobDescr) .Node("UDF8").InnerText(personDispCredentials) .Node("UDF9").InnerText(person.EmployeeID) .Node("ACCESSLEVELS").Within(); } catch (Exception) { throw (new Exception(string.Format("Exception building API XML for {0}, {1}", person.LastName, person.FirstName))); } try { var levels = db.LevelsAssignedToPerson(person.PersonID); var levelCount = 0; foreach (var l in levels) { levelCount++; if (levelCount < MAX_LEVELS_S2_SUPPORTS) { xo.Node("ACCESSLEVEL").InnerText(l.AccessLevelName); } } if (person.Active == false) { xo.Node("ACCESSLEVEL").InnerText("TERMINATED ASSOCIATE"); } //if (levelCount > MAX_LEVELS_S2_SUPPORTS) //{ // db.Syslog(OwningSystem, // RSMDataModelDataContext.LogSeverity.ERROR, // string.Format("{0}, {1} {2} has too many levels assigned.", person.LastName, person.FirstName, person.MiddleName), // string.Format("The S2 hardware has a limit of {0} access levels per person. This person has {1}. You will need to remove some roles or consolidate multiple levels into one on the S2 hardware.", MAX_LEVELS_S2_SUPPORTS, levelCount)); // return false; //} } catch (Exception) { throw (new Exception(string.Format("Exception adding levels for {0}, {1}", person.LastName, person.FirstName))); } try { var doc = HttpPost(xo); if (CallWasSuccessful(doc)) { db.Syslog(ExportSystem, Severity.Informational, string.Format("Exported associate \"{0}, {1} {2}\" to S2.", person.LastName, person.FirstName, person.MiddleName), ""); return(true); } db.Syslog(ExportSystem, Severity.Error, string.Format("FAILED exporting associate \"{0}, {1} {2}\" to S2.", person.LastName, person.FirstName, person.MiddleName), doc["NETBOX"]["RESPONSE"]["DETAILS"]["ERRMSG"].InnerText); } catch (Exception) { throw (new Exception(string.Format("Exception parsing response for {0}, {1}", person.LastName, person.FirstName))); } return(false); }
public bool AddPerson(Person person) { string personDispCredentials; string jobDisplayDescription; string jobDescription; try { personDispCredentials = person.DisplayCredentials; if (personDispCredentials == " ") { personDispCredentials = string.Empty; } } catch (Exception) { personDispCredentials = string.Empty; } try { jobDescription = person.Job.JobDescription; } catch (Exception) { jobDescription = string.Empty; } try { jobDisplayDescription = person.Job.DisplayDescription; if (jobDisplayDescription.Length < 1) { jobDisplayDescription = jobDescription; } } catch (Exception) { jobDisplayDescription = jobDescription; } var jobDescr = personDispCredentials.Length > 0 ? string.Format("{0}, {1}", jobDisplayDescription, personDispCredentials) : jobDisplayDescription; var db = new RSMDataModelDataContext(); XmlOutput xo; try { xo = new XmlOutput() .XmlDeclaration() .Node("NETBOX-API").Attribute("sessionid", SessionID).Within() .Node("COMMAND").Attribute("name", "AddPerson").Attribute("num", "1").Within() .Node("PARAMS").Within() .Node("PERSONID").InnerText(person.PersonID.ToString()) .Node("LASTNAME").InnerText(person.LastName) .Node("FIRSTNAME").InnerText(person.NickFirst) .Node("MIDDLENAME").InnerText(person.MiddleName) .Node("CONTACTLOCATION").InnerText(person.Facility) .Node("UDF1").InnerText(person.JobCode) .Node("UDF2").InnerText(jobDescr) .Node("UDF3").InnerText(person.DeptID) .Node("UDF4").InnerText(person.DeptDescr) .Node("UDF5").InnerText(person.Facility) .Node("UDF6").InnerText(person.BadgeNumber) .Node("UDF7").InnerText(person.JobDescr) .Node("UDF8").InnerText(personDispCredentials) .Node("UDF9").InnerText(person.EmployeeID) .Node("ACCESSLEVELS").Within(); } catch (Exception) { throw (new Exception(string.Format("Exception building API XML for {0}, {1}", person.LastName, person.FirstName))); } try { // TODO Deal with no access levels var levels = db.LevelsAssignedToPerson(person.PersonID); var lcount = 0; foreach (var l in levels) { lcount++; if (lcount < MAX_LEVELS_S2_SUPPORTS) { xo.Node("ACCESSLEVEL").InnerText(l.AccessLevelName); } } } catch (Exception) { throw (new Exception(string.Format("Exception adding levels for {0}, {1}", person.LastName, person.FirstName))); } XmlDocument doc; try { doc = HttpPost(xo); if (CallWasSuccessful(doc)) { db.Syslog(ExportSystem, Severity.Informational, string.Format("Exported associate \"{0}, {1} {2}\" to S2.", person.LastName, person.FirstName, person.MiddleName), ""); XmlNode details = doc["NETBOX"]["RESPONSE"]["DETAILS"]; return(true); } } catch (Exception) { throw (new Exception(string.Format("Exception checking success for {0}, {1}", person.LastName, person.FirstName))); } try { db.Syslog(ExportSystem, Severity.Error, string.Format("FAILED exporting associate \"{0}, {1} {2}\" to S2.", person.LastName, person.FirstName, person.MiddleName), doc["NETBOX"]["RESPONSE"]["DETAILS"]["ERRMSG"].InnerText); } catch (Exception) { throw (new Exception(string.Format("Exception logging error for {0}, {1}\n'{2}'", person.LastName, person.FirstName, doc.InnerXml))); } return(false); }