private static void UploadDocument(MySqlConnection conn, APIInterface apiInterface, string text) { string documentText = text.Replace("'", "''"); string documentName = "com_object_" + apiInterface.Name.ToLower(); string documentTitle = apiInterface.Name + " object"; string documentLatestChange = DateTime.Now.ToString("yyyy'-'MM'-'dd"); int documentReads = 0; int documentParentID = 53; int documentIndex = 0; int documentIsBook = 0; int documentFirstPage = 0; // check if the document exists. string name = "select * from hm_documents where documentname = '" + documentName + "'"; MySqlCommand command = new MySqlCommand(name, conn); bool exists = false; using (MySqlDataReader reader = command.ExecuteReader()) { exists = reader.Read(); reader.Close(); } string sql = null; if (exists) { sql = string.Format("update hm_documents set documenttext = '{0}' where documentname = '{1}'", documentText, documentName); } else { sql = string.Format(@"insert into hm_documents (documentname, documenttitle, documenttext, documentlatestchange, documentreads, documentparentid, documentindex, documentisbook, documentfirstpage) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', {5}, {6}, {7}, {8})", documentName, documentTitle, documentText, documentLatestChange, documentReads, documentParentID, documentIndex, documentIsBook, documentFirstPage); } MySqlCommand updateCommand = new MySqlCommand(sql, conn); updateCommand.ExecuteNonQuery(); }
public void ParseLine(string line) { line = line.Trim(); line = line.Trim("\t".ToCharArray()); if (line.StartsWith("object")) { // we're starting a new object. _currentInterface = null; _currentHelpText = ""; } else if (line.StartsWith("helpstring")) { int startPos = "helpstring(\"".Length; int endPos = line.LastIndexOf("\""); int len = endPos - startPos; _currentHelpText = line.Substring(startPos, len); } else if (line.StartsWith("interface") && line.Contains("IDispatch")) { // extract the first word after interface. string [] values = line.SplitString(" "); string interfaceName = ""; for (int i = 1; i < values.Length; i++) { string value = values[i]; if (value.Length > 0) { interfaceName = value; break; } } if (string.IsNullOrEmpty(interfaceName)) { throw new Exception("Could not locate interface name"); } // Remove the IInterface signature. interfaceName = interfaceName.Substring("IInterface".Length); if (interfaceName == "FetchAccount") { int i = 0; } _currentInterface = new APIInterface(); _currentInterface.Name = interfaceName; _currentInterface.HelpString = _currentHelpText; apiInterfaces.Add(_currentInterface); } else if (line.StartsWith("[propget")) { // [propget, id(1), helpstring("Undelivered messages")] HRESULT UndeliveredMessages([out, retval] BSTR *pVal); if (_currentInterface == null) { return; } ParsePropLine(line, false); } else if (line.StartsWith("[propput")) { // [propput, id(34), helpstring("SMTP relayer requires authentication")] HRESULT SMTPRelayerRequiresAuthentication([in] VARIANT_BOOL newVal); if (_currentInterface == null) { return; } ParsePropLine(line, true); } else if (line.StartsWith("[id")) { if (_currentInterface == null) { return; } if (line.Contains("CreateExternalDatabase")) { int i = 0; } ParseMethodLine(line); } }
public void ParseLine(string line) { line = line.Trim(); line = line.Trim("\t".ToCharArray()); if (line.StartsWith("object")) { // we're starting a new object. _currentInterface = null; _currentHelpText = ""; } else if (line.StartsWith("helpstring")) { int startPos = "helpstring(\"".Length; int endPos = line.LastIndexOf("\""); int len = endPos - startPos; _currentHelpText = line.Substring(startPos, len); } else if (line.StartsWith("interface") && line.Contains("IDispatch")) { // extract the first word after interface. string [] values = line.SplitString(" "); string interfaceName = ""; for (int i = 1; i < values.Length; i++ ) { string value = values[i]; if (value.Length > 0) { interfaceName = value; break; } } if (string.IsNullOrEmpty(interfaceName)) { throw new Exception("Could not locate interface name"); } // Remove the IInterface signature. interfaceName = interfaceName.Substring("IInterface".Length); if (interfaceName == "FetchAccount") { int i = 0; } _currentInterface = new APIInterface(); _currentInterface.Name = interfaceName; _currentInterface.HelpString = _currentHelpText; apiInterfaces.Add(_currentInterface); } else if (line.StartsWith("[propget")) { // [propget, id(1), helpstring("Undelivered messages")] HRESULT UndeliveredMessages([out, retval] BSTR *pVal); if (_currentInterface == null) return; ParsePropLine(line, false); } else if (line.StartsWith("[propput")) { // [propput, id(34), helpstring("SMTP relayer requires authentication")] HRESULT SMTPRelayerRequiresAuthentication([in] VARIANT_BOOL newVal); if (_currentInterface == null) return; ParsePropLine(line, true); } else if (line.StartsWith("[id")) { if (_currentInterface == null) return; if (line.Contains("CreateExternalDatabase")) { int i = 0; } ParseMethodLine(line); } }