Esempio n. 1
0
        private void ThreadUserCheckLogin()
        {
            string result = null;

            Var.mLoginCheckEvent.Reset();
            int iret = 0;

            LogManager.WriteLogTran(LogType.Message, "启动检查用户二维码扫描登录线程...", "");
            while (true)
            {
                if (Var.mLoginCheckEvent.WaitOne(50) == true)
                {
                    LogManager.WriteLogTran(LogType.Message, "关闭检查用户二维码扫描登录线程", "");
                    break;
                }
                iret = PayApi.ApiQrCodeLogin(guid, out result);
                if (iret == 1)
                {
                    output(1, "");
                }
                else
                {
                    output(4, result);
                }
                Thread.Sleep(2000);
            }
        }
Esempio n. 2
0
        private void ThreadChengeBarCode()
        {
            string result = null;

            Var.mChengeBarCodeEvent.Reset();
            LogManager.WriteLogTran(LogType.Message, "启动刷新二维码线程...", "");
            while (true)
            {
                if (Var.mChengeBarCodeEvent.WaitOne(50) == true)
                {
                    LogManager.WriteLogTran(LogType.Message, "关闭刷新二维码线程", "");
                    break;
                }
                Var.iCountTime++;
                if (Var.iCountTime == Var.RefreshTime)
                {
                    output(5, "");
                    if (PayApi.ApiGetQrCode("user", out result, out guid, out url) == true)
                    {
                        output(6, "");
                    }
                    else
                    {
                        output(3, result);
                    }
                    Var.iCountTime = 0;
                }
                Thread.Sleep(1000);
            }
        }
Esempio n. 3
0
        private void SaveBmp()
        {
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            try
            {
                Bitmap   bitmap00 = CapScreen.GetDesktopImage();
                Bitmap   newImg   = new Bitmap(Var.CaptureScreen_Width, Var.CaptureScreen_Height);
                Graphics g        = Graphics.FromImage(newImg);
                g.DrawImage(bitmap00, 0, 0, new System.Drawing.Rectangle(Var.CaptureScreen_Left, Var.CaptureScreen_Top, newImg.Width, newImg.Height), GraphicsUnit.Pixel);

                newImg.Save(filePath);
                image1.Source = BitmapToBitmapImage(newImg);
            }
            catch (Exception ex)
            {
                LogManager.WriteLogTran(LogType.Message, "Exception =", ex.Message);
                LogManager.WriteLogTran(LogType.Message, "Exception =", ex.Source);
                LogManager.WriteLogTran(LogType.Message, "Exception =", ex.StackTrace);
            }

            //-------------------
            //Bitmap bitmap00 = CapScreen.GetDesktopImage();
            //Bitmap B = new Bitmap(Var.CaptureScreen_Width, Var.CaptureScreen_Height); //新建一个理想大小的图像文件
            //Graphics g = Graphics.FromImage(B);//实例一个画板的对象,就用上面的图像的画板
            //g.DrawImage(bitmap00, 0, 0);//把目标图像画在这个图像文件的画板上

            //B.Save(filePath, System.Drawing.Imaging.ImageFormat.Bmp);//通过这个图像来保存

            //image1.Source = BitmapToBitmapImage(B);


            ////---------------------
            //Thread.Sleep(1000);
            //System.Drawing.Bitmap bitmap = new Bitmap(Var.CaptureScreen_Width, Var.CaptureScreen_Height);
            //using (System.Drawing.Graphics graphics = Graphics.FromImage(bitmap))
            //{
            //    graphics.CopyFromScreen(Var.CaptureScreen_Left, Var.CaptureScreen_Top, 0, 0, new System.Drawing.Size(Var.CaptureScreen_Width, Var.CaptureScreen_Height));
            //    bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Bmp);
            //    image1.Source = BitmapToBitmapImage(bitmap);
            //}
        }
