Example #1
0
        /// <summary>
        /// Method called by data load event. It does the following:
        /// 1> Get Onload FSAR value
        /// 2> Get all affected VIN mapped to currently opened reported Incident
        /// 3> If _showSRFormAfterSave is set then show SR/VIN form
        /// </summary>
        private void _recordContext_DataLoaded(object sender, EventArgs e)
        {
            //Making onload async to reduce time of record load
            var backgroundService = new BackgroundServiceUtil();

            backgroundService.RunAsync(() =>
            {
                //Get all affected VIN's of reported incident
                _affectedBusIds = new List <string>();
                _incidentRecord = (IIncident)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident);
                if (_incidentRecord != null)
                {
                    string[] response = RightNowConnectService.GetService().GetAffectedBus(_incidentRecord.ID);
                    if (response != null)
                    {
                        _affectedBusIds = response.ToList();
                    }
                }
                //Get FSAR value on Load
                _onLoadFSARVal            = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "FSAR", _incidentRecord);
                string[] internalIncident = RightNowConnectService.GetService().GetAllInternalIncident(_incidentRecord.ID);
                if (internalIncident != null)
                {
                    RightNowConnectService.GetService().setIncidentField("CO", "no_of_sr", internalIncident.Length.ToString(), _incidentRecord);
                }
            });
        }
