/// <summary> /// User has clicked on upload button. /// </summary> protected void UploadButton_Click(object sender, EventArgs e) { using (ApsoilWeb.Service Soils = new Apsoil.ApsoilWeb.Service()) { StreamReader In = new StreamReader(File1.FileContent); string contents = In.ReadToEnd(); if (!userSoil) { // Insert all soils into database. Soils.UpdateAllSoils(contents); } else { // Update a user soil. XmlDocument doc = new XmlDocument(); doc.LoadXml(contents); foreach (var soil in XmlHelper.ChildNodes(doc.DocumentElement, "Soil")) { var soilParams = new ApsoilWeb.JsonSoilParam() { JSonSoil = JsonConvert.SerializeXmlNode(soil) }; var ok = Soils.UpdateUserSoil(soilParams); } } string[] AllSoils = Soils.SoilNames(); SuccessLabel.Text = "Success. " + AllSoils.Length.ToString() + " soils in database."; SuccessLabel.Visible = true; } }
/// <summary> /// User has clicked on upload button. /// </summary> protected void UploadButton_Click(object sender, EventArgs e) { using (ApsoilWeb.Service Soils = new Apsoil.ApsoilWeb.Service()) { StreamReader In = new StreamReader(File1.FileContent); string contents = In.ReadToEnd(); if (pathToOverride == null) { // Insert all soils into database. Soils.UpdateAllSoils(contents); } else { // Update a single soil. Soils.UpdateSoil(pathToOverride, contents); } string[] AllSoils = Soils.SoilNames(); SuccessLabel.Text = "Success. " + AllSoils.Length.ToString() + " soils in database."; SuccessLabel.Visible = true; } }