public RightNowService(IGlobalContext _gContext) { // Set up SOAP API request to retrieve Endpoint Configuration - // Get the SOAP API url of current site as SOAP Web Service endpoint EndpointAddress endPointAddr = new EndpointAddress(_gContext.GetInterfaceServiceUrl(ConnectServiceType.Soap)); // Minimum required BasicHttpBinding binding2 = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding2.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding2.MaxReceivedMessageSize = 1024 * 1024; binding2.MaxBufferSize = 1024 * 1024; binding2.MessageEncoding = WSMessageEncoding.Mtom; // Create client proxy class _rnowClient = new RightNowSyncPortClient(binding2, endPointAddr); BindingElementCollection elements = _rnowClient.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; _rnowClient.Endpoint.Binding = new CustomBinding(elements); // Add SOAP msg inspector behavior //_rnowClient.Endpoint.Behaviors.Add(new LogMsgBehavior()); // Ask the Add-In framework the handle the session logic _gContext.PrepareConnectSession(_rnowClient.ChannelFactory); // Set up query and set request _rnowClientInfoHeader = new ClientInfoHeader(); _rnowClientInfoHeader.AppID = "Case Management Accelerator Services"; }
public Boolean initializeLogger(IGlobalContext globalContext) { EndpointAddress endPointAddr = new EndpointAddress(globalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap)); // Minimum required BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; // Create client proxy class RightNowSyncPortClient client = new RightNowSyncPortClient(binding, endPointAddr); // Ask the client to not send the timestamp BindingElementCollection elements = client.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; client.Endpoint.Binding = new CustomBinding(elements); // Ask the Add-In framework the handle the session logic globalContext.PrepareConnectSession(client.ChannelFactory); this.client = client; this.extObject = getExtension(); return(true); }
public bool Init() { try { bool result = false; EndpointAddress endPointAddr = new EndpointAddress(gcontext.GetInterfaceServiceUrl(ConnectServiceType.Soap)); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; binding.ReceiveTimeout = new TimeSpan(0, 10, 0); binding.MaxReceivedMessageSize = 1048576; //1MB binding.SendTimeout = new TimeSpan(0, 10, 0); clientORN = new RightNowSyncPortClient(binding, endPointAddr); BindingElementCollection elements = clientORN.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; clientORN.Endpoint.Binding = new CustomBinding(elements); gcontext.PrepareConnectSession(clientORN.ChannelFactory); if (clientORN != null) { result = true; } return(result); } catch (Exception ex) { MessageBox.Show("Error en INIT: " + ex.Message); return(false); } }
public bool Init() { try { bool result = false; EndpointAddress endPointAddr = new EndpointAddress(globalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap)); // Minimum required BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; binding.ReceiveTimeout = new TimeSpan(0, 10, 0); binding.MaxReceivedMessageSize = 1048576; //1MB binding.SendTimeout = new TimeSpan(0, 10, 0); // Create client proxy class clientRN = new RightNowSyncPortClient(binding, endPointAddr); // Ask the client to not send the timestamp BindingElementCollection elements = clientRN.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; clientRN.Endpoint.Binding = new CustomBinding(elements); // Ask the Add-In framework the handle the session logic globalContext.PrepareConnectSession(clientRN.ChannelFactory); if (clientRN != null) { result = true; } return(result); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// Create a log entry in the custom object PSLog$Log /// /// If this table does not exists, please retrieve the package from: https://tools.src.rightnow.com/spaces/logging/documents /// </summary> /// <param name="client">Extend the RightNow soap client</param> /// <param name="existingID">ID of the existing PSLog object</param> /// <param name="type">Optional (default=blank): application type causing the log m /// <param name="message">Optional (default=blank): human readable friendly message</param>essage</param> /// <param name="subtype">Optional (default=blank): friendly name of the application</param> /// <param name="source">Optional (default=blank): name of the current assembly or script</param> /// <param name="note">Optional (default=blank): additional details about the message</param> /// <param name="interfaceID">Optional (default=blank): the interface this error occurred on. (GlobalContext.InterfaceId)</param> /// <param name="severity">Optional (default=blank): mark the importance of the message</param> /// <param name="exception">Optional (default=blank): if populated the stack trace from the exception will be stored in the log</param> /// <param name="account">Optional (default=blank): reference to an Account</param> /// <param name="answer">Optional (default=blank): reference to an Answer</param> /// <param name="contact">Optional (default=blank): reference to a Contact</param> /// <param name="incident">Optional (default=blank): reference to an Incident</param> /// <param name="opportunity">Optional (default=blank): reference to an Opportunity</param> /// <param name="org">Optional (default=blank): reference to an Organization</param> /// <param name="task">Optional (default=blank): reference to a Task</param> /// <param name="customObjects">Optional (default=blank): an array of custom object references. the name of the object must match the name of the database column</param> /// <returns>ID of the newly created log object</returns> public static void UpdateLogAsync(this RightNowSyncPortClient client, int existingID, Type type = Type.None, string message = null, string subtype = null, string note = null, string source = null, int?interfaceID = null, Severity severity = Severity.None, Exception exception = null, Account account = null, Answer answer = null, Contact contact = null, Incident incident = null, Opportunity opportunity = null, Organization org = null, Task task = null, GenericObject[] customObjects = null) { BackgroundWorker asyncWorker = new BackgroundWorker(); asyncWorker.DoWork += delegate(object sender, DoWorkEventArgs e) { UpdateLog(client, existingID, type, message, subtype, note, source, interfaceID, severity, exception, account, answer, contact, incident, opportunity, org, task, customObjects); }; asyncWorker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { if (UpdateLogAsyncCompleteEvent != null) { UpdateLogAsyncCompleteEvent(); } }; asyncWorker.RunWorkerAsync(); }
public RightNowService(IGlobalContext _gContext) { // Set up SOAP API request to retrieve Endpoint Configuration - // Get the SOAP API url of current site as SOAP Web Service endpoint EndpointAddress endPointAddr = new EndpointAddress(_gContext.GetInterfaceServiceUrl(ConnectServiceType.Soap)); // Minimum required BasicHttpBinding binding2 = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding2.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding2.MaxReceivedMessageSize = 5 * 1024 * 1024; binding2.MaxBufferSize = 5 * 1024 * 1024; binding2.MessageEncoding = WSMessageEncoding.Mtom; // Create client proxy class _rnowClient = new RightNowSyncPortClient(binding2, endPointAddr); BindingElementCollection elements = _rnowClient.Endpoint.Binding.CreateBindingElements(); elements.Find<SecurityBindingElement>().IncludeTimestamp = false; _rnowClient.Endpoint.Binding = new CustomBinding(elements); // Add SOAP msg inspector behavior //_rnowClient.Endpoint.Behaviors.Add(new LogMsgBehavior()); // Ask the Add-In framework the handle the session logic _gContext.PrepareConnectSession(_rnowClient.ChannelFactory); // Set up query and set request _rnowClientInfoHeader = new ClientInfoHeader(); _rnowClientInfoHeader.AppID = "Case Management Accelerator Services"; }
public SCLogWrapper(string productExtSignature = null, string productExtName = null, string businessFunction = null) : base(productExtName, productExtName, default(DateTime), logLevel.Debug, businessFunction) { _rnowClient = ConfigurationSetting.client; _businessFunction = businessFunction; base.initializeLogger(_rnowClient); _host = ConfigurationSetting.host; }
public Boolean initializeLogger(RightNowSyncPortClient client) { // Ask the client to not send the timestamp BindingElementCollection elements = client.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; client.Endpoint.Binding = new CustomBinding(elements); this.client = client; this.extObject = getExtension(); return(true); }
public static IRightNowConnectService GetService() { if (_rightnowConnectService != null) { return(_rightnowConnectService); } try { lock (_sync) { if (_rightnowConnectService == null) { // Initialize client with current interface soap url string url = IOTClouddAutoClientAddIn.GlobalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap); EndpointAddress endpoint = new EndpointAddress(url); //EndpointAddress endpoint = new EndpointAddress("https://day04-16500-sql-80h.qb.lan/cgi-bin/day04_16500_sql_80h.cfg/services/soap"); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; _rightNowClient = new RightNowSyncPortClient(binding, endpoint); // Initialize credentials for rightnow client /*var rightNowConnectUser = ConfigurationManager.AppSettings["rightnow_user"]; * var rightNowConnectPassword = ConfigurationManager.AppSettings["rightnow_password"]; * * _rightNowClient.ClientCredentials.UserName.UserName = "******"; * _rightNowClient.ClientCredentials.UserName.Password = "******";*/ BindingElementCollection elements = _rightNowClient.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; _rightNowClient.Endpoint.Binding = new CustomBinding(elements); _rightnowConnectService = new RightNowConnectService(); } } } catch (Exception e) { _rightnowConnectService = null; MessageBox.Show(ExceptionMessages.RIGHTNOW_CONNECT_SERVICE_NOT_INITIALIZED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(_rightnowConnectService); }
public static IRightNowConnectService GetService() { if (_rightnowConnectService != null) { return _rightnowConnectService; } try { lock (_sync) { if (_rightnowConnectService == null) { // Initialize client with current interface soap url string url = SalesCloudAutoClientAddIn.GlobalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap); EndpointAddress endpoint = new EndpointAddress(url); //EndpointAddress endpoint = new EndpointAddress("https://osc-svc-integration-qb1--dvp.qb.lan/cgi-bin/osc_svc_integration_qb1.cfg/services/soap"); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; _rightNowClient = new RightNowSyncPortClient(binding, endpoint); // Initialize credentials for rightnow client /*var rightNowConnectUser = ConfigurationManager.AppSettings["rightnow_user"]; var rightNowConnectPassword = ConfigurationManager.AppSettings["rightnow_password"]; _rightNowClient.ClientCredentials.UserName.UserName = rightNowConnectUser; _rightNowClient.ClientCredentials.UserName.Password = rightNowConnectPassword;*/ BindingElementCollection elements = _rightNowClient.Endpoint.Binding.CreateBindingElements(); elements.Find<SecurityBindingElement>().IncludeTimestamp = false; _rightNowClient.Endpoint.Binding = new CustomBinding(elements); _rightnowConnectService = new RightNowConnectService(); } } } catch (Exception e) { _rightnowConnectService = null; MessageBox.Show(OSCExceptionMessages.RightNowConnectServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return _rightnowConnectService; }
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 static RightNowConnectService GetService(IGlobalContext _globalContext) { if (_rightnowConnectService != null) { return(_rightnowConnectService); } try { lock (_sync) { if (_rightnowConnectService == null) { // Initialize client with current interface soap url string url = _globalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap); EndpointAddress endpoint = new EndpointAddress(_globalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap)); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; _rightNowClient = new RightNowSyncPortClient(binding, endpoint); BindingElementCollection elements = _rightNowClient.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; _rightNowClient.Endpoint.Binding = new CustomBinding(elements); WorkspaceAddIn._globalContext.PrepareConnectSession(_rightNowClient.ChannelFactory); _rightnowConnectService = new RightNowConnectService(); } } } catch (Exception e) { _rightnowConnectService = null; // WorkspaceAddIn.InfoLog(e.Message); } return(_rightnowConnectService); }
/// <summary> /// Create a log entry in the custom object PSLog$Log /// /// If this table does not exists, please retrieve the package from: https://tools.src.rightnow.com/spaces/logging/documents /// </summary> /// <param name="client">Extend the RightNow soap client</param> /// <param name="existingID">ID of the existing PSLog object</param> /// <param name="type">Optional (default=blank): application type causing the log m /// <param name="message">Optional (default=blank): human readable friendly message</param>essage</param> /// <param name="subtype">Optional (default=blank): friendly name of the application</param> /// <param name="source">Optional (default=blank): name of the current assembly or script</param> /// <param name="note">Optional (default=blank): additional details about the message</param> /// <param name="interfaceID">Optional (default=blank): the interface this error occurred on. (GlobalContext.InterfaceId)</param> /// <param name="severity">Optional (default=blank): mark the importance of the message</param> /// <param name="exception">Optional (default=blank): if populated the stack trace from the exception will be stored in the log</param> /// <param name="account">Optional (default=blank): reference to an Account</param> /// <param name="answer">Optional (default=blank): reference to an Answer</param> /// <param name="contact">Optional (default=blank): reference to a Contact</param> /// <param name="incident">Optional (default=blank): reference to an Incident</param> /// <param name="opportunity">Optional (default=blank): reference to an Opportunity</param> /// <param name="org">Optional (default=blank): reference to an Organization</param> /// <param name="task">Optional (default=blank): reference to a Task</param> /// <param name="customObjects">Optional (default=blank): an array of custom object references. the name of the object must match the name of the database column</param> /// <returns>ID of the newly created log object</returns> public static void UpdateLog(this RightNowSyncPortClient client, int existingID, Type type = Type.None, string message = null, string subtype = null, string note = null, string source = null, int?interfaceID = null, Severity severity = Severity.None, Exception exception = null, Account account = null, Answer answer = null, Contact contact = null, Incident incident = null, Opportunity opportunity = null, Organization org = null, Task task = null, GenericObject[] customObjects = null) { try { GenericObject go = CreateLogGenericObject(type, subtype, message, note, source, interfaceID, severity, exception, account, answer, contact, incident, opportunity, org, task, customObjects); go.ID = new ID { id = existingID, idSpecified = true }; client.Update( new ClientInfoHeader { AppID = "PSLog" }, new RNObject[] { go }, new UpdateProcessingOptions { SuppressExternalEvents = true, SuppressRules = false }); } catch (Exception ex) { if (LogFailedEvent != null) { LogFailedEvent(ex); } } }
public static IRightNowConnectService GetService() { if (_rightnowConnectService != null) { return(_rightnowConnectService); } try { lock (_sync) { if (_rightnowConnectService == null) { // Initialize client with current interface soap url string url = OutOfOfficeClientAddIn.GlobalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap); EndpointAddress endpoint = new EndpointAddress(url); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; _rightNowClient = new RightNowSyncPortClient(binding, endpoint); BindingElementCollection elements = _rightNowClient.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; _rightNowClient.Endpoint.Binding = new CustomBinding(elements); _rightnowConnectService = new RightNowConnectService(); } } } catch (Exception e) { _rightnowConnectService = null; MessageBox.Show(OOOExceptionMessages.RightNowConnectServiceNotInitialized, Common.Common.ErrorLabel, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(_rightnowConnectService); }
/// <summary> /// Method which is invoked by the AddIn framework when the control is created. /// </summary> /// <param name="inDesignMode">Flag which indicates if the control is being drawn on the Workspace Designer. (Use this flag to determine if code should perform any logic on the workspace record)</param> /// <param name="RecordContext">The current workspace record context.</param> /// <returns>The control which implements the IWorkspaceComponent2 interface.</returns> public IWorkspaceComponent2 CreateControl(bool inDesignMode, IRecordContext RecordContext) { if (!ConfigurationSetting.configVerbPerfect) { if (!ConfigurationSetting.loginUserIsAdmin) { MessageBox.Show("Contact Search Add-In is not initialized properly. \nPlease contact your system administrator.\n You are now logged out."); _globalContext.Logout(); } else // don't want to logout admin { MessageBox.Show("Contact Search Add-In is not loaded because of invalid configuration verb."); return(new ContactWorkspaceAddIn(inDesignMode, RecordContext, _globalContext)); } } _rContext = RecordContext; if (!inDesignMode && RecordContext != null) { //Get configuration ConfigurationSetting instance = ConfigurationSetting.Instance(_globalContext); _usr = ConfigurationSetting.username; _pwd = ConfigurationSetting.password; _client = ConfigurationSetting.client; _rnSrv = ConfigurationSetting.rnSrv; _log = ConfigurationSetting.logWrap; Accelerator.EBS.SharedServices.ContactModel.ServiceProvider = ConfigurationSetting.EBSProvider; Accelerator.EBS.SharedServices.ContactModel.ListLookupURL = ConfigurationSetting.LookupContactList_WSDL; Accelerator.EBS.SharedServices.ContactModel.ServiceUsername = String.IsNullOrEmpty(_usr) ? "ebusiness" : _usr; Accelerator.EBS.SharedServices.ContactModel.ServicePassword = String.IsNullOrEmpty(_pwd) ? "password" : _pwd; Accelerator.EBS.SharedServices.ContactModel.ServiceClientTimeout = ConfigurationSetting.EBSServiceTimeout; Accelerator.EBS.SharedServices.ContactModel.InitEBSProvider(); Contact_Search_Report_ID = ConfigurationSetting.contactSearchReportID; } _wsAddIn = new ContactWorkspaceAddIn(inDesignMode, RecordContext, _globalContext); _wsAddIn._contactSearchReportId = Contact_Search_Report_ID; _wsAddIn._rnSrv = _rnSrv; _wsAddIn._log = _log; return(_wsAddIn); }
private void SetupRightNowClient() { var configBindings = ConfigurationManager.GetSection("system.serviceModel/bindings") as System.ServiceModel.Configuration.BindingsSection; var configClient = ConfigurationManager.GetSection("system.serviceModel/client") as System.ServiceModel.Configuration.ClientSection; var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; binding.MaxBufferSize = int.MaxValue; binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferPoolSize = int.MaxValue; var endPointAddr = new EndpointAddress(configClient.Endpoints[0].Address); _client = new RightNowSyncPortClient(binding, endPointAddr); if (_client.ClientCredentials != null) { _client.ClientCredentials.UserName.UserName = _user; _client.ClientCredentials.UserName.Password = _pass; } BindingElementCollection elements = _client.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; elements.Find <TransportBindingElement>().MaxReceivedMessageSize = int.MaxValue; elements.Find <TransportBindingElement>().MaxBufferPoolSize = int.MaxValue; _client.Endpoint.Binding = new CustomBinding(elements); _client.Endpoint.Binding.SendTimeout = configBindings.CustomBinding.ConfiguredBindings[0].SendTimeout; _client.Endpoint.Binding.ReceiveTimeout = configBindings.CustomBinding.ConfiguredBindings[0].ReceiveTimeout; _client.Endpoint.Binding.OpenTimeout = configBindings.CustomBinding.ConfiguredBindings[0].OpenTimeout; _client.Endpoint.Binding.CloseTimeout = configBindings.CustomBinding.ConfiguredBindings[0].CloseTimeout; _clientInfoHeader = new ClientInfoHeader { AppID = "AmberLeaf Data Integrator" }; }
static RightNowSyncPortClient SetupConnection(string endpointAddress, string user, string password) { BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.MaxBufferPoolSize = 20000000; binding.MaxBufferSize = 20000000; binding.MaxReceivedMessageSize = 20000000; binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; EndpointAddress endPointAddress = new EndpointAddress(endpointAddress); var service = new RightNowSyncPortClient(binding, endPointAddress); service.ClientCredentials.UserName.UserName = user; service.ClientCredentials.UserName.Password = password; BindingElementCollection elements = service.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; service.Endpoint.Binding = new CustomBinding(elements); return(service); }
public Program() { _Service = new RightNowSyncPortClient(); _Service.ClientCredentials.UserName.UserName = "******"; _Service.ClientCredentials.UserName.Password = "******"; }
static void GetAllContacts(RightNowSyncPortClient client) { Contact contactTemplate = new Contact(); contactTemplate.Phones = new Phone[] { }; UpdateProcessingOptions options = new UpdateProcessingOptions(); RNObject[] objectTemplates = new RNObject[] { contactTemplate }; bool hasMoreResults = true; int currentOffset = 0; do { var resultTable = client.QueryObjects(s_clientInfoHeader, String.Format("SELECT Contact FROM Contact LIMIT {0} OFFSET {1}", PageSize, currentOffset), objectTemplates, PageSize); RNObject[] rnObjects = resultTable[0].RNObjectsResult; List <RNObject> updatedObjects = new List <RNObject>(); foreach (RNObject obj in rnObjects) { Contact contact = (Contact)obj; Phone[] phones = contact.Phones; if (phones != null) { List <Phone> newPhoneNumbers = new List <Phone>(); foreach (Phone phone in phones) { var sanitizedNumber = SanitizeNumber(phone.Number); System.Console.WriteLine(contact.Name.Last + " - " + phone.Number + " (" + phone.RawNumber + ") - " + sanitizedNumber); if (sanitizedNumber != phone.Number) { //need to create a new Phone object, if we reuse/update the existing one, the update won't work. var newNumber = new Phone() { action = ActionEnum.update, actionSpecified = true, Number = SanitizeNumber(phone.Number), PhoneType = phone.PhoneType }; newPhoneNumbers.Add(newNumber); } } if (newPhoneNumbers.Count > 0) { updatedObjects.Add(new Contact() { ID = contact.ID, Phones = newPhoneNumbers.ToArray(), }); } } } if (updatedObjects.Count > 0) { client.Update(s_clientInfoHeader, updatedObjects.ToArray(), options); } hasMoreResults = resultTable[0].Paging.ReturnedCount == PageSize; currentOffset = currentOffset + resultTable[0].Paging.ReturnedCount; Console.WriteLine(String.Format("Processed {0} contacts", currentOffset)); } while (hasMoreResults); }
/// <summary> /// Method which is invoked by the AddIn framework when the control is created. /// </summary> /// <param name="inDesignMode">Flag which indicates if the control is being drawn on the Workspace Designer. (Use this flag to determine if code should perform any logic on the workspace record)</param> /// <param name="RecordContext">The current workspace record context.</param> /// <returns>The control which implements the IWorkspaceComponent2 interface.</returns> public IWorkspaceComponent2 CreateControl(bool inDesignMode, IRecordContext RecordContext) { if (!ConfigurationSetting.configVerbPerfect) { if (!ConfigurationSetting.loginUserIsAdmin) { MessageBox.Show("Contact Search Add-In is not initialized properly. \nPlease contact your system administrator.\n You are now logged out."); _globalContext.Logout(); } else // don't want to logout admin { MessageBox.Show("Contact Search Add-In is not loaded because of invalid configuration verb."); return new ContactWorkspaceAddIn(inDesignMode, RecordContext, _globalContext); } } _rContext = RecordContext; if (!inDesignMode && RecordContext != null) { //Get configuration ConfigurationSetting instance = ConfigurationSetting.Instance(_globalContext); _usr = ConfigurationSetting.username; _pwd = ConfigurationSetting.password; _client = ConfigurationSetting.client; _rnSrv = ConfigurationSetting.rnSrv; _log = ConfigurationSetting.logWrap; Accelerator.Siebel.SharedServices.ContactModel.ServiceProvider = ConfigurationSetting.SiebelProvider; Accelerator.Siebel.SharedServices.ContactModel.ListLookupURL = ConfigurationSetting.LookupContactList_WSDL; Accelerator.Siebel.SharedServices.ContactModel.ServiceUsername = String.IsNullOrEmpty(_usr) ? "ebusiness" : _usr; Accelerator.Siebel.SharedServices.ContactModel.ServicePassword = String.IsNullOrEmpty(_pwd) ? "password" : _pwd; Accelerator.Siebel.SharedServices.ContactModel.ServiceClientTimeout = ConfigurationSetting.SiebelServiceTimeout; Accelerator.Siebel.SharedServices.ContactModel.InitSiebelProvider(); Contact_Search_Report_ID = ConfigurationSetting.contactSearchReportID; } _wsAddIn = new ContactWorkspaceAddIn(inDesignMode, RecordContext, _globalContext); _wsAddIn._contactSearchReportId = Contact_Search_Report_ID; _wsAddIn._rnSrv = _rnSrv; _wsAddIn._log = _log; return _wsAddIn; }
public QueryCSV() { _client = new RightNowSyncPortClient(); _client.ClientCredentials.UserName.UserName = "******"; _client.ClientCredentials.UserName.Password = "******"; }
//Retrieve configuration verb via RNow SOAP and Parse it as JSON public static bool getConfigVerb(IGlobalContext _gContext) { //Init the RightNow Service rnSrv = new RightNowService(_gContext); client = rnSrv._rnowClient; string logMessage, logNote; //Query configuration from Cloud Service String query = "select Configuration.Value from Configuration where lookupname='CUSTOM_CFG_Accel_Ext_Integrations'"; String[] rowData = null; try { rowData = rnSrv.queryData(query); } catch (Exception ex) { if (logWrap != null) { logMessage = "Integration Configuration verb is not set properly. "; logNote = "Error in query config 'CUSTOM_CFG_Accel_Ext_Integrations' from Cloud Service. Error query: " + query + "; Error Message: " + ex.Message; logWrap.ErrorLog(); } MessageBox.Show("Integration Configuration verb is not set properly. Please contact your system administrator. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } // Check whether configuration is set if (rowData.Length == 0) { String message = "Integration Configuration verb does not exist. Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (logWrap != null) { logMessage = "Integration Configuration verb does not exist."; logNote = "CUSTOM_CFG_Accel_Ext_Integrations is missing in Configuration Settings."; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); } return(false); } // Get configuration value string jsonString = rowData[0]; jsonString = jsonString.Replace("\"\"", "\""); // get the AdminProfileID // make sure it is located before "hosts" (if this is also missing, well, the config // verb is in bad shape. // can't use "{"AdminProfileID" because { can be followed by newline in config verb if (jsonString.Contains("AdminProfileID") && jsonString.Contains("hosts") && jsonString.IndexOf("AdminProfileID") < jsonString.IndexOf("hosts")) { // get the AdminProfileID value AdminProfileID = Convert.ToInt32(jsonString.Split(',')[0].Split(':')[1]); } else { String message = "Integration Configuration verb does not contain AdminProfileID as first member of JSON.\n Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (logWrap != null) { logMessage = "Integration Configuration verb does not contain AdminProfileID as first member of JSON"; logNote = "The string is: " + jsonString; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); } AdminProfileID = 0; return(false); } loginUserIsAdmin = _gContext.ProfileId == ConfigurationSetting.AdminProfileID; // Parse endpoint configuration int i = jsonString.IndexOf("["); int j = jsonString.LastIndexOf("]"); if (i < 0 || i > j) { String message = "Siebel Integration Configuration verb is not set properly. Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (logWrap != null) { logMessage = "Accelerator Integration Configuration verb [] array is not set properly."; logNote = "Configuration cannot be parsed, the string is: " + jsonString; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); } return(false); } string jsonTrim = jsonString.Substring(i, j - i + 1); /* Using Serializer to parse Configuration JSON String * The parsing is based on the classes definition in the following region */ var serializer = new JavaScriptSerializer(); List <ConfigurationVerb> configVerbArray = null; try { configVerbArray = serializer.Deserialize <List <ConfigurationVerb> >(jsonTrim); } catch (System.ArgumentException ex) { String message = "Accelerator Integration Configuration verb JSON is invalid. Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); logMessage = "Accelerator Integration Configuration verb JSON is invalid."; logNote = "Configuration cannot be parsed, the string is: " + jsonString; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); return(false); } bool found = false; // Get the server url of current site string _interfaceUrl = _gContext.InterfaceURL; string[] splittedInterfaceUrl = _interfaceUrl.Split('/'); string _configServerUrl = splittedInterfaceUrl[2]; // Get values in configuration settings foreach (ConfigurationVerb configVerb in configVerbArray) { if (configVerb.rnt_host.Contains(_configServerUrl)) { string extBaseUrl = configVerb.integration.ext_base_url; //Get Siebel server type and initiate Siebel Provider string serverType = configVerb.integration.server_type; SiebelProvider = serverTypeToProvider(serverType); username = configVerb.integration.username; password = configVerb.integration.password; siebelServiceUserId = configVerb.integration.siebel_service_user_id; siebelDefaultSrOwnerId = configVerb.integration.siebel_default_sr_owner_id; SiebelServiceTimeout = configVerb.integration.SiebelServiceTimeout; log_level = configVerb.integration.log_level; assignLogLevelEnum(); rnt_host = configVerb.rnt_host; //Prepare the Service Request Type Mapping if (configVerb.integration.request_type_mapping != null) { requestTypeMapping = setRequestTypeMapping(configVerb.integration.request_type_mapping); } incidentsByContactReportID = configVerb.integration.incidentsByContactReportID; contactSearchReportID = configVerb.integration.contactSearchReportID; uspsUsername = configVerb.postalValidation.username; ext_address_validate_url = configVerb.postalValidation.ext_address_validate_url; Dictionary <String, Service> extServices = configVerb.integration.ext_services; foreach (KeyValuePair <String, Service> extService in extServices) { switch (extService.Key) { case "service_request_detail": if (extService.Value.create != null) { CreateSR_WSDL = extBaseUrl + extService.Value.create.relative_path; } if (extService.Value.update != null) { UpdateSR_WSDL = extBaseUrl + extService.Value.update.relative_path; } if (extService.Value.read != null) { LookupSR_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; case "service_request_list": if (extService.Value.read != null) { LookupSRbyContactPartyID_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; case "repair_order_detail": if (extService.Value.create != null) { CreateRepair_WSDL = extBaseUrl + extService.Value.create.relative_path; } if (extService.Value.update != null) { UpdateRepair_WSDL = extBaseUrl + extService.Value.update.relative_path; } if (extService.Value.read != null) { LookupRepair_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; case "repair_order_list": if (extService.Value.read != null) { RepairOrderList_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; case "service_request_note": if (extService.Value.create != null) { CreateInteraction_WSDL = extBaseUrl + extService.Value.create.relative_path; } break; case "contact_list": if (extService.Value.read != null) { LookupContactList_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; case "item_list": if (extService.Value.read != null) { ItemList_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; case "entitlement_list": if (extService.Value.read != null) { EntitlementList_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; case "repair_logistics_list": if (extService.Value.read != null) { RepairLogisticsList_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; case "repair_list": if (extService.Value.read != null) { RepairOrderList_WSDL = extBaseUrl + extService.Value.read.relative_path; } break; } } found = true; break; } } // If current site is not set in configuration. if (!found) { String message = "The current host, " + _configServerUrl + ", is not present in Integration Configuration verb.\n Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (logWrap != null) { logMessage = "Current Host is not present in Integration Configuration verb. "; logNote = "Current site is not set in configuration CUSTOM_CFG_Accel_Ext_Integrations. The configuration verb is: " + jsonString; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); } return(false); } configVerbPerfect = true; return(true); }
public RightNowTestHarness() { this.client = new RightNowSyncPortClient(); this.client.ClientCredentials.UserName.UserName = "******"; this.client.ClientCredentials.UserName.Password = "******"; }
public sampleClient() { _service = new RightNowSyncPortClient(); _service.ClientCredentials.UserName.UserName = "******"; _service.ClientCredentials.UserName.Password = "******"; }
/// <summary> /// Create a log entry in the custom object PSLog$Log /// /// If this table does not exists, please retrieve the package from: https://tools.src.rightnow.com/spaces/logging/documents /// </summary> /// <param name="client">Extend the RightNow soap client</param> /// <param name="type">Required: application type causing the log message</param> /// <param name="message">Required: human readable friendly message</param> /// <param name="subtype">Required: friendly name of the application</param> /// <param name="note">Optional (default=blank): additional details about the message</param> /// <param name="source">Optional (default=current assembly name): the name of the script that is executing</param> /// <param name="interfaceID">Optional (default=blank): the interface this error occurred on. (GlobalContext.InterfaceId)</param> /// <param name="severity">Optional (default=blank): mark the importance of the message</param> /// <param name="exception">Optional (default=blank): if populated the stack trace from the exception will be stored in the log</param> /// <param name="account">Optional (default=blank): reference to an Account</param> /// <param name="answer">Optional (default=blank): reference to an Answer</param> /// <param name="contact">Optional (default=blank): reference to a Contact</param> /// <param name="incident">Optional (default=blank): reference to an Incident</param> /// <param name="opportunity">Optional (default=blank): reference to an Opportunity</param> /// <param name="org">Optional (default=blank): reference to an Organization</param> /// <param name="task">Optional (default=blank): reference to a Task</param> /// <param name="customObjects">Optional (default=blank): an array of custom object references. the name of the object must match the name of the database column</param> /// <returns>ID of the newly created log object</returns> public static int CreateLog(this RightNowSyncPortClient client, Type type, string message, string subtype = null, string note = null, string source = null, int?interfaceID = null, Severity severity = Severity.None, Exception exception = null, Account account = null, Answer answer = null, Contact contact = null, Incident incident = null, Opportunity opportunity = null, Organization org = null, Task task = null, GenericObject[] customObjects = null) { #region sanity checks if (type == Type.None) { throw new Exception("Type can not be None when creating a new Log entry"); } if (string.IsNullOrWhiteSpace(message)) { throw new Exception("Message can not be empty"); } #endregion try { if (source == null) { source = Assembly.GetExecutingAssembly().ManifestModule.Name + " (" + Assembly.GetExecutingAssembly().GetName().Version + ")"; } GenericObject go = CreateLogGenericObject(type, subtype, message, note, source, interfaceID, severity, exception, account, answer, contact, incident, opportunity, org, task, customObjects); RNObject[] results = client.Create( new ClientInfoHeader { AppID = "PSLog" }, new RNObject[] { go }, new CreateProcessingOptions { SuppressExternalEvents = true, SuppressRules = false }); if (results == null || results.Length == 0) { return(0); } else { return((int)results[0].ID.id); } } catch (Exception ex) { if (LogFailedEvent != null) { LogFailedEvent(ex); } return(0); } }
// Initialize CWSS public static void initCWSS(IGlobalContext _gContext) { rnSrv = new RightNowService(_gContext); client = rnSrv._rnowClient; }
//Retrieve configuration verb via RNow SOAP and Parse it as JSON public static bool getConfigVerb(IGlobalContext _gContext) { //Init the RightNow Service rnSrv = new RightNowService(_gContext); client = rnSrv._rnowClient; string logMessage, logNote; //Query configuration from Cloud Service String query = "select Configuration.Value from Configuration where lookupname='CUSTOM_CFG_Accel_Ext_Integrations'"; String[] rowData = null; try { rowData = rnSrv.queryData(query); } catch (Exception ex) { if (logWrap != null) { logMessage = "Integration Configuration verb is not set properly. "; logNote = "Error in query config 'CUSTOM_CFG_Accel_Ext_Integrations' from Cloud Service. Error query: " + query + "; Error Message: " + ex.Message; logWrap.ErrorLog(); } MessageBox.Show("Integration Configuration verb is not set properly. Please contact your system administrator. ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } // Check whether configuration is set if (rowData.Length == 0) { String message = "Integration Configuration verb does not exist. Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (logWrap != null) { logMessage = "Integration Configuration verb does not exist."; logNote = "CUSTOM_CFG_Accel_Ext_Integrations is missing in Configuration Settings."; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); } return false; } // Get configuration value string jsonString = rowData[0]; jsonString = jsonString.Replace("\"\"", "\""); // get the AdminProfileID // make sure it is located before "hosts" (if this is also missing, well, the config // verb is in bad shape. // can't use "{"AdminProfileID" because { can be followed by newline in config verb if (jsonString.Contains("AdminProfileID") && jsonString.Contains("hosts") && jsonString.IndexOf("AdminProfileID") < jsonString.IndexOf("hosts")) { // get the AdminProfileID value AdminProfileID = Convert.ToInt32(jsonString.Split(',')[0].Split(':')[1]); } else { String message = "Integration Configuration verb does not contain AdminProfileID as first member of JSON.\n Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (logWrap != null) { logMessage = "Integration Configuration verb does not contain AdminProfileID as first member of JSON"; logNote = "The string is: " + jsonString; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); } AdminProfileID = 0; return false; } loginUserIsAdmin = _gContext.ProfileId == ConfigurationSetting.AdminProfileID; // Parse endpoint configuration int i = jsonString.IndexOf("["); int j = jsonString.LastIndexOf("]"); if (i < 0 || i > j) { String message = "Siebel Integration Configuration verb is not set properly. Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (logWrap != null) { logMessage = "Accelerator Integration Configuration verb [] array is not set properly."; logNote = "Configuration cannot be parsed, the string is: " + jsonString; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); } return false; } string jsonTrim = jsonString.Substring(i, j - i + 1); /* Using Serializer to parse Configuration JSON String * The parsing is based on the classes definition in the following region */ var serializer = new JavaScriptSerializer(); List<ConfigurationVerb> configVerbArray = null; try { configVerbArray = serializer.Deserialize<List<ConfigurationVerb>>(jsonTrim); } catch (System.ArgumentException ex) { String message = "Accelerator Integration Configuration verb JSON is invalid. Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); logMessage = "Accelerator Integration Configuration verb JSON is invalid."; logNote = "Configuration cannot be parsed, the string is: " + jsonString; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); return false; } bool found = false; // Get the server url of current site string _interfaceUrl = _gContext.InterfaceURL; string[] splittedInterfaceUrl = _interfaceUrl.Split('/'); string _configServerUrl = splittedInterfaceUrl[2]; // Get values in configuration settings foreach (ConfigurationVerb configVerb in configVerbArray) { if (configVerb.rnt_host.Contains(_configServerUrl)) { string extBaseUrl = configVerb.integration.ext_base_url; //Get Siebel server type and initiate Siebel Provider string serverType = configVerb.integration.server_type; SiebelProvider = serverTypeToProvider(serverType); username = configVerb.integration.username; password = configVerb.integration.password; siebelServiceUserId = configVerb.integration.siebel_service_user_id; siebelDefaultSrOwnerId = configVerb.integration.siebel_default_sr_owner_id; SiebelServiceTimeout = configVerb.integration.SiebelServiceTimeout; log_level = configVerb.integration.log_level; assignLogLevelEnum(); rnt_host = configVerb.rnt_host; //Prepare the Service Request Type Mapping if (configVerb.integration.request_type_mapping != null) { requestTypeMapping = setRequestTypeMapping(configVerb.integration.request_type_mapping); } incidentsByContactReportID = configVerb.integration.incidentsByContactReportID; contactSearchReportID = configVerb.integration.contactSearchReportID; uspsUsername = configVerb.postalValidation.username; ext_address_validate_url = configVerb.postalValidation.ext_address_validate_url; Dictionary<String, Service> extServices = configVerb.integration.ext_services; foreach (KeyValuePair<String, Service> extService in extServices) { switch (extService.Key) { case "service_request_detail": if (extService.Value.create != null) CreateSR_WSDL = extBaseUrl + extService.Value.create.relative_path; if (extService.Value.update != null) UpdateSR_WSDL = extBaseUrl + extService.Value.update.relative_path; if (extService.Value.read != null) LookupSR_WSDL = extBaseUrl + extService.Value.read.relative_path; break; case "service_request_list": if (extService.Value.read != null) LookupSRbyContactPartyID_WSDL = extBaseUrl + extService.Value.read.relative_path; break; case "repair_order_detail": if (extService.Value.create != null) CreateRepair_WSDL = extBaseUrl + extService.Value.create.relative_path; if (extService.Value.update != null) UpdateRepair_WSDL = extBaseUrl + extService.Value.update.relative_path; if (extService.Value.read != null) LookupRepair_WSDL = extBaseUrl + extService.Value.read.relative_path; break; case "repair_order_list": if (extService.Value.read != null) RepairOrderList_WSDL = extBaseUrl + extService.Value.read.relative_path; break; case "service_request_note": if (extService.Value.create != null) CreateInteraction_WSDL = extBaseUrl + extService.Value.create.relative_path; break; case "contact_list": if (extService.Value.read != null) LookupContactList_WSDL = extBaseUrl + extService.Value.read.relative_path; break; case "item_list": if (extService.Value.read != null) ItemList_WSDL = extBaseUrl + extService.Value.read.relative_path; break; case "entitlement_list": if (extService.Value.read != null) EntitlementList_WSDL = extBaseUrl + extService.Value.read.relative_path; break; case "repair_logistics_list": if (extService.Value.read != null) RepairLogisticsList_WSDL = extBaseUrl + extService.Value.read.relative_path; break; case "repair_list": if (extService.Value.read != null) RepairOrderList_WSDL = extBaseUrl + extService.Value.read.relative_path; break; } } found = true; break; } } // If current site is not set in configuration. if (!found) { String message = "The current host, " + _configServerUrl + ", is not present in Integration Configuration verb.\n Please contact your system administrator"; MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (logWrap != null) { logMessage = "Current Host is not present in Integration Configuration verb. "; logNote = "Current site is not set in configuration CUSTOM_CFG_Accel_Ext_Integrations. The configuration verb is: " + jsonString; logWrap.ErrorLog(logMessage: logMessage, logNote: logNote); } return false; } configVerbPerfect = true; return true; }