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;
            }
        }
Example #2
0
        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);
        }
        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;
            }
        }
        /// <summary>
        /// To get Parts details and Call Webservice
        /// </summary>
        public void ProcessSelectedRowInfo()
        {
            POEHEADERREC           partsHeaderRecord = new POEHEADERREC();
            RightNowConnectService _rnConnectService = RightNowConnectService.GetService();
            /*Get Work Order Info*/

            //Get ship set from Current Reported Incident
            string shipSet = _rnConnectService.GetCOFieldValue("ship_set", _workOrder);

            //Get Num of VIN for which this order will be placed
            int numOfVIN = 1;//will always be one

            string orderTypeId = _rnConnectService.GetCOFieldValue("Order_Type", _workOrderExtra);

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

            string shipToId = _rnConnectService.GetCOFieldValue("Ship_To_Site", _workOrder);

            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.GetCOFieldValue("requested_ship_date", _workOrder);

            if (shipDate == String.Empty)
            {
                shipDate = DateTime.Today.ToString();//set to today's date
            }
            partsHeaderRecord.SHIP_DATE = Convert.ToDateTime(shipDate).ToString("dd-MMM-yyyy");

            string dcID = _rnConnectService.GetCOFieldValue("Distribution_center", _workOrderExtra);

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

            string Organization = _rnConnectService.GetCOFieldValue("Organization", _workOrder);

            partsHeaderRecord.CUSTOMER_ID = Convert.ToInt32(_rnConnectService.GetCustomerEbsID(Convert.ToInt32(Organization)));

            string incVinID = _rnConnectService.GetCOFieldValue("Incident_VIN_ID", _workOrder);

            partsHeaderRecord.CLAIM_NUMBER = _rnConnectService.GetRefNum(Convert.ToInt32(incVinID));

            partsHeaderRecord.PROJECT_NUMBER = _rnConnectService.GetCOFieldValue("Project_Number", _workOrder);
            // partsHeaderRecord.RETROFIT_NUMBER = _rnConnectService.GetCOFieldValue("retrofit_number", _workOrder);
            partsHeaderRecord.CUST_PO_NUMBER        = _rnConnectService.GetCOFieldValue("PO_Number", _workOrder);//
            partsHeaderRecord.SHIPPING_INSTRUCTIONS = _rnConnectService.GetCOFieldValue("Shipping_Instruction", _workOrder);

            List <OELINEREC> lineRecords = new List <OELINEREC>();

            //Loop over each selected parts that user wants to order
            //Get required info needed for EBS web-service
            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")
                    {
                        lineRecord.ORDERED_QUANTITY = Convert.ToDouble(Math.Round(Convert.ToDecimal(cell.Value), 2).ToString()) * numOfVIN;//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, _workOrder, partsHeaderRecord, Convert.ToInt32(shipToId));
            form.Hide();
            _recordContext.ExecuteEditorCommand(RightNow.AddIns.Common.EditorCommand.Save);
        }