Ejemplo n.º 1
0
        private void InitializeForm()
        {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.Load(Application.StartupPath + "/LoginConfig.xml");
            XmlNode address = xmldoc.SelectSingleNode("//address");

            //XmlNodeList xnlist = xmldoc.SelectNodes("//Template");
            //List<string> classiten = new List<string>();
            //for (int i = 0; i < xnlist.Count; i++)
            //{
            //    XmlElement xmle = (XmlElement)xnlist[i];
            //    //string id = xmle.GetAttribute("id");
            //    string text = xmle.GetAttribute("text");
            //    this.toolStripComboBoxClass.Items.Add(text);
            //    //classiten.Add(text);
            //}
            try
            {
                HttpHelper httphelper = new HttpHelper();
                string stagexml = httphelper.getHttpRespone("http://" + address.InnerText + "/api/Item/get?token=stage");
                XmlDocument xmldocstage = new XmlDocument();
                xmldocstage.LoadXml(stagexml.Trim());
                xmldocstage.Save(Application.StartupPath + stagefilename);

                string sourcexml = httphelper.getHttpRespone("http://" + address.InnerText + "/api/Item/get?token=source");
                XmlDocument xmldocsource = new XmlDocument();
                xmldocsource.LoadXml(sourcexml.Trim());
                xmldocsource.Save(Application.StartupPath + sourcefilename);

                string xuekexml = httphelper.getHttpRespone("http://" + address.InnerText + "/api/Item/get?token=xueke");
                XmlDocument xmldocxueke = new XmlDocument();
                xmldocxueke.LoadXml(xuekexml.Trim());
                xmldocxueke.Save(Application.StartupPath + xuekefilename);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            testpaper = new TestPaper();//初始化试卷属性

            foreach (string st in Enum.GetNames(typeof(Subject.SubjecttypeEnum)))
            {
                System.Windows.Forms.TreeNode treeNode = new System.Windows.Forms.TreeNode(st);
                treeNode.Text = st;
                this.treeViewSubject.Nodes.Add(treeNode);
            }
        }