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;
            }
        }
        public static RightNowConnectService GetService()
        {
            if (_rightnowConnectService != null)
            {
                return(_rightnowConnectService);
            }

            try
            {
                lock (_sync)
                {
                    if (_rightnowConnectService == null)
                    {
                        // Initialize client with current interface soap url
                        string          url      = ReportCommandAddIn._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);
                        ReportCommandAddIn._globalContext.PrepareConnectSession(_rightNowClient.ChannelFactory);

                        _rightnowConnectService = new RightNowConnectService();
                    }
                }
            }
            catch (Exception e)
            {
                _rightnowConnectService = null;
            }

            return(_rightnowConnectService);
        }
Exemple #3
0
        public PartsRequiredModel(IRecordContext RecordContext)
        {
            _rnConnectService = RightNowConnectService.GetService();

            string partsRequiredConfigValue = _rnConnectService.GetConfigValue("CUSTOM_CFG_PARTS_REQUIRED");

            if (partsRequiredConfigValue != null)
            {
                var s          = new JavaScriptSerializer();
                var configVerb = s.Deserialize <WebServiceConfigVerbs.RootObject>(partsRequiredConfigValue);
                _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;
            }
        }
Exemple #4
0
        /// <summary>
        /// To get Parts details and Call Webservice
        /// </summary>
        public void ProcessSelectedRowInfo()
        {
            POEHEADERREC           partsHeaderRecord = new POEHEADERREC();
            RightNowConnectService _rnConnectService = RightNowConnectService.GetService();
            /*Get Reported Incident Info*/

            //Get Incident Type
            string incType = _rnConnectService.getIncidentField("c", "Incident Type", _incidentRecord);

            //Get ship set from Current Reported Incident
            string shipSet = _rnConnectService.getIncidentField("CO", "ship_set", _incidentRecord);

            //Get Num of VIN for which this order will be placed
            string numOfVINInString = _rnConnectService.getIncidentField("CO", "no_of_vins", _incidentRecord);

            if (numOfVINInString == String.Empty)
            {
                if (incType == "30")        //case of claim type
                {
                    numOfVINInString = "1"; //set it to 1
                }
                else
                {
                    form.Hide();
                    MessageBox.Show("Number Of VIN is empty");
                    return;
                }
            }
            int numOfVIN = Convert.ToInt32(numOfVINInString);

            string orderTypeId = _rnConnectService.getIncidentField("CO", "order_type", _incidentRecord);

            if (orderTypeId == String.Empty)
            {
                form.Hide();
                MessageBox.Show("Order Type is empty");
                return;
            }
            partsHeaderRecord.ORDER_TYPE = _rnConnectService.GetOrderTypeName(Convert.ToInt32(orderTypeId));

            string shipToId = _rnConnectService.getIncidentField("CO", "Ship_to_site", _incidentRecord);

            if (shipToId == String.Empty)
            {
                form.Hide();
                MessageBox.Show("Ship to Site is empty");
                return;
            }
            partsHeaderRecord.SHIP_TO_ORG_ID = Convert.ToInt32(_rnConnectService.GetEbsID(Convert.ToInt32(shipToId)));

            string shipDate = _rnConnectService.getIncidentField("CO", "requested_ship_date", _incidentRecord);

            if (shipDate == String.Empty)
            {
                if (incType == "30")                      //case of claim
                {
                    shipDate = DateTime.Today.ToString(); //set to today's date
                }
                else
                {
                    form.Hide();
                    MessageBox.Show("Requested Ship Date is empty");
                    return;
                }
            }
            partsHeaderRecord.SHIP_DATE = Convert.ToDateTime(shipDate).ToString("dd-MMM-yyyy");

            string dcID = _rnConnectService.GetIncidentExtraFieldValue("Distribution_center", _incidentExtra);

            if (dcID == String.Empty)
            {
                form.Hide();
                MessageBox.Show("Distribution Center is empty");
                return;
            }
            partsHeaderRecord.WAREHOUSE_ORG = _rnConnectService.GetDistributionCenterIDName(Convert.ToInt32(dcID));

            partsHeaderRecord.CUSTOMER_ID           = Convert.ToInt32(_rnConnectService.GetCustomerEbsID((int)_incidentRecord.OrgID));
            partsHeaderRecord.CLAIM_NUMBER          = _incidentRecord.RefNo;
            partsHeaderRecord.PROJECT_NUMBER        = _rnConnectService.getIncidentField("CO", "project_number", _incidentRecord);
            partsHeaderRecord.RETROFIT_NUMBER       = _rnConnectService.getIncidentField("CO", "retrofit_number", _incidentRecord);
            partsHeaderRecord.CUST_PO_NUMBER        = _rnConnectService.getIncidentField("CO", "PO_Number", _incidentRecord);
            partsHeaderRecord.SHIPPING_INSTRUCTIONS = _rnConnectService.getIncidentField("CO", "shipping_instructions", _incidentRecord);

            string partOdrInstrIDString = _rnConnectService.getIncidentField("CO", "PartOrderInstruction_ID", _incidentRecord);
            int    partOdrInstrID       = 0;//default case where we won't have partsorderinstruction

            if (partOdrInstrIDString != String.Empty)
            {
                partOdrInstrID = Convert.ToInt32(partOdrInstrIDString);
            }

            //List<int> partsIDOrdered = new List<int>();
            List <OELINEREC> lineRecords = new List <OELINEREC>();

            //Loop over each selected parts that user wants to order
            //Get required info needed for EBS web-service
            double oq = 0.00;

            foreach (IReportRow row in _selectedRows)
            {
                OELINEREC           lineRecord = new OELINEREC();
                IList <IReportCell> cells      = row.Cells;

                foreach (IReportCell cell in cells)
                {
                    if (cell.Name == "Part ID")
                    {
                        //Create PartsOrder record first as EBS web-service need PartsOrder ID
                        lineRecord.ORDERED_ID = _rnConnectService.CreatePartsOrder(Convert.ToInt32(cell.Value));//Pass parts Order ID
                    }
                    if (cell.Name == "Part #")
                    {
                        lineRecord.ORDERED_ITEM = cell.Value;
                    }
                    if (cell.Name == "Qty")
                    {
                        oq = Convert.ToDouble(Math.Round(Convert.ToDecimal(cell.Value), 2).ToString()) * numOfVIN;
                        lineRecord.ORDERED_QUANTITY = Math.Round(oq, 2);//get total qyantity
                    }
                    if (cell.Name == "Source Type")
                    {
                        lineRecord.SOURCE_TYPE = cell.Value;
                    }
                }
                lineRecord.SHIP_SET = shipSet;

                lineRecords.Add(lineRecord);
            }
            //Call PartsRequired Model to send parts info to EBS
            PartsRequiredModel partsRequired = new PartsRequiredModel(_recordContext);

            partsRequired.GetDetails(lineRecords, _incidentRecord, numOfVIN, partsHeaderRecord, Convert.ToInt32(shipToId), partOdrInstrID);
            form.Hide();
            _recordContext.ExecuteEditorCommand(RightNow.AddIns.Common.EditorCommand.Save);
        }