internal static XmlContentDisplayDialog Show(string xmlString, string header, bool allowEdit, bool allowFormat, bool allowExecute, SaveFormat saveFormat, FetchXmlBuilder caller) { if (xmlString.Length > 100000) { var dlgresult = MessageBox.Show("Huge result, this may take a while!\n" + xmlString.Length.ToString() + " characters in the XML document.\n\nContinue?", "Huge result", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dlgresult == DialogResult.No) { return(null); } } var xcdDialog = new XmlContentDisplayDialog(xmlString, header, allowEdit, allowFormat, allowExecute, saveFormat, caller); xcdDialog.StartPosition = FormStartPosition.CenterParent; xcdDialog.ShowDialog(); return(xcdDialog); }
private void DisplayQExCode() { try { var QEx = GetQueryExpression(); var code = QueryExpressionCodeGenerator.GetCSharpQueryExpression(QEx); var view = new XmlContentDisplayDialog(code, "QueryExpression Code", false, false, false, this); LogUse("DisplayQExCode"); view.ShowDialog(); } catch (FetchIsAggregateException ex) { MessageBox.Show("This FetchXML is not possible to convert to QueryExpression in the current version of the SDK.\n\n" + ex.Message, "QueryExpression", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show("Failed to generate C# QueryExpression code.\n\n" + ex.Message, "QueryExpression", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ExecuteFetch(string fetch) { working = true; WorkAsync("Executing FetchXML...", (eventargs) => { //var fetchxml = GetFetchDocument().OuterXml; var resp = (ExecuteFetchResponse)Service.Execute(new ExecuteFetchRequest() { FetchXml = fetch }); eventargs.Result = resp.FetchXmlResult; }, (completedargs) => { working = false; if (completedargs.Error != null) { MessageBox.Show(completedargs.Error.Message); } else if (completedargs.Result is string) { XmlDocument doc = new XmlDocument(); doc.LoadXml(completedargs.Result.ToString()); var xcdDialog = new XmlContentDisplayDialog(doc.OuterXml, "FetchXML result", false, false, false, this); xcdDialog.StartPosition = FormStartPosition.CenterParent; xcdDialog.ShowDialog(); } }); LogUse("ExecuteFetch"); }
private void UpdateLiveXML() { if (tsmiLiveUpdate.Checked) { liveUpdateXml = GetFetchString(false); if (xmlLiveUpdate == null) { xmlLiveUpdate = new XmlContentDisplayDialog(liveUpdateXml, "FetchXML Live Update", false, true, false, this); xmlLiveUpdate.Disposed += LiveXML_Disposed; xmlLiveUpdate.txtXML.KeyUp += LiveXML_KeyUp; xmlLiveUpdate.Visible = true; AlignLiveXML(); } else { xmlLiveUpdate.UpdateXML(liveUpdateXml); } } if (tsmiShowOData.Checked) { DisplayOData(); } }
private void tsmiLiveUpdate_CheckedChanged(object sender, EventArgs e) { if (tsmiLiveUpdate.Checked) { UpdateLiveXML(); } else if (xmlLiveUpdate != null) { xmlLiveUpdate.Close(); xmlLiveUpdate = null; } }
private void tsbEdit_Click(object sender, EventArgs e) { var xml = GetFetchString(false); var xcdDialog = new XmlContentDisplayDialog(xml, "FetchXML", true, true, Service != null, this); xcdDialog.StartPosition = FormStartPosition.CenterParent; if (xcdDialog.ShowDialog() == DialogResult.OK) { XmlNode resultNode = xcdDialog.result; EnableControls(false); ParseXML(resultNode.OuterXml, !xcdDialog.execute); UpdateLiveXML(); RecordHistory("manual edit"); if (xcdDialog.execute) { FetchResults(resultNode.OuterXml); } } }
public override void ClosingPlugin(PluginCloseInfo info) { if (!SaveIfChanged()) { info.Cancel = true; } else { if (xmlLiveUpdate != null) { xmlLiveUpdate.Close(); xmlLiveUpdate = null; } SaveSetting(); LogUse("Close"); } }
private void RetrieveMultiple(string fetch) { working = true; var outputtype = tsmiResultOption.SelectedIndex; var outputtypestring = tsmiResultOption.SelectedItem.ToString(); WorkAsync("Executing FetchXML...", (eventargs) => { EntityCollection resultCollection = null; QueryBase query; try { query = GetQueryExpression(); } catch (FetchIsAggregateException) { query = new FetchExpression(fetch); } resultCollection = Service.RetrieveMultiple(query); if (outputtype == 2) { var json = EntityCollectionSerializer.ToJSON(resultCollection, Formatting.Indented); eventargs.Result = json; } else { eventargs.Result = resultCollection; } }, (completedargs) => { working = false; if (completedargs.Error != null) { if (MessageBox.Show(completedargs.Error.Message + "\n\nTry with result as ExecuteFetch?", "Execute", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { ExecuteFetch(fetch); } } else if (outputtype == 0 && completedargs.Result is EntityCollection) { var gridDialog = new ResultGrid((EntityCollection)completedargs.Result, this); gridDialog.StartPosition = FormStartPosition.CenterParent; gridDialog.ShowDialog(); } else if (outputtype == 1 && completedargs.Result is EntityCollection) { var serialized = EntityCollectionSerializer.Serialize((EntityCollection)completedargs.Result); var xcdDialog = new XmlContentDisplayDialog(serialized.OuterXml, "XML Serialized RetrieveMultiple result", false, false, false, this); xcdDialog.StartPosition = FormStartPosition.CenterParent; xcdDialog.ShowDialog(); } else if (outputtype == 2 && completedargs.Result is string) { var result = completedargs.Result.ToString(); var xcdDialog = new XmlContentDisplayDialog(result, "JSON Serialized RetrieveMultiple result", false, false, false, this); xcdDialog.btnFormat.Visible = false; xcdDialog.StartPosition = FormStartPosition.CenterParent; xcdDialog.ShowDialog(); } }); LogUse("RetrieveMultiple-" + outputtypestring); }