Example #2
0
        public StatusBarControl(IGlobalContext gContext)
        {
            _staffAccount = RightNowConnectService.GetService().GetAccountDetails();

            InitializeComponent(_staffAccount);
            _gContext = gContext;
        }
        /// <summary>
        /// Create Internal Incident and FSAR_VIN records Function
        /// </summary>
        private void CreateRecords()
        {
            //To not allow build event to add multiple VINs in case of warranty workorder type
            //if VIN records already exist.
            if (_woCatLabel == "Warranty")
            {
                string[] response = RightNowConnectService.GetService().GetAffectedBus(_incidentRecord.ID);
                if (response != null)
                {
                    _affectedBusIds = response.ToList();
                }


                if (_affectedBusIds.Count > 0)
                {
                    form.Hide();
                    MessageBox.Show("For Warranty Work Order Category Multiple VINs cannot be added.");
                }
                else
                {
                    CompleteBuildProcess();
                }
            }
            else
            {
                CompleteBuildProcess();
            }
        }
        /// <summary>
        /// Get required details to build WebRequest
        /// </summary>
        public void GetDetails(IIncident incidentRecord, IRecordContext recordContext)
        {
            _incidentRecord = incidentRecord;
            //Get the VIN Number
            string[] vinDetails = RightNowConnectService.GetService().getBusInfo(_incidentRecord.ID);
            if (vinDetails != null)
            {
                _vin = vinDetails[0].Split('~')[0];
            }

            //Get OOTB ORG ID
            _supplierID = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "supplier_from_webservice", _incidentRecord);
            if (_supplierID == String.Empty)
            {
                WorkspaceAddIn.InfoLog("Supplier ID is blank");
                return;
            }
            else
            {
                //Get EBS ORG ID
                _supplierID = RightNowConnectService.GetService().GetEbsOrgID(Convert.ToInt32(_supplierID));
            }
            _causalPartNumber = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "causal_part_nmbr", _incidentRecord);
            if (_causalPartNumber == String.Empty)
            {
                WorkspaceAddIn.InfoLog("Causal Part Number is blank");
                return;
            }
            _odometerReading = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "odometer_reading", _incidentRecord);
            if (_odometerReading == String.Empty)
            {
                WorkspaceAddIn.InfoLog("Odometer Reading is blank");
                return;
            }
            _failedDate = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "failure_date", _incidentRecord);
            if (_failedDate == String.Empty)
            {
                WorkspaceAddIn.InfoLog("Failed Date is blank");
                return;
            }
            //If all required info is valid then form jSon request parameter
            var content     = GetReqParam();
            var jsonContent = WebServiceRequest.JsonSerialize(content);

            jsonContent = jsonContent.Replace("xmlns", "@xmlns");

            //Call webservice
            string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST");

            if (jsonResponse == "")
            {
                WorkspaceAddIn.InfoLog("Server didn't return any info");
            }
            else
            {
                ExtractResponse(jsonResponse);
            }
            return;
        }
        /// <summary>
        /// Search for VIN records based on SR No or VIN No
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SeacrhBtnClick(object sender, EventArgs e)
        {
            SelectAll_chkbx.Checked = false;
            ClearAll_Chkbx.Checked  = false;

            var filters = new List <KeyValuePair <string, string> >();

            #region if SR and VIN null
            if ((SR_Cmbbx.SelectedItem == null || ((KeyValuePair <int, string>)SR_Cmbbx.SelectedItem).Key == 0) &&
                Vin_txtbx.Text == String.Empty && CustomerFleetNo_txtbx.Text == string.Empty)
            {
                if (dataGridView1 != null)
                {
                    clearDataGrid();//clear old view
                }
                MessageBox.Show("Select at least one Filter", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            #region if SR is not null
            if (SR_Cmbbx.SelectedItem != null && ((KeyValuePair <int, string>)SR_Cmbbx.SelectedItem).Key != 0)
            {
                filters.Add(new KeyValuePair <string, string>("Sales Release", ((KeyValuePair <int, string>)SR_Cmbbx.SelectedItem).Value));
            }
            #endregion

            #region if VIN is not null
            if (Vin_txtbx.Text != String.Empty)
            {
                filters.Add(new KeyValuePair <string, string>("VIN", Vin_txtbx.Text));
            }
            #endregion

            #region if Customer Fleet is not null
            if (CustomerFleetNo_txtbx.Text != String.Empty)
            {
                filters.Add(new KeyValuePair <string, string>("Customer Fleet Number", CustomerFleetNo_txtbx.Text));
            }

            #endregion
            //Run and Get Report Data based on filter value
            CSVTable resultTable = RightNowConnectService.GetService().FilterSearch(filters);
            if (resultTable.Rows.Length > 0)
            {
                //Show report data in grid format
                ShowData(resultTable);
                //Select the checkbox for Vins that already exist
                SelectExistingVins();
            }
            else
            {
                if (dataGridView1 != null)
                {
                    clearDataGrid();//clear old view
                }
                MessageBox.Show("No Result Found", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            #endregion
        }
Example #6
0
        /// <summary>
        /// Get ExternalReference for Contact/Org
        /// </summary>
        /// <param name="id"></param>
        /// <param name="isContact"></param>
        /// <param name="applicationId"></param>
        /// <returns></returns>
        public long GetContactOrgExternalReference(int id, bool isContact, String applicationId)
        {
            IRightNowConnectService rightNowConnect = RightNowConnectService.GetService();
            String extRef      = rightNowConnect.GetContactOrgExternalReference(id, isContact, applicationId);
            long   externalRef = Convert.ToInt64((String.IsNullOrWhiteSpace(extRef) ? "-1": extRef));

            return(externalRef);
        }
Example #7
0
        /// <summary>
        /// Method to perform warranty check for creating "WARRANTY" type work order using old BOM query.
        /// </summary>
        public void WarrantyCheck(IIncident incidentRecord)
        {
            _rnConnectService = RightNowConnectService.GetService();
            _rnConnectService._incidentVINObjects.Clear();//Clear the _incidentVINObjects variable that holds all incident_vin record to be updated with response
            _incidentRecord = incidentRecord;

            //Get basic field that need to be pass in webservce call,
            //Null validation of these fields are handle by workspace rules
            _odometer   = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "odometer_reading", _incidentRecord);
            _causalPart = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "causal_part_nmbr", _incidentRecord);
            string failureDateInSTring = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "failure_date", _incidentRecord);

            _failureDate = Convert.ToDateTime(failureDateInSTring).ToString("dd-MMM-yyyy");
            string[] busInfo = _rnConnectService.getBusInfo(_incidentRecord.ID);
            if (busInfo != null && busInfo.Length > 0)
            {
                if (busInfo.Length > 1)
                {
                    WorkspaceAddIn.InfoLog("It seems multi VIN are mapped with Reporting Incident, warrant type work order" +
                                           " works only for individual VIN");
                    return;
                }
                else
                {
                    _vin      = busInfo[0].Split('~')[0];
                    _srNum    = busInfo[0].Split('~')[1];
                    _incVinID = Convert.ToInt32(busInfo[0].Split('~')[2]);

                    //If all required info is valid then form jSon request parameter
                    var content     = GetWarrantyReqParam();
                    var jsonContent = WebServiceRequest.JsonSerialize(content);
                    jsonContent = jsonContent.Replace("xmlns", "@xmlns");

                    //Call webservice
                    string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST");
                    if (jsonResponse == "")
                    {
                        WorkspaceAddIn.InfoLog("Server didn't returned any info");
                        return;
                    }
                    else
                    {
                        ExtractResponse(jsonResponse);
                        _rnConnectService.updateIncidentVinRecords();
                    }
                }
            }
            else
            {
                WorkspaceAddIn.InfoLog("No Bus info found, please map a bus to reporting Incident and then click check warranty button");
                return;
            }
            return;
        }
Example #8
0
        /// <summary>
        /// This function does basic validation like if unordered parts beed added to reported Incident, if so then
        /// Call EBS parts order web-service to pass parts related info and store NF_SALES_ORDER no to each parts record
        /// </summary>
        /// <returns>string content that need to send to web-service</returns>
        public void OrderParts(IIncident incidentRecord)
        {
            //Get reported Incident Info
            int    orderTypeId = Convert.ToInt32(RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "order_type", incidentRecord));
            int    billToId    = Convert.ToInt32(RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "Bill_to_site", incidentRecord));
            int    shipToId    = Convert.ToInt32(RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "Ship_to_site", incidentRecord));
            string claimNum    = incidentRecord.RefNo;
            string projectNum  = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "project_number", incidentRecord);
            string retrofitNum = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "retrofit_number", incidentRecord);

            //Get EBS ID from OSvC OOTB ID
            string billToEbsID = _rnConnectService.GetEbsID(billToId);
            string shipToEbsID = _rnConnectService.GetEbsID(shipToId);
            string orgEbsID    = _rnConnectService.GetBusOwnerEbsID(Convert.ToInt32(incidentRecord.OrgID));
            string odrTypName  = _rnConnectService.GetOrderTypeName(orderTypeId);

            //Get unordered Parts mapped to reported incident
            _partsInfo = _rnConnectService.GetPartsInfo(incidentRecord.ID);
            if (_partsInfo == null || _partsInfo.Length <= 0)
            {
                WorkspaceAddIn.InfoLog("No parts have beed added to order");
                return;
            }
            else
            {
                //Frame parts order request param structure
                var content = GetPartsOdrReqParam(odrTypName, orgEbsID, shipToEbsID, billToEbsID, claimNum, projectNum, retrofitNum);
                if (content == null)
                {
                    return;
                }
                else
                {
                    //Convert object to jSon string
                    var jsonContent = WebServiceRequest.JsonSerialize(content);
                    jsonContent = jsonContent.Replace("xmlns", "@xmlns");

                    //Call web-service
                    string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST");

                    if (jsonResponse == "")
                    {
                        WorkspaceAddIn.InfoLog("Server didn't returned any info");
                        return;
                    }
                    else
                    {
                        ExtractResponse(jsonResponse);
                        _rnConnectService.updateIncidentVinRecords();
                    }
                }
            }
        }
Example #9
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);
        }
