예제 #1
0
        public void GetBillList(string userId)
        {
            try
            {
                Context.Response.ContentType = "text/plain";
                if (userId == "1")
                {
                    string     sql  = "select * from goods";
                    DataTable  dt   = DBAccess.RunSQLReturnTable(sql);
                    BillStruct bill = new BillStruct();
                    bill.id    = 1;
                    bill.time  = "2019-1-10";
                    bill.price = "2019rmb";
                    goods goods1 = new goods();
                    goods1.name = "百果园";
                    goods1.num  = "23";

                    List <goods> goodsList = new List <goods>();
                    goodsList.Add(goods1);
                    bill.cont = goodsList;
                    ArrayList billList = new ArrayList();
                    billList.Add(bill);
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    Context.Response.Write(jss.Serialize(bill));
                }
                else
                {
                    Context.Response.Write("[]");
                }
            }
            catch
            {
                Context.Response.Write("[]");
            }
        }
예제 #2
0
        public void BillKeenanProblem()
        {
            string           xml        = @"<?xml version='1.0'?> 
<methodResponse> 
  <params> 
    <param> 
      <value>
        <struct>
          <member>
            <name>x</name>
            <value>
              <i4>123</i4>
            </value>
          </member>
          <member>
            <name>s</name>
            <value>
              <string>ABD~~DEF</string>
            </value>
          </member>
          <member>
            <name>unexpected</name>
            <value>
              <string>this is unexpected</string>
            </value>
          </member>
        </struct>
      </value> 
    </param> 
  </params> 
</methodResponse>";
            StringReader     sr         = new StringReader(xml);
            XmlRpcSerializer serializer = new XmlRpcSerializer();
            XmlRpcResponse   response
                = serializer.DeserializeResponse(sr, typeof(BillStruct));

            Object o = response.retVal;

            Assert.IsTrue(o is BillStruct, "retval is BillStruct");
            BillStruct bs = (BillStruct)o;

            Assert.IsTrue(bs.x == 123 && bs.s == "ABD~~DEF", "struct members");
        }