Пример #1
0
        /// <summary>
        /// Get Inbound Service object
        /// </summary>
        /// <returns></returns>
        public static InboundService GetService()
        {
            if (_inboundService != null)
            {
                return(_inboundService);
            }

            if (!RightNowConfigService.IsConfigured())
            {
                return(null);
            }

            try
            {
                lock (_sync)
                {
                    if (_inboundService == null)
                    {
                        var inboundWsdlUrl = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.ToaInboundServiceUrl);

                        EndpointAddress  endpoint = new EndpointAddress(inboundWsdlUrl);
                        BasicHttpBinding binding  = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                        _inboundService = new InboundService();
                        _inboundService._inboundInterfaceService = new InboundInterfacePortClient(binding, endpoint);
                        _inboundService._log = ToaLogService.GetLog();
                    }
                }
            }
            catch (Exception e)
            {
                _inboundService = null;
                MessageBox.Show(ToaExceptionMessages.InboudServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_inboundService);
        }
Пример #2
0
        public static MessageService GetService()
        {
            if (_messageService != null)
            {
                return(_messageService);
            }

            try
            {
                lock (_sync)
                {
                    _messageService = new MessageService();
                    MESSAGE_URL     = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.ICS_GET_MESSAGES_URL);
                    USERNAME        = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.ICS_USERNAME);
                    PASSWORD        = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.ICS_PASSWORD);
                }
            }
            catch (Exception e)
            {
                _messageService = null;
                LogService.GetLog().Error(ExceptionMessages.IOT_MESSAGE_SERVICE_NOT_INITIALIZED, e.StackTrace);
                MessageBox.Show(ExceptionMessages.IOT_MESSAGE_SERVICE_NOT_INITIALIZED, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_messageService);
        }
Пример #3
0
        /// <summary>
        /// Get instance of CapacityService Object
        /// </summary>
        /// <returns></returns>
        public static ICapacityService GetService()
        {
            if (!RightNowConfigService.IsConfigured())
            {
                return(null);
            }
            CapacityService service = null;

            try
            {
                string endPointUrl = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.ToaCapacityServiceUrl);
                service = new CapacityService();
                service._toaCapacityInterface = new toa_capacity_interface(endPointUrl);
                service._log = ToaLogService.GetLog();
            }
            catch (Exception e)
            {
                service = null;
                service._log.Error("Unable to create CapacityService Object");
                service._log.Error("Exception: " + e.StackTrace);
                MessageBox.Show(ToaExceptionMessages.CapacityServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(service);
        }
Пример #4
0
        public static bool ValidateCurrentSiteName()
        {
            string RightNowSiteNameFromConfig = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.RightnowHost);
            string CurrentRightNowSiteName    = RightNowConnectService.GetService().GetRightNowEndPointURIHost();

            if (RightNowSiteNameFromConfig.Equals(CurrentRightNowSiteName))
            {
                return(true);
            }

            MessageBox.Show(OSCExceptionMessages.OracleSalesIntegrationSiteWarningMessage, OSCExceptionMessages.OracleSalesIntegrationSiteWarningTitle, MessageBoxButton.OK, MessageBoxImage.Warning);
            return(false);
        }
Пример #5
0
        /// <summary>
        /// Get instance of 'user_element' class used in Capacity service
        /// </summary>
        /// <returns></returns>
        public static user_element GetCapacityUser()
        {
            var    userObj = new user_element();
            string now     = DateTime.Now.ToString("O");

            userObj.login   = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.UserName);
            userObj.company = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.CompanyName);
            var password = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.Password);

            userObj.now         = now;
            userObj.auth_string = ToaMD5HashUtil.AuthString(now, password);

            return(userObj);
        }
