ToJson() публичный Метод

public ToJson ( ) : string
Результат string
Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     JsonData pjd = new JsonData();
     pjd["OPCODE"] = (Int32)GameOpcode.CreateSprite;
     pjd["UUID"] = game.SelfUUID;
     Program.SendDataSingle(pjd.ToJson(), game.SelfUUID);
 }
Пример #2
0
        public static void createResource()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            DirectoryInfo             di = new DirectoryInfo(Global.PATH + "/res");
            var jd = new LitJson.JsonData();

            FileInfo[] fs = di.GetFiles("*", SearchOption.TopDirectoryOnly);

            foreach (FileInfo fi in fs)
            {
                if (fi.Name.Contains(".manifest"))
                {
                    continue;
                }

                string pPath = "res/" + fi.Name;
                jd[pPath.Replace("/", "@").Replace("\\", "@")] = pPath;
            }


            getJsonData(jd, "");
            JsonWriter writer = new JsonWriter(sb);

            writer.PrettyPrint = true;
            writer.IndentValue = 4;
            jd.ToJson(writer);



            string result = CoccosHelper.Properties.Resources.tpl.Replace("#1#", sb.ToString());

            File.WriteAllText(Global.PATH + "/src/resource.js", result);
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            if (context.Session["SlipAdmin"] == null)
            {
                //保存出错

                context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                context.Response.StatusCode = 401;
                context.Response.StatusDescription = "您没有登录或登录超时,请重新登录!";
                context.Response.End();
            }
            int status = 0;
            string msg = "未知错误";
            DataModal dm = new DataModal();
            try
            {
                int ef =dm.DeleteNews(context.Request.Params["nids"]);
                status = 1;
                msg = "成功删除" + ef + "条记录";

            }
            catch (Exception ex)
            {
                status = 2;
                msg = ex.Message;
            }

            JsonData jd = new JsonData();
            jd["status"] = status;
            jd["msg"] = msg;
            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(jd.ToJson());
            context.Response.End();
        }
Пример #4
0
 public string Marshal()
 {
     JsonData data = new JsonData();
     data["S"] = Pattern;
     data["E"] = Deadline;
     return data.ToJson();
 }
Пример #5
0
 public void Deserialize(string json)
 {
     data = JsonMapper.ToObject(json);
     IShip ww = JsonMapper.ToObject<VikingShip>(data.ToJson());
    
 
 }
Пример #6
0
    static int ToJson(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1 && TypeChecker.CheckTypes(L, typeof(LitJson.JsonData)))
            {
                LitJson.JsonData obj = (LitJson.JsonData)ToLua.ToObject(L, 1);
                string           o   = obj.ToJson();
                LuaDLL.lua_pushstring(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, typeof(LitJson.JsonData), typeof(LitJson.JsonWriter)))
            {
                LitJson.JsonData   obj  = (LitJson.JsonData)ToLua.ToObject(L, 1);
                LitJson.JsonWriter arg0 = (LitJson.JsonWriter)ToLua.ToObject(L, 2);
                obj.ToJson(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: LitJson.JsonData.ToJson"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
		public IEnumerator Post (string url) {
			// HEADERはHashtableで記述
			Hashtable header = new Hashtable ();
			header.Add ("Content-Type", "application/json; charset=UTF-8");
			
			// LitJsonを使いJSONデータを生成
			JsonData obj = new JsonData();
			obj["itemName"] = "katana";
			obj["itemType"] = "buki";
			obj["price"] = 300;
			obj["attack"] = "10";
			obj["defense"] = "0";
			obj["description"] = "atk";
			
			// シリアライズする(LitJson.JsonData→JSONテキスト)
			string postJsonStr = obj.ToJson();
			Debug.Log(postJsonStr);
			byte[] postBytes = Encoding.Default.GetBytes (postJsonStr);
			
			// 送信開始
			WWW www = new WWW (url, postBytes, header);
			yield return www;
			
			// 成功
			if (ErrorCheck(www)) {
				Debug.Log("WWW Ok!: " + www.data);
			}
			// 失敗
			else{
				Debug.Log("WWW Error: "+ www.error);          
			}
		}
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                int status = 0;
                string msg = "未知错误";
                int wkpID = Convert.ToInt32(Request.Params["wkpID"]);
                float wlpReal = float.Parse(Request.Params["wlpReal"]);
                int wlpAdmin = Convert.ToInt32(Session["adminID"].ToString());
                string wlpTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                LNSql lnSql = new LNSql();
                lnSql.conn.Open();
                try
                {
                    lnSql.cmd.CommandText = "update wkPay_tb set wlpReal=@wlpReal , wlpAdmin=@wlpAdmin,wlpTime=@wlpTime where wkpID=" + wkpID;
                    lnSql.cmd.Parameters.AddWithValue("@wlpReal", wlpReal);
                    lnSql.cmd.Parameters.AddWithValue("@wlpAdmin", wlpAdmin);
                    lnSql.cmd.Parameters.AddWithValue("@wlpTime", wlpTime);
                    lnSql.cmd.Parameters.AddWithValue("@wkpID", wkpID);
                    lnSql.cmd.ExecuteNonQuery();
                    status = 1;
                    msg = "保存成功!";
                }
                catch (Exception ex)
                {
                    msg = ex.Message;
                }
                finally
                {
                    lnSql.conn.Close();
                    JsonData jsonData = new JsonData();
                    jsonData["status"] = status;
                    jsonData["msg"] = msg;
                    string echoString = jsonData.ToJson();

                    Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                    Response.Write(echoString);
                    Response.End();
                }

            }
            else
            {
                int wkpID = Convert.ToInt32(Request.Params["did"]);
                LNSql lnSql = new LNSql();
                lnSql.conn.Open();
                lnSql.cmd.CommandText = "select wlpReal from wkPay_tb where wkpID=" + wkpID;
                lnSql.dr = lnSql.cmd.ExecuteReader();
                if (lnSql.dr.Read())
                {
                    if (lnSql.dr["wlpReal"] != null)
                    {
                        this.wlpReal.Text = lnSql.dr["wlpReal"].ToString();
                    }
                }

                lnSql.conn.Close();
                this.wkpID.Value = wkpID.ToString();
            }
        }
