コード例 #1
0
    // 支付的回调方法
    private void PayCallFunc(string content)
    {
        Debug.Log("BeCallFunc");


        if (Application.platform == RuntimePlatform.Android)
        {
            if (content.Equals("success"))
            {
                str = "PayType : " + TCTForUnity.getUserInfo("PayType");
            }
            else
            {
                str = content;// 错误信息
            }
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            Debug.Log("daolezhifu");
            Debug.Log(content);

            JsonStr jsonText = JsonTest.ReadJsonGet(content);
            string  code     = jsonText.code;

            Debug.Log(code);
        }
        else
        {
            // 写一些东西
        }
    }
コード例 #2
0
    /// <summary>
    ///0code 1id 2profit 3amount 4type 5message
    ///要读取的json字符串
    /// </summary>
    /// <param name="_whichData"></param>
    /// <param name="_jsonString"></param>
    public static void GetWhichData(byte _whichData, string _jsonString)
    {
        JsonStr jsonText = ReadJsonGet(_jsonString);


        short id = short.Parse(jsonText.strAll[_whichData]);
    }
コード例 #3
0
    //private void Start ()
    //{
    //    ReadJson();
    //}
    //static  string CreatJson1 ()
    //  {
    //      JsonStr jsonIns = new JsonStr();
    //      jsonIns.amount = "我是amount";
    //      jsonIns.code = "我是code";
    //      jsonIns.id = "我是id";
    //      //jsonIns.profit = "我是profit";
    //      jsonIns.type = "我是type";
    //      jsonIns.message = "我是message";
    //      string jsonString = JsonUtility.ToJson(jsonIns);
    //      return jsonString;
    //  }
    //  static string CreatJson2 ()
    //  {
    //      string jsonTest = Resources.Load<TextAsset>("Jsonn").text;
    //      return jsonTest;
    //  }
    //  static void ReadJson ()
    //  {
    //      //string jsonString = CreatJson1();
    //      string jsonString = CreatJson2();
    //      JsonStr jsonText = JsonUtility.FromJson<JsonStr>(jsonString);
    //      jsonText.SaveString();
    //      foreach (var item in jsonText.strAll)
    //      {
    //          Debug.Log(item.ToString());
    //      }
    //  }
    /// <summary>
    /// 要传入的json字符串
    /// </summary>
    /// <param name="_jsonString"></param>
    /// <returns></returns>
    public static JsonStr ReadJsonGet(string _jsonString)
    {
        JsonStr jsonText = JsonUtility.FromJson <JsonStr>(_jsonString);//实例化数据类 并存入json字符串内容

        jsonText.SaveString();
        foreach (var item in jsonText.strAll)
        {
            Debug.LogError(item.ToString());
        }
        return(jsonText);
    }
コード例 #4
0
        ///// <summary>
        ///// 接口回调Json拼接方法
        ///// </summary>
        ///// <param name="state">调用状态0:失败 1:成功</param>
        ///// <param name="jsonData">返回数据</param>
        ///// <param name="otherValue">其他信息</param>
        ///// <returns></returns>
        //public static string JsonSplitJoint(int state, string jsonData, string otherValue)
        //{
        //    string result = "{";
        //    result += "\"stateCode\":" + "\"" + state + "\"";
        //    if (!string.IsNullOrEmpty(jsonData))
        //        result += "," + "\"data\":" + jsonData;

        //    result += "," + "\"Message\":\"" + otherValue + "\"";
        //    result += "}";
        //    return result;
        //}

        /// <summary>
        /// 接口回调Json拼接方法
        /// </summary>
        /// <param name="state">调用状态0:失败 1:成功</param>
        /// <param name="jsonData">返回数据</param>
        /// <param name="otherValue">其他信息</param>
        /// <returns></returns>
        public static void JsonSplitJoint(JsonStr model, string zidingyiJosn = null)
        {
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            string json = jss.Serialize(model);

            if (!string.IsNullOrEmpty(zidingyiJosn))
            {
                json  = json.TrimEnd('}');
                json += zidingyiJosn + "}";
            }
            HttpContext.Current.Response.ContentType = "text/plain";
            HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*"); //允许所有域名访问
            HttpContext.Current.Response.Write(json);
        }