Пример #6
0
        /// <summary>
        /// Get Inbound Service object
        /// </summary>
        /// <returns></returns>
        public static IOpportunityService GetService()
        {
            if (_opportunityService != null)
            {
                return(_opportunityService);
            }

            if (!RightNowConfigService.IsConfigured())
            {
                return(null);
            }

            try
            {
                lock (_sync)
                {
                    if (_opportunityService == null)
                    {
                        var opptyServiceUrl = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.OSCOpptyServiceUrl);

                        EndpointAddress  endpoint = new EndpointAddress(opptyServiceUrl);
                        BasicHttpBinding binding  = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                        //honoring config verb's value only if it is greater than 0 bytes.
                        string maxResponseSize = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.SalesMaxReceivedMessageSize);
                        if (!String.IsNullOrEmpty(maxResponseSize) && Convert.ToInt32(maxResponseSize) > 0)
                        {
                            binding.MaxReceivedMessageSize = Convert.ToInt32(maxResponseSize);
                        }

                        _opportunityService = new OpportunityService();
                        _opportunityService._opportunityClient = new OpportunityServiceClient(binding, endpoint);
                        _opportunityService._opportunityClient.ClientCredentials.UserName.UserName =
                            RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.UserName);
                        _opportunityService._opportunityClient.ClientCredentials.UserName.Password =
                            RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.Password);
                        _opportunityService._opportunityClient.Endpoint.Behaviors.Add(new EmptyElementBehavior());

                        //_inboundService._log = ToaLogService.GetLog();
                    }
                }
            }
            catch (Exception e)
            {
                _opportunityService = null;
                MessageBox.Show(OSCExceptionMessages.OpportunityServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_opportunityService);
        }
Пример #7
0
        /// <summary>
        /// Validate site names
        /// </summary>
        /// <returns>bool based on if the site name and current site name is same or not</returns>
        public static bool ValidateCurrentSiteName()
        {
            string RightNowSiteNameFromConfig = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.RightnowHost);
            string CurrentRightNowSiteName    = RightNowConnectService.GetService().GetRightNowEndPointURIHost();

            if (RightNowSiteNameFromConfig.Equals(CurrentRightNowSiteName))
            {
                return(true);
            }

            MessageBox.Show(ToaExceptionMessages.IntegrationWithFieldServiceIsNotSetupForThisServiceSite,
                            ToaExceptionMessages.FieldServiceIntegrationConfigurationError, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return(false);
        }
Пример #8
0
        public static bool ValidateCurrentSiteName()
        {
            string RightNowSiteNameFromConfig = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.RIGHTNOW_HOST);
            string CurrentRightNowSiteName    = RightNowConnectService.GetService().GetRightNowEndPointURIHost();

            if (RightNowSiteNameFromConfig.Equals(CurrentRightNowSiteName))
            {
                LogService.GetLog().Notice("Sitename validated!");
                return(true);
            }

            LogService.GetLog()
            .Error(string.Format("RightNowSiteNameFromConfig [{0}] is different from CurrentRightNowSiteName[{1}]",
                                 RightNowSiteNameFromConfig, CurrentRightNowSiteName));

            MessageBox.Show(ExceptionMessages.IOT_CONF_ERROR_MESSAGE, ExceptionMessages.IOT_CONF_ERROR_TITLE, MessageBoxButton.OK, MessageBoxImage.Warning);
            return(false);
        }
Пример #9
0
        /// <summary>
        /// Get Inbound Service object
        /// </summary>
        /// <returns></returns>
        public static IAccountService GetService()
        {
            if (_accountService != null)
            {
                return(_accountService);
            }

            if (!RightNowConfigService.IsConfigured())
            {
                return(null);
            }

            try
            {
                lock (_sync)
                {
                    if (_accountService == null)
                    {
                        var accountServiceUrl = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.OSCAcctServiceUrl);

                        EndpointAddress endpoint = new EndpointAddress(accountServiceUrl);

                        BasicHttpBinding binding = new BasicHttpBinding();
                        binding.Security.Mode = BasicHttpSecurityMode.Transport;
                        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                        _accountService = new AccountService();
                        _accountService._accountClient = new AccountServiceClient(binding, endpoint);

                        _accountService._accountClient.ClientCredentials.UserName.UserName = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.UserName);
                        _accountService._accountClient.ClientCredentials.UserName.Password = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.Password);

                        //_accountService._log = ToaLogService.GetLog();
                    }
                }
            }
            catch (Exception e)
            {
                _accountService = null;
                MessageBox.Show(OSCExceptionMessages.AccountServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_accountService);
        }