Example #10
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);
        }
Example #11
0
        private void SetInventoryModel(WorkOrderModel workOrderModel, int workOrderId, InventoryModel primaryAssetInventoryModel, int workOrderType)
        {
            List <InventoryModel> InventoryModelList = new List <InventoryModel>();

            if (null != primaryAssetInventoryModel && null != primaryAssetInventoryModel.Type)
            {
                InventoryModelList.Add(primaryAssetInventoryModel);
                _log.Notice("WorkOrder Primary Asset Type :" + primaryAssetInventoryModel.Type);
            }

            //adding asset inventory model into workorder.
            if (InventoryModelList.Count > 0)
            {
                workOrderModel.ActivityInventories = InventoryModelList;
            }

            //Adding work Order Type Inventory into Required Inventory List
            List <RequiredInventoryModel> RequiredInventoryModelList = new List <RequiredInventoryModel>();

            //string salesProductQuery = String.Format("select Quantity, Serial_Number, WO_Inventory from TOA.WO_Type_Inventory where Work_Order_Type = {0}", workOrderModel.WorkType);
            string[] workOrder_type_inventories = RightNowConnectService.GetService().GetRequiredInventoryDetailsFromWorkOrderType(workOrderType);
            if (workOrder_type_inventories != null)
            {
                foreach (string workOrder_type_inventory in workOrder_type_inventories)
                {
                    string[] details = workOrder_type_inventory.Split('|');
                    RequiredInventoryModel reqInventoryModel = new RequiredInventoryModel();
                    reqInventoryModel.Quantity = details[1];                                                                  //Quantity = Quantity
                    reqInventoryModel.Model    = details[2];                                                                  //model = Model
                    string[] productDetails = RightNowConnectService.GetService().GetProductDetailsFromProductID(details[0]); //Type = Product's ID (i.e. SalesProduct.PartNumber)
                    if (null != productDetails && productDetails.Length > 0)
                    {
                        reqInventoryModel.Type = productDetails[0];
                    }
                    else
                    {
                        _log.Warning("invtype_label is not valid for required inventory.");
                    }

                    RequiredInventoryModelList.Add(reqInventoryModel);
                    _log.Notice("Adding WorkOrder Required Inventory with ID :" + workOrderId);
                }
            }

            if (RequiredInventoryModelList.Count > 0)
            {
                workOrderModel.RequiredInventories = RequiredInventoryModelList;
            }
        }
Example #12
0
        public void Handler()
        {
            try
            {
                string                duration = null;
                bool                  manual_duration;
                IGenericField         durationField = null;
                IList <IGenericField> fields        = _workOrderRecord.GenericFields;
                foreach (IGenericField field in fields)
                {
                    switch (field.Name)
                    {
                    case "Duration":
                        durationField = field;
                        break;

                    case "WO_Type":
                        if (field.DataValue.Value == null)
                        {
                            break;
                        }
                        int      workorderTypeId = (Int32)field.DataValue.Value;
                        string[] workordertype   = RightNowConnectService.GetService().GetWorkOrderTypeFromID(workorderTypeId);
                        manual_duration = (workordertype[1].Equals("1")) ? true : false;
                        if (manual_duration)
                        {
                            duration = workordertype[2];
                        }
                        break;
                    }
                }

                if (duration != null)
                {
                    durationField.DataValue.Value = duration;
                }
                else
                {
                    durationField.DataValue.Value = null;
                }
                _recordContext.RefreshWorkspace();
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex.StackTrace);
                MessageBox.Show(ToaExceptionMessages.UnexpectedError, ToaExceptionMessages.TitleError,
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #13
0
        public WebServiceRequest(string method)
        {
            Timeout           = 900000;
            Method            = method;
            _rnConnectService = RightNowConnectService.GetService();
            string webServiceLoginValue = _rnConnectService.GetConfigValue("CUSTOM_CFG_EBS_WS_LOGIN");

            if (webServiceLoginValue != null)
            {
                var s          = new JavaScriptSerializer();
                var loginValue = s.Deserialize <WebServiceLoginCredential>(webServiceLoginValue);
                _userName = loginValue.UserName;
                _password = loginValue.Password;
            }
        }
        /// <summary>
        /// Get required details to build WebRequest
        /// </summary>
        public void MultiVinWarrantyCheck(IIncident incidentRecord)
        {
            try
            {
                _rnConnectService = RightNowConnectService.GetService();
                _incidentRecord   = incidentRecord;
                string multiWarrantyConfigValue = _rnConnectService.GetConfigValue("CUSTOM_CFG_NEW_BOM_QUERY");
                if (multiWarrantyConfigValue != null)
                {
                    var s = new JavaScriptSerializer();

                    var configVerb = s.Deserialize <ConfigVerbs.RootObject>(multiWarrantyConfigValue);
                    _curlURL         = configVerb.URL;
                    _headerURL       = configVerb.xmlns;
                    _xmlnsURL        = configVerb.RESTHeader.xmlns;
                    _respApplication = configVerb.RESTHeader.RespApplication;
                    _responsibility  = configVerb.RESTHeader.Responsibility;
                    _securityGroup   = configVerb.RESTHeader.SecurityGroup;
                    _nLSLanguage     = configVerb.RESTHeader.NLSLanguage;
                    _orgID           = configVerb.RESTHeader.Org_Id;
                }

                _rnConnectService._incidentVINObjects.Clear();//Clear the _incidentVINObjects variable that holds all incident_vin record to be updated with response

                _causalPart = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "causal_part_nmbr", incidentRecord);

                string[] internalIncInfo = _rnConnectService.GetInternalIncident(incidentRecord.ID);
                if (internalIncInfo != null)
                {
                    _allInternalincident = internalIncInfo.ToList();
                }
                if (_allInternalincident.Count > 0)
                {
                    var tasks = new Task[_allInternalincident.Count];
                    int ii    = 0;
                    foreach (string internalIncident in _allInternalincident)
                    {
                        tasks[ii++] = Task.Factory.StartNew(() => RequestPerSR(internalIncident));
                    }
                    Task.WaitAll(tasks);
                    _rnConnectService.updateIncidentVinRecords();//Once all task over, call batch job to update Incident_VIN record
                }
            }
            catch (Exception ex)
            {
                WorkspaceAddIn.InfoLog("Exeption in GetDetails: " + ex.Message);
            }
        }
Example #15
0
        /// <summary>
        /// Method which is called to to show SR/VIN search form.
        /// </summary>
        public void selectSR_VIN()
        {
            IOrganization orgRecord = (IOrganization)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Organization);
            string        orgType   = RightNowConnectService.GetService().getFieldFromOrgRecord("CO", "org_type", orgRecord);

            string[] srList = RightNowConnectService.GetService().GetOrgSR(orgRecord.ID, Convert.ToInt32(orgType));
            if (srList != null)
            {
                SalesReleaseVINSearchForm srVinForm = new SalesReleaseVINSearchForm(srList, _affectedBusIds, _recordContext);
                srVinForm.ShowDialog();
            }
            else
            {
                InfoLog("No Sales release found for Org " + orgRecord.Name +
                        ". Please make sure Customer submitting the incident has some sales relase mapped to it.");
            }
        }
