public static void Main(string[] args) { BasicHttpBinding basicHttpBinding = null; EndpointAddress endpointAddress = null; basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); endpointAddress = new EndpointAddress(new Uri("url-soap-aqui")); try { System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12; ServiceReference1.RightNowSyncPortClient syncClient = new RightNowSyncPortClient(basicHttpBinding,endpointAddress); syncClient.ClientCredentials.UserName.UserName = "******"; syncClient.ClientCredentials.UserName.Password = "******"; Contact contact = new Contact(); ID cID = new ID(); cID.id = 0; cID.idSpecified = true; contact.ID = cID; var api = new APIAccessRequestHeader(); GetProcessingOptions getProcessiongOptions = new GetProcessingOptions(); getProcessiongOptions.FetchAllNames = false; ClientInfoHeader clientInfoHeader = new ClientInfoHeader(); clientInfoHeader.AppID = "Read Contact"; RNObject[] orgObjects = new RNObject[] { contact }; RNObject[] readReturn; var resp = syncClient.GetAsync(clientInfoHeader, api, orgObjects, getProcessiongOptions); readReturn = resp.Result.RNObjectsResult; Contact readContact = (Contact)readReturn[0]; Console.WriteLine("Lookup name: " + readContact.LookupName); Console.WriteLine("Login: "******"Digite \"ENTER\" para sair..."); Console.ReadLine(); }
public RNObject[] CreateContact(string FirstName, string LastName,string EmailAddress) { Contact newContact = populateContactInfo(FirstName, LastName,EmailAddress); //Set the application ID in the client info header ClientInfoHeader clientInfoHeader = new ClientInfoHeader(); clientInfoHeader.AppID = ".NET Getting Started test in log API"; //Set the create processing options, allow external events and rules to execute CreateProcessingOptions createProcessingOptions = new CreateProcessingOptions(); createProcessingOptions.SuppressExternalEvents = false; createProcessingOptions.SuppressRules = false; RNObject[] createObjects = new RNObject[] { newContact }; GetProcessingOptions options = new GetProcessingOptions(); options.FetchAllNames = false; //Invoke the create operation on the server. This will create a contact RNObject[] createResults = _service.Create(clientInfoHeader, createObjects, createProcessingOptions); newContact = createResults[0] as Contact; RNObject[] rnObjects = _service.Get(clientInfoHeader, createResults, options); return rnObjects; }
public AnalyticsReport getAnalyticsReport(long reportID) { AnalyticsReport analyticsReport = new AnalyticsReport(); ID analyticsReportID = new ID(); analyticsReportID.id = reportID; analyticsReportID.idSpecified = true; analyticsReport.ID = analyticsReportID; AnalyticsReportFilter filter = new AnalyticsReportFilter(); analyticsReport.Filters = (new AnalyticsReportFilter[] { filter }); GetProcessingOptions processingOptions = new GetProcessingOptions(); processingOptions.FetchAllNames = true; RNObject[] getAnalyticsObjects = new RNObject[] { analyticsReport }; RNObject[] rnObjects = _client.Get(_clientInfoHeader, getAnalyticsObjects, processingOptions); AnalyticsReport report = (AnalyticsReport)rnObjects[0]; return(report); }
internal RunAnalyticsResponse GetAnalyticsReportResults(long reportId, AnalyticsReportFilter[] filters, int limit = 100, int start = 0, string delimiter = ",") { //Create new AnalyticsReport Object AnalyticsReport analyticsReport = new AnalyticsReport(); //Specify a report ID of Public Reports>Common>Data integration>Opportunities ID reportID = new ID(); reportID.id = reportId; reportID.idSpecified = true; analyticsReport.ID = reportID; analyticsReport.Filters = filters; GetProcessingOptions processingOptions = new GetProcessingOptions(); processingOptions.FetchAllNames = true; RNObject[] getAnalyticsObjects = new RNObject[] { analyticsReport }; CSVTableSet thisSet = new CSVTableSet(); byte[] ignore; bool mustRetry = false; // used to determine if we should retry a failed job int retryTimes = 0; // we don't want to endlessly retry, so we only will retry 3 times do { try { thisSet = _client.RunAnalyticsReport(_clientInfoHeader, analyticsReport, limit, start, delimiter, false, true, out ignore); return(new RunAnalyticsResponse { RunAnalyticsTableSet = thisSet, Successful = true, SuccessfulSet = true }); } catch (Exception ex) { GlobalContext.Log(string.Format("Failed RunAnalyticsReport: Retry {0}: {1}", retryTimes, ex.Message), true); GlobalContext.Log(string.Format("Failed RunAnalyticsReport: Retry {0}: {1}{2}{3}", retryTimes, ex.Message, Environment.NewLine, ex.StackTrace), false); if (retryTimes < 3) { // if we haven't retried 3 times then we retry the load again mustRetry = true; retryTimes++; } else { // don't retry for 3rd retry return(new RunAnalyticsResponse { Successful = false, SuccessfulSet = false, Details = ex.Message }); } } GlobalContext.Log(string.Format("RunAnalyticsReport Must Retry {0}", mustRetry), false); } while (mustRetry); GlobalContext.Log("RunAnalyticsReport End: This code should never be hit.", false); return(null); // this code should never be hit }