/// <summary> /// Execute command /// </summary> /// <returns>Available databases</returns> public async Task <List <string> > Execute() { List <string> databases = new List <string>(); XmlNode xmlResponse = await m_fm.Communicate("-dbnames"); List <string> errors = new List <string>(); foreach (XmlNode rootNode in xmlResponse.ChildNodes) { switch (rootNode.Name) { case "error": string theError = rootNode.Attributes.GetNamedItem("code").Value; if (theError != "0") { throw new FilemakerException("FileMaker Server returned an error in retrieving the XML. Error: " + theError); } break; case "resultset": foreach (XmlNode fileNode in rootNode.ChildNodes) { string filename = fileNode.FirstChild.FirstChild.InnerText; databases.Add(filename); } break; } } return(databases); }
/// <summary> /// Execute :0 /// </summary> public async Task <int> Execute() { string extra = ""; foreach (KeyValuePair <string, string> field in m_values) { extra += "&" + Uri.EscapeDataString(field.Key == null ? "" : field.Key) + "=" + Uri.EscapeDataString(field.Value == null ? "" : field.Value); } if (m_afterScript != null) { extra += "&-script=" + Uri.EscapeDataString(m_afterScript); } if (m_afterScriptParameter != null) { extra += "&-script.param=" + Uri.EscapeDataString(m_afterScriptParameter); } XmlNode xmlResponse = await m_fm.Communicate("-lay=" + m_layout + "&-new" + extra, true); int recordID = -1; foreach (XmlNode rootNode in xmlResponse.ChildNodes) { switch (rootNode.Name) { case "error": string theError = rootNode.Attributes.GetNamedItem("code").Value; if (theError != "0") { throw new FilemakerException("FileMaker Server returned an error in retrieving the XML. Error: " + theError); } break; case "resultset": foreach (XmlNode record in rootNode.ChildNodes) { foreach (XmlAttribute attribute in record.Attributes) { switch (attribute.Name) { case "record-id": recordID = int.Parse(attribute.Value); break; } } } break; case "metadata": // TODO: parse meta data break; } } return(recordID); }
/// <summary> /// Execute command /// </summary> /// <returns>Available items</returns> public async Task <LayoutInfo> Execute() { LayoutInfo info = new LayoutInfo(); List <LayoutField> fields = new List <LayoutField>(); XmlNode xmlResponse = await m_fm.Communicate("-lay=" + m_layout + "&-view", true); foreach (XmlNode rootNode in xmlResponse.ChildNodes) { switch (rootNode.Name) { case "datasource": foreach (XmlAttribute a in rootNode.Attributes) { switch (a.Name) { case "table": info.TableName = a.Value; break; } } break; case "error": string theError = rootNode.Attributes.GetNamedItem("code").Value; if (theError != "0") { throw new FilemakerException("FileMaker Server returned an error in retrieving the XML. Error: " + theError); } break; case "metadata": foreach (XmlNode fileNode in rootNode.ChildNodes) { string fieldname = fileNode.Attributes["name"].InnerText; string type = fileNode.Attributes["type"].InnerText; string result = fileNode.Attributes["result"].InnerText; bool AutoEnter = fileNode.Attributes["auto-enter"].InnerText == "yes"; fields.Add(new LayoutField { Name = fieldname, Type = type, Result = result, AutoEnter = AutoEnter }); } break; } } info.Fields = fields; return(info); }
/// <summary> /// Execute find /// </summary> /// <returns></returns> public async Task <List <FilemakerRecord> > Execute() { string search = ""; if (m_command == "-find") { foreach (var item in m_items) { search += "&" + Uri.EscapeDataString(item.Name) + "=" + Uri.EscapeDataString(item.Value) + "&" + Uri.EscapeDataString(item.Name) + ".op=" + RealSearchCriterium(item.Operator); } } if (m_max != 0) { search += "&-max=" + m_max; } if (m_skip != -1) { search += "&-skip=" + m_skip; } XmlNode xmlResponse = await m_fm.Communicate("-lay=" + m_layout + "&" + m_command + search, true); m_records = new List <FilemakerRecord>(); foreach (XmlNode rootNode in xmlResponse.ChildNodes) { switch (rootNode.Name) { case "error": string theError = rootNode.Attributes.GetNamedItem("code").Value; if (theError != "0") { if (!m_throwErrorOnNotFound && theError == "401") { return(null); } throw new FilemakerException("FileMaker Server returned an error in retrieving the XML. Error: " + theError); } break; case "resultset": HandleRecords(rootNode); break; case "metadata": // TODO: parse meta data break; } } return(m_records); }
public async Task <string> Execute() { XmlNode xmlResponse = await m_fm.Communicate("-lay=" + m_layout + "&-delete&-recid=" + m_recordID, true); string errorcode = "0"; foreach (XmlNode rootNode in xmlResponse.ChildNodes) { switch (rootNode.Name) { case "error": errorcode = rootNode.Attributes.GetNamedItem("code").Value; break; } } return(errorcode); }
/// <summary> /// Execute :0 /// </summary> public async Task <int> Execute() { XmlNode xmlResponse = await m_fm.Communicate(GenerateUrl(), true); int recordID = -1; foreach (XmlNode rootNode in xmlResponse.ChildNodes) { switch (rootNode.Name) { case "error": string theError = rootNode.Attributes.GetNamedItem("code").Value; if (theError != "0") { throw new FilemakerException("FileMaker Server returned an error in retrieving the XML. Error: " + theError); } break; case "resultset": foreach (XmlNode record in rootNode.ChildNodes) { foreach (XmlAttribute attribute in record.Attributes) { switch (attribute.Name) { case "record-id": recordID = int.Parse(attribute.Value); break; } } } break; case "metadata": // TODO: parse meta data break; } } return(recordID); }