Example #16
0
        private static void Main(string[] args)
        {
            //RightNowConfigService.Config();
            //RightNowConnectService.GetService();

            //QueryResultData[] result = RightNowConnectService.GetService().GetProductCatalogDetailsFromId(21);
            //Console.WriteLine("Data:"+result);
            var service = RightNowConnectService.GetService();
            var config  = service.GetRightNowConfigVerbValue("CUSTOM_CFG_Sales_Accel_Integrations");
            var log     = ToaLogService.GetLog();

            log.Debug("Deepak: Hello Word!! : 11");
            log.Error("Deepak: Hello Word!! : 12");
            log.Fatal("Deepak: Hello Word!! : 13");
            log.Notice("Deepak: Hello Word!! : 14");
            log.Warning("Deepak: Hello Word!! : 15");
            log.Click("Deepak: Hello Word!! : 16");
        }
Example #17
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);
        }
Example #18
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());
        }
Example #19
0
        /// <summary>
        /// Initializes and displays out of office dialog.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void statusButton_Click(object sender, EventArgs e)
        {
            _staffAccount = RightNowConnectService.GetService().GetAccountDetails();

            if (_staffAccount != null)
            {
                var OOOControl = new OutOfOfficeControl(this);
                OOOControl.PopulateControls(_staffAccount);
                Window window = new Window
                {
                    Title                 = Common.Title,
                    Content               = OOOControl,
                    SizeToContent         = SizeToContent.WidthAndHeight,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen,
                    ResizeMode            = ResizeMode.NoResize
                };
                window.ShowDialog();
            }
        }
        public SupplierWarrantyCheckModel()
        {
            _rnConnectService = RightNowConnectService.GetService();
            string supplierWarrantyConfigValue = _rnConnectService.GetConfigValue("CUSTOM_CFG_SUPPLIER_WARRANTY");

            if (supplierWarrantyConfigValue != null)
            {
                var s          = new JavaScriptSerializer();
                var configVerb = s.Deserialize <WebServiceConfigVerbs.RootObject>(supplierWarrantyConfigValue);
                _curlURL         = configVerb.URL;
                _xmlnsURL        = configVerb.xmlns;
                _headerURL       = configVerb.RESTHeader.xmlns;
                _respApplication = configVerb.RESTHeader.RespApplication;
                _responsibility  = configVerb.RESTHeader.Responsibility;
                _securityGroup   = configVerb.RESTHeader.SecurityGroup;
                _nlsLanguage     = configVerb.RESTHeader.NLSLanguage;
                _orgID           = configVerb.RESTHeader.Org_Id;
            }
        }
