示例#1
0
        // returns true if the results were successfully submitted, false if they weren't
        // however you must catch Exceptions for things like network failure, etc.
        public bool SubmitResults(string name, string email, string organization, string homepage, string comments, string apptype)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(xml_report_path);

            SetXmlMetadataValue(doc, "name", name);
            SetXmlMetadataValue(doc, "email", email);
            SetXmlMetadataValue(doc, "homepage", homepage);
            SetXmlMetadataValue(doc, "organization", organization);
            SetXmlMetadataValue(doc, "comments", comments);

            SetXmlMetadataValue(doc, "apptype", apptype);

            MoMAWebService.MoMASubmit ws = new MoMAWebService.MoMASubmit();
            return(ws.SubmitResults(doc.OuterXml));
        }
		private Version DownloadLatestDefinitions ()
		{
			Version v = null;
			// try to download files from the net
			try {
				string definitionsUri;
				using (MoMASubmit ws = new MoMASubmit ()) {
					string lastest_def = ws.GetLatestDefinitionsVersion ();
					int s = lastest_def.LastIndexOf ('/') + 1;
					int e = lastest_def.IndexOf ('-', s);
					v = new Version (lastest_def.Substring (s, e - s));
					definitionsUri = lastest_def.Split ('|') [2];
				}

				using (WebClient wc = new WebClient ()) {
					string filename = GetFileName (v);
					wc.DownloadFile (new Uri (definitionsUri), filename);
				}
			}
			catch (WebException e) {
				if (Runner.VerbosityLevel > 0)
					Console.Error.WriteLine (e);
			}
			return v;
		}