private static SendResult Send(string url, string receivers, string message, Purpose purpose, string signature) { NameValueCollection collection = new NameValueCollection(); collection.Add("Message", message); collection.Add("Receivers", receivers); collection.Add("Signature", signature); collection.Add("Purpose", purpose.ToString()); string json = HttpUtility.PostHtml(url, collection, Encoding.UTF8); var serializer = new JavaScriptSerializer(); return(serializer.Deserialize <SendResult>(json)); }
protected List <string> GetSQLCommands(string sqlDialect, Purpose enumPurpose, bool isFirstOfThisType, List <StrReplace> list) { string purpose = enumPurpose.ToString().ToLower(); string sqlCommands; string customFilepath = "./sql/" + sqlDialect + "/" + purpose + "/cmd.sql"; string defaultFilepath = "./sql/" + sqlDialect + "/" + purpose + "/default-cmd.sql"; Logger.Log(String.Format("\tLoading SQL commands from file: {0}", File.Exists(customFilepath) ? customFilepath : defaultFilepath) ); sqlCommands = File.Exists(customFilepath) ? File.ReadAllText(customFilepath) : File.ReadAllText(defaultFilepath); // Ted se sekce Queries v JSONu plni tak, ze se nacte napriklad definice procedury a ta se vlozi do Queries. // Potrebujeme uzivatelum dat moznost, aby meli moznost vlozit vlastni SQL prikaz z jine tabulku a nejen databazoveho katalogu. A to by se ulozilo do Queries. // Navrhuju to resit tak, ze by vznikl v kazdem adresari s dialektemadresar custom, cili / sql / teradata / custom // Tam by se lionfish vzdy koukl a pokud by tam existoval nejaky fajl, tak by ho spustil. // Uvnitr by byl takovyhle nejaky dotaz, ktery by rovnou vracel vsechny fieldy, ktere jsou treba vyplnit v Queries. // SELECT // sql_query_stmt as sourceCode, // sql_name as name, --can be left empty // sql_group_name as groupName, --can be empty // 'my-database-name' as databaseName // 'SCOTT' as schemaName // FROM // ETL_LOG if (enumPurpose == Purpose.QUERIES) { if (isFirstOfThisType) { string customPath = "./sql/" + sqlDialect + "/custom"; if (Directory.Exists(customPath)) { Logger.Log(string.Format("\tChecked custom sql files in {0} - directory exists.", customPath)); foreach (var file in Directory.GetFiles(customPath)) { if (file.EndsWith("sql", StringComparison.InvariantCultureIgnoreCase)) { string customSqlCommands = System.IO.File.ReadAllText(file); // add to standard sqlCommands += "\n--split\n"; sqlCommands += customSqlCommands; // log it Logger.Log(string.Format("\tConfFile {0} in custom directory succesfully added ({1} characters read).", file, customSqlCommands.Length)); } else { Logger.Log(string.Format("\tConfFile {0} in custom directory ignored - expected extension sql.", customPath)); } } } else { Logger.Log(string.Format("\tChecked custom sql files in {0} - directory does not exist.", customPath)); } } } // a dale jedeme jako posledne if (list != null) { foreach (var item in list) { sqlCommands = sqlCommands.Replace(item.SearchText, item.ReplaceText); } } string[] separator = { "--split" }; List <string> sqlCommandsList = sqlCommands.Split(separator, StringSplitOptions.RemoveEmptyEntries).ToList(); return(sqlCommandsList); }