Example #21
0
        public PartsOrderModel()
        {
            _rnConnectService = RightNowConnectService.GetService();
            string partsConfigValue = _rnConnectService.GetConfigValue("CUSTOM_CFG_PARTS_ORDER");

            if (partsConfigValue != null)
            {
                var s = new JavaScriptSerializer();

                var configVerb = s.Deserialize <ConfigVerbs.RootObject>(partsConfigValue);
                _curlURL         = configVerb.URL;
                _headerURL       = configVerb.xmlns;
                _xmlnsURL        = configVerb.RESTHeader.xmlns;
                _respApplication = configVerb.RESTHeader.RespApplication;
                _responsibility  = configVerb.RESTHeader.Responsibility;
                _securityGroup   = configVerb.RESTHeader.SecurityGroup;
                _nLSLanguage     = configVerb.RESTHeader.NLSLanguage;
                _orgID           = configVerb.RESTHeader.Org_Id;
            }
        }
        /// <summary>
        /// Keep Select All and Clear All checkboxes unchecked during form load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void IncidentVinFormLoad(object sender, EventArgs e)
        {
            ClearAll_Chkbx.Checked  = false;
            SelectAll_chkbx.Checked = false;

            string woCatID = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "work_order_category", _incidentRecord);

            if (woCatID != "")
            {
                _woCatLabel = RightNowConnectService.GetService().GetWOCategoryLabel(Convert.ToInt32(woCatID));
            }
            if (_woCatLabel == "Warranty" && _existingAffectedVins.Count == 0)
            {
                MessageBox.Show("Work Order Category is selected as Warranty. Only one VIN can be added.");
                dataGridView1.MultiSelect = false;
            }
            if (_woCatLabel == "Warranty" && _existingAffectedVins.Count > 0)
            {
                MessageBox.Show("Work Order Category is selected as Warranty. Multiple VINs cannot be added.");
                this.Close();
            }
        }
        /// <summary>
        /// Funtion to handle ebs webservice response
        /// </summary>
        /// <param name="respJson">response in jSON string</param>
        public void ExtractResponse(string jsonResp)
        {
            int _internalIncidentID = 0;

            string[] internalIncident = RightNowConnectService.GetService().GetAllInternalIncident(_incidentRecord.ID);
            if (internalIncident != null)
            {
                _internalIncidentID = Convert.ToInt32(internalIncident[0]);
            }
            //Extract response
            Dictionary <string, object> data             = (Dictionary <string, object>)WebServiceRequest.JsonDeSerialize(jsonResp);
            Dictionary <String, object> outputParameters = (Dictionary <String, object>)data["OutputParameters"];
            Dictionary <String, object> output           = (Dictionary <String, object>)outputParameters["CIN_SUPPLIER_WARRANTY_PKG-24ISP"];

            if (output["ISCOVERED"].ToString() == "1")
            {
                //autogenerate sClaim
                //_rnConnectService.CreatesClaim(_incidentRecord.ID);

                RightNowConnectService.GetService().UpdateInternalIncidentForSupplier(_internalIncidentID, true, output["DESCRIPTION"].ToString());

                //Create a child object to store Supplier recoverable limit
                _rnConnectService.CreateSupplierInfo(_incidentRecord.ID,
                                                     output["DESCRIPTION"].ToString(),
                                                     output["TEMPLATE_NAME"].ToString(),
                                                     output["PARTS_REIMB_PERC"].ToString(),
                                                     output["PARTS_MAX_AMOUNT"].ToString(),
                                                     output["LABOUR_REIMB_PERC"].ToString(),
                                                     output["LABOUR_MAX_AMOUNT"].ToString(),
                                                     output["OTHER_REIMB_PERC"].ToString(),
                                                     output["OTHER_MAX_AMOUNT"].ToString()
                                                     );
            }
            else
            {
                RightNowConnectService.GetService().UpdateInternalIncidentForSupplier(_internalIncidentID, false, output["DESCRIPTION"].ToString());
            }
        }
Example #24
0
        /// <summary>
        /// Method called by data Save event. It doesn the following task;
        /// 1> Check if FSAR is changed
        /// 2> If FSAR is changed then it updates all internal incident (which SR virtually) with new FSAR record
        ///
        /// </summary>
        private void _recordContext_Saved(object sender, System.EventArgs e)
        {
            _allInternalIncidents = new List <string>();
            string currentFSAR = RightNowConnectService.GetService().getFieldFromIncidentRecord("CO", "FSAR", _incidentRecord);

            //If FSAR is changed then update all internal incident with same FSAR
            if (_onLoadFSARVal != currentFSAR)
            {
                string[] allInternalInc = RightNowConnectService.GetService().GetAllInternalIncident(_incidentRecord.ID);
                if (allInternalInc != null)
                {
                    _allInternalIncidents = allInternalInc.ToList();
                    RightNowConnectService.GetService().UpdateInternalIncident(_allInternalIncidents, currentFSAR);
                }
            }
            //If flag is set to show SR/VIN form on save then call selectSR_VIN function
            if (_showSRFormAfterSave)
            {
                _showSRFormAfterSave = false;
                System.Threading.Thread selectSrVinThread = new System.Threading.Thread(selectSR_VIN);
                selectSrVinThread.Start();
            }
        }
