public Feed ReadFeed(Uri uri) { Feed feed = null; var feedItems = new List<FeedItem>(); Category category = null; SyndicationFeed syndicationFeed; using (var xmlReader = XmlReader.Create(uri.AbsoluteUri)) { syndicationFeed = SyndicationFeed.Load(xmlReader); xmlReader.Close(); } if (syndicationFeed == null) return null; foreach (var item in syndicationFeed.Items) { var feedItem = new FeedItem(); Guid id; feedItem.Id = Guid.TryParse(item.Id, out id) ? id : new Guid(); feedItem.Title = item.Title.Text; feedItem.Mp3Url = item.Links.Count > 1 ? item.Links[1].Uri : item.Links[0].Uri; feedItem.PublishDate = item.PublishDate.DateTime; feedItem.Description = StripHTML(item.Summary.Text); feedItem.IsUsed = false; feedItems.Add(feedItem); } var items = new List<Data.IFeedItem>(); feedItems.ForEach(x => items.Add(x)); feed = new Feed(Guid.NewGuid(), syndicationFeed.Title.Text, items, uri, category,0); return feed; }
public List<FeedItem> ReadFeedItems(Uri uri) { var feedItems = new List<Data.IFeedItem>(); SyndicationFeed syndicationFeed; using (var xmlReader = XmlReader.Create(uri.AbsoluteUri)) { syndicationFeed = SyndicationFeed.Load(xmlReader); xmlReader.Close(); } foreach (var item in syndicationFeed.Items) { var feedItem = new FeedItem(); var id = Guid.NewGuid(); feedItem.Id = Guid.TryParse(item.Id, out id) ? new Guid(item.Id) : id; feedItem.Title = item.Title.Text; feedItem.Mp3Url = item.Links[0].Uri; feedItem.PublishDate = item.PublishDate.DateTime; feedItems.Add(feedItem); } var ret = new List<FeedItem>(); feedItems.ForEach(x => ret.Add(new FeedItem() { Id = x.Id, Mp3Url = x.Mp3Url, PublishDate = x.PublishDate, Title = x.Title })); return ret; }
public static void WhenDataFetchedThenWritesEachLine() { var data = new List<string> { Guid.NewGuid().ToString() }; var repository = new Mock<IDataRepository>(); repository.Setup(m => m.Fetch()).Returns(data); var writer = new Mock<TextWriter>(); new DisplayData(writer.Object, repository.Object).Run(); data.ForEach(x => writer.Verify(m => m.WriteLine(x), Times.Once)); }
public void Init() { if (!Directory.Exists(_workdirectory)) { Directory.CreateDirectory(_workdirectory); } _requirements = Directory.EnumerateFiles(_workdirectory, "*.tz").ToList().Select(file => new Requirement {Code = Path.GetFileNameWithoutExtension(file), Context = File.ReadAllText(file)}) .ToList(); DbManagementRepository dbManagementRepository = new DbManagementRepository(); _requirements.ForEach(p => dbManagementRepository.Insert(p)); }
public List<Category> GetEssayCategories() { var categories = new List<Category>(); foreach (var essayDictItem in essaysDictionary) { if (!categories.Exists(e => e.Name == essayDictItem.Value.Category)) { categories.Add(new Category(essayDictItem.Value.Category)); } categories.Single(e => e.Name == essayDictItem.Value.Category).EssaysForCategory.Add( new EssayForCategory(essayDictItem.Value.Title, essayDictItem.Key, essayDictItem.Value.PublishInfo.OriginalPublishDate)); } categories.ForEach(c => c.EssaysForCategory = c.EssaysForCategory.OrderByDescending(e => e.PublishDate).ToList()); return categories; }
//jlg bad logic private void UpdateAdCacheFromPaper(Newspaper entity) { List<Advertisement> deletedAds = new List<Advertisement>(); foreach (var ad in entity.Advertisements) { switch (entity.DbStatus) { case DbModificationState.Unchanged: case DbModificationState.Added: case DbModificationState.Modified: if(!_advertisementCache.ContainsKey(ad.UKey)) _advertisementCache.Add(ad.UKey,ad); deletedAds.AddRange(entity.Advertisements.Where(a=>a.DbStatus==DbModificationState.Deleted)); break; case DbModificationState.Deleted: foreach (var cacheAd in _advertisementCache.Values.ToList()) { cacheAd.Newspapers.Remove(entity); } break; } } deletedAds.ForEach(a=>_advertisementCache.Remove(a.UKey)); }
public static List<Translation> CreateTranslations(TranslationRepository translationsRepository) { var english = new CultureInfo("en-US"); var dutch = new CultureInfo("nl-NL"); var translations = new List<Translation> { // en-US new Translation("Login", "Login", english), new Translation("Logout", "Logout", english), new Translation("Home", "Home", english), new Translation("Users", "Users", english), new Translation("SendEmail", "Send email", english), new Translation("FlashMessages", "Flash messages", english), new Translation("Unauthorized", "Unauthorized", english), new Translation("Forbidden", "Forbidden", english), new Translation("PageNotFound", "Page not found", english), new Translation("InternalServerError", "Internal server error", english), new Translation("DearSirOrMadam", "Dear sir or madam", english), new Translation("KindRegards", "Kind regards", english), new Translation("ResetPassword", "Reset password", english), new Translation("ResetPasswordMailMessage", "We received a request to change your password. By clicking the link below you are able to reset your password.\r\nIn case you did not initiate this request, you can simply ignore this message, your password will remain unchanged.\r\n", english), new Translation("ResetPasswordMailMessageText", "We received a request to change your password. By using the link below you are able to reset your password.\r\nIn case you did not initiate this request, you can simply ignore this message, your password will remain unchanged.\r\n", english), new Translation("Required", "Required", english), new Translation("Email", "Email", english), new Translation("Password", "Password", english), new Translation("RepeatPassword", "Repeat password", english), new Translation("SignIn", "Sign in", english), new Translation("EmailAndPasswordCombinationNotValid", "Email and/or password is not valid", english), new Translation("InvalidEmailAddress", "Emailaddress is not valid", english), new Translation("UserWithEmailAddressWasNotFound", "User with emailaddress '{0}' was not found", english), new Translation("Send", "Send", english), new Translation("Back", "Back", english), new Translation("ChangePassword", "Change password", english), new Translation("PasswordsDoNotMatch", "Passwords do not match", english), new Translation("RequestToResetYourPassword", "Request to reset your password", english), new Translation("Success", "Success", english), new Translation("Info", "Info", english), new Translation("Warning", "Warning", english), new Translation("Error", "Error", english), new Translation("AnEmailWasSendToYourEmailaddressWithInstructionsOnHowToResetYourPassword", "An email was send to your emailaddress with instructions on how to reset your password", english), new Translation("YourPasswordWasChangedSuccessfully", "Your password was changed successfully", english), new Translation("ChuckNorrisFacts", "Chuck Norris Facts", english), new Translation("Shortcuts", "Shortcuts", english), new Translation("MorePages", "More pages", english), new Translation("PasswordShouldContainAtLeast5Characters", "Password should contain at least 5 characters", english), new Translation("ClientSideFlashMessages", "Client side flash messages", english), new Translation("InlineClientSideFlashMessages", "Inline client side flash messages", english), new Translation("EmailSuccessfullySend", "Email successfully send", english), // nl-NL new Translation("Login", "Inloggen", dutch), new Translation("Logout", "Uitloggen", dutch), new Translation("Home", "Thuis", dutch), new Translation("Users", "Gebruikers", dutch), new Translation("SendEmail", "Verstuur e-mail", dutch), new Translation("FlashMessages", "Notificatie berichten", dutch), new Translation("Unauthorized", "Onbevoegd", dutch), new Translation("Forbidden", "Verboden", dutch), new Translation("PageNotFound", "Pagina niet gevonden", dutch), new Translation("InternalServerError", "Interne server fout", dutch), new Translation("DearSirOrMadam", "Geachte heer, mevrouw", dutch), new Translation("KindRegards", "Vriendelijke groeten", dutch), new Translation("ResetPassword", "Reset wachtwoord", dutch), new Translation("ResetPasswordMailMessage", "Een aanvraag voor wijziging van uw wachtwoord is bij ons aangekomen. Door op onderstaande link te klikken kunt u een nieuw wachtwoord opgeven.\r\nIndien u geen verzoek tot wijziging heeft gedaan kunt u deze email als niet verzonden beschouwen, uw bestaande wachtwoord blijft dan intact.\r\n", dutch), new Translation("ResetPasswordMailMessage", "Een aanvraag voor wijziging van uw wachtwoord is bij ons aangekomen. Door onderstaande link te gebruiken kunt u een nieuw wachtwoord opgeven.\r\nIndien u geen verzoek tot wijziging heeft gedaan kunt u deze email als niet verzonden beschouwen, uw bestaande wachtwoord blijft dan intact.\r\n", dutch), new Translation("Required", "Verplicht", dutch), new Translation("Email", "Email", dutch), new Translation("Password", "Wachtwoord", dutch), new Translation("RepeatPassword", "Herhaal wachtwoord", dutch), new Translation("SignIn", "Inloggen", dutch), new Translation("EmailAndPasswordCombinationNotValid", "Email en/of wachtwoord is niet geldig", dutch), new Translation("InvalidEmailAddress", "Emailadres is niet geldig", dutch), new Translation("UserWithEmailAddressWasNotFound", "Gebruiker met emailadres '{0}' is niet gevonden", dutch), new Translation("Send", "Verzenden", dutch), new Translation("Back", "Terug", dutch), new Translation("ChangePassword", "Wachtwoord wijzigen", dutch), new Translation("PasswordsDoNotMatch", "Wachtwoorden komen niet overeen", dutch), new Translation("RequestToResetYourPassword", "Verzoek om uw wachtwoord te wijzigen", dutch), new Translation("Success", "Succes", dutch), new Translation("Info", "Info", dutch), new Translation("Warning", "Pas op", dutch), new Translation("Error", "Fout", dutch), new Translation("AnEmailWasSendToYourEmailaddressWithInstructionsOnHowToResetYourPassword", "Een email is naar u toegestuurd met instructies hoe u uw wachtwoord kunt resetten.", dutch), new Translation("YourPasswordWasChangedSuccessfully", "Uw wachtwoord is succesvol aangepast", dutch), new Translation("ChuckNorrisFacts", "Chuck Norris Feiten", dutch), new Translation("Shortcuts", "Shortcuts", dutch), new Translation("MorePages", "Meer pagina's", dutch), new Translation("PasswordShouldContainAtLeast5Characters", "Wachtwoord dient minimaal 5 tekens te bevatten", dutch), new Translation("ClientSideFlashMessages", "Client side flash berichten", dutch), new Translation("InlineClientSideFlashMessages", "Inline client side flash berichten", dutch), new Translation("EmailSuccessfullySend", "Email succesvol verzonden", dutch), }; translations.ForEach(translationsRepository.Save); return translations; }
static async void Run() { //var extractPath = ExtractingFromZip(); var xmlPath = @"E:\TWs\Database-2015-Team-Flerovium-\ImportingReports\ImportingReports\XmlImportFile\Books.xml"; XDocument doc = XDocument.Load(xmlPath); var zipFilePath = @"E:\TWs\Database-2015-Team-Flerovium-\ImportingReports\ImportingReports\ZipFile\Sales-Reports.zip"; var extractedFolderPath = ExtractZip(zipFilePath); var dateNamedFolders = GetDateNamedFolders(extractedFolderPath); var allSales = new List<Sale>(); foreach (var folder in dateNamedFolders) { foreach (var file in folder.GetFiles()) { var salesForFile = ExtractExcelData(file.FullName, file.Name, folder.Name); allSales.AddRange(salesForFile); } } allSales.ForEach(Console.WriteLine); var root = doc.Root; var books = root.Elements().AsQueryable().Select(BookMongo.FromXElement).ToList(); var client = new MongoClient("mongodb://localhost"); var db = client.GetDatabase("books-db"); var booksCollection = db.GetCollection<BsonDocument>("books"); var bsonBooks = books.AsQueryable().Select(BookMongo.ToBsonDocument); await booksCollection.InsertManyAsync(bsonBooks); var dbContext = new BooksDbContext(); var mongoBooks = await booksCollection.Find(new BsonDocument()).ToListAsync(); var bookModels = mongoBooks.Select(bookBson => { var authorIdToString = bookBson["AuthorId"].ToString(); var author = dbContext.Authors.FirstOrDefault(a => a.AuthorId.ToString() == authorIdToString); if (author == null) { author = new Author { AuthorId = int.Parse(bookBson["AuthorId"].ToString()), AuthorName = bookBson["Author"].ToString() }; dbContext.Authors.AddOrUpdate(a => a.AuthorName, author); dbContext.SaveChanges(); } var publisherIdToString = bookBson["PublisherId"].ToString(); var publisher = dbContext.BookPublishers.FirstOrDefault( b => b.BookPublisherId.ToString() == publisherIdToString); if (publisher == null) { publisher = new BookPublisher { BookPublisherId = int.Parse(bookBson["PublisherId"].ToString()), BookPublisherName = bookBson["Publisher"].ToString() }; dbContext.BookPublishers.AddOrUpdate(p => p.BookPublisherName, publisher); dbContext.SaveChanges(); } var book = new Book { BookId = int.Parse(bookBson["BookId"].ToString()), AuthorId = int.Parse(bookBson["AuthorId"].ToString()), BookPublisherId = int.Parse(bookBson["PublisherId"].ToString()), Title = bookBson["Title"].ToString(), BasePrice = decimal.Parse(bookBson["BasePrice"].ToString()), Author = author, Publisher = publisher }; return book; }); Console.WriteLine("--------------- {0} Saving Books", bookModels.Count()); dbContext.Books.AddOrUpdate(b => b.Title, bookModels.ToArray()); dbContext.SaveChanges(); Console.WriteLine("---------------Books saved!"); allSales.ForEach(sale => dbContext.Sales.Add(sale)); dbContext.SaveChanges(); Console.WriteLine("HERE"); var products = MySQLReadProductsTable(); WriteExcelSheet(products, "Products.xlsx"); var towns = MySQLReadTownsTable(); WriteExcelSheet(towns, "Towns.xlsx"); var couriers = MySQLReadCouriersTable(); WriteExcelSheet(couriers, "Couriers.xlsx"); Console.ReadKey(); //booksCollection.InsertManyAsync(bsonBooks); //Console.ReadKey(); /* In order to create a PDF report, use this: var db = new dbEntities(); // or whatever we use var testPdf = new PDFReporter(db); // creating an instance var data = db.Sales.ToList(); // or something more precise testPdf.GeneratePdfSalesReport("Sales", data); */ }
public static void HandleUrl(string url, MetroWindow window) { url = WebUtility.UrlDecode(url.Remove(0, FullName.Length)); var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?"); foreach (Match m in r) { var linkType = m.Groups[1].ToString(); switch (linkType) { case "project": var gitHubUser = m.Groups[2].ToString(); var repositoryName = m.Groups[3].ToString(); var assemblyName = m.Groups[4].ToString(); var w = new InstallerWindow { Owner = window }; w.ListAssemblies( string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true, assemblyName != "" ? m.Groups[4].ToString() : null); w.ShowDialog(); break; case "projectGroup": var remaining = url.Remove(0, 13); var assemblies = new List<LeagueSharpAssembly>(); while (remaining.IndexOf("/", StringComparison.InvariantCulture) != -1) { var data = remaining.Split(new[] {'/'}); if (data.Length < 3) { break; } var assembly = new LeagueSharpAssembly(data[2], "", string.Format("https://github.com/{0}/{1}", data[0], data[1])); assemblies.Add(assembly); for (int i = 0; i < 3; i++) { remaining = remaining.Remove(0, remaining.IndexOf("/", StringComparison.InvariantCulture) + 1); } } if (assemblies.Count > 0) { assemblies.ForEach( assembly => Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly)); ((MainWindow) window).PrepareAssemblies(assemblies, true, true, false); ((MainWindow) window).ShowTextMessage(Utility.GetMultiLanguageText("Installer"), Utility.GetMultiLanguageText("SuccessfullyInstalled")); } break; } } }
public static Tuple<string, string> Copy(StatsSummary statsSummary, Skills skills, AbnormalityStorage abnormals, bool timedEncounter, string header, string content, string footer, string orderby, string order, string lowDpsContent, int lowDpsThreshold) { //stop if nothing to paste var entityInfo = statsSummary.EntityInformation; var playersInfos = statsSummary.PlayerDamageDealt; var firstTick = entityInfo.BeginTime; var lastTick = entityInfo.EndTime; var firstHit = firstTick/TimeSpan.TicksPerSecond; var lastHit = lastTick/TimeSpan.TicksPerSecond; var heals = statsSummary.PlayerHealDealt; playersInfos.RemoveAll(x => x.Amount == 0); IEnumerable<PlayerDamageDealt> playerInfosOrdered; if (order == "ascending") { switch (orderby) { case "damage_received": playerInfosOrdered = playersInfos.OrderBy( playerInfo => skills.DamageReceived(playerInfo.Source.User, entityInfo.Entity, timedEncounter)); break; case "name": playerInfosOrdered = playersInfos.OrderBy(playerInfo => playerInfo.Source.Name); break; case "damage_percentage": case "damage_dealt": case "dps": playerInfosOrdered = playersInfos.OrderBy(playerInfo => playerInfo.Amount); break; case "crit_rate": playerInfosOrdered = playersInfos.OrderBy(playerInfo => playerInfo.CritRate); break; case "hits_received": playerInfosOrdered = playersInfos.OrderBy( playerInfo => skills.HitsReceived(playerInfo.Source.User, entityInfo.Entity, timedEncounter)); break; default: Console.WriteLine("wrong value for orderby"); throw new Exception("wrong value for orderby"); } } else { switch (orderby) { case "damage_received": playerInfosOrdered = playersInfos.OrderByDescending( playerInfo => skills.DamageReceived(playerInfo.Source.User, entityInfo.Entity, timedEncounter)); break; case "name": playerInfosOrdered = playersInfos.OrderByDescending(playerInfo => playerInfo.Source.Name); break; case "damage_percentage": case "damage_dealt": case "dps": playerInfosOrdered = playersInfos.OrderByDescending(playerInfo => playerInfo.Amount); break; case "crit_rate": playerInfosOrdered = playersInfos.OrderByDescending(playerInfo => playerInfo.CritRate); break; case "hits_received": playerInfosOrdered = playersInfos.OrderByDescending( playerInfo => skills.HitsReceived(playerInfo.Source.User, entityInfo.Entity, timedEncounter)); break; default: Console.WriteLine("wrong value for orderby"); throw new Exception("wrong value for orderby"); } } var dpsString = new StringBuilder(header); var name = entityInfo.Entity?.Info.Name ?? ""; AbnormalityDuration enrage; var bossDebuff = abnormals.Get(entityInfo.Entity); bossDebuff.TryGetValue(BasicTeraData.Instance.HotDotDatabase.Enraged, out enrage); var enrageperc = lastTick - firstTick == 0 ? 0 : (double) (enrage?.Duration(firstTick, lastTick) ?? 0)/(lastTick - firstTick); dpsString.Replace("{encounter}", name); var interval = TimeSpan.FromSeconds(lastHit - firstHit); dpsString.Replace("{timer}", interval.ToString(@"mm\:ss")); dpsString.Replace("{partyDps}", FormatHelpers.Instance.FormatValue(lastHit - firstHit > 0 ? entityInfo.TotalDamage/(lastHit - firstHit) : 0) + LP.PerSecond); dpsString.Replace("{enrage}", FormatHelpers.Instance.FormatPercent(enrageperc)); dpsString.Replace("{debuff_list}", String.Join(" | ", bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select( x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick)) + " (" + TimeSpan.FromTicks(x.Value.Duration(firstTick, lastTick)).ToString(@"mm\:ss") + ") ") )); dpsString.Replace("{debuff_list_p}", String.Join(" | ", bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select( x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick))) )); var placeholders = new List<KeyValuePair<PlayerDamageDealt, Dictionary<string, string>>>(); foreach (var playerStats in playerInfosOrdered) { var playerHolder = new Dictionary<string, string>(); placeholders.Add(new KeyValuePair<PlayerDamageDealt, Dictionary<string, string>>(playerStats, playerHolder)); var buffs = abnormals.Get(playerStats.Source); AbnormalityDuration slaying; var firstOrDefault = heals.FirstOrDefault(x => x.Source == playerStats.Source); double healCritrate = 0; if (firstOrDefault != null) { healCritrate = firstOrDefault.CritRate; } buffs.Times.TryGetValue(BasicTeraData.Instance.HotDotDatabase.Slaying, out slaying); var slayingperc = lastTick - firstTick == 0 ? 0 : (double)(slaying?.Duration(firstTick, lastTick) ?? 0) / (lastTick - firstTick); playerHolder["{slaying}"] = FormatHelpers.Instance.FormatPercent(slayingperc); playerHolder["{dps}"] = FormatHelpers.Instance.FormatValue(playerStats.Interval == 0 ? playerStats.Amount : playerStats.Amount * TimeSpan.TicksPerSecond / playerStats.Interval) + LP.PerSecond; playerHolder["{global_dps}"] = FormatHelpers.Instance.FormatValue(entityInfo.Interval == 0 ? playerStats.Amount : playerStats.Amount * TimeSpan.TicksPerSecond / entityInfo.Interval) + LP.PerSecond; playerHolder["{interval}"] = playerStats.Interval/TimeSpan.TicksPerSecond + LP.Seconds; playerHolder["{damage_dealt}"] = FormatHelpers.Instance.FormatValue(playerStats.Amount); playerHolder["{class}"] = LP.ResourceManager.GetString(playerStats.Source.Class.ToString(), LP.Culture) + ""; playerHolder["{fullname}"] = playerStats.Source.FullName; playerHolder["{name}"] = playerStats.Source.Name; playerHolder["{deaths}"] = buffs.Death.Count(firstTick, lastTick) + ""; playerHolder["{death_duration}"] = TimeSpan.FromTicks(buffs.Death.Duration(firstTick, lastTick)).ToString(@"mm\:ss"); playerHolder["{aggro}"] = buffs.Aggro(entityInfo.Entity).Count(firstTick, lastTick) + ""; playerHolder["{aggro_duration}"] = TimeSpan.FromTicks(buffs.Aggro(entityInfo.Entity).Duration(firstTick, lastTick)).ToString(@"mm\:ss"); playerHolder["{damage_percentage}"] = playerStats.Amount * 100 / entityInfo.TotalDamage + "%"; playerHolder["{crit_rate}"] = playerStats.CritRate + "%"; playerHolder["{crit_rate_heal}"] = healCritrate + "%"; playerHolder["{biggest_crit}"] = FormatHelpers.Instance.FormatValue(skills.BiggestCrit(playerStats.Source.User, entityInfo.Entity, timedEncounter)); playerHolder["{damage_received}"] = FormatHelpers.Instance.FormatValue(skills.DamageReceived(playerStats.Source.User, entityInfo.Entity, timedEncounter)); playerHolder["{hits_received}"] = FormatHelpers.Instance.FormatValue(skills.HitsReceived(playerStats.Source.User, entityInfo.Entity, timedEncounter)); playerHolder["{debuff_list}"] = String.Join(" | ", bossDebuff.Where(x=>x.Key.Id!=8888888 && x.Value.InitialPlayerClass==playerStats.Source.Class && x.Value.Duration(firstTick,lastTick)>0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select( x=>x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick,lastTick) / (lastTick - firstTick)) + " ("+ TimeSpan.FromTicks(x.Value.Duration(firstTick, lastTick)).ToString(@"mm\:ss")+") ") ); playerHolder["{debuff_list_p}"] = String.Join(" | ", bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.InitialPlayerClass == playerStats.Source.Class && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select( x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick))) ); } var placeholderLength = placeholders.SelectMany(x => x.Value).GroupBy(x=>x.Key).ToDictionary(x=>x.Key,x=>x.Max(z=> graphics.MeasureString(z.Value, Font, default(PointF), StringFormat.GenericTypographic).Width)); var dpsmono = new StringBuilder(dpsString.ToString()); var placeholderMono = placeholders.SelectMany(x => x.Value).GroupBy(x => x.Key).ToDictionary(x => x.Key, x => x.Max(z => z.Value.Length)); if ((content.Contains('\\')||lowDpsContent.Contains('\\')) && BasicTeraData.Instance.WindowData.FormatPasteString) placeholders.ForEach(x => { var currentContent = x.Key.Amount*100/entityInfo.TotalDamage >= lowDpsThreshold ? new StringBuilder(content): new StringBuilder(lowDpsContent); x.Value.ToList().ForEach(z => currentContent.Replace(z.Key, PadRight(z.Value,placeholderLength[z.Key]))); dpsString.Append(currentContent); currentContent = x.Key.Amount * 100 / entityInfo.TotalDamage >= lowDpsThreshold ? new StringBuilder(content) : new StringBuilder(lowDpsContent); x.Value.ToList().ForEach(z => currentContent.Replace(z.Key, z.Value.PadRight(placeholderMono[z.Key]))); dpsmono.Append(currentContent); }); else { placeholders.ForEach(x => { var currentContent = x.Key.Amount * 100 / entityInfo.TotalDamage >= lowDpsThreshold ? new StringBuilder(content) : new StringBuilder(lowDpsContent); x.Value.ToList().ForEach(z => currentContent.Replace(z.Key, z.Value)); dpsString.Append(currentContent); }); dpsmono = dpsString; } var footerstr=footer.Replace("{debuff_list}", String.Join(" | ", bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select( x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick)) + " (" + TimeSpan.FromTicks(x.Value.Duration(firstTick, lastTick)).ToString(@"mm\:ss") + ") ") )).Replace("{debuff_list_p}", String.Join(" | ", bossDebuff.Where(x => x.Key.Id != 8888888 && x.Value.Duration(firstTick, lastTick) > 0).OrderByDescending(x => x.Value.Duration(firstTick, lastTick)).ToList().Select( x => x.Key.ShortName + " " + FormatHelpers.Instance.FormatPercent((double)x.Value.Duration(firstTick, lastTick) / (lastTick - firstTick))) )); dpsString.Append(footerstr); dpsmono.Append(footerstr); var paste = dpsString.ToString(); var monoPaste = dpsmono.ToString(); while (paste.Contains(" \\")) paste = paste.Replace(" \\", "\\"); while (monoPaste.Contains(" \\")) monoPaste = monoPaste.Replace(" \\", "\\"); monoPaste = monoPaste.Replace("\\", Environment.NewLine); return new Tuple<string,string>(paste ,monoPaste); }
public List<Year> GetEssayYears() { var years = new List<Year>(); foreach (var essayDictItem in essaysDictionary) { if (!years.Exists(e => e.YearValue == essayDictItem.Value.PublishYear)) { years.Add(new Year(essayDictItem.Value.PublishYear)); } years.Single(e => e.YearValue == essayDictItem.Value.PublishYear).EssaysForYear.Add( new EssayForYear(essayDictItem.Value.Title, essayDictItem.Key, essayDictItem.Value.Category, essayDictItem.Value.PublishInfo.OriginalPublishDate)); } years.ForEach(c => c.EssaysForYear = c.EssaysForYear.OrderByDescending(e => e.PublishDate).ToList()); return years.OrderByDescending(y => y.YearValue).ToList(); }