예제 #1
0
        private void GetDeviceListAndDisplay()
        {
            string result = string.Empty;

            Var.g_DeviceList_Info   = new Var.DeviceList_Info[128];
            Var.Get_DeviceListCount = 0;
            if (PayApi.ApiGetDeviceList(store_id_key, Var.ltoken, out result, out Var.g_DeviceList_Info, out Var.Get_DeviceListCount) == false)
            {
                MessageBox.Show("获取设备列表:" + result, "系统提示");
                return;
            }
            else
            {
                cmb_device_id.Items.Clear();
                cmb_device_id.Items.Add("所有设备");
                for (int i = 0; i < Var.Get_DeviceListCount; i++)
                {
                    cmb_device_id.Items.Add(Var.g_DeviceList_Info[i].name);
                }
                cmb_device_id.SelectedIndex = 1;
            }
        }
예제 #2
0
파일: Set.xaml.cs 프로젝트: zsurge/UBPayApp
        private void GetDeviceListAndDisplay()
        {
            string result = string.Empty;

            Var.g_DeviceList_Info   = new Var.DeviceList_Info[128];
            Var.Get_DeviceListCount = 0;
            if (PayApi.ApiGetDeviceList(Var.store_id, Var.ltoken, out result, out Var.g_DeviceList_Info, out Var.Get_DeviceListCount) == false)
            {
                MessageBox.Show("获取设备列表:" + result, "系统提示", MessageBoxButton.OK, MessageBoxImage.None);
                return;
            }
            else
            {
                cmbDevice.Items.Clear();

                for (int i = 0; i < Var.Get_DeviceListCount; i++)
                {
                    cmbDevice.Items.Add(Var.g_DeviceList_Info[i].name);
                }
                cmbDevice.SelectedIndex = 0;
            }
        }