Example #25
0
        /// <summary>
        /// Funtion to handle ebs webservice response
        /// </summary>
        /// <param name="respJson">response in jSON string</param>
        public void ExtractResponse(string jsonResp)
        {
            //save webservice response
            // RightNowConnectService.GetService().setIncidentField("CO", "WebServiceResponse", jsonResp, _incidentRecord);
            Dictionary <string, string> incidentVinInfo = new Dictionary <string, string>();
            Dictionary <string, object> singleOptionGroup;

            jsonResp = jsonResp.Replace("@xmlns:xsi", "@xmlns_xsi"); //formating json string
            jsonResp = jsonResp.Replace("@xsi:nil", "@xsi_nil");     //formating json string
            jsonResp = jsonResp.Replace("PKG_V2-24", "PKG_V2_24");   //formating json string

            //converting json string to Dictionary<string, object>
            Dictionary <string, object> data   = (Dictionary <string, object>)WebServiceRequest.JsonDeSerialize(jsonResp);
            Dictionary <string, object> output = (Dictionary <string, object>)data["OutputParameters"];
            Dictionary <string, object> param  = (Dictionary <string, object>)output["CIN_BOM_QUERY_PKG_V2_24ISPARTWA"];

            string combo    = "";
            string busModel = "";
            string vin      = "";

            string[] ewrInfo;

            string[] busInfo = _rnConnectService.getBusInfoIV(_incVinID);

            //Check if multi option group is retured, if so then save jSon response
            if (IsArray(param["CIN_BOM_QUERY_PKG_V2_24ISPARTWA_ITEM"]))
            {
                object[] optionItems = (object[])param["CIN_BOM_QUERY_PKG_V2_24ISPARTWA_ITEM"];

                if (optionItems.Length == 1)//if one elemnet in an array that mean too single option group
                {
                    singleOptionGroup = (Dictionary <string, object>)optionItems[0];
                }
                else
                {
                    //Get part desc from first item, as it will same across all item of multioption grp
                    Dictionary <string, object> firstItem = (Dictionary <string, object>)optionItems[0];
                    RightNowConnectService.GetService().setIncidentField("CO", "causal_part_desc", firstItem["PART_DESC"].ToString(), _incidentRecord);

                    //Include the vendor id (org) and EWR_Xref_Id in multi option grp object[], so it can be used in other add-in logic
                    foreach (object option in optionItems)
                    {
                        Dictionary <string, object> response = (Dictionary <string, object>)option;
                        if (busInfo != null && busInfo.Length > 0)
                        {
                            vin      = busInfo[0].Split('~')[0];
                            busModel = vin.Substring(4, 1);
                            combo    = busModel + "-" + response["OPTIONGROUP_SEQNO"].ToString().Trim();

                            ewrInfo = _rnConnectService.getEWRID(combo);
                            if (ewrInfo != null && ewrInfo.Length > 0)
                            {
                                response.Add("EWR_Xref_Id", ewrInfo[0].Split('~')[0]);// add  EWR_Xref_Id in response list for multi option grp
                            }
                        }
                    }
                    string optionGrpJson = WebServiceRequest.JsonSerialize(output["CIN_BOM_QUERY_PKG_V2_24ISPARTWA"]);
                    _rnConnectService.addIncidentVINRecord(_incVinID, null, optionGrpJson);
                    return;
                }
            }
            //If 1 item is retured then set individual field of incident_vin record
            else
            {
                singleOptionGroup = (Dictionary <string, object>)param["CIN_BOM_QUERY_PKG_V2_24ISPARTWA_ITEM"];
            }
            if (singleOptionGroup != null)
            {
                RightNowConnectService.GetService().setIncidentField("CO", "causal_part_desc", singleOptionGroup["PART_DESC"].ToString(), _incidentRecord);


                if (singleOptionGroup["VENDOR_ID"].ToString().Trim() != "")
                {
                    //Get OOTB ORG ID from EBS ORG ID
                    string orgID = _rnConnectService.GetOrgID(Convert.ToInt32(singleOptionGroup["VENDOR_ID"].ToString()));
                    //RightNowConnectService.GetService().setIncidentField("CO", "supplier_from_webservice", orgID, _incidentRecord);
                    incidentVinInfo.Add("supplier_from_webservice", orgID);
                }
                if (singleOptionGroup["DESCRIPTION"].ToString().Trim() == "Warranty Start Date and Date From Plant are blank for the VIN")
                {
                    WorkspaceAddIn.InfoLog(singleOptionGroup["DESCRIPTION"].ToString());
                }

                incidentVinInfo.Add("under_warranty", singleOptionGroup["ISCOVERED"].ToString().Trim());
                incidentVinInfo.Add("causal_part_nmbr_bom_pn", singleOptionGroup["PART_NUMBER"].ToString().Trim());
                incidentVinInfo.Add("causal_part_desc_bom_pn", singleOptionGroup["DESCRIPTION"].ToString().Trim());
                incidentVinInfo.Add("coverage_name", singleOptionGroup["COVERAGE_NAME"].ToString().Trim());
                incidentVinInfo.Add("coverage_desc", singleOptionGroup["COVERAGE_DESC"].ToString().Trim());
                incidentVinInfo.Add("optiongroup_seqno", singleOptionGroup["OPTIONGROUP_SEQNO"].ToString().Trim());
                incidentVinInfo.Add("s_policy_name", singleOptionGroup["SPOLICY_NAME"].ToString().Trim());
                incidentVinInfo.Add("s_policy_desc", singleOptionGroup["SPOLICY_DESC"].ToString().Trim());
                //_rnConnectService.addIncidentVINRecord(_incVinID, "", "", singleOptionGroup["ISCOVERED"].ToString(), "",
                //                       singleOptionGroup["OPTIONGROUP_SEQNO"].ToString());
                //Logic to update EWR_Xref_Id field

                if (busInfo != null && busInfo.Length > 0)
                {
                    vin = busInfo[0].Split('~')[0];
                    if (vin != "")
                    {
                        busModel = vin.Substring(4, 1);
                        combo    = busModel + "-" + singleOptionGroup["OPTIONGROUP_SEQNO"].ToString().Trim();

                        ewrInfo = _rnConnectService.getEWRID(combo);
                        if (ewrInfo != null && ewrInfo.Length > 0)
                        {
                            incidentVinInfo.Add("EWR_Xref_Id", ewrInfo[0].Split('~')[0]);
                        }
                    }
                }
                _rnConnectService.addIncidentVINRecord(_incVinID, incidentVinInfo, "");
            }
        }
        /// <summary>
        /// Saves date on OK button click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="routedEventArgs"></param>
        public void OkClick(object sender, RoutedEventArgs routedEventArgs)
        {
            logger.Debug("OutOfOfficeControl - OkClick() - Entry");

            var updatedAccount = new StaffAccount();

            updatedAccount.OooFlag     = OutOfOfficeCheckbox.IsChecked.GetValueOrDefault();
            updatedAccount.OooTimezone = (TimezoneDropdown.SelectedValue != null) ? TimezoneDropdown.SelectedValue.ToString() : null;
            DateTime?fromDateTime = null;
            DateTime?toDateTime   = null;

            if (FromDateTime.SelectedDate != null || ToDateTime.SelectedDate != null)
            {
                //Combining date and time to store
                string fromDate = FromDateTime.SelectedDate.GetValueOrDefault().Date.ToString("d");
                string fromTime = FromTimeDropdown.SelectedValue.ToString();

                string toDate = ToDateTime.SelectedDate.GetValueOrDefault().Date.ToString("d");
                string toTime = ToTimeDropdown.SelectedValue.ToString();

                fromDateTime = Convert.ToDateTime(fromDate + " " + fromTime);
                toDateTime   = Convert.ToDateTime(toDate + " " + toTime);

                //Validating if user entered date/time without timezone.
                if ((fromDateTime != default(DateTime) || toDateTime != default(DateTime)) && TimezoneDropdown.SelectedValue == null)
                {
                    System.Windows.Forms.MessageBox.Show(OOOExceptionMessages.TimezoneCannotBeEmpty,
                                                         Common.ErrorLabel, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TimezoneLabel.Content    = "*" + Common.TimezoneLabel;
                    TimezoneLabel.Foreground = new SolidColorBrush(Colors.Red);
                    return;
                }
                //Validating if user entered From Date/Time is less than To Date/Time.
                if (fromDateTime > toDateTime)
                {
                    System.Windows.Forms.MessageBox.Show(OOOExceptionMessages.FromDateGreaterThanToDate,
                                                         Common.ErrorLabel, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (updatedAccount.OooTimezone != null)
                {
                    string       windowsTimezone = TimezoneService.GetService().GetWindowsTimezone(updatedAccount.OooTimezone);
                    TimeZoneInfo timeszone       = TimeZoneInfo.FindSystemTimeZoneById(windowsTimezone);

                    fromDateTime = TimeZoneInfo.ConvertTimeToUtc((DateTime)fromDateTime, timeszone);
                    toDateTime   = TimeZoneInfo.ConvertTimeToUtc((DateTime)toDateTime, timeszone);
                }
            }

            updatedAccount.OooStart     = fromDateTime;
            updatedAccount.OooEnd       = toDateTime;
            updatedAccount.OooMsgOption = PersonalMsgOptionsDropdown.SelectedValue.ToString();
            updatedAccount.OooMsg       = PersonalMsgOptionsDropdown.SelectedValue.ToString().Equals(PersonalMsgOptions.StandardMessage) ? " " : PersonalMsgTextbox.Text;

            var result = RightNowConnectService.GetService().updateCustomFields(updatedAccount);

            if (result)
            {
                _statusBarControl.statusButton.Text      = (updatedAccount.OooFlag) ? Common.OutOfOfficeLabel : Common.AvailableLabel;
                _statusBarControl.statusButton.ForeColor = (updatedAccount.OooFlag) ? Color.DarkRed : Color.DarkGreen;
            }

            Window.GetWindow(this).Close();

            logger.Debug("OutOfOfficeControl - OkClick() - Exit");
        }
Example #27
0
        public void PopulateContactDetails()
        {
            IContact  contactRecord  = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Contact) as IContact;
            IIncident incidentRecord = _recordContext.GetWorkspaceRecord(WorkspaceRecordType.Incident) as IIncident;

            IList <IGenericField> fields = _workOrderRecord.GenericFields;

            foreach (IGenericField field in fields)
            {
                switch (field.Name)
                {
                case "Contact_Street":
                    if (contactRecord != null && contactRecord.AddrStreet != null)
                    {
                        field.DataValue.Value = contactRecord.AddrStreet;
                    }
                    break;

                case "Contact_Province_State":
                    if (contactRecord != null && contactRecord.AddrProvID != null)
                    {
                        field.DataValue.Value = contactRecord.AddrProvID;
                    }
                    break;

                case "Contact_City":
                    if (contactRecord != null && contactRecord.AddrCity != null)
                    {
                        field.DataValue.Value = contactRecord.AddrCity;
                    }
                    break;

                case "Contact_Postal_Code":
                    if (contactRecord != null && contactRecord.AddrPostalCode != null)
                    {
                        field.DataValue.Value = contactRecord.AddrPostalCode;
                    }
                    break;

                case "Contact_Email":
                    if (contactRecord != null && contactRecord.EmailAddr != null)
                    {
                        field.DataValue.Value = contactRecord.EmailAddr;
                    }
                    break;

                case "Contact_Phone":
                    if (contactRecord != null && contactRecord.PhHome != null)
                    {
                        field.DataValue.Value = contactRecord.PhHome;
                    }
                    else if (contactRecord != null && contactRecord.PhOffice != null)
                    {
                        field.DataValue.Value = contactRecord.PhOffice;
                    }
                    break;

                case "Contact_Mobile_Phone":
                    if (contactRecord != null && contactRecord.PhMobile != null)
                    {
                        field.DataValue.Value = contactRecord.PhMobile;
                    }
                    break;

                case "Resolution_Due":
                    string[] milestones = RightNowConnectService.GetService().GetResolutionDueFromID(incidentRecord.ID);
                    if (milestones != null && milestones.Count() > 0)
                    {
                        field.DataValue.Value = milestones[0];
                    }
                    break;
                }
                _recordContext.RefreshWorkspace();
            }
        }
        /// <summary>
        /// Get the Incident Vin ID
        /// </summary>
        /// <param name="vinInfos"></param>
        /// <param name="vin"></param>
        /// <returns></returns>
        private void ExtractIncidentVinInfo(object vinItem, string[] vinsOfInternalInc)
        {
            Dictionary <string, object> singleOptionGroup = null;
            string orgID    = "";
            string vendorID = "";
            Dictionary <string, object> item            = (Dictionary <string, object>)vinItem;
            Dictionary <string, string> incidentVinInfo = new Dictionary <string, string>();
            string combo    = "";
            string busModel = "";
            string vin      = "";

            string[] ewrInfo;

            int incidentVinID = getIncidentVinID(vinsOfInternalInc, item["VIN"].ToString());

            string[] busInfo = _rnConnectService.getBusInfoIV(incidentVinID);

            //By deafult set causal_part_desc at RI level
            RightNowConnectService.GetService().setIncidentField("CO", "causal_part_desc", item["PART_DESC"].ToString(), _incidentRecord);

            //Get OOTB ORG ID from EBS ORG ID
            if (item["VENDOR_ID"].ToString().Trim() != "")
            {
                vendorID = item["VENDOR_ID"].ToString();
                orgID    = _rnConnectService.GetOrgID(Convert.ToInt32(vendorID));
                incidentVinInfo.Add("supplier_from_webservice", orgID);
            }

            Dictionary <string, object> vinSubResult = (Dictionary <string, object>)item["VIN_SUB_RESULT"];

            if (vinSubResult == null)//if no info sent by EBS then return
            {
                return;
            }

            //Check if multi option group is retured, if so then save jSon response
            if (IsArray(vinSubResult["VIN_SUB_RESULT_ITEM"]))
            {
                object[] optionItems = (object[])vinSubResult["VIN_SUB_RESULT_ITEM"];
                if (optionItems.Length == 1)//if one elemnet in an array that mean too single option group
                {
                    singleOptionGroup = (Dictionary <string, object>)optionItems[0];
                }
                else
                {
                    //Include the vendor id (org) and EWR_Xref_Id in multi option grp object[], so it can be used in other add-in logic
                    foreach (object option in (object[])((Dictionary <string, object>)((Dictionary <string, object>)vinItem)["VIN_SUB_RESULT"])["VIN_SUB_RESULT_ITEM"])
                    {
                        Dictionary <string, object> response = (Dictionary <string, object>)option;
                        if (busInfo != null && busInfo.Length > 0)
                        {
                            vin      = busInfo[0].Split('~')[0];
                            busModel = vin.Substring(4, 1);
                            combo    = busModel + "-" + response["OPTIONGROUP_SEQNO"].ToString().Trim();

                            ewrInfo = _rnConnectService.getEWRID(combo);
                            if (ewrInfo != null && ewrInfo.Length > 0)
                            {
                                response.Add("EWR_Xref_Id", ewrInfo[0].Split('~')[0]);// add  EWR_Xref_Id in response list for multi option grp
                            }
                        }
                        response.Add("VENDOR_ID", vendorID);//add VENDOR_ID in response list
                    }
                    string optionGrpJson = WebServiceRequest.JsonSerialize(((Dictionary <string, object>)vinItem)["VIN_SUB_RESULT"]);
                    _rnConnectService.addIncidentVINRecord(incidentVinID, null, optionGrpJson);
                }
            }
            //If not in array that means single option group
            else
            {
                singleOptionGroup = (Dictionary <String, object>)vinSubResult["VIN_SUB_RESULT_ITEM"];
            }

            if (singleOptionGroup != null)
            {
                incidentVinInfo.Add("warranty_start_date", singleOptionGroup["WARRANTY_START_DATE"].ToString().Trim());
                incidentVinInfo.Add("warranty_end_date", singleOptionGroup["WARRANTY_END_DATE"].ToString().Trim());
                incidentVinInfo.Add("under_warranty", singleOptionGroup["ISCOVERED"].ToString().Trim());
                incidentVinInfo.Add("optiongroup_seqno", singleOptionGroup["OPTIONGROUP_SEQNO"].ToString().Trim());
                incidentVinInfo.Add("causal_part_desc_bom_pn", singleOptionGroup["DESCRIPTION"].ToString().Trim());
                incidentVinInfo.Add("causal_part_nmbr_bom_pn", singleOptionGroup["PART_NUMBER"].ToString().Trim());
                //Logic to update EWR_Xref_Id field
                if (busInfo != null && busInfo.Length > 0)
                {
                    vin      = busInfo[0].Split('~')[0];
                    busModel = vin.Substring(4, 1);
                    combo    = busModel + "-" + singleOptionGroup["OPTIONGROUP_SEQNO"].ToString().Trim();

                    ewrInfo = _rnConnectService.getEWRID(combo);
                    if (ewrInfo != null && ewrInfo.Length > 0)
                    {
                        incidentVinInfo.Add("EWR_Xref_Id", ewrInfo[0].Split('~')[0]);
                    }
                }
                _rnConnectService.addIncidentVINRecord(incidentVinID, incidentVinInfo, "");
            }
        }
        /// <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);
        }
Example #30
0
        public void SetExpirationDate()
        {
            try
            {
                string fsarTimeLimit = "";
                string offset;
                string duration;

                //Get FSAR time limit value
                IGenericObject fsar     = (IGenericObject)_recordContext.GetWorkspaceRecord("CO$FSAR");
                IIncident      incident = (IIncident)_recordContext.GetWorkspaceRecord(RightNow.AddIns.Common.WorkspaceRecordType.Incident);
                foreach (IGenericField genField in fsar.GenericFields)
                {
                    if (genField.Name == "time_limit" && genField.DataValue.Value != null)
                    {
                        fsarTimeLimit = genField.DataValue.Value.ToString();
                        break;
                    }
                }

                if (fsarTimeLimit != "")
                {
                    offset   = fsarTimeLimit.Split(' ')[0];
                    duration = fsarTimeLimit.Split(' ')[1];

                    //Check for adding Days to current date
                    if (duration.Contains("D") || duration.Contains("d"))
                    {
                        _expirationDate = DateTime.Now.AddDays(Convert.ToDouble(offset));
                    }

                    //Check for adding Weeks to current date
                    if (duration.Contains("W") || duration.Contains("w"))
                    {
                        double days = Convert.ToDouble(offset);
                        //Convert weeks to days
                        days            = days * 7;
                        _expirationDate = DateTime.Now.AddDays(Convert.ToDouble(days));
                    }

                    //Check for adding Months to current date
                    if (duration.Contains("M") || duration.Contains("m"))
                    {
                        _expirationDate = DateTime.Now.AddMonths(Convert.ToInt32(offset));
                    }

                    RightNowConnectService.GetService().setIncidentField("CO", "expiration_date", _expirationDate.ToString(), incident);

                    /*foreach (ICustomAttribute customAttribute in incident.CustomAttributes)
                     * {
                     *  if (customAttribute.GenericField.Name == "CO$expiration_date")
                     *  {
                     *      customAttribute.GenericField.DataValue.Value = (object)_expirationDate;
                     *      break;
                     *  }
                     * }*/
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception in Setting Expiration Date: " + ex.Message);
            }
        }