Пример #10
0
        /// <summary>
        /// Initialize the Scheduler
        /// </summary>
        /// <param name="isManagerOverride"></param>
        /// <returns>True if the scheduler is properly initialized</returns>
        public bool InitializeScheduler(bool isManagerOverride)
        {
            //_log.Info("Inside InitializeScheduler");
            string bucket        = null;
            string workOrderType = null;
            string postalCode    = null;

            ICustomObject record = _recordContext.GetWorkspaceRecord(this._recordContext.WorkspaceTypeName) as ICustomObject;

            IList <IGenericField> fields = record.GenericFields;

            foreach (IGenericField field in fields)
            {
                if (field.Name == "WO_Area")
                {
                    bucket = (string)field.DataValue.Value;
                }
                else if (field.Name == "WO_Type")
                {
                    int      workorderTypeId = (Int32)field.DataValue.Value;
                    string[] workordertype   = RightNowConnectService.GetService().GetWorkOrderTypeFromID(workorderTypeId);
                    workOrderType = workordertype[0];
                }
                else if (field.Name == "Contact_Postal_Code")
                {
                    postalCode = field.DataValue.Value.ToString();
                }
            }

            var monthlyViewSchedulerViewModel = new MonthlyViewSchedulerViewModel();

            monthlyViewSchedulerViewModel.CalendarFirstDayOfWeek = (int)MonthlyViewCalendar.FirstDayOfWeek;
            monthlyViewSchedulerViewModel.Bucket            = bucket;
            monthlyViewSchedulerViewModel.PostalCode        = postalCode;
            monthlyViewSchedulerViewModel.WorkOrderType     = workOrderType;
            monthlyViewSchedulerViewModel.RedQuotaCutoff    = float.Parse(RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.RedQuotaCutoff));
            monthlyViewSchedulerViewModel.GreenQuotaCutoff  = float.Parse(RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.GreenQuotaCutoff));
            monthlyViewSchedulerViewModel.IsManagerOverride = isManagerOverride;
            DataContext = monthlyViewSchedulerViewModel;

            //_log.Info("Bucket: " + bucket + " WorkOrderType: " + workOrderType + " Postal Code: " + postalCode + " IsManagerOverride: " + isManagerOverride);
            return(monthlyViewSchedulerViewModel.InitializeCalendar());
        }
Пример #11
0
        /// <summary>
        /// Get Lead Service object
        /// </summary>
        /// <returns></returns>
        public static ILeadService GetService()
        {
            if (_leadService != null)
            {
                return(_leadService);
            }

            if (!RightNowConfigService.IsConfigured())
            {
                return(null);
            }

            try
            {
                lock (_sync)
                {
                    if (_leadService == null)
                    {
                        var leadServiceUrl = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.OSCLeadServiceUrl);

                        EndpointAddress  endpoint = new EndpointAddress(leadServiceUrl);
                        BasicHttpBinding binding  = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
                        binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

                        _leadService             = new LeadService();
                        _leadService._leadClient = new LeadIntegrationServiceClient(binding, endpoint);
                        _leadService._leadClient.ClientCredentials.UserName.UserName = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.UserName);
                        _leadService._leadClient.ClientCredentials.UserName.Password = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.Password);
                        _leadService._leadClient.Endpoint.Behaviors.Add(new EmptyElementBehavior());

                        // TODO: Need to work on this while working on SCLog story.
                        //_inboundService._log = ToaLogService.GetLog();
                    }
                }
            }
            catch (Exception e)
            {
                _leadService = null;
                MessageBox.Show(OSCExceptionMessages.LeadServiceNotInitialized, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(_leadService);
        }
Пример #12
0
        /// <summary>
        /// Get the lead type
        /// </summary>
        /// <returns></returns>
        private string populateLeadType()
        {
            String leadOpptyType = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.OpportunityLeadType);

            if (String.IsNullOrWhiteSpace(leadOpptyType))
            {
                leadOpptyType = OSCOpportunitiesCommon.OpportunityRecordType;
            }
            IList <IGenericField> fields = _leadRecord.GenericFields;

            foreach (IGenericField field in fields)
            {
                switch (field.Name)
                {
                case "lead_type":
                    field.DataValue.Value = leadOpptyType;
                    break;
                }
            }

            return(leadOpptyType);
        }
Пример #13
0
        /// <summary>
        /// Get instance of 'UserElement' class used in Inbound service
        /// </summary>
        /// <returns></returns>
        public static UserElement GetInboundUser()
        {
            var    userObj = new UserElement();
            string now     = DateTime.Now.ToString("O");

            userObj.login   = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.UserName);
            userObj.company = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.CompanyName);
            var password = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.Password);

            userObj.now = now;

            if (isSHA256Enabled)
            {
                userObj.auth_string = ToaHashUtil.SHA256AuthString(now, userObj.login, password);
            }
            else
            {
                userObj.auth_string = ToaHashUtil.MD5AuthString(now, password);
            }

            return(userObj);
        }