コード例 #5
0
ファイル: Form2.cs プロジェクト: youzunFu/CsharpSQL
        //MySqlReader select
        private void button2_Click(object sender, EventArgs e)
        {
            dbName = "hems";
            string          config     = "server=" + dbHost + ";uid=" + dbUser + ";pwd=" + dbPass + ";database=" + dbName;
            MySqlConnection connection = new MySqlConnection(config);


            //string query = "SELECT * FROM equipment WHERE `id` != 0 ";
            //string query = "SELECT * FROM equipment WHERE `id` = 2 ";

            string query = "SELECT * FROM plug WHERE 1 ";
            // string query = "SELECT * FROM plug WHERE 1 ";
            MySqlCommand command = new MySqlCommand(query, connection);

            connection.Open();

            MySqlDataReader Reader = command.ExecuteReader();

            while (Reader.Read())
            {
                PagesJSON pj = new PagesJSON();

                JsonStr pr = new JsonStr();
                try
                {
                    // loop on columns
                    pr.id              = Reader[0].ToString();
                    pr.name            = Reader[1].ToString();
                    pr.status          = Reader[2].ToString();
                    pr.voltage         = Reader[3].ToString();
                    pr.current         = Reader[4].ToString();
                    pr.power           = Reader[5].ToString();
                    pr.S               = Reader[6].ToString();
                    pr.PF              = Reader[7].ToString();
                    pr.schedule        = Reader[8].ToString();
                    pr.before_schedule = Reader[9].ToString();
                    pr.before_status   = Reader[10].ToString();
                    pr.checked_        = Reader[11].ToString();
                    pr.recover         = Reader[12].ToString();

                    pr.now   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", Reader[13]);
                    pr.start = string.Format("{0:yyyy-MM-dd HH:mm:ss}", Reader[14]);
                    pr.end   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", Reader[15]);

                    pr.timedif = Reader[16].ToString();
                    pr.count   = Reader[17].ToString();
                    pr.total   = Reader[18].ToString();

                    pr.updated_at = string.Format("{0:yyyy-MM-dd HH:mm:ss}", Reader[19]);
                    pr.updating   = string.Format("{0:yyyy-MM-dd HH:mm:ss}", Reader[20]);

                    pr.timediff = Reader[21].ToString();

                    pj.plug.Add(pr);
                }
                catch (MySql.Data.Types.MySqlConversionException ConEx)
                {
                    //MessageBox.Show("MySqlConversionException : " + "\n" + ConEx);
                }
                catch (MySqlException sqlEX)
                {
                    MessageBox.Show("MySqlException : " + "\n" + sqlEX);
                }
                catch (ArgumentOutOfRangeException ee)
                {
                    MessageBox.Show("ArgumentOutOfRangeException : " + "\n" + ee);
                }


                // D:\\Thisway_Log產生log檔案(txt) 可查詢log資料
                try
                {
                    //如果此路徑沒有資料夾
                    if (!Directory.Exists("D:\\Thisway_Log"))
                    {
                        //新增資料夾
                        Directory.CreateDirectory("D:\\Thisway_Log");
                    }
                    //把內容寫到目的檔案,若檔案存在則附加在原本內容之後(換行)
                    File.AppendAllText("D:\\Thisway_Log\\" + "logJson1" + ".txt", "\r\n" + JsonConvert.SerializeObject(pj) + ":" + "內容");
                }
                catch (IOException eee)
                {
                    MessageBox.Show("IOException : " + "\n" + eee);
                }

                DBJson = DBJson + JsonConvert.SerializeObject(pj);
            } //while
            connection.Close();

            MessageBox.Show("" + DBJson);
        }
