Global.cs
上传用户:jxqhsy
上传日期:2020-12-31
资源大小:1793k
文件大小:8k
源码类别:

SilverLight

开发平台:

HTML/CSS

  1. using System;
  2. using System.Net;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Documents;
  6. using System.Windows.Ink;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Animation;
  10. using System.Windows.Shapes;
  11. using System.Collections.Generic;
  12. using System.Xml;
  13. using System.IO;
  14. namespace SFGS
  15. {
  16.     public class Customer
  17.     {
  18.         public String ID { get; set; }
  19.         public String Name { get; set; }
  20.         public String Description { get; set; }
  21.         public String Responses { get; set; }
  22.         public String IsCurrentSurvey { get; set; }
  23.         public String Result { get; set; }
  24.         public String Question { get; set; }
  25.         public String Edit { get; set; }
  26.         public String Delete { get; set; }
  27.         public String theNew { get; set; }
  28.         public Customer()
  29.         {
  30.         }
  31.         public Customer(string id, String name, String description, String responses, String iscurrent, String result, String question, String edit, String del, String thenew)
  32.         {
  33.             this.ID = id;
  34.             this.Name = name;
  35.             this.Description = description;
  36.             this.Responses = responses;
  37.             this.IsCurrentSurvey = iscurrent;
  38.             this.Result = result;
  39.             this.Question = question;
  40.             this.Edit = edit;
  41.             this.Delete = del;
  42.             this.theNew = thenew;
  43.         }
  44.     }
  45.     public class QuestionOptioner
  46.     {
  47.         public String ID { get; set; }
  48.         public String SurveyID { get; set; }
  49.         public String Text { get; set; }
  50.         public String OptionA { get; set; }
  51.         public String OptionB { get; set; }
  52.         public String OptionC { get; set; }
  53.         public String OptionD { get; set; }
  54.         public QuestionOptioner()
  55.         {
  56.         }
  57.         public QuestionOptioner(string ID, String SurveyID, String Text, String OptionA, String OptionB, String OptionC, String OptionD)
  58.         {
  59.             this.ID = ID;
  60.             this.SurveyID = SurveyID;
  61.             this.Text = Text;
  62.             this.OptionA = OptionA;
  63.             this.OptionB = OptionB;
  64.             this.OptionC = OptionC;
  65.             this.OptionD = OptionD;
  66.         }
  67.     }
  68.     public class Global
  69.     {
  70.         public static bool IsLogin = false;
  71.    
  72.         /// <summary>
  73.         /// 指定XML,返回一个customer集合
  74.         /// </summary>
  75.         /// <param name="xml"></param>
  76.         /// <returns></returns>
  77.         public static List<Customer> getList(String xml)
  78.         {
  79.             List<Customer> tmpList = new List<Customer>();
  80.             List<Customer> list = new List<Customer>();
  81.             using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
  82.             {
  83.                 while (reader.Read())
  84.                 {
  85.                     if (reader.IsStartElement() && reader.Name == "Survey")
  86.                     {
  87.                         Customer customer = new Customer();
  88.                         using (XmlReader itemReader = reader.ReadSubtree())
  89.                         {
  90.                             while (itemReader.Read())
  91.                             {
  92.                                 if (!itemReader.IsStartElement())
  93.                                 {
  94.                                     continue;
  95.                                 }
  96.                                 switch (itemReader.Name)
  97.                                 {
  98.                                     case "ID":
  99.                                         itemReader.Read();
  100.                                         customer.ID = itemReader.Value;
  101.                                         break;
  102.                                     case "Name":
  103.                                         itemReader.Read();
  104.                                         customer.Name = itemReader.Value;
  105.                                         break;
  106.                                     case "Description":
  107.                                         itemReader.Read();
  108.                                         customer.Description = itemReader.Value;
  109.                                         break;
  110.                                     case "Responses":
  111.                                         itemReader.Read();
  112.                                         customer.Responses = itemReader.Value;
  113.                                         break;
  114.                                     case "IsCurrentSurvey":
  115.                                         itemReader.Read();
  116.                                         customer.IsCurrentSurvey = itemReader.Value;
  117.                                         break;
  118.                                 }
  119.                             }
  120.                             customer.Result = "Result...";
  121.                             customer.Question = "Question...";
  122.                             customer.Edit = "Edit...";
  123.                             customer.Delete = "Delete...";
  124.                             customer.theNew = "New...";
  125.                             tmpList.Add(customer);
  126.                         }
  127.                     }
  128.                 }
  129.             }
  130.             return tmpList;
  131.         }
  132.         /// <summary>
  133.         /// 指定XML,返回一个QuestionOptioner集合
  134.         /// </summary>
  135.         /// <param name="xml"></param>
  136.         /// <returns></returns>
  137.         public static List<QuestionOptioner> getQuestionList(String xml)
  138.         {
  139.             List<QuestionOptioner> tmpList = new List<QuestionOptioner>();
  140.             List<QuestionOptioner> list = new List<QuestionOptioner>();
  141.             using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
  142.             {
  143.                 while (reader.Read())
  144.                 {
  145.                     if (reader.IsStartElement() && reader.Name == "Question")
  146.                     {
  147.                         QuestionOptioner customer = new QuestionOptioner();
  148.                         using (XmlReader itemReader = reader.ReadSubtree())
  149.                         {
  150.                             while (itemReader.Read())
  151.                             {
  152.                                 if (!itemReader.IsStartElement())
  153.                                 {
  154.                                     continue;
  155.                                 }
  156.                                 switch (itemReader.Name)
  157.                                 {
  158.                                     case "ID":
  159.                                         itemReader.Read();
  160.                                         customer.ID = itemReader.Value;
  161.                                         break;
  162.                                     case "SurveyID":
  163.                                         itemReader.Read();
  164.                                         customer.SurveyID = itemReader.Value;
  165.                                         break;
  166.                                     case "Text":
  167.                                         itemReader.Read();
  168.                                         customer.Text = itemReader.Value;
  169.                                         break;
  170.                                     case "OptionA":
  171.                                         itemReader.Read();
  172.                                         customer.OptionA = itemReader.Value;
  173.                                         break;
  174.                                     case "OptionB":
  175.                                         itemReader.Read();
  176.                                         customer.OptionB = itemReader.Value;
  177.                                         break;
  178.                                     case "OptionC":
  179.                                         itemReader.Read();
  180.                                         customer.OptionC = itemReader.Value;
  181.                                         break;
  182.                                     case "OptionD":
  183.                                         itemReader.Read();
  184.                                         customer.OptionD = itemReader.Value;
  185.                                         break;
  186.                                 }
  187.                             }                            
  188.                             tmpList.Add(customer);
  189.                         }
  190.                     }
  191.                 }
  192.             }
  193.             return tmpList;
  194.         }
  195.     }
  196. }