//To get all items by running this on all tickers. public static void GetAllFRItemFromNASDAQ(string[] tickers, string reportType) { string periodType = "Annual"; string numPeriods = "10"; string reportParam = FinancialReportsConfig.params_NASDAQ[reportType]; string periodParam = FinancialReportsConfig.params_NASDAQ[periodType]; var keys = (Dictionary<string, int>)FinancialReportsConfig.mappings_NASDAQ[reportType]; List<string[]> list = new List<string[]>(); list.Add(new string[] { "ticker", "not in key", "previous key", "next key", "number" }); foreach (string ticker in tickers) { Dictionary<string, object> data = new Dictionary<string, object>(); try { WebData webData = new WebData(string.Format(Constants.NASDAQFinancialReportingURL, reportParam, periodParam, numPeriods, ticker)); data = webData.ReadNASDAQFRHtmlTable().ElementAt(1); } catch { } data.Each((d, i) => { int nexti = i + 1 == data.Count ? i : i + 1; if (!keys.ContainsKey(d.Key)) list.Add(new string[] { ticker, d.Key, data.ElementAt(i - 1).Key, data.ElementAt(nexti).Key, i.ToString() }); } ); //list.Add(new string[]{"","","","",""}); } Excel.Worksheet ws = ExcelUtil.Worksheet("Test_" + reportType); ws.Range("A2").Resize(list.Count, list[0].Length).Formula = ExcelUtil.To2DArray(list); }
public void Each() { var dict = new Dictionary<int, string>() { { 1, "one" }, { 2, "two" } }; var res = ""; dict.Each((i, s) => res += i + s + ","); Assert.AreEqual("1one,2two,", res); }
public void Copy_Razor_files_to_AWS_Bucket() { var fs = new FileSystemVirtualPathProvider(appHost, "~/../RazorRockstars.WebHost".MapHostAbsolutePath()); var skipDirs = new[] { "bin", "obj" }; var matchingFileTypes = new[] { "cshtml", "md", "css", "js", "png", "jpg" }; var replaceHtmlTokens = new Dictionary<string, string> { { "title-bg.png", "title-bg-aws.png" }, //Title Background { "https://gist.github.com/3617557.js", "https://gist.github.com/mythz/396dbf54ce6079cc8b2d.js" }, //AppHost.cs { "https://gist.github.com/3616766.js", "https://gist.github.com/mythz/ca524426715191b8059d.js" }, //S3 RockstarsService.cs { "RazorRockstars.WebHost/RockstarsService.cs", "RazorRockstars.S3/RockstarsService.cs" }, //S3 RockstarsService.cs { "http://github.com/ServiceStackApps/RazorRockstars/", "https://github.com/ServiceStackApps/RazorRockstars/tree/master/src/RazorRockstars.S3" } //Link to GitHub project }; foreach (var file in fs.GetAllFiles()) { if (skipDirs.Any(x => file.VirtualPath.StartsWith(x))) continue; if (!matchingFileTypes.Contains(file.Extension)) continue; if (file.Extension == "cshtml") { var html = file.ReadAllText(); replaceHtmlTokens.Each(x => html = html.Replace(x.Key, x.Value)); s3.WriteFile(file.VirtualPath, html); } else { s3.WriteFile(file); } } }
private void AddHashes() { var stringMap = new Dictionary<string, string> { {"one","a"}, {"two","b"}, {"three","c"}, {"four","d"} }; var stringIntMap = new Dictionary<string, int> { {"one",1}, {"two",2}, {"three",3}, {"four",4} }; stringMap.Each(x => Redis.SetEntryInHash("testhash", x.Key, x.Value)); var hash = Redis.Hashes["testhash"]; stringIntMap.Each(x => hash.Add(x.Key, x.Value.ToString())); }
public void Start(string bootstrapperName, Dictionary<string, string> properties, MarshalByRefObject remoteListener) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var domainSetup = AppDomain.CurrentDomain.SetupInformation; System.Environment.CurrentDirectory = domainSetup.ApplicationBase; // TODO -- need to handle exceptions gracefully here EventAggregator.Start((IRemoteListener) remoteListener); properties.Each(x => PackageRegistry.Properties[x.Key] = x.Value); var loader = BottleServiceApplication.FindLoader(bootstrapperName); _shutdown = loader.Load(); EventAggregator.SendMessage(new LoaderStarted { LoaderTypeName = _shutdown.GetType().FullName }); }
public void Can_SetRangeInHash() { var newStringMap = new Dictionary<string, string> { {"five","e"}, {"six","f"}, {"seven","g"} }; stringMap.Each(x => Redis.SetEntryInHash(HashId, x.Key, x.Value)); Redis.SetRangeInHash(HashId, newStringMap); newStringMap.Each(x => stringMap.Add(x.Key, x.Value)); var members = Redis.GetAllEntriesFromHash(HashId); Assert.That(members, Is.EquivalentTo(stringMap)); }
public void Can_call_GetAllEntriesFromHash_in_transaction() { var stringMap = new Dictionary<string, string> { {"one","a"}, {"two","b"}, {"three","c"}, {"four","d"} }; stringMap.Each(x => Redis.SetEntryInHash(HashKey, x.Key, x.Value)); Dictionary<string, string> results = null; using (var trans = Redis.CreateTransaction()) { trans.QueueCommand(r => r.GetAllEntriesFromHash(HashKey), x => results = x); trans.Commit(); } Assert.That(results, Is.EquivalentTo(stringMap)); }
public void LogAction(Enum logID, int? objectID, Dictionary<string, string> additionalParams = null) { if (GetBaseModel().GetUserPolicyState<bool>(UserPolicyGlobal.IsStatisticsDisabled)) { return; } var pars = new Dictionary<string, string> { {"utm_source", UtmParam.UtmSource}, {"utm_campaign", UtmParam.UtmCampaign}, {"utm_medium", UtmParam.UtmMedium} }; if (additionalParams != null) { additionalParams.Each(kv => { pars[kv.Key] = kv.Value; }); } UserActionLogger.Log(CurrentUser.GuestID, logID, objectID, pars); }