コード例 #6
0
ファイル: LmsjWxPay.cs プロジェクト: dmhai/dxpay
        /// <summary>
        /// 公众号转微信wap支付接口H5模式
        /// </summary>
        /// <param name="apptype">风控配置表id</param>
        /// <param name="code">订单编号</param>
        /// <param name="goodsname">商品名称</param>
        /// <param name="price">支付金额</param>
        /// <param name="orderid">订单id</param>
        /// <param name="ip">ip地址</param>
        /// <param name="appid">应用id</param>
        /// <returns></returns>
        private InnerResponse gzhwaph5(int apptype, string code, string goodsname, decimal price, int orderid, string ip, int appid, int infoTimes, int paymode)
        {
            InnerResponse   respon = new InnerResponse();
            InnerResponse   inn    = new InnerResponse();
            SelectInterface SeIn   = new SelectInterface();

            try
            {
                //查询应用是否开通微信公众号支付
                var payType = new PayWxGzh();
                var payc    = payType.LoadChannel(paymode, apptype, infoTimes, appid);
                if (string.IsNullOrEmpty(payc.PassName))
                {
                    inn = inn.ToResponse(ErrorCode.Code106);
                    return(inn);
                }
                System.Collections.Specialized.NameValueCollection Palist = new System.Collections.Specialized.NameValueCollection();

                string hckey = "wxgzhzwap" + appid;
                SeIn = SelectUserInfo(hckey, apptype, appid, infoTimes);
                JmPayParameter.JsonStr jsonStr = new JsonStr();
                PayBankModels          modes   = jsonStr.ParameterEntity(code, goodsname, price, "4", apptype, paymode);
                //h5模式
                respon = jsonStr.H5JsonStr(modes, ip);
                if (respon.ErrorCode == 100)
                {
                    Palist.Add("key", SeIn.UserKey);                                                             //key
                    Palist.Add("f", "json");                                                                     //API返回的格式支持json和js
                    Palist.Add("url", respon.ExtraData.ToString());                                              //要跳转的链接,先要经过urlencode编码
                    Palist.Add("b", "other");                                                                    //浏览器 默认other 表示其他浏览器,  baidu则表示手机百度,androd_chrome表示android chrome浏览器
                    string    urlstr                = ConfigurationManager.AppSettings["gzhzwapUrl"].ToString(); //公众号转wap请求地址
                    WebClient webClient             = new WebClient();
                    byte[]    responseData          = webClient.UploadValues(urlstr, "POST", Palist);            //得到返回字符流
                    string    srcString             = Encoding.UTF8.GetString(responseData);                     //解码
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic = JMP.TOOL.JsonHelper.DataRowFromJSON(srcString);
                    if (dic["status"].ToString() == "ok")
                    {
                        inn = inn.ToResponse(ErrorCode.Code100);
                        string ticket_url = dic["ticket_url"].ToString();
                        if (paymode == 3)
                        {
                            inn.ExtraData = ticket_url;
                            inn.IsJump    = true;
                        }
                        else
                        {
                            string json = "{\"data\":\"" + ticket_url + "\",\"PaymentType\":\"2\",\"SubType\":\"6\",\"IsH5\":\"1\"}";
                            inn.ExtraData = JMP.TOOL.AesHelper.AesEncrypt(json, ConfigurationManager.AppSettings["encryption"].ToString());
                        }
                    }
                    else
                    {
                        inn = inn.ToResponse(ErrorCode.Code104);
                        //转换微信链接失败
                        PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + srcString, summary: "公众号转wap支付接口错误信息", channelId: SeIn.PayId);
                    }
                    return(inn);
                }
                else
                {
                    return(respon);
                }
            }
            catch (Exception ex)
            {
                inn = inn.ToResponse(ErrorCode.Code104);
                //转换微信链接失败
                PayApiDetailErrorLogger.UpstreamPaymentErrorLog("报错信息:" + ex, summary: "公众号转wap支付接口错误信息", channelId: SeIn.PayId);
                return(inn);
            }
        }