예제 #3
0
        public void output(int iState, string sMsg)
        {
            try
            {
                this.Dispatcher.Invoke(new DispFunction(delegate()
                {
                    switch (iState)
                    {
                    case 0:
                        string result = null;
                        if (PayApi.ApiLogin(tBoxInputID.Text, tBoxInputPW.Password, out result) == false)
                        {
                            gridLoginInfo.Visibility = System.Windows.Visibility.Hidden;
                            bLogining = false;

                            MessageBox.Show(result, "系统提示", MessageBoxButton.OK, MessageBoxImage.None);
                            this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                        (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                            return;
                        }
                        output(1, "");
                        break;

                    case 1:
                        gridLoginInfo.Visibility = System.Windows.Visibility.Visible;
                        if (PayApi.ApiGetUserInfo(Var.ltoken, out result, out Var.g_User_Info, out Var.g_Agent_Info, out Var.g_Merchant_Info, out Var.g_Store_Info) == false)
                        {
                            gridLoginInfo.Visibility = System.Windows.Visibility.Hidden;
                            bLogining = false;

                            MessageBox.Show("获取用户信息:" + result, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                            this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                        (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                            return;
                        }

                        Var.merchant_id = Var.g_User_Info.merchant_id;
                        Var.store_id    = Var.g_User_Info.store_id;
                        Var.operator_id = Var.g_User_Info.id;
                        Var.device_id   = ParmIni.IniReadValue("Init", "device_id");
                        Var.device_name = ParmIni.IniReadValue("Init", "device_name");

                        ParmIni.IniWriteValue("Init", "merchant_id", Var.merchant_id);
                        ParmIni.IniWriteValue("Init", "store_id", Var.store_id);
                        ParmIni.IniWriteValue("Init", "operator_id", Var.operator_id);

                        if (Var.g_User_Info.type == "2")
                        {
                            Var.g_StoreList_Info   = new Var.StoreList_Info[128];
                            Var.Get_StoreListCount = 0;
                            if (PayApi.ApiGetStoreList(Var.ltoken, out result, out Var.g_StoreList_Info, out Var.Get_StoreListCount) == false)
                            {
                                gridLoginInfo.Visibility = System.Windows.Visibility.Hidden;
                                bLogining = false;

                                MessageBox.Show("获取门店列表:" + result, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                                this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                            (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                                return;
                            }

                            //modify 20181104 放在设置时查询,不同的门店有不同的用户ID和设备ID
                            Var.g_UserList_Info   = new Var.UserList_Info[128];
                            Var.Get_UserListCount = 0;
                            if (PayApi.ApiGetUserList(Var.g_Store_Info.id, Var.ltoken, out result, out Var.g_UserList_Info, out Var.Get_UserListCount) == false)
                            {
                                gridLoginInfo.Visibility = System.Windows.Visibility.Hidden;
                                bLogining = false;

                                MessageBox.Show("获取店员列表:" + result, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                                this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                            (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                                return;
                            }

                            Var.g_DeviceList_Info   = new Var.DeviceList_Info[128];
                            Var.Get_DeviceListCount = 0;
                            if (PayApi.ApiGetDeviceList(Var.g_Store_Info.id, Var.ltoken, out result, out Var.g_DeviceList_Info, out Var.Get_DeviceListCount) == false)
                            {
                                gridLoginInfo.Visibility = System.Windows.Visibility.Hidden;
                                bLogining = false;

                                MessageBox.Show("获取设备列表:" + result, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                                this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                            (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                                return;
                            }
                        }
                        else
                        {
                            //复制门店信息
                            Var.Get_StoreListCount                  = 1;
                            Var.g_StoreList_Info                    = new Var.StoreList_Info[1];
                            Var.g_StoreList_Info[0].id              = Var.g_Store_Info.id;
                            Var.g_StoreList_Info[0].merchant_id     = Var.g_Store_Info.merchant_id;
                            Var.g_StoreList_Info[0].name            = Var.g_Store_Info.name;
                            Var.g_StoreList_Info[0].number          = Var.g_Store_Info.number;
                            Var.g_StoreList_Info[0].principal_name  = Var.g_Store_Info.principal_name;
                            Var.g_StoreList_Info[0].principal_phone = Var.g_Store_Info.principal_phone;
                            Var.g_StoreList_Info[0].status          = Var.g_Store_Info.status;
                            Var.g_StoreList_Info[0].time_create     = Var.g_Store_Info.time_create;
                            Var.g_StoreList_Info[0].time_update     = Var.g_Store_Info.time_update;
                            Var.g_StoreList_Info[0].address         = Var.g_Store_Info.address;

                            //复制店员信息
                            Var.g_UserList_Info   = new Var.UserList_Info[1];
                            Var.Get_UserListCount = 1;

                            Var.g_UserList_Info[0].id       = Var.g_User_Info.id;
                            Var.g_UserList_Info[0].phone    = Var.g_User_Info.phone;
                            Var.g_UserList_Info[0].username = Var.g_User_Info.username;

                            //复制设备信息
                            Var.g_DeviceList_Info         = new Var.DeviceList_Info[1];
                            Var.Get_DeviceListCount       = 1;
                            Var.g_DeviceList_Info[0].id   = ParmIni.IniReadValue("Init", "device_id");
                            Var.g_DeviceList_Info[0].name = ParmIni.IniReadValue("Init", "device_name");
                        }
                        //if (Var.Get_DeviceListCount >= 1)
                        //{
                        //    Var.device_id = Var.g_DeviceList_Info[0].id;
                        //    ParmIni.IniWriteValue("Init", "device_id", Var.g_DeviceList_Info[0].id);
                        //}

                        //获取交易类型列表
                        Var.g_all_tran_list     = new Var.all_tran_list[128];
                        Var.all_tran_list_count = 0;

                        if (PayApi.ApiGet_all_paymentList(Var.ltoken, out result, out Var.g_all_payment_list) == false)
                        {
                            gridLoginInfo.Visibility = System.Windows.Visibility.Hidden;
                            bLogining = false;

                            MessageBox.Show("获取交易类型列表:" + result, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                            this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                        (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                            return;
                        }

                        //获取交易方式列表 add 1130
                        if (PayApi.ApiGet_all_paymentChannel(Var.ltoken, out result, out Var.g_all_payment_channel) == false)
                        {
                            gridLoginInfo.Visibility = System.Windows.Visibility.Hidden;
                            bLogining = false;

                            MessageBox.Show("获取交易方式表表:" + result, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                            this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                        (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                            return;
                        }

                        //获取订单状态 add 1130
                        if (PayApi.ApiGet_all_OrderStatus(Var.ltoken, out result, out Var.g_all_payment_Order_Status) == false)
                        {
                            MessageBox.Show("获取订单状态:" + result, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                            this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                        (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                            return;
                        }

                        if (PayApi.ApiGet_all_RefundStatus(Var.ltoken, out result, out Var.g_all_payment_refund_status) == false)
                        {
                            MessageBox.Show("获取退款订单状态:" + result, "错误提示", MessageBoxButton.OK, MessageBoxImage.Error);
                            this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                                        (Action)(() => { Keyboard.Focus(tBoxInputID); }));
                            return;
                        }


                        //记录下登录的时间 2018.11.18
                        Var.LoginTime = DateTime.Now.ToString();

                        Var.mChengeBarCodeEvent.Set();
                        goPage("MainPay.xaml");

                        break;

                    case 2:
                        img__Code.Visibility = System.Windows.Visibility.Visible;
                        lb__Info.Visibility  = System.Windows.Visibility.Visible;

                        //初始化二维码生成工具
                        QRCodeEncoder qrCodeEncoder      = new QRCodeEncoder();
                        qrCodeEncoder.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
                        qrCodeEncoder.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                        qrCodeEncoder.QRCodeVersion      = 0;
                        qrCodeEncoder.QRCodeScale        = 4;

                        //将字符串生成二维码图片
                        Bitmap img = qrCodeEncoder.Encode(url, Encoding.Default);

                        image = BitmapToBitmapImage(img);

                        img__Code.Source = image;
                        lb__Info.Content = "";

                        Var.mLoginCheckEvent.Set();
                        procCheckLoginThreadProcess = new Thread(new ThreadStart(this.ThreadUserCheckLogin));
                        procCheckLoginThreadProcess.Start();          // 重新启动设备初始化线程

                        Var.mChengeBarCodeEvent.Set();
                        Var.iCountTime = 0;
                        procChengeBarCodeThreadProcess = new Thread(new ThreadStart(ThreadChengeBarCode));
                        procChengeBarCodeThreadProcess.Start();
                        break;

                    case 3:
                        lb__Info.Content = sMsg;
                        lb__Info.Margin  = new Thickness(0, 26, 0, 0);
                        break;

                    case 4:
                        lb__Info.Content = sMsg;
                        lb__Info.Margin  = new Thickness(0, 110, 0, 0);
                        break;

                    case 5:
                        img__Code.Visibility = System.Windows.Visibility.Hidden;
                        lb__Info.Visibility  = System.Windows.Visibility.Visible;
                        lb__Info.Margin      = new Thickness(0, 26, 0, 0);
                        lb__Info.Content     = "正在获取登录二维码...";
                        break;

                    case 6:
                        //初始化二维码生成工具
                        img__Code.Visibility              = System.Windows.Visibility.Visible;
                        QRCodeEncoder qrCodeEncoder1      = new QRCodeEncoder();
                        qrCodeEncoder1.QRCodeEncodeMode   = QRCodeEncoder.ENCODE_MODE.BYTE;
                        qrCodeEncoder1.QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M;
                        qrCodeEncoder1.QRCodeVersion      = 0;
                        qrCodeEncoder1.QRCodeScale        = 4;

                        //将字符串生成二维码图片
                        Bitmap img1 = qrCodeEncoder1.Encode(url, Encoding.Default);

                        image = BitmapToBitmapImage(img1);

                        img__Code.Source = image;
                        lb__Info.Content = "";
                        break;
                    }
                }));
            }
            catch (Exception)
            {
            }
        }