Esempio n. 4
0
        private bool GetNum(ref double Money)
        {
            bool         bRet     = false;
            const string language = "amt";

            try
            {
                //Bitmap bitmap00 = CapScreen.GetDesktopImage();
                //Bitmap newImg = new Bitmap(Var.CaptureScreen_Width, Var.CaptureScreen_Height);
                //Graphics g = Graphics.FromImage(newImg);
                //g.DrawImage(bitmap00, 0, 0, new System.Drawing.Rectangle(Var.CaptureScreen_Left, Var.CaptureScreen_Top, newImg.Width, newImg.Height), GraphicsUnit.Pixel);

                //newImg.Save(filePath);
                //image1.Source = BitmapToBitmapImage(newImg);

                SaveBmp();


                //使用tesseract算法 2018.11.29
                if (File.Exists(filePath))
                {
                    var             image = new Bitmap(filePath);
                    TesseractEngine ocr   = new TesseractEngine("./tessdata", language);
                    ocr.SetVariable("tessedit_char_whitelist", "0123456789."); // If digit only
                    var result = ocr.Process(image);
                    Money = Convert.ToDouble(result.GetText());
                    bRet  = true;
                }
                else
                {
                    MessageBox.Show("未找到截图", "系统提示", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLogTran(LogType.Message, "Exception =", ex.Message);
                LogManager.WriteLogTran(LogType.Message, "Exception =", ex.Source);
                LogManager.WriteLogTran(LogType.Message, "Exception =", ex.StackTrace);
            }
            return(bRet);
        }
Esempio n. 5
0
        //1.7 退款状态查询 add 20181108
        public bool ApiRefundStatusQuery(string refund_order_id, string merchant_id, out Dictionary <string, string> result)
        {
            const string httpurl = "http://cashier.cdsoftware.cn/index.php/api/channel/query_refund";
            bool         ret     = false;

            //string key = "bf0ac37accfb6ed19d4676a54d6aaaf0";

            result = new Dictionary <string, string>();

            //1 json
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("refund_order_id", refund_order_id);
            dic.Add("timestamp", GetTimeStamp());
            string jsonData = JsonConvert.SerializeObject(dic);

            LogManager.WriteLogTran(LogType.Message, "ApiRefundStatusQuery jsonData= ", jsonData.ToString());

            //2 encrypt
            string encryptData = AESEncrypt(jsonData, Var.gkey);

            string httppara = string.Format("merchant_id={0}&data={1}", merchant_id, encryptData);

            LogManager.WriteLogTran(LogType.Message, "ApiRefundStatusQuery httppara= ", httppara.ToString());

            //3 send
            string inResult = HttpPost(httpurl, httppara, null);

            LogManager.WriteLogTran(LogType.Message, "ApiRefundStatusQuery Result= ", inResult.ToString());

            try
            {
                //4 get return json
                JObject result_json = JsonConvert.DeserializeObject(inResult) as JObject;
                if (result_json.Count == 0)
                {
                    return(false);
                }

                //5 judge
                if (result_json["code"].ToString() == "1")
                {
                    inResult = result_json["msg"].ToString();
                    LogManager.WriteLogTran(LogType.Message, "inResult= ", inResult.ToString());

                    string tmpdata = result_json["data"].ToString();

                    string tmpJson = AESDecrypt(tmpdata, Var.gkey);

                    result = JsonConvert.DeserializeObject <Dictionary <string, string> >(tmpJson);

                    ret = true;
                }
                else if (result_json["code"].ToString() == "0")
                {
                    result.Add("msg", "更新失败");
                    ret = false;
                }
                else
                {
                    //log
                    ret = false;
                }
            }
            catch (Exception)
            {
                ret = false;
            }
            return(ret);
        }
Esempio n. 6
0
        //1.2下单
        public bool InterfaceAddOrder(string paychannel, string payment, string amount, string auth_code, string subject, string body, string merchant_id, string store_id, string operator_id, string device_id, string key, out string order_id, out Dictionary <string, string> result)
        {
            const string httpurl = "http://cashier.cdsoftware.cn/index.php/api/channel/add_order";
            bool         ret     = false;

            //key = "bf0ac37accfb6ed19d4676a54d6aaaf0";

            result   = new Dictionary <string, string>();
            order_id = string.Empty;

            //1 json
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("payment", payment);
            dic.Add("channel", paychannel);
            dic.Add("order_id", "");
            dic.Add("amount", amount);
            dic.Add("auth_code", auth_code);
            dic.Add("subject", subject);
            dic.Add("body", body);
            dic.Add("store_id", store_id);
            dic.Add("operator_id", operator_id);
            dic.Add("device_id", device_id);
            dic.Add("timestamp", GetTimeStamp());

            string jsonData = JsonConvert.SerializeObject(dic);

            LogManager.WriteLogTran(LogType.Message, "InterfaceAddOrder jsonData= ", jsonData.ToString());

            //2 encrypt
            string encryptData = AESEncrypt(jsonData, Var.gkey);

            string httppara = string.Format("merchant_id={0}&data={1}", merchant_id, encryptData);

            LogManager.WriteLogTran(LogType.Message, "InterfaceAddOrder httppara= ", httppara.ToString());

            //3 send
            string inResult = HttpPost(httpurl, httppara, null);

            LogManager.WriteLogTran(LogType.Message, "InterfaceAddOrder Result= ", inResult.ToString());

            try
            {
                //4 get return json
                JObject result_json = JsonConvert.DeserializeObject(inResult) as JObject;
                if (result_json.Count == 0)
                {
                    return(false);
                }

                //5 judge
                if (result_json["code"].ToString() == "1")
                {
                    inResult = result_json["msg"].ToString();
                    LogManager.WriteLogTran(LogType.Message, "inResult= ", inResult.ToString());

                    string tmpdata = result_json["data"].ToString();

                    string tmpJson = AESDecrypt(tmpdata, Var.gkey);

                    result = JsonConvert.DeserializeObject <Dictionary <string, string> >(tmpJson);

                    result.TryGetValue("order_id", out order_id);

                    ret = true;
                }
                else if (result_json["code"].ToString() == "0")
                {
                    ret = false;
                }
                else
                {
                    //log
                    ret = false;
                }
            }
            catch (Exception)
            {
                ret = false;
            }
            return(ret);
        }