Пример #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if ( Session["SlipAdmin"] == null)
            {
                //保存出错

                Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                Response.StatusCode = 402;
                Response.StatusDescription = "您没有登录或登录超时,请重新登录!";
                Response.End();
            }
            if (IsPostBack)
            {
                JsonData jd = new JsonData();

                int status = 0;
                string msg = "未知状态";
                Support spt = new Support();
                DataModal dm = new DataModal();
                try
                {
                    spt.supportID = Convert.ToInt32(Request.Form["supportID"]);
                    spt.supportTitle = Request.Form["supportTitle"];
                    spt.supportContent = Request.Form["supportContent"];
                    dm.SaveSupport(spt);
                    status = 1;
                    msg = "保存成功!";
                }
                catch (Exception ex)
                {
                    msg = "错误:" + ex.Message;
                }

                jd["stauts"] = status;
                jd["msg"] = msg;
                Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                Response.Write(jd.ToJson());
                Response.End();
            }
            else
            {
                int id = 1;
                if (Request.Params["id"] == null || Request.Params["id"] == "")
                {
                    id = 1;
                }
                else
                {
                    id = Convert.ToInt32(Request.Params["id"]);
                }

                Support spt = new Support();
                DataModal dm = new DataModal();
                spt = dm.GetSupport(id);
                this.supportContent.Text = spt.supportContent;
               this.supportID.Value = spt.supportID.ToString();
               this.supportTitle.Text = spt.supportTitle;
               this.supportTitle.ReadOnly = true;
            }
        }
Пример #10
0
    protected void onDataUploadResult(LitJson.JsonData data, object userData)
    {
        if (data == null || data.ToJson() == "")
        {
            return;
        }
        string guid   = userData as string;
        string result = data["result"].ToString();

        if (result == "fail")
        {
            mSqlLiteLock.waitForUnlock();
            mSQLite.updateData(mTableName, new string[] { "uploaded" }, new object[] { 0 }, new string[] { "guid = '" + guid + "'" });
            mSqlLiteLock.unlock();
            // 上传失败,设置为未上传状态
            mSendLock.waitForUnlock();
            mLogSendList[guid].mState = LOG_STATE.LS_UNUPLOAD;
            mSendLock.unlock();
        }
        else if (result == "success")
        {
            mSqlLiteLock.waitForUnlock();
            mSQLite.updateData(mTableName, new string[] { "uploaded" }, new object[] { 1 }, new string[] { "guid = '" + guid + "'" });
            mSqlLiteLock.unlock();
            // 上传成功,移除该条信息
            mSendLock.waitForUnlock();
            mLogSendList.Remove(guid);
            mSendLock.unlock();
        }
    }
Пример #11
0
        public static void createResource()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            DirectoryInfo di = new DirectoryInfo(Global.PATH + "/res");
            var jd = new LitJson.JsonData();
            FileInfo[] fs = di.GetFiles("*", SearchOption.TopDirectoryOnly);

            foreach (FileInfo fi in fs)
            {
                if (fi.Name.Contains(".manifest"))
                {
                    continue;
                }

                string pPath = "res/" + fi.Name;
                jd[pPath.Replace("/", "@").Replace("\\", "@")] = pPath;
            }


            getJsonData(jd,"");
            JsonWriter writer = new JsonWriter(sb);
            writer.PrettyPrint = true;
            writer.IndentValue = 4;
            jd.ToJson(writer);
             
            

 
            string result = CoccosHelper.Properties.Resources.tpl.Replace("#1#", sb.ToString());
            File.WriteAllText(Global.PATH + "/src/resource.js", result);

        }
Пример #12
0
 public static WWW pack2Get(string path, JsonData jsdata)
 {
     if (!string.IsNullOrEmpty(accessToken) && !jsdata.Keys.Contains(TokenIDKey))
         jsdata[TokenIDKey] = accessToken;
     string str = jsdata.ToJson ();
     int cid = jsdata.Keys.Contains ("cmdid") ? int.Parse (jsdata ["cmdid"].ToString ()) : -1;
     return pack2Get(path, str, true,cid);
 }
Пример #13
0
        public override string GenerateSkillAppendData()
        {
            JsonData json = new JsonData();
            json["lastRound"] = this.lastRound;
            json["allLastRound"] = this.allLastRound;

            return json.ToJson();
        }
Пример #14
0
        protected PlayerCard EquipedCard; //装备了该装备的英雄

        #endregion Fields

        #region Methods

        public string GenerateEquipAppend()
        {
            JsonData json = new JsonData();

            //----这里实现装备附加值的添加

            return json.ToJson();
        }