Пример #14
0
        /// <summary>
        /// Method to fetch Opportunity and return respective models.
        /// </summary>
        /// <param name="context"></param>
        /// <returns>List of Opportunity Models</returns>
        private List <OpportunityModel> getOpportunitesList(IRecordContext context)
        {
            var opportunitiesList = new List <OpportunityModel>();

            if (context != null)
            {
                var tokenSource                = new CancellationTokenSource();
                CancellationToken token        = tokenSource.Token;
                Boolean           timeout      = false;
                string            timeoutValue = RightNowConfigService.GetConfigValue(RightNowConfigKeyNames.SalesTimeout);

                var orgRecord = context.GetWorkspaceRecord(WorkspaceRecordType.Organization) as IOrganization;
                if (orgRecord != null)
                {
                    string ext_ref = RightNowConnectService.GetService().GetContactOrgExternalReference(orgRecord.ID,
                                                                                                        false, OracleRightNowOSCAddInNames.OpportunityReportTableAddIn);

                    //If the contact is a non sales contact
                    if (String.IsNullOrEmpty(ext_ref))
                    {
                        _logger.Debug("External reference is empty or null for the org. Returning empty opportunity list.");
                        return(opportunitiesList);
                    }

                    if (!String.IsNullOrEmpty(timeoutValue))
                    {
                        var task = Task.Factory.StartNew(() => OpportunityService.GetService().FindOpenOpportunities(OSCOpportunitiesTableMetadata.OrgFilterColumn, ext_ref), token);

                        if (!task.Wait(Convert.ToInt32(timeoutValue)))
                        {
                            timeout = true;
                            tokenSource.Cancel();
                        }
                        else
                        {
                            opportunitiesList = task.Result;
                            task.Dispose();
                        }
                    }
                    else
                    {
                        _logger.Debug("Sales Timesout value is either empty or null");
                        opportunitiesList = OpportunityService.GetService().FindOpenOpportunities(OSCOpportunitiesTableMetadata.OrgFilterColumn, ext_ref);
                    }
                    _logger.Debug("No. of opportunities fetched for Org #" + ext_ref + " : " + ((opportunitiesList != null) ? opportunitiesList.Count.ToString() : "null"));
                }
                else
                {
                    var contactRecord = context.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact;
                    if (contactRecord != null)
                    {
                        string ext_ref = RightNowConnectService.GetService().GetContactOrgExternalReference(contactRecord.ID,
                                                                                                            true, OracleRightNowOSCAddInNames.OpportunityReportTableAddIn);

                        //If the contact is a non sales contact
                        if (String.IsNullOrEmpty(ext_ref))
                        {
                            _logger.Debug("External reference is empty or null for contact. Returning empty opportunity list.");
                            return(opportunitiesList);
                        }

                        if (!String.IsNullOrEmpty(timeoutValue))
                        {
                            var task = Task.Factory.StartNew(() => OpportunityService.GetService().FindOpenOpportunities(OSCOpportunitiesTableMetadata.ContactFilterColumn, ext_ref), token);

                            if (!task.Wait(Convert.ToInt32(timeoutValue)))
                            {
                                timeout = true;
                                tokenSource.Cancel();
                            }
                            else
                            {
                                opportunitiesList = task.Result;
                                task.Dispose();
                            }
                        }
                        else
                        {
                            _logger.Debug("Sales Timesout value is either empty or null");
                            opportunitiesList = OpportunityService.GetService().FindOpenOpportunities(OSCOpportunitiesTableMetadata.ContactFilterColumn, ext_ref);
                        }
                        _logger.Debug("No. of opportunities fetched for Contact #" + ext_ref + " : " + ((opportunitiesList != null) ? opportunitiesList.Count.ToString() : "null"));
                    }
                }

                if (timeout)
                {
                    _logger.Debug("FindOpportunity request timed out!");
                    MessageBox.Show(OSCExceptionMessages.FindOppTimedOut, OSCOpportunitiesCommon.FindOppTimedOutTitle,
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            return(opportunitiesList);
        }