public string GetOrganization(string accountNumber) { var fnoWs = new v1UserOrgHierarchyService(); fnoWs.Url = EndPointUrl + "UserOrgHierarchyService"; fnoWs.PreAuthenticate = true; CredentialCache credCache = new System.Net.CredentialCache(); NetworkCredential netCred = new NetworkCredential(UserName, Password); credCache.Add(new Uri(fnoWs.Url), "Basic", netCred); fnoWs.Credentials = credCache; var rqType = new getOrganizationsQueryRequestType(); rqType.batchSize = "10"; rqType.pageNumber = "1"; rqType.queryParams = new organizationQueryParametersType { orgName = new UserOrganizationHierachy.SimpleQueryType { searchType = UserOrganizationHierachy.simpleSearchType.EQUALS, value = accountNumber } }; var resp = fnoWs.getOrganizationsQuery(rqType); if (resp.statusInfo.status == UserOrganizationHierachy.StatusType.SUCCESS) { if (resp.responseData != null) { return(resp.responseData[0].organization.uniqueId); } else { return(string.Empty); } } else { return(string.Empty); } }
public string CreateOrganization(string CompanyName, string accountNumber) { var fnoWs = new v1UserOrgHierarchyService(); fnoWs.Url = EndPointUrl + "UserOrgHierarchyService"; fnoWs.PreAuthenticate = true; CredentialCache credCache = new System.Net.CredentialCache(); NetworkCredential netCred = new NetworkCredential(UserName, Password); credCache.Add(new Uri(fnoWs.Url), "Basic", netCred); fnoWs.Credentials = credCache; var rqType = new createOrgRequestType(); var orgDataType = new List <organizationDataType>(); orgDataType.Add(new organizationDataType { name = accountNumber, displayName = CompanyName, orgType = OrgType.CUSTOMER }); rqType.organization = orgDataType.ToArray(); var resp = fnoWs.createOrganization(rqType); if (resp.statusInfo.status == UserOrganizationHierachy.StatusType.SUCCESS) { return(resp.responseData[0].uniqueId); } else { throw new Exception(resp.statusInfo.reason); } }