Пример #15
0
 //计算按钮的点击事件
 void ButtonClick(GameObject button)
 {
     JsonData data = new JsonData ();
     data ["name"] = username.text;
     data ["password"] = password.text;
     byte[] msg = System.Text.UTF8Encoding.UTF8.GetBytes (data.ToJson ());
     NetMgr.Instance.SendMsg (msg, 1);
 }
Пример #16
0
        public override string GenerateSkillAppendData()
        {
            JsonData data = new JsonData();
            data["damage"] = GetCalculatedDamage();
            data["energy"] = this.skillEnergyCost;

            return data.ToJson();
        }
Пример #17
0
 public void returnMsg(int status,string msg)
 {
     JsonData jd = new JsonData();
     jd["stauts"] = status;
     jd["msg"] = msg;
     Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
     Response.Write(jd.ToJson());
     Response.End();
 }
Пример #18
0
    public static string IntArrayToString(int[] array)
    {
        JsonData data = new JsonData();
        foreach (int a in array)
        {
            data.Add(a);
        }

        return data.ToJson();
    }
Пример #19
0
        public void ProcessRequest(HttpContext context)
        {
            int status = 0;
            string msg = "未知错误!";
            if (context.Request.Cookies["SyglAdmin"] == null)
            {
                msg = "您未登录或登录超时!";
            }
            else
            {
                if (context.Request["imgids"] == "" || context.Request["imgids"] == null)
                {
                    msg = "您没有提交数据!";
                }
                else
                {
                    string imgids = context.Request["imgids"];
                    OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["SyglConnStr"].ConnectionString);
                    try
                    {
                        conn.Open();
                        OleDbCommand cmd = new OleDbCommand();
                        cmd.Connection = conn;

                        //删除数据记录
                        cmd.CommandText = "delete from imgs_tb where imgID in ( " + imgids + ") ";
                        int effects = cmd.ExecuteNonQuery();
                        //删除图片文件
                        string imgFile = context.Request["imgFile"];
                        SrCom srCom = new SrCom();
                        srCom.DeleteFile(imgFile);

                        status = 1;
                        msg = "成功删除" + effects + "条记录";
                        conn.Close();
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                    }
                    finally
                    {
                        conn.Close();
                    }
                }
            }
            JsonData jd = new JsonData();
            jd["status"] = status;
            jd["msg"] = msg;
            string echoData = jd.ToJson();
            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(echoData);
            context.Response.End();
        }
Пример #20
0
 public static void PrepareForSendMessage(string methodName, string status, LitJson.JsonData json)
 {
     if (!isDebug)
     {
         LitJson.JsonData data = new LitJson.JsonData();
         data ["Method"] = methodName;
         data ["Status"] = status;
         data ["target"] = json.ToJson();
         Utility.SendMessageToMobile(data);
     }
 }
Пример #21
0
        public void ProcessRequest(HttpContext context)
        {
            int total = 0;
            JsonData rows = new JsonData();
            if (context.Request.Cookies["SyglAdmin"] == null)
            {
                context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                context.Response.Write("未登录或登录超时!请重新登陆!");
                context.Response.End();
            }
            else
            {
                string connStr = ConfigurationManager.ConnectionStrings["SyglConnStr"].ConnectionString;

                OleDbConnection conn = new OleDbConnection();
                conn.ConnectionString = connStr;
                conn.Open();
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = conn;
                cmd.CommandText = "select ptmID,ptmName from ptms_tb order by ptmID";

                OleDbDataReader dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    do
                    {
                        JsonData row = new JsonData();
                        row["ptmName"] = dr["ptmName"].ToString();
                        row["ptmID"] = Convert.ToInt32(dr["ptmID"].ToString());
                        rows.Add(row);
                    } while (dr.Read());
                }

                //查询数量
                cmd = new OleDbCommand();
                cmd.Connection = conn;
                cmd.CommandText = "select count(ptmID) from ptms_tb ";

                total = Convert.ToInt32(cmd.ExecuteScalar());

                conn.Close();

                JsonData jsonData = new JsonData();
                jsonData["total"] = total;
                jsonData["rows"] = rows;
                string echoString = jsonData.ToJson();

                context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                context.Response.Write(echoString);
                context.Response.End();

            }
        }
Пример #22
0
        public void AsArrayTest ()
        {
            JsonData data = new JsonData ();

            data.Add (1);
            data.Add (2);
            data.Add (3);
            data.Add ("Launch!");

            Assert.IsTrue (data.IsArray, "A1");
            Assert.AreEqual ("[1,2,3,\"Launch!\"]", data.ToJson (), "A2");
        }
 void Facebook_onGraphRequest(bool result, JsonData reply)
 {
     print("Facebook_onGraphRequest " + reply.ToJson());
     if (String.IsNullOrEmpty(userId) && _Loader.loggedIn)
     {
         userName = dict[_Loader.playerName.ToLower()] = reply["name"].ToString();
         site = Site.FB;
         userId = reply["id"].ToString();
         Download(mainSite + "scripts/dict.php", delegate { }, true, "key", "fb" + userId, "value", _Loader.playerNamePrefixed);
         print("App Installed " + reply["installed"]);
     }
 }
