public ActionResult LoadSampleData(SetupInputModel input) { MgUserInformation user = new MgUserInformation(input.Username, input.Password); MgSiteConnection conn = new MgSiteConnection(); conn.Open(user); MgResourceService resSvc = (MgResourceService)conn.CreateService(MgServiceType.ResourceService); //Load the package file if specified if (input.Package != null && input.Package.ContentLength > 0) { var path = Path.GetTempFileName(); try { input.Package.SaveAs(path); MgByteSource bs = new MgByteSource(path); MgByteReader br = bs.GetReader(); resSvc.ApplyResourcePackage(br); } finally { try { if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch { } } } //Load in our sample-specific resources MgResourceIdentifier sample1 = new MgResourceIdentifier(AJAX_LAYOUT); MgResourceIdentifier sample2 = new MgResourceIdentifier(FLEX_LAYOUT); MgByteSource bs1 = new MgByteSource(Server.MapPath("~/App_Data/SheboyganAspMvc.WebLayout.xml")); MgByteReader br1 = bs1.GetReader(); resSvc.SetResource(sample1, br1, null); MgByteSource bs2 = new MgByteSource(Server.MapPath("~/App_Data/SheboyganAspMvc.ApplicationDefinition.xml")); MgByteReader br2 = bs2.GetReader(); resSvc.SetResource(sample2, br2, null); return(RedirectToAction("Index")); }
public ActionResult LoadSampleData(SetupInputModel input) { MgUserInformation user = new MgUserInformation(input.Username, input.Password); MgSiteConnection conn = new MgSiteConnection(); conn.Open(user); MgResourceService resSvc = (MgResourceService)conn.CreateService(MgServiceType.ResourceService); //Load the package file if specified if (input.Package != null && input.Package.ContentLength > 0) { var path = Path.GetTempFileName(); try { input.Package.SaveAs(path); MgByteSource bs = new MgByteSource(path); MgByteReader br = bs.GetReader(); resSvc.ApplyResourcePackage(br); } finally { try { if (System.IO.File.Exists(path)) System.IO.File.Delete(path); } catch { } } } //Load in our sample-specific resources MgResourceIdentifier sample1 = new MgResourceIdentifier(AJAX_LAYOUT); MgResourceIdentifier sample2 = new MgResourceIdentifier(FLEX_LAYOUT); MgByteSource bs1 = new MgByteSource(Server.MapPath("~/App_Data/SheboyganAspMvc.WebLayout.xml")); MgByteReader br1 = bs1.GetReader(); resSvc.SetResource(sample1, br1, null); MgByteSource bs2 = new MgByteSource(Server.MapPath("~/App_Data/SheboyganAspMvc.ApplicationDefinition.xml")); MgByteReader br2 = bs2.GetReader(); resSvc.SetResource(sample2, br2, null); return RedirectToAction("Index"); }