Global.cs
上传用户:jxqhsy
上传日期:2020-12-31
资源大小:1793k
文件大小:8k
- using System;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Ink;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using System.Collections.Generic;
- using System.Xml;
- using System.IO;
- namespace SFGS
- {
- public class Customer
- {
- public String ID { get; set; }
- public String Name { get; set; }
- public String Description { get; set; }
- public String Responses { get; set; }
- public String IsCurrentSurvey { get; set; }
- public String Result { get; set; }
- public String Question { get; set; }
- public String Edit { get; set; }
- public String Delete { get; set; }
- public String theNew { get; set; }
- public Customer()
- {
- }
- public Customer(string id, String name, String description, String responses, String iscurrent, String result, String question, String edit, String del, String thenew)
- {
- this.ID = id;
- this.Name = name;
- this.Description = description;
- this.Responses = responses;
- this.IsCurrentSurvey = iscurrent;
- this.Result = result;
- this.Question = question;
- this.Edit = edit;
- this.Delete = del;
- this.theNew = thenew;
- }
- }
- public class QuestionOptioner
- {
- public String ID { get; set; }
- public String SurveyID { get; set; }
- public String Text { get; set; }
- public String OptionA { get; set; }
- public String OptionB { get; set; }
- public String OptionC { get; set; }
- public String OptionD { get; set; }
- public QuestionOptioner()
- {
- }
- public QuestionOptioner(string ID, String SurveyID, String Text, String OptionA, String OptionB, String OptionC, String OptionD)
- {
- this.ID = ID;
- this.SurveyID = SurveyID;
- this.Text = Text;
- this.OptionA = OptionA;
- this.OptionB = OptionB;
- this.OptionC = OptionC;
- this.OptionD = OptionD;
- }
- }
- public class Global
- {
- public static bool IsLogin = false;
-
- /// <summary>
- /// 指定XML,返回一个customer集合
- /// </summary>
- /// <param name="xml"></param>
- /// <returns></returns>
- public static List<Customer> getList(String xml)
- {
- List<Customer> tmpList = new List<Customer>();
- List<Customer> list = new List<Customer>();
- using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
- {
- while (reader.Read())
- {
- if (reader.IsStartElement() && reader.Name == "Survey")
- {
- Customer customer = new Customer();
- using (XmlReader itemReader = reader.ReadSubtree())
- {
- while (itemReader.Read())
- {
- if (!itemReader.IsStartElement())
- {
- continue;
- }
- switch (itemReader.Name)
- {
- case "ID":
- itemReader.Read();
- customer.ID = itemReader.Value;
- break;
- case "Name":
- itemReader.Read();
- customer.Name = itemReader.Value;
- break;
- case "Description":
- itemReader.Read();
- customer.Description = itemReader.Value;
- break;
- case "Responses":
- itemReader.Read();
- customer.Responses = itemReader.Value;
- break;
- case "IsCurrentSurvey":
- itemReader.Read();
- customer.IsCurrentSurvey = itemReader.Value;
- break;
- }
- }
- customer.Result = "Result...";
- customer.Question = "Question...";
- customer.Edit = "Edit...";
- customer.Delete = "Delete...";
- customer.theNew = "New...";
- tmpList.Add(customer);
- }
- }
- }
- }
- return tmpList;
- }
- /// <summary>
- /// 指定XML,返回一个QuestionOptioner集合
- /// </summary>
- /// <param name="xml"></param>
- /// <returns></returns>
- public static List<QuestionOptioner> getQuestionList(String xml)
- {
- List<QuestionOptioner> tmpList = new List<QuestionOptioner>();
- List<QuestionOptioner> list = new List<QuestionOptioner>();
- using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
- {
- while (reader.Read())
- {
- if (reader.IsStartElement() && reader.Name == "Question")
- {
- QuestionOptioner customer = new QuestionOptioner();
- using (XmlReader itemReader = reader.ReadSubtree())
- {
- while (itemReader.Read())
- {
- if (!itemReader.IsStartElement())
- {
- continue;
- }
- switch (itemReader.Name)
- {
- case "ID":
- itemReader.Read();
- customer.ID = itemReader.Value;
- break;
- case "SurveyID":
- itemReader.Read();
- customer.SurveyID = itemReader.Value;
- break;
- case "Text":
- itemReader.Read();
- customer.Text = itemReader.Value;
- break;
- case "OptionA":
- itemReader.Read();
- customer.OptionA = itemReader.Value;
- break;
- case "OptionB":
- itemReader.Read();
- customer.OptionB = itemReader.Value;
- break;
- case "OptionC":
- itemReader.Read();
- customer.OptionC = itemReader.Value;
- break;
- case "OptionD":
- itemReader.Read();
- customer.OptionD = itemReader.Value;
- break;
- }
- }
- tmpList.Add(customer);
- }
- }
- }
- }
- return tmpList;
- }
- }
- }