Пример #24
0
    /// <summary>
    /// ひらがな変換リクエスト.
    /// </summary>
    /// <param name="Sentence">変換したい文字列.</param>
    /// <param name="ConvertType">変換タイプ(1:ひらがな、2:カタカナ).</param>
    public IEnumerator HiraganaPostRequest(string Sentence, int ConvertType) {

        // JsonDataの作成.
        JsonData data = new JsonData();

        // アプリケーションID.
        data["app_id"] = APPLICATION_ID;

        // 対象文字列.
        data["sentence"] = Sentence;

        // 変換タイプ(ひらがな、カタカナ).
        switch(ConvertType){
            case 1:
                data["output_type"] = "hiragana";
                break;
            case 2:
                data["output_type"] = "katakana";
                break;
        }

        string postJsonStr = data.ToJson();

        Debug.Log("send post json: " + postJsonStr);
        
        // bodyを作成.
        byte[] postBytes = Encoding.Default.GetBytes (postJsonStr);
    
        // ヘッダー.
        Dictionary<string, string> headers = new Dictionary<string, string>();
        headers["Content-Type"] = "application/json; charaset-UTF8";

        Debug.Log("send post json: " + postJsonStr);

        // リクエストを送信.
        WWW result = new WWW(HIRAGANA_API, postBytes, headers);
        yield return result;

        if (result.error != null) {
            Debug.Log("Post Failure…");
        } else{
            Debug.Log("Post Success!");
            Debug.Log("result: " + result.text);

            JsonData jsonParser = JsonMapper.ToObject(result.text);

            // パース.
            m_hiragana = jsonParser["converted"].ToString();

            Debug.Log(m_hiragana);
        }
    }
Пример #25
0
        public override void OnOpen(USocket us)
        {
            Console.WriteLine ("连接建立");
            JsonData data = new JsonData ();
            data ["cmd"] = 1;
            data ["name"] = "你好";
            data ["pwd"] = "ldfkjl";

            Frame f = new Frame (512);
            f.PutString (data.ToJson());
            f.End ();
            us.Send (f);
        }
Пример #26
0
        public static void WriteJsonData(this JsonWriter writer, JsonData jsonData)
        {
            var reader = new JsonReader(jsonData.ToJson());

            while (reader.Read())
            {
                switch (reader.Token)
                {
                    case JsonToken.None:
                        break;
                    case JsonToken.ObjectStart:
                        writer.WriteObjectStart();
                        break;
                    case JsonToken.PropertyName:
                        writer.WritePropertyName(reader.Value.ToString());
                        break;
                    case JsonToken.ObjectEnd:
                        writer.WriteObjectEnd();
                        break;
                    case JsonToken.ArrayStart:
                        writer.WriteArrayStart();
                        break;
                    case JsonToken.ArrayEnd:
                        writer.WriteArrayEnd();
                        break;
                    case JsonToken.Int:
                        writer.Write((int)reader.Value);
                        break;
                    case JsonToken.Long:
                        writer.Write((long)reader.Value);
                        break;
                    case JsonToken.ULong:
                        writer.Write((ulong)reader.Value);
                        break;
                    case JsonToken.Double:
                        writer.Write((double)reader.Value);
                        break;
                    case JsonToken.String:
                        writer.Write((string)reader.Value);
                        break;
                    case JsonToken.Boolean:
                        writer.Write((bool)reader.Value);
                        break;
                    case JsonToken.Null:
                        break;
                    default:
                        break;
                }
            }
        }
Пример #27
0
    public static string parseJson(string[] dataString)
    {
        LitJson.JsonData json  = new LitJson.JsonData();
        string[]         lines = dataString;

        if (lines.Length > 1)
        {
            string[] columnNames = WWWData.SplitWithDoubleQuote(lines[0], ',');

            int count = 0;
            for (int i = 0; i < columnNames.Length; i++)
            {
                if (columnNames[i] == string.Empty ||
                    columnNames[i].Contains("\r"))
                {
                    break;
                }
                count++;
            }

            for (int i = 1; i < lines.Length; i++)
            {
                LitJson.JsonData dic = new LitJson.JsonData();
                dic.SetJsonType(LitJson.JsonType.Object);

                string[] value = WWWData.SplitWithDoubleQuote(lines[i], ',');
                for (int j = 0; j < count; j++)
                {
                    string val = "";
                    try
                    {
                        val = value[j];
                    }
                    catch
                    {
                        Debug.LogError("Utils::parseJson error / line is " + lines[i]);
                    }
                    if (string.IsNullOrEmpty(val) == false)
                    {
                        dic[columnNames[j]] = val;
                    }
                }

                json.Add(dic);
            }
        }

        return(json.ToJson());
    }
Пример #28
0
    private static void SendMessageToMobile(LitJson.JsonData data)
    {
        Utility.LogPrint(data.ToString());
        switch (Application.platform)
        {
        case RuntimePlatform.Android:
            AndroidJavaClass  jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject jo = jc.GetStatic <AndroidJavaObject> ("currentActivity");
            if (data.ToJson() != "")
            {
                jo.Call("UnityCallBack", data.ToJson());
            }
            break;

        case RuntimePlatform.IPhonePlayer:
                #if UNITY_IPHONE
            InteractInterface.UnityCallBack(data.ToJson());
                #endif
            break;

        default:
            break;
        }
    }
Пример #29
0
        public static void validateAuthorJson(HttpContext context, string sessionName, string loginUrl)
        {
            if (context.Session[sessionName] == null || context.Session[sessionName].ToString() == "")
            {
                //未通过
                JsonData jd = new JsonData();

                jd["status"] = 0;
                jd["msg"] = @"<a target='_top' href='" + loginUrl + @"'> 请登录 !</a>";

                context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                context.Response.Write(jd.ToJson());
                context.Response.End();
            }
        }
Пример #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                int status = 0;
                string msg = "未知错误";
                string account = Request.Form["account"];
                string pwd = Request.Form["pwd"];
                SrCom srCom = new SrCom();
                //加密
                pwd = srCom.HashPassword(pwd);

                LNSql lnSql = new LNSql();
                lnSql.conn.Open();
                lnSql.cmd.CommandText = "select * from admins_tb where adminAccount=@account";
                lnSql.cmd.Parameters.AddWithValue("@account",account);
                lnSql.dr = lnSql.cmd.ExecuteReader();
                if (lnSql.dr.Read())
                {
                    if (pwd == lnSql.dr["adminPwd"].ToString())
                    {
                        //登录成功,设置登录sesseion
                        Session["adminID"] = lnSql.dr["adminID"].ToString();
                        Session["adminName"] = lnSql.dr["adminName"].ToString();
                        Session["adminClass"] = lnSql.dr["adminClass"].ToString();
                        status = 1;
                        msg = "登录成功";
                    }
                    else
                    {
                        msg = "密码错误!"; //+ pwd;
                    }
                }
                else
                {
                    msg = "账号不存在!";
                }
                lnSql.conn.Close();

                JsonData data = new JsonData();
                data["status"] =status;
                data["msg"] = msg;
                string json = data.ToJson();
                Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                Response.Write(json);
                Response.End();
            }
        }
Пример #31
0
        public void ProcessRequest(HttpContext context)
        {
            int status = 0;
            string msg = "";
            if (context.Session["userID"] != null)
            {
                //
                if (context.Request.Params["mid"] == "" || context.Request.Params["mid"] == null)
                {
                    msg = "未提交删除数据!";
                }
                else
                {
                    int effict=0;
                    SRDel.SRSql srSql = new SRDel.SRSql();
                    srSql.conn.Open();
                    srSql.cmd.CommandText = "delete from msgs_tb where msgID in (0 , " + context.Request.Params["mid"] + ")";
                    try
                    {
                        status = 1;
                        effict = srSql.cmd.ExecuteNonQuery();
                        msg = "成功删除" + effict + "条记录!";
                    }
                    catch (Exception ex)
                    {
                        msg = ex.Message;
                    }
                    finally
                    {
                        srSql.conn.Close();
                    }

                }
            }
            else
            {
                msg = "您还没有登录或者登录超时!请重新登陆!";
            }

            JsonData jd = new JsonData();
            jd["status"] = status;
            jd["msg"] = msg;
            string echoStr = jd.ToJson();
            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(echoStr);
            context.Response.End();
        }
Пример #32
0
 public void ProcessRequest(HttpContext context)
 {
     int status = 0;
     string msg = "未知错误!";
     if (context.Session["SlipAdmin"] == null)
     {
         //未登录
         msg = "未登录或登录超时!请重新登陆!<a href='LogOn.aspx'  target='_top'> 请登录</a>";
     }
     else
     {
         if (context.Request["dids"] == "" || context.Request["dids"] == null)
         {
             msg = "您没有提交数据!";
         }
         else
         {
             string dids = context.Request["dids"];
             SRSql srSql = new SRSql();
             try
             {
                 srSql.conn.Open();
                 srSql.cmd.CommandText = "delete from newsTB where newsID in ( " + dids + ") ";
                 int effects = srSql.cmd.ExecuteNonQuery();
                 status = 1;
                 msg = "成功删除" + effects + "条记录";
                 srSql.conn.Close();
             }
             catch (Exception ex)
             {
                 msg = ex.Message;
             }
             finally
             {
                 srSql.conn.Close();
             }
         }
     }
     JsonData jd = new JsonData();
     jd["status"] = status;
     jd["msg"] = msg;
     string echoData = jd.ToJson();
     context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
     context.Response.Write(echoData);
     context.Response.End();
 }
Пример #33
0
        /// <summary>
        /// Ons the button get identify handler. 获取验证码
        /// </summary>
        /// <param name="go">Go.</param>
        private void _onBtnGetIdentifyHandler(GameObject go)
        {
            var phoneNum = input_phone.text;

            //			if ( phoneNum== "" ||phoneNum.Length<11)
            //			{
            //				MessageHint.Show ("请输入正确的手机号");
            //				return;
            //			}

            if (GameModel.IsTelephone(phoneNum) == false)
            {
                MessageHint.Show("手机号错误,请重新输入");
                input_phone.text = "";
                return;
            }

            var getcodemodel = new PlayerGetCode();

            getcodemodel.phone = phoneNum;


            LitJson.JsonData data = new LitJson.JsonData();
            data ["phone"] = getcodemodel.phone;

            HttpRequestManager.GetInstance().GetCheckCodeData(data.ToJson());
            //HttpRequestManager.GetInstance ().GetCheckCodeData(data.ToJson());
            //			Console.WriteLine ("jsonString="+data.ToJson());
            //Coding<PlayerGetCode>.encode (getcodemodel);
            //			var getCodeStr = HttpRequestHelp.GetInstance ().GetCheckCodeData(data.ToJson());
            //			var getcodeback = Coding<PlayerGetCodeBackVo>.decode (getCodeStr);
            //
            //			Console.WriteLine (getCodeStr);
            //
            //			if(getcodeback.status==0)//成功
            //			{
            //				identyCode = getcodeback.data.code;
            //				MessageHint.Show ("已经发验证码,注意接收");
            //			}
            //			else
            //			{
            //				Console.WriteLine (getcodeback.msg);
            //			}
        }
Пример #34
0
        private void _OnShowBottom()
        {
            _btnserver.SetActiveEx(false);

            //Audio.AudioManager.Instance.StartMusic ();
            Audio.AudioManager.Instance.StartMusic();
            EventTriggerListener.Get(_btnLogin.gameObject).onClick       += _OnLoginHandler;
            EventTriggerListener.Get(_btnWeChatLogin.gameObject).onClick += _OnWeChatLoginHandler;
            EventTriggerListener.Get(_btnRegist.gameObject).onClick      += _OnRegistHandler;

            EventTriggerListener.Get(_btnModify.gameObject).onClick += _OnModifyHandler;
            EventTriggerListener.Get(_btnserver.gameObject).onClick += _OnShowServerHandler;
            EventTriggerListener.Get(_btnfankui.gameObject).onClick += _OnfankuiHandler;

            EventTriggerListener.Get(btn_showPhone.gameObject).onClick       += _OnShowPhoneBaordHandler;
            EventTriggerListener.Get(btn_closePhoneBoard.gameObject).onClick += _OnClosePhoneBoardHandler;

            _currentSever = System.Convert.ToString(_localConfig.LoadValue("curServer", ""));

            _loginUsername.text = System.Convert.ToString(_localConfig.LoadValue(savedPhone, ""));

            _loginPassword.text = System.Convert.ToString(_localConfig.LoadValue(GameModel.GetInstance.UserPassword, ""));

            //EventTriggerListener.Get (btn_login.gameObject).onClick+=_OnLoginHandler;
            //var squence = DOTween.Sequence ();
            //squence.Append (img_tipword.transform.DOLocalMoveY (-240, 1f));
            //squence.Append (img_tipword.transform.DOLocalMoveY (-200,1f));
            //squence.SetLoops(int.MaxValue);

            NetWorkScript.getInstance();

            if (_currentSever == "")
            {
                //SetServerName ("请选择服务器",false);
            }
            _HidePhoneBoard();

            LitJson.JsonData data = new LitJson.JsonData();
            data["versionCode"] = GameModel.GetInstance.version;
            //data.ToJson()
            HttpRequestManager.GetInstance().GetCheckVersionNew(data.ToJson());
            //HttpRequestManager.GetInstance ().GetCheckVersionOld ();
        }
Пример #35
0
        /* 返回json格式
         *  id:节点id,对载入远程数据很重要。
            text:显示在节点的文本。
            state:节点状态,'open' or 'closed',默认为'open'。当设置为'closed'时,拥有子节点的节点将会从远程站点载入它们。
            checked:表明节点是否被选择。
            attributes:可以为节点添加的自定义属性。
            children:子节点,必须用数组定义。
         */
        public void ProcessRequest(HttpContext context)
        {
            //查询数据库获取实验室列表
            DataModel dm=new DataModel();
            JsonData jd = new JsonData();
            List<LabType> lts = dm.GetLabTypes();
            List<LabChType> lcts = dm.GetLabChTypes();
            List<Lab> labs = dm.GetLabs();
            foreach (var t in lts)
            {
                JsonData jt = new JsonData();
                jt["id"] = t.LabTypeID;
                jt["text"] = t.LabTypeName;
                jt["iconCls"] = "icon-application_cascade";
                jt["children"] = new JsonData();
                foreach (var ct in lcts.FindAll(delegate(LabChType lct) { return lct.LabSupType == t.LabTypeID; }))
                {
                    JsonData jct = new JsonData();
                    jct["id"] = ct.LabChID;
                    jct["text"] = ct.LabChName;
                    jct["iconCls"] = "icon-application_cascade";
                    jct["children"] = new JsonData();
                    foreach (var lb in labs.FindAll(delegate(Lab _lb) { return _lb.LabType == ct.LabChID; }))
                    {
                        JsonData jLab = new JsonData();
                        jLab["id"] = lb.LabID;
                        jLab["text"] =lb.LabName;
                        //"iconCls":"icon-search"
                        jLab["iconCls"] = "icon-application_home";
                        jLab["checked"] =  lb.LabDefault;
                        jct["children"].Add(jLab);
                    }
                    jt["children"].Add(jct);
                }

                jd.Add(jt);
            }
            string labStr=jd.ToJson();

            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(labStr);
            context.Response.End();
        }
Пример #36
0
        public void ProcessRequest(HttpContext context)
        {
            lxyAuthor.validateAuthorJson(context);
            DataModel dm = new DataModel();
            int userID = Convert.ToInt32(context.Session["lxyLabUserID"]);
            LxyUser lxyUser = new LxyUser();
            lxyUser = dm.GetUser(userID);
            lxyUser.UserAccount = context.Request["UserAccount"];
            lxyUser.UserCollege = context.Request["UserCollege"];
            lxyUser.UserName = context.Request["UserName"];
            lxyUser.UserTel = context.Request["UserTel"];

            dm.SaveLxyUser(lxyUser);
            JsonData jd = new JsonData();
            jd["status"] = 1;
            jd["msg"] = "修改个人信息成功!";
            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(jd.ToJson());
            context.Response.End();
        }
Пример #37
0
        public void ProcessRequest(HttpContext context)
        {
            OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["SyglConnStr"].ConnectionString);
            conn.Open();
            OleDbCommand cmd = new OleDbCommand();
            cmd.Connection = conn;
            cmd.CommandText = "select * from imgs_tb order by imgID";
            OleDbDataReader dr = cmd.ExecuteReader();

            string echoString="";
            JsonData rows = new JsonData();
            int total = 0;
            if (dr.Read())
            {

                do
                {
                    total++;
                    JsonData jsonDataItem = new JsonData();
                    jsonDataItem["imgID"] = Convert.ToInt32( dr["imgID"].ToString());
                    jsonDataItem["imgFile"] = dr["imgFile"].ToString();
                    jsonDataItem["imgLink"] = dr["imgLink"].ToString();
                    rows.Add(jsonDataItem);
                } while (dr.Read());

            }
            else
            {
                rows = "";
            }
            JsonData jsonData = new JsonData();
            jsonData["total"] = total;
            jsonData["rows"] = rows;
            echoString = jsonData.ToJson();

            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(echoString);
            context.Response.End();
        }
Пример #38
0
        public void ProcessRequest(HttpContext context)
        {
            lxyAuthor.validateAuthorJson(context);
            int status = 0;
            string msg = "未知错误";

            if (context.Request["UserNewPwd"] != context.Request["UserComPwd"])
            {
                msg = "两次密码不一致!";
            }
            else
            {
                DataModel dm = new DataModel();
                int userID = Convert.ToInt32(context.Session["lxyLabUserID"]);
                LxyUser lxyUser = new LxyUser();
                lxyUser = dm.GetUser(userID);

                string oldPwd = context.Request.Params["UserOldPwd"];
                string newPwd = context.Request.Params["UserNewPwd"];
                if (lxyUser.UserPwd == SRLib.Des.EncryptDES(oldPwd, "SatanRabbit"))
                {

                    lxyUser.UserPwd = SRLib.Des.EncryptDES(newPwd, "SatanRabbit");
                    dm.SaveLxyUser(lxyUser);
                    status = 1;
                    msg = "修改密码成功!";
                }
                else
                {
                    msg = "原密码错误!";
                }
            }
            JsonData jd = new JsonData();
            jd["status"] = status;
            jd["msg"] = msg;
            context.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            context.Response.Write(jd.ToJson());
            context.Response.End();
        }
Пример #39
0
        private static object ReadValue(Type inst_type, JsonReader reader)
        {
            reader.Read();
            if (reader.Token == JsonToken.ArrayEnd)
            {
                return(null);
            }

            if (reader.Token == JsonToken.Null)
            {
                if (!inst_type.IsClass)
                {
                    throw new JsonException(String.Format(
                                                "Can't assign null to an instance of type {0}",
                                                inst_type));
                }

                return(null);
            }

            if (reader.Token == JsonToken.Double ||
                reader.Token == JsonToken.Int ||
                reader.Token == JsonToken.Long ||
                reader.Token == JsonToken.String ||
                reader.Token == JsonToken.Boolean)
            {
                Type json_type = reader.Value.GetType();
                //简单类型应该不需要被jsondata类型覆盖,直接导出即可
                if (inst_type.IsAssignableFrom(json_type) || inst_type == typeof(JsonData) || inst_type == typeof(Hashtable))
                {
                    return(reader.Value);
                }

                // If there's a custom importer that fits, use it
                if (custom_importers_table.ContainsKey(json_type) &&
                    custom_importers_table[json_type].ContainsKey(
                        inst_type))
                {
                    ImporterFunc importer =
                        custom_importers_table[json_type][inst_type];

                    return(importer(reader.Value));
                }

                // Maybe there's a base importer that works
                if (base_importers_table.ContainsKey(json_type) &&
                    base_importers_table[json_type].ContainsKey(
                        inst_type))
                {
                    ImporterFunc importer =
                        base_importers_table[json_type][inst_type];

                    return(importer(reader.Value));
                }

                // Maybe it's an enum
                if (inst_type.IsEnum)
                {
                    return(Enum.ToObject(inst_type, reader.Value));
                }

                // Try using an implicit conversion operator
                MethodInfo conv_op = GetConvOp(inst_type, json_type);

                if (conv_op != null)
                {
                    return(conv_op.Invoke(null,
                                          new object[] { reader.Value }));
                }

                // No luck
                throw new JsonException(String.Format(
                                            "Can't assign value '{0}' (type {1}) to type {2}",
                                            reader.Value, json_type, inst_type));
            }

            object instance = null;

            if (reader.Token == JsonToken.ArrayStart)
            {
                AddArrayMetadata(inst_type);
                ArrayMetadata t_data = array_metadata[inst_type];

                if (!t_data.IsArray && !t_data.IsList)
                {
                    throw new JsonException(String.Format(
                                                "Type {0} can't act as an array",
                                                inst_type));
                }

                IList list;
                Type  elem_type;

                if (!t_data.IsArray)
                {
                    list      = (IList)Activator.CreateInstance(inst_type);
                    elem_type = t_data.ElementType;
                }
                else
                {
                    list      = new ArrayList();
                    elem_type = inst_type.GetElementType();
                }

                while (true)
                {
                    //未知object用hashtable实现
                    object item = null;
                    if (elem_type == typeof(System.Object))
                    {
                        if (inst_type == typeof(Array) || inst_type == typeof(IList))
                        {
                            item = ReadValue(elem_type, reader);
                        }
                        else
                        {
                            item = ReadValue(typeof(Hashtable), reader);
                        }
                    }
                    else
                    {
                        item = ReadValue(elem_type, reader);
                    }
                    if (reader.Token == JsonToken.ArrayEnd)
                    {
                        if (list.GetType() == typeof(JsonData))
                        {
                            //尝试转换成array导出
                            JsonData data = (JsonData)list;
                            if (data.IsArray)
                            {
                                list = ToObject <ArrayList>(new JsonReader(data.ToJson()));
                            }
                        }
                        break;
                    }

                    list.Add(item);
                }

                if (t_data.IsArray)
                {
                    int n = list.Count;
                    instance = Array.CreateInstance(elem_type, n);

                    for (int i = 0; i < n; i++)
                    {
                        ((Array)instance).SetValue(list[i], i);
                    }
                }
                else
                {
                    instance = list;
                }
            }
            else if (reader.Token == JsonToken.ObjectStart)
            {
                AddObjectMetadata(inst_type);
                ObjectMetadata t_data = object_metadata[inst_type];

                instance = Activator.CreateInstance(inst_type);
                while (true)
                {
                    reader.Read();

                    if (reader.Token == JsonToken.ObjectEnd)
                    {
                        if (instance.GetType() == typeof(JsonData))
                        {
                            //尝试转换成hashtable导出
                            JsonData data = (JsonData)instance;
                            if (data.IsObject)
                            {
                                instance = ToObject <Hashtable>(new JsonReader(data.ToJson()));
                            }
                        }
                        break;
                    }

                    string property = (string)reader.Value;

                    if (t_data.Properties.ContainsKey(property))
                    {
                        PropertyMetadata prop_data =
                            t_data.Properties[property];

                        if (prop_data.IsField)
                        {
                            ((FieldInfo)prop_data.Info).SetValue(
                                instance, ReadValue(prop_data.Type, reader));
                        }
                        else
                        {
                            PropertyInfo p_info =
                                (PropertyInfo)prop_data.Info;

                            if (p_info.CanWrite)
                            {
                                p_info.SetValue(
                                    instance,
                                    ReadValue(prop_data.Type, reader),
                                    null);
                            }
                            else
                            {
                                ReadValue(prop_data.Type, reader);
                            }
                        }
                    }
                    else
                    {
                        if (!t_data.IsDictionary)
                        {
                            throw new JsonException(String.Format(
                                                        "The type {0} doesn't have the " +
                                                        "property '{1}'", inst_type, property));
                        }

                        ((IDictionary)instance).Add(
                            property, ReadValue(
                                t_data.ElementType, reader));
                    }
                }
            }

            return(instance);
        }
Пример #40
0
    /// <summary>
    /// 根据牌局Id请求战绩回调
    /// </summary>
    /// <param name="args"></param>
    private void RequestRecordByBattleIdCallBack(NetWorkHttp.CallBackArgs args)
    {
        m_isBusy = false;
        if (args.HasError)
        {
            ShowMessage("提示", "网络连接失败");
        }
        else
        {
            if (args.Value.code < 0)
            {
                ShowMessage("提示", args.Value.msg);
                return;
            }

            LitJson.JsonData jsonData = args.Value.data;
            if (jsonData.Count == 0)
            {
                ShowMessage("提示", "无此牌局战绩");
                return;
            }
            List <TestRecord> lstRecord = LitJson.JsonMapper.ToObject <List <TestRecord> >(jsonData.ToJson());

            RecordProxy.Instance.AllRecord = lstRecord;

            cfg_gameEntity gameEntity = cfg_gameDBModel.Instance.Get(m_CurrentRequestGameId);
            if (gameEntity == null)
            {
                return;
            }
            string gameType = gameEntity.GameType;

            TransferData data = new TransferData();
            data.SetValue("GameType", gameType);
            List <TransferData> lst = new List <TransferData>();
            for (int i = 0; i < lstRecord.Count; ++i)
            {
                TestRecord   record     = lstRecord[i];
                TransferData recordData = new TransferData();
                recordData.SetValue("Index", i + 1);
                recordData.SetValue("BattleId", record.battleId);
                recordData.SetValue("RoomId", record.roomId);
                recordData.SetValue("GameId", record.gameId);
                recordData.SetValue("MaxLoop", record.detail.Count);
                recordData.SetValue("RoomType", record.roomType);
                recordData.SetValue("OwnerName", record.ownerName);
                recordData.SetValue("DateTime", record.time);
                List <TransferData> lstPlayer = new List <TransferData>();
                for (int j = 0; j < record.Players.Count; ++j)
                {
                    TestPlayer   player     = record.Players[j];
                    TransferData playerData = new TransferData();
                    playerData.SetValue("NickName", player.nickname);
                    playerData.SetValue("Gold", player.gold);
                    playerData.SetValue("PlayerID", player.id);
                    playerData.SetValue("IsPlayer", player.id == AccountProxy.Instance.CurrentAccountEntity.passportId);
                    lstPlayer.Add(playerData);
                }
                recordData.SetValue("Player", lstPlayer);
                lst.Add(recordData);
            }
            data.SetValue("Record", lst);
            m_UIRecordView.ShowRecord(data);
        }
    }
Пример #41
0
 void OnGUI()
 {
     LitJson.JsonData jd = new LitJson.JsonData();
     jd["TestJson"] = 1;
     GUILayout.Label(jd.ToJson());
 }