Beispiel #1
0
 /// <summary>
 /// 多條條信息生成Json包(Data)
 /// Conver parameters to JSON string
 /// </summary>
 /// <returns></returns>
 public static string GetJsonPackagesString(List<DataPackage> dataPackage)
 {
     //string datatype, string userid, string group, string datetime, string msgid, string msg, string username
     if (dataPackage.Count > 0)
     {
         DataPackageList datapacklist = new DataPackageList();
         datapacklist.GetDataPackage = dataPackage;
         return new JavaScriptSerializer().Serialize(datapacklist);
     }
     else
     {
         return "";
     }
 }
Beispiel #2
0
 /// <summary>
 /// Data to JSON string
 /// </summary>
 /// <returns></returns>
 public void GetJsonString()
 {
     List<DataPackage> dataPackage = new List<DataPackage>(){  
                 new DataPackage(){DataType="1",
                                   UserID="D003842",
                                   GroupID="S234567",
                                   DateTime="",
                                   MessageID="",
                                   Message="Hello guys...",
                                   UserName="******",
                                   MessageState="-1"}
                 };
     DataPackageList datapacklist = new DataPackageList();
     datapacklist.GetDataPackage = dataPackage;
     textBox1.Text = new JavaScriptSerializer().Serialize(datapacklist);
     textBox2.Text = new JavaScriptSerializer().Serialize(dataPackage[0]);
 }
Beispiel #3
0
 /// <summary>
 /// 單條信息生成Json包
 /// Conver parameters to JSON string
 /// </summary>
 /// <returns></returns>
 public static string GetJsonString(string datatype, string userid, string group, string datetime, string msgid, string msgread, string msg, string username)
 {
     List<DataPackage> dataPackage = new List<DataPackage>(){  
                 new DataPackage(){DataType=datatype,
                                   UserID=userid,
                                   GroupID=group,
                                   DateTime=datetime,
                                   MessageID=msgid,
                                   Message=msg,
                                   UserName=username,
                                   MessageGUID=msgid,
                                   MessageState="-1",
                                   MessageRead=msgread,
                                   DocState="",
                                   DocDescription="",
                                   AvatarID="",
                                   Tags="0"}
                 };
     DataPackageList datapacklist = new DataPackageList();
     datapacklist.GetDataPackage = dataPackage;
     return new JavaScriptSerializer().Serialize(datapacklist);
 }