public override void Preview() { //Save the current resource to another session copy string resId = $"Session:{this.EditorService.SessionID}//Preview{Guid.NewGuid()}.{this.Resource.ResourceType.ToString()}"; //NOXLATE string xml = this.XmlContent; var resSvc = this.EditorService.CurrentConnection.ResourceService; try { using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { resSvc.SetResourceXmlData(resId, ms); } } catch (Exception ex) { XmlContentErrorDialog.CheckAndHandle(ex, xml, false); } //Copy any resource data var previewCopy = resSvc.GetResource(resId); var conn = _edSvc.CurrentConnection; this.Resource.CopyResourceDataTo(conn, previewCopy); var previewer = ResourcePreviewerFactory.GetPreviewer(conn.ProviderName); if (previewer != null) { previewer.Preview(previewCopy, this.EditorService); } }
public override void Run() { var wb = Workbench.Instance; var exp = wb.ActiveSiteExplorer; var mgr = ServiceRegistry.GetService <ServerConnectionManager>(); var conn = mgr.GetConnection(exp.ConnectionName); string xml = "<FeatureSource xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"FeatureSource-1.0.0.xsd\">\n" + "<Foo />\n" + "</FeatureSource>"; try { string resId = "Session:" + conn.SessionID + "//Dummy.FeatureSource"; using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { conn.ResourceService.SetResourceXmlData(resId, ms); } } catch (Exception ex) { XmlContentErrorDialog.CheckAndHandle(ex, xml, false); } }
/// <summary> /// Updates the session copy's resource content /// </summary> /// <param name="xml"></param> public void UpdateResourceContent(string xml) { try { using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { _conn.ResourceService.SetResourceXmlData(this.EditedResourceID, ms); } } catch (Exception ex) { XmlContentErrorDialog.CheckAndHandle(ex, xml, false); } }
/// <summary> /// Sets the XML content of the given resource id /// </summary> /// <param name="conn"></param> /// <param name="resourceId"></param> /// <param name="xml"></param> public void SetResourceXml(IServerConnection conn, string resourceId, string xml) { try { using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { conn.ResourceService.SetResourceXmlData(resourceId, ms); } } catch (Exception ex) { XmlContentErrorDialog.CheckAndHandle(ex, xml, false); } }
/// <summary> /// Synchronises changes in the in-memory resource back to the session repository. This is usually called /// before validation of the edited resource begins. /// </summary> public void SyncSessionCopy() { string xml = ObjectFactory.SerializeAsString(_editCopy); try { using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { _conn.ResourceService.SetResourceXmlData(_editCopy.ResourceID, ms); } } catch (Exception ex) { XmlContentErrorDialog.CheckAndHandle(ex, xml, false); } }
public override void SyncSessionCopy() { //Write our XML changes back into the edited resource copy and re-read string xml = this.XmlContent; try { using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml))) { _edSvc.CurrentConnection.ResourceService.SetResourceXmlData(_edSvc.EditedResourceID, ms); } } catch (Exception ex) { XmlContentErrorDialog.CheckAndHandle(ex, xml, false); } //base.SyncSessionCopy(); }