Beispiel #1
0
        public Main(ChatClient chat, AuthCred cred)
        {
            InitializeComponent();

            _ = chat.ConnectSSL("pvp.net", cred);
            chat.PresenceManager.OnPlayerPresenceRecieved += PresenceManager_OnPlayerPresenceRecieved;
            chat.IqManager.OnRosterItemRecieved           += IqManager_OnRosterItemRecieved;
            chat.MessageManager.OnMessage += MessageManager_OnMessage;
        }
Beispiel #2
0
        public async Task ConnectSSL(string host, AuthCred cred)
        {
            PresenceManager = new PresenceManager(this);
            IqManager       = new IqHandler(this);
            await TcpClient.ConnectSSL(host);

            TcpClient.SendString(
                $"<stream:stream to=\"{host}\" xml:lang=\"*\" version=\"1.0\" xmlns:stream=\"http://etherx.jabber.org/streams\" xmlns=\"jabber:client\">");
            AuthCred = cred;
        }
Beispiel #3
0
        public async Task ConnectSSL(string host, AuthCred cred)
        {
            TcpClient.OnStringReceived += ReadXMPPMessage;

            await TcpClient.ConnectSSL(host);

            Host = host;
            TcpClient.SendString(
                $"<stream:stream to=\"{host}\" xml:lang=\"*\" version=\"1.0\" xmlns:stream=\"http://etherx.jabber.org/streams\" xmlns=\"jabber:client\">");
            AuthCred = cred;
            IqManager.DoChatPing();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var regionData = AuthClass.ReadSystemRegionData(System.IO.Path.Combine(MainWindow.MyLocation, "system.yaml"), Region.SelectedItem.ToString());
            var auth       = AuthClass.GetLoginToken(user.Text, pass.Password, regionData, config);

            var servers = Dns.GetHostAddresses(regionData.Servers.Chat.ChatHost);
            var chat    = new ChatClient(
                new IPEndPoint(servers.First(), regionData.Servers.Chat.ChatPort));
            var chatAuth = new AuthCred
            {
                Token = Convert.ToBase64String(Encoding.UTF8.GetBytes(auth.AccessTokenJson.AccessToken))
            };

            MainWindow.UpdateView(new Main(chat, chatAuth));
        }
Beispiel #5
0
    public SageWoodResponse ValidateSageWoodMeter(string meterNo)
    {
        string           rawRequest;
        SageWoodResponse woodResponse = new SageWoodResponse();
        DatabaseHandler  dh           = new DatabaseHandler();

        try
        {
            string clientId = "2019112800001";
            string opName   = "UDEMO";
            string password = "******";
            //string meterno = "14012018064";//replace with user input
            string    date         = DateTime.Now.ToString("yyyyMMddHHmmss").ToString();
            string    randomnumber = GenerateRandomNumber().ToString();
            MeterInfo custInfo     = new MeterInfo();
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback
                                                                          (delegate { return(true); });
            EANDeviceID deviceId = new EANDeviceID();
            deviceId.ean = clientId;
            GenericDeviceID genericDeviceID = new GenericDeviceID();
            genericDeviceID.id = clientId;
            PurchaseValueCurrency purchaseValue = new PurchaseValueCurrency();
            purchaseValue.amt        = new Currency();
            purchaseValue.amt.symbol = "UGX";
            purchaseValue.amt.value  = Decimal.Parse("10");
            Electricity electricity = new Electricity();
            MsgID       msg         = new MsgID();
            msg.dateTime     = DateTime.Now.ToString("yyyyMMddHHmmss").ToString();
            msg.uniqueNumber = randomnumber;
            AuthCred authCred = new AuthCred();
            authCred.opName      = opName;
            authCred.password    = password;
            authCred.newPassword = "";
            MsgID       messageId = msg;
            AuthCred    creds     = authCred;
            MeterDetail meter     = new MeterDetail();
            meter.msno = meterNo;
            VendIDMethod vendIDMethod = new VendIDMethod();
            vendIDMethod.meterIdentifier = meter;
            ConfirmCustomerReq request  = new ConfirmCustomerReq();
            XMLVendService21   sageWood = new XMLVendService21();
            request.clientID   = deviceId;
            request.msgID      = msg;
            request.authCred   = authCred;
            request.terminalID = genericDeviceID;
            request.idMethod   = vendIDMethod;
            rawRequest         = XmlConfirmCustomerReq(request);
            ConfirmCustomerResp response = sageWood.ConfirmCustomerRequest(request);
            string rawResponse           = XmlConfirmCustomerResp(response);
            //log raw request and response
            dh.LogRequestAndResponse("SAGEWOOD", meterNo, rawRequest, rawResponse);
            foreach (ConfirmCustResult meterDetails in response.confirmCustResult)
            {
                woodResponse.Name               = meterDetails.custVendDetail.name;
                woodResponse.Msno               = meterDetails.custVendDetail.accNo;
                woodResponse.Address            = meterDetails.custVendDetail.address;
                woodResponse.ContactNo          = meterDetails.custVendDetail.contactNo;
                woodResponse.AccNo              = meterDetails.custVendDetail.accNo;
                woodResponse.LocRef             = meterDetails.custVendDetail.locRef;
                woodResponse.DaysOflastPurchase = meterDetails.custVendDetail.daysLastPurchase;
                woodResponse.StatusCode         = "0";
                woodResponse.StatusDescription  = "SUCCESS";
            }
        }
        catch (SoapException soapException)
        {
            //XMLVendFaultResp xmlVendFaultResp = XMLDeserialize.Deserialize(soapException.Detail);

            // if (xmlVendFaultResp.fault.GetType() ==
            //typeof(UnknownMeterEx))
            // {
            //     Console.WriteLine("Unknown Meter Serial Number!");
            // }
            // else
            // {
            //     string fert = xmlVendFaultResp.fault.GetType().ToString();
            //     Console.WriteLine("Unexpected XMLVend Fault Response" +
            //                 "received: (" + xmlVendFaultResp.fault.GetType().ToString()
            //     + ")" + xmlVendFaultResp.fault.desc);
            // }
            dh.LogError(soapException.Detail.InnerXml, meterNo, DateTime.Now, "SAGEWOOD");
            woodResponse.StatusCode = "100";
            woodResponse.Name       = "INVALID METER NUMBER";
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex);
            dh.LogError(ex.ToString(), meterNo, DateTime.Now, "SAGEWOOD");
            woodResponse.StatusCode = "100";
            woodResponse.Name       = "INVALID METER NUMBER";
        }
        return(woodResponse);
    }
Beispiel #6
0
    public SageWoodResponse PaySageWoodElectricity(string MNo, string amount, string transactionId)
    {
        SageWoodResponse woodResponse = new SageWoodResponse();
        string           rawRequest;
        DatabaseHandler  dh = new DatabaseHandler();

        try
        {
            string    clientId     = "2019112800001";
            string    opName       = "UDEMO";
            string    password     = "******";
            string    meterno      = "14012018064";
            string    date         = DateTime.Now.ToString("yyyyMMddHHmmss").ToString();
            string    randomnumber = GenerateRandomNumber().ToString();
            MeterInfo custInfo     = new MeterInfo();
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback
                                                                          (delegate { return(true); });
            EANDeviceID deviceId = new EANDeviceID();
            deviceId.ean = clientId;
            GenericDeviceID genericDeviceID = new GenericDeviceID();
            genericDeviceID.id = clientId;
            PurchaseValueCurrency purchaseValue = new PurchaseValueCurrency();
            purchaseValue.amt        = new Currency();
            purchaseValue.amt.symbol = "UGX";
            purchaseValue.amt.value  = Decimal.Parse("10");
            Electricity electricity = new Electricity();
            MsgID       msg         = new MsgID();
            msg.dateTime     = DateTime.Now.ToString("yyyyMMddHHmmss").ToString();
            msg.uniqueNumber = randomnumber;
            AuthCred authCred = new AuthCred();
            authCred.opName      = opName;
            authCred.password    = password;
            authCred.newPassword = "";
            MsgID       messageId = msg;
            AuthCred    creds     = authCred;
            MeterDetail meter     = new MeterDetail();
            meter.msno = meterno;
            Cash pay = new Cash();
            pay.tenderAmt        = new Currency();
            pay.tenderAmt.symbol = "UGX";
            pay.tenderAmt.value  = Decimal.Parse("100");
            VendIDMethod vendIDMethod = new VendIDMethod();
            vendIDMethod.meterIdentifier = meter;
            CreditVendReq    request  = new CreditVendReq();
            XMLVendService21 sageWood = new XMLVendService21();
            request.clientID      = deviceId;
            request.msgID         = msg;
            request.authCred      = authCred;
            request.terminalID    = genericDeviceID;
            request.idMethod      = vendIDMethod;
            request.resource      = electricity;
            request.purchaseValue = purchaseValue;
            request.payType       = pay;
            rawRequest            = XmlCreditVend(request);
            CreditVendResp    response     = sageWood.CreditVendRequest(request);
            Tx                tx           = response.creditVendReceipt.transactions.tx[0];
            CreditVendTx      creditVendTx = (CreditVendTx)tx;
            CreditVendReceipt resp         = response.creditVendReceipt;
            STS1Token         sts1Token    = (STS1Token)creditVendTx.creditTokenIssue.token;
            woodResponse.Token     = sts1Token.stsCipher;
            woodResponse.ReceiptNo = response.creditVendReceipt.receiptNo;
            woodResponse.Units     = creditVendTx.creditTokenIssue.units.value.ToString();
            string rawResponse = XmlCreditVendResp(response);

            //log raw request and response
            dh.LogRequestAndResponse("SAGEWOOD", transactionId, rawRequest, rawResponse);
        }
        catch (SoapException soapException)
        {
            // XMLVendFaultResp xmlVendFaultResp = XMLDeserialize.Deserialize(soapException.Detail);

            // if (xmlVendFaultResp.fault.GetType() ==
            //typeof(UnknownMeterEx))
            // {
            //     Console.WriteLine("Unknown Meter Serial Number!");
            // }
            // else
            // {
            //     string fert = xmlVendFaultResp.fault.GetType().ToString();
            //     Console.WriteLine("Unexpected XMLVend Fault Response" +
            //                 "received: (" + xmlVendFaultResp.fault.GetType().ToString()
            //     + ")" + xmlVendFaultResp.fault.desc);
            // }
            dh.LogError(soapException.Detail.InnerXml, transactionId, DateTime.Now, "SAGEWOOD");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: " + ex);
            dh.LogError(ex.ToString(), transactionId, DateTime.Now, "SAGEWOOD");
        }
        return(woodResponse);
    }
Beispiel #7
0
 protected BaseAuth(ChatClient client, AuthCred cred)
 {
     ChatClient = client;
     AuthCred   = cred;
 }