static void Main(string[] args) { Console.WriteLine("Einfaches Beispiel:"); // Simple Write Console.WriteLine("Schreiben..."); XmlSerializer _xmlGenSimpleWrite = new XmlSerializer(typeof(string)); _xmlGenSimpleWrite.Serialize(Console.Out, "www.code-inside.de"); Console.WriteLine(""); // Simple Read Console.WriteLine("Lesen..."); XmlSerializer _xmlGenSimpleRead = new XmlSerializer(typeof(string)); Console.WriteLine(_xmlGenSimpleRead.Deserialize(new StringReader("<string>www.Code-Inside.de</string>"))); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Komplexes Beispiel:"); // Complex Write Console.WriteLine("Datei schreiben..."); string _path = Path.Combine(Application.StartupPath, "test.xml"); using (StreamWriter _xmlFile = new StreamWriter(_path)) { Console.WriteLine("Blogeintrag 'XML erstellen mit XmlAttributen' erstellen."); XmlSerializer _xmlGen = new XmlSerializer(typeof(BlogEntry)); BlogEntry _myBlogEntry = new BlogEntry(); _myBlogEntry.Title = "XML erstellen mit XmlAttributen"; _myBlogEntry.Content = "Es gibt viele Möglichkeiten..."; for (int i = 0; i < 5; i++) { Console.WriteLine("Kommentar anfügen: " + i); _myBlogEntry.Comments.Add(new BlogComment("Paul", "Cooole Sache" + i)); _myBlogEntry.Comments[i].Comments.Add(new BlogComment("Tim", "Finde ich auch Paul")); } _xmlGen.Serialize(_xmlFile, _myBlogEntry); } Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("Datei laden..."); // Complex Read using (StreamReader _xmlFile = new StreamReader(_path)) { XmlSerializer _xmlGen = new XmlSerializer(typeof(BlogEntry)); BlogEntry _myBlogEntry =(BlogEntry)_xmlGen.Deserialize(_xmlFile); Console.WriteLine("Blogeintrag '" + _myBlogEntry.Title + "' geladen:"); foreach (BlogComment _comments in _myBlogEntry.Comments) { Console.WriteLine("Kommentar: '" + _comments.Name + ": " + _comments.Content + "'"); } } Console.ReadLine(); }
public void Invoke(HttpSessionState session, DataInputStream input) { _result = HttpProcessor.GetClient<BlogServiceSoapClient>(session).GetEntry( input.ReadString(), input.ReadString(), input.ReadInt32()); }
/// <summary> /// Adds a blog entry to the database. /// </summary> public override void CreateBlogEntry(BlogEntry blogEntryToCreate) { var entity = ConvertBlogEntryToBlogEntryEntity(blogEntryToCreate); _entities.AddToBlogEntryEntitySet(entity); _entities.SaveChanges(); }
public override void CreateBlogEntry(BlogEntry blogEntryToCreate) { //throw new NotImplementedException(); var entity = ConvertBlogEntryToBlogEntryEntity(blogEntryToCreate); _entities.AddToBlogEntryEntities(entity); _entities.SaveChanges(); }
public async Task Post_WhenUserNotOwner_ReturnsForbidden() { // Arrange var blogEntryDTO = new BlogEntryDTO() { Id = 0, Title = "Title", Content = "Content", EntryUpdates = new List <BlogEntryUpdateDTO>(), Status = BlogEntryStatus.Public, CreationDate = DateTime.MinValue, LastUpdated = DateTime.MinValue, Deleted = false, Blog = new BlogDTO() { Id = 1, Name = "Test blog", CreationDate = DateTime.Now, Entries = null, Deleted = false, Owner = null } }; var blogEntry = new BlogEntry() { Id = 1, Title = "Title", Content = "Content", EntryUpdates = new List <BlogEntryUpdate>(), Status = BlogEntryStatus.Public, CreationDate = DateTime.Now, LastUpdated = DateTime.Now, Deleted = false, BlogId = 1 }; blogServiceMock .Setup(m => m.GetAsync(It.IsAny <int>())) .ReturnsAsync(new Blog() { Id = 1, Name = "Test blog", CreationDate = DateTime.Now, Entries = null, Deleted = false, OwnerId = 1, Owner = null }); blogEntryServiceMock .Setup(m => m.AddOrUpdateAsync(It.IsAny <BlogEntry>())) .ReturnsAsync(blogEntry); var controller = GetController(mapper); controller.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new Claim[] { new Claim(ClaimTypes.Name, "jdoe"), new Claim(ClaimTypes.Sid, "2") }, "jwt")) } }; // Act var result = await controller.Post(blogEntryDTO); // Assert Assert.NotNull(result); var forbidResult = Assert.IsType <ObjectResult>(result); Assert.Equal(403, forbidResult.StatusCode); blogServiceMock.Verify(m => m.GetAsync(It.IsAny <int>()), Times.Once); blogEntryServiceMock.Verify(m => m.AddOrUpdateAsync(It.IsAny <BlogEntry>()), Times.Never); }
private static Entry GetBlogEntryFromResult(BlogEntry entry) { return(new Entry { Id = entry.Id, Date = entry.PublishDateTime, Markdown = entry.Body, Title = entry.Title }); }
public ActionResult ApproveBlogEntry(BlogEntry blog) { var repo = RepositoryFactory.CreateRepository(); blog = repo.GetBlogEntryById(blog.EntryId); blog.IsApproved = true; repo.EditBlogEntry(blog); return(RedirectToAction("ManageBlog", "Admin")); }
private void IncrementUsersTags(BlogEntry entry) { foreach (var tag in entry.Tags) { tag.TagToUsers .Where(ttu => ttu.Account.Name.Equals(User.Identity.Name)) .ToList() .ForEach(ttu => ttu.TimesSeen++); } }
// // GET: /Blog/Edit/5 public ActionResult Edit(int id = 0) { BlogEntry blogentry = unitOfWork.BlogRepository.GetByID(id); if (blogentry == null) { return(HttpNotFound()); } return(View(blogentry)); }
public ActionResult Edit([Bind(Include = "BlogEntryId,Title,Text,CreatedDate")] BlogEntry blogEntry) { if (ModelState.IsValid) { db.Entry(blogEntry).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(blogEntry)); }
public ActionResult Edit(BlogEntry blogentry) { if (ModelState.IsValid) { unitOfWork.BlogRepository.Update(blogentry); unitOfWork.Save(); return(RedirectToAction("Index")); } return(View(blogentry)); }
public HttpResponseMessage Put(BlogEntry blogEntry) { var blogOp = new BlogOperations(); blogOp.EditBlogEntry(blogEntry); var response = Request.CreateResponse(HttpStatusCode.OK, blogEntry); return(response); }
public ActionResult Delete(int id) { return(UseDatabaseWithValidModel(() => { BlogEntry a = db.BlogEntrys.Find(id); db.BlogEntrys.Remove(a); db.SaveChanges(); return Ok(); })); }
public ActionResult EntryEdit(int blogId, int blogEntryId) { //need permissions checks Blog blog = CurrentStoreFrontOrThrow.Blogs.Where(b => b.BlogId == blogId).Single(); BlogEntry entry = blog.BlogEntries.Where(be => be.BlogEntryId == blogEntryId).Single(); this.BlogAdminViewModel.FilterBlogId = blogId; return(View("EntryIndex", this.BlogAdminViewModel)); }
public async Task <IActionResult> Manage() { BlogEntry entry = await db.BlogEntries .Include(e => e.Tags) .Where(e => e.Tags.Any(t => t.Name.ToLower() == "home")) .FirstOrDefaultAsync(); ViewData["HomeBlogId"] = entry?.Id; return(View()); }
public static void WriteGetEntryResult(this DataOutputStream output, BlogEntry value) { if (value == null) { throw new ArgumentNullException("value"); } output.WriteInt32(value.ID); output.WriteString(value.Title); output.WriteString(value.Body); output.WriteDateTime(value.DTCreated.ToDateTime()); }
public Comment(BlogEntry blogEntry, string name, string emailAddress, string commentText) { BlogEntry = blogEntry; Name = name; EmailAddress = emailAddress; CommentText = commentText; DateWritten = DateTime.Now; var commentValidator = new CommentValidator(); commentValidator.ValidateAndThrow(this); }
public async Task <IActionResult> Create([Bind("Id,Body,Author,Title,Published")] BlogEntry blogEntry) { if (ModelState.IsValid) { _context.Add(blogEntry); await _context.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(blogEntry)); }
public ActionResult CreateBlog(BlogEntry model) { model.DatePosted = DateTime.Now; model.LastEdited = DateTime.Now; model.Author = Session["name"].ToString();//Db.CurrentBlogger.FirstName + " " + Db.CurrentBlogger.LastName; model.AuthorId = Session["userid"].ToString(); Db.BlogEntries.Add(model); Db.SaveChanges(); return(RedirectToAction("BlogIndex", new { id = model.Id })); }
public ActionResult Create([Bind(Include = "Id,Title,Content,Thumbnail,Created")] BlogEntry blogEntry) { if (ModelState.IsValid) { db.BlogEntries.Add(blogEntry); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(blogEntry)); }
public ActionResult Put(int id, [FromBody] BlogEntry value) { return(UseDatabaseWithValidModel(() => { BlogEntry a = db.BlogEntrys.Find(id); a.Categories = value.Categories; a.Entry = value.Entry; a.Subject = value.Subject; db.SaveChanges(); return Ok(); })); }
private BlogEntrySummaryModel MapToSummary(BlogEntry entry) { return(new BlogEntrySummaryModel { Key = entry.Slug, Title = entry.Title, Summary = ConvertToMarkDown(entry.Summary), Date = entry.DateCreated.ToDateString(), PrettyDate = entry.DateCreated.ToPrettyDate(), IsPublished = entry.IsPublished ?? true }); }
public void GetRating_WhenEntryThereIs() { var repositoryStub = new Mock <IRepository <BlogEntry> >(); var blog = new BlogEntry(new User(0, ""), DateTime.Now, new Rating(10, 5), 0, ""); repositoryStub.Setup(stub => stub.GetEntry(0)).Returns(blog); var ratingService = new RatingService <BlogEntry>(repositoryStub.Object); var actualRating = ratingService.GetRating(0); var exeptedRating = 5; Assert.AreEqual(exeptedRating, actualRating); }
public async Task GetBlogById_PlusId_ReturnsPlusElement() { var repositorystub = new Mock <IRepository <BlogEntry> >(); BlogEntry expextedBlogEntryblog = new BlogEntry(new User(0, ""), DateTime.Now, new Rating(0, 0), 1, "FirstElement"); repositorystub.Setup(stub => stub.GetEntry(1)).Returns(expextedBlogEntryblog); var blogservise = new BlogService(repositorystub.Object); Assert.AreEqual(expextedBlogEntryblog, await blogservise.GetBlogById(1)); }
public IActionResult OnPostDelete() { var id = Request.Form["id"][0]; if (!string.IsNullOrEmpty(id)) { GetEntry(id); BlogEntry.DeleteOne(Entry); } return(Redirect("~/")); }
public bool InsertBlogEntry(BlogEntry entry) { //Insert a new blog entry into the application blog bool inserted = false; try { inserted = new DataService().ExecuteNonQuery(SQL_CONNID, USP_BLOG_INSERT, new object[] { entry.Date, entry.Comment, entry.UserID }); } catch (Exception ex) { throw new ApplicationException(ex.Message, ex); } return(inserted); }
//-------------------------------------- //-------------------------------------- public BlogEntry BlogEntryCreate(string title, string summary, string content) { ContentTransfer contentXfer = new ContentTransfer { Content = content, Path = BlogEntry.PathMake(), Summary = summary, Title = title }; return(new BlogEntry(NodeCreate(contentXfer))); }
private void CRUD_Create_HTTPPost_Correct_Entry() { var blogEntry = new BlogEntry { Id = 1, UserName = "******", Entry = "Entry1", Title = "Title1", EntryDate = DateTime.Parse("2015-01-01") }; var viewResult = testController.Create(blogEntry) as RedirectToRouteResult; A.CallTo(() => fakeBlogService.Create(blogEntry)).MustHaveHappened(Repeated.Exactly.Once); Assert.NotNull(viewResult); Assert.Equal("Index", viewResult.RouteValues["action"]); }
private async Task <bool> TestOpenForCommentsAsync(int blogEntry) { using (BlogEntryDataProvider entryDP = new BlogEntryDataProvider()) { BlogEntry ent = await entryDP.GetItemAsync(blogEntry); if (ent == null) { throw new InternalError("Entry with id {0} not found", blogEntry); } return(ent.OpenForComments); } }
public void UpDown_WhenEntryThereIs() { var repositoryStub = new Mock <IRepository <BlogEntry> >(); var blog = new BlogEntry(new User(0, ""), DateTime.Now, new Rating(0, 0), 0, ""); repositoryStub.Setup(stub => stub.GetEntry(0)).Returns(blog); var ratingService = new RatingService <BlogEntry>(repositoryStub.Object); ratingService.DownVote(0); Assert.AreEqual(-1, blog.Rating.Sum); }
internal static void UpdateBlogCategory(BlogEntryView model) { var context = ApplicationDbContext.Create(); BlogEntry entry = GetBlogEntry(model.Id, context); entry.CategoryId = model.CategoryId; entry.Content = model.Content; entry.PreviewImageUrl = model.PreviewImageUrl; entry.ShortDescription = model.ShortDescription; entry.Title = model.Title; context.SaveChanges(); }
public ActionResult Create(BlogEntry blogentry) { if (ModelState.IsValid) { blogentry.CreatedDate = DateTime.Now; unitOfWork.BlogRepository.Insert(blogentry); unitOfWork.Save(); return(RedirectToAction("Index")); } return(View(blogentry)); }
/// <summary> /// Add the Atom entry to the collection. Return its id and the actual entry that was added to the collection. /// If the item could not be added return null. /// </summary> /// <param name="collection">collection name</param> /// <param name="entry">entry to be added</param> /// <param name="location">URI for the added entry</param> /// <returns></returns> protected override SyndicationItem AddEntry(string collection, SyndicationItem entry, out Uri location) { var blogEntry = entry.ConvertToModelEntry(); bool isAdded = false; try { blogEntry.PrepareNewEntry(); foreach (var sCat in entry.Categories) { // search if the category already exists. var category = unitOfWork.Categories.GetById(BlogEntry.StripeDownTitle(sCat.Label)); if (category == null) { // create a new category category = new Category() { Name = sCat.Label, Value = BlogEntry.StripeDownTitle(sCat.Label) }; } blogEntry.Categories.Add(category); } // TODO: add author based on logged-in user. var author = this.unitOfWork.People.GetByEmailHash("4cf6ef00ca33cc3f4010b8f0fdd980fe"); blogEntry.Author = author; this.unitOfWork.Entries.Add(blogEntry); this.unitOfWork.Commit(); isAdded = true; } catch (Exception) { // TODO: Catch only specific exceptions. isAdded = false; } if (isAdded) // successful add { entry = blogEntry.ConvertToSyndicationItem(this.webOperationContext.BaseUri); ConfigureAtomEntry(collection, entry, blogEntry.BlogEntryId.ToString(), out location); this.sEntry = entry; return(sEntry); } else { this.sEntry = null; location = null; return(null); } }
public async virtual Task <ActionResult> EditBlogEntry(Guid?id, [Bind(Include = "Header, Author, ShortContent, Content, Visible")] BlogEntry blogEntry, FormCollection formValues) { if (!this.ModelState.IsValid) { return(this.View(new EditBlogEntry() { BlogEntry = blogEntry, Tags = await this.repository.Tags.AsNoTracking().OrderBy(t => t.Name).ToArrayAsync(), Images = await this.repository.Images.AsNoTracking().OrderByDescending(t => t.Created).ToArrayAsync(), IsUpdate = id.HasValue })); } if (id.HasValue) { var existingBlogEntry = await this.repository.BlogEntries .Include(b => b.Tags) .SingleAsync(b => b.Id == id.Value); existingBlogEntry.Header = blogEntry.Header; existingBlogEntry.Author = blogEntry.Author; existingBlogEntry.ShortContent = blogEntry.ShortContent; existingBlogEntry.Content = blogEntry.Content; existingBlogEntry.PublishDate = blogEntry.PublishDate; existingBlogEntry.Visible = blogEntry.Visible; blogEntry = existingBlogEntry; } blogEntry.PublishDate = DateTime.Parse(formValues["PublishDate"]); var tags = formValues.AllKeys.Where(k => k.StartsWith("Tag") && !string.IsNullOrEmpty(formValues[k])).Select(k => formValues[k]); if (id.HasValue) { await this.updateBlogEntryCommandHandler.HandleAsync(new UpdateBlogEntryCommand() { Entity = blogEntry, Tags = tags }); } else { await this.addBlogEntryCommandHandler.HandleAsync(new AddBlogEntryCommand() { Entity = blogEntry, Tags = tags }); } return(this.RedirectToAction(MVC.Administration.EditBlogEntry(blogEntry.Id).Result)); }
private BlogEntryEntity ConvertBlogEntryToBlogEntryEntity(BlogEntry entry) { var entity = new BlogEntryEntity(); entity.Id = entry.Id; entity.Author = entry.Author; entity.Description = entry.Description; entity.Name = entry.Name; entity.DatePublished = entry.DatePublished; entity.Text = entry.Text; entity.Title = entry.Title; return entity; }
public ActionResult Blog(int? id = null) { IBlogEntry myEntry = new BlogEntry(); myEntry.ID = id; if (id != null) { myEntry = BlogService.Get(myEntry, Url.Content(IMAGE_PATH)); return View(myEntry); } myEntry = BlogService.GetRows(null).OrderByDescending(p => p.DateCreated).FirstOrDefault(); return View("Index", myEntry); }
public ActionResult Delete_List(BlogEntry entry = null) { if (entry.CRUD) { BlogService.Delete(entry); return new RedirectResult("~//Home/Blogs"); } else { IBlogView myBlogView = new BlogView(); myBlogView.Entries = BlogService.GetRows(null, IMAGE_PATH).OrderByDescending(p => p.DateCreated); return View(myBlogView); } }
public ActionResult Create(BlogEntry entry = null) { if (entry.CRUD) { entry.CreatedBy = "David Harvey"; entry.DateCreated = DateTime.Now; BlogService.Add(entry); return new RedirectResult("~//Home/Blogs"); } else { ServiceManager myManager = new ServiceManager(); return View(myManager.BlogEntry); } }
public void UpdateEntryToBlog(BlogEntry blogentry) { lock (_blogphotolock) { RunNonQuery(String.Format( "update blogphoto set title='{0}', desc='{1}'" + " where blogid='{2}' and photoid='{3}';", EscapeStr(blogentry.Title), EscapeStr(blogentry.Desc), blogentry.Blogid, blogentry.Photoid)); } }
// Don't really care about the selection data sent. Because, we can // rather easily just look at the selected photos. private void OnPhotoDraggedForAddition(object o, DragDataReceivedArgs args) { TreePath path; TreeViewDropPosition pos; // This line determines the destination row. treeview1.GetDestRowAtPos(args.X, args.Y, out path, out pos); if (path == null) return; int destindex = path.Indices[0]; if (selectedtab == 0) { // albums // TODO: Allow addition to sets. if (uploadbutton.Active) return; // Doesn't allow addition to sets yet. string setid = ((Album) _albums[destindex]).SetId; foreach (TreePath photospath in treeview2.Selection.GetSelectedRows()) { string photoid = GetPhoto(photospath).Id; bool exists = PersistentInformation.GetInstance() .HasAlbumPhoto(photoid, setid); if (exists) { TreePath albumselectedpath = treeview1.Selection.GetSelectedRows()[0]; if (!streambutton.Active && !conflictbutton.Active && treeview2.Selection.GetSelectedRows().Length == 1 // If dragged dest album is same as the one selected. && albumselectedpath.Indices[0] == destindex) { // Scenario: The user is viewing the set, and decides to // change the primary photo. He can do so by dragging the photo // from the respective set, to the set itself. However, make // sure that only one photo is selected. // The album selected is the same as the album the photo is // dragged on. PersistentInformation.GetInstance().SetPrimaryPhotoForAlbum(setid, photoid); PersistentInformation.GetInstance().SetAlbumDirtyIfNotNew(setid); PopulateAlbums(); } } else { // The photo isn't present in set. PersistentInformation.GetInstance().AddPhotoToAlbum(photoid, setid); if (PersistentInformation.GetInstance().GetPhotoIdsForAlbum(setid).Count == 1) { PersistentInformation.GetInstance().SetPrimaryPhotoForAlbum(setid, photoid); } PersistentInformation.GetInstance().SetAlbumDirtyIfNotNew(setid); UpdateAlbumAtPath(path, (Album) _albums[destindex]); } } } else if (selectedtab == 1) { // tags ArrayList selectedphotos = new ArrayList(); foreach (TreePath photospath in treeview2.Selection.GetSelectedRows()) { Photo photo = GetPhoto(photospath); string tag = (string) _tags[destindex]; if (uploadbutton.Active) { photo.AddTag(tag); PersistentInformation.GetInstance().UpdateInfoForUploadPhoto(photo); } else { // Check if the original version is stored in db. Allow for revert. if (!PersistentInformation.GetInstance().HasOriginalPhoto(photo.Id) && !PersistentInformation.GetInstance().IsPhotoDirty(photo.Id)) { PersistentInformation.GetInstance().InsertOriginalPhoto(photo); } if (!PersistentInformation.GetInstance().HasTag(photo.Id, tag)) { PersistentInformation.GetInstance().InsertTag(photo.Id, tag); PersistentInformation.GetInstance().SetPhotoDirty(photo.Id, true); } } photo.AddTag(tag); TreePath childpath = filter.ConvertPathToChildPath(photospath); SelectedPhoto selphoto = new SelectedPhoto(photo, childpath.ToString()); selectedphotos.Add(selphoto); } // UpdatePhotos will replace the old photos, with the new ones containing // the tag information. UpdatePhotos(selectedphotos); UpdateTagAtPath(path, (string) _tags[destindex]); } else if (selectedtab == 2) { // pools // TODO: Allow addition to pools. if (uploadbutton.Active) return; // Doesn't allow addition to sets yet. PersistentInformation.Entry entry = (PersistentInformation.Entry) _pools[destindex]; string groupid = entry.entry1; foreach (TreePath photospath in treeview2.Selection.GetSelectedRows()) { Photo photo = GetPhoto(photospath); if (!PersistentInformation.GetInstance().HasPoolPhoto(photo.Id, groupid)) { PersistentInformation.GetInstance().InsertPhotoToPool(photo.Id, groupid); PersistentInformation.GetInstance().MarkPhotoAddedToPool(photo.Id, groupid, true); } else if (PersistentInformation.GetInstance() .IsPhotoDeletedFromPool(photo.Id, groupid)) { PersistentInformation.GetInstance() .MarkPhotoDeletedFromPool(photo.Id, groupid, false); } } UpdatePoolAtPath(path, entry); } else if (selectedtab == 3) { // blogs if (uploadbutton.Active) return; PersistentInformation.Entry entry = (PersistentInformation.Entry) _blogs[destindex]; string blogid = entry.entry1; ArrayList selectedphotos = new ArrayList(); foreach (TreePath photospath in treeview2.Selection.GetSelectedRows()) { Photo photo = GetPhoto(photospath); if (!PersistentInformation.GetInstance().HasBlogPhoto(blogid, photo.Id)) { BlogEntry blogentry = new BlogEntry(blogid, photo.Id, photo.Title, photo.Description); PersistentInformation.GetInstance().InsertEntryToBlog(blogentry); } TreePath childpath = filter.ConvertPathToChildPath(photospath); SelectedPhoto selphoto = new SelectedPhoto(photo, childpath.ToString()); selectedphotos.Add(selphoto); } UpdatePhotos(selectedphotos); UpdateBlogAtPath(path, entry); } }
protected void Page_Load(object sender, EventArgs e) { string blogResult = string.Empty; string oldMediaResult = string.Empty; List<BlogEntry> blogEntries = new List<BlogEntry>(); Dictionary<string, string> blogNameReplace = new Dictionary<string, string>(); blogNameReplace["Erik Laakso | På Uppstuds"] = "Erik Laakso"; blogNameReplace["opassande"] = "Opassande"; blogNameReplace["Tommy k Johanssons blogg om datorer & Internet"] = "Tommy K Johansson"; blogNameReplace["MinaModerataKarameller..."] = "Mary X Jensen"; blogNameReplace["d y s l e s b i s k ."] = "Dyslesbisk"; blogNameReplace["syrrans granne"] = "Syrrans Granne"; blogNameReplace["SURGUBBEN"] = "Surgubben"; blogNameReplace["Henrik-Alexandersson.se"] = "Henrik Alexandersson"; blogNameReplace["BIOLOGY & POLITICS"] = "Biology & Politics"; blogNameReplace["Blogge Bloggelito - regeringsblogg"] = "Blogge Bloggelito"; blogNameReplace["drottningsylt"] = "Drottningsylt"; blogNameReplace["RADIKALEN"] = "Radikalen"; blogNameReplace["Idéer, tankar och reflektionerHeit…"] = "Idéer Tankar Reflektioner"; blogNameReplace["stationsvakt"] = "Stationsvakt"; blogNameReplace["Framtidstanken - Accelererande för…"] = "Framtidstanken"; blogNameReplace["CONJOINER"] = "Conjoiner"; blogNameReplace["..:: josephzohn | gås blogger ::.."] = "Josephzohn"; blogNameReplace["S I N N E R"] = "Sinner"; blogNameReplace["mp) blog från Staffanstorp"] = "Olle (mp) från Staffanstorp"; blogNameReplace["Oväsentligheter ... ?? ???"] = "Oväsentligheter"; blogNameReplace["SJÖLANDER"] = "Sjölander"; blogNameReplace["UPPSALAHANSEN - en og en halv nordmann i sverige"] = "Uppsala-Hansen"; blogNameReplace["se|com|org|nu)"] = "Lex Orwell"; blogNameReplace["s) blogg"] = "John Johansson (s)"; blogNameReplace["m) 3.0"] = "Edvin Ala(m) 3.0"; blogNameReplace["PLIKTEN FRAMFÖR ALLT"] = "Plikten framför allt"; blogNameReplace["*Café Liberal"] = "Café Liberal"; blogNameReplace["Disruptive - En blogg om entreprenörskap, riskkapital och webb 2.0"] = "Disruptive"; blogNameReplace["C)KER"] = "Törnqvist tänker och tycker"; blogNameReplace["serier mot FRA)"] = "Inte så PK (Serier mot FRA)"; blogNameReplace["BÄSTIGAST.SNYGGAST.SNÄLLAST.ÖDMJUKAST"] = "Johanna Wiström"; blogNameReplace["LOKE - KULTUR & POLITIK"] = "Loke kultur & politik"; blogNameReplace["Webnewspaper)"] = "The Awkward Swedeblog"; blogNameReplace["SOCIALIST OCH BAJARE- Livets passion"] = "Nicke Grozdanovski"; blogNameReplace["MÅRTENSSON"] = "Mårtensson"; blogNameReplace["FRADGA"] = "Fradga"; blogNameReplace["UD/RK Samhälls Debatt"] = "UD/RK Samhällsdebatt"; blogNameReplace["GRETAS SVAMMEL"] = "Gretas Svammel"; blogNameReplace["ISAK ENGQVIST"] = "Isak Engqvist"; blogNameReplace["Smålandsposten - Blogg - Marcus Svensson"] = "Marcus Svensson"; blogNameReplace["f.d. Patrik i Politiken)"] = "Mittenradikalen"; blogNameReplace["Rick Falkvinge (pp)"] = "Rick Falkvinge"; blogNameReplace["Christian Engström (pp)"] = "Christian Engström"; blogNameReplace["Basic personligt"] = "Daniel Brahneborg"; blogNameReplace["yo mstuff!"] = "Marcin de Kaminski"; blogNameReplace["EXORCISTEN"] = "Tommy Funebo"; blogNameReplace["www.webhackande.se"] = "Lars Holmqvist"; blogNameReplace["satmaran"] = "Satmaran"; blogNameReplace["PiratJanne"] = "Jan Lindgren"; blogNameReplace["EXORCISTEN"] = "Tommy Funebo"; blogNameReplace["Intensifier"] = "Christopher Kullenberg"; blogNameReplace["Anders Widén Författare"] = "Anders Widén"; blogNameReplace["ProjektPåRiktigt"] = "Urban Cat"; blogNameReplace["Davids åsikter"] = "David Wienehall"; blogNameReplace["Minimaliteter"] = "Mikael Nilsson"; blogNameReplace["scaber_nestor"] = "Scaber Nestor"; blogNameReplace["andra sidan"] = "Andra Sidan"; blogNameReplace["Klibbnisses Blogg"] = "Klibbnisse"; blogNameReplace["V, fildelning & upphovsrätt"] = "Mikael von Knorring"; blogNameReplace["SVT Opinion - redaktionsblogg"] = "SVT Opinion"; blogNameReplace["Copyriot"] = "Rasmus Fleischer"; blogNameReplace["Motpol"] = "Hans Engnell"; blogNameReplace["Dynamic Man"] = "Mattias Swing"; blogNameReplace["insane psycho clowns"] = "Insane Clowns"; blogNameReplace["Samtidigt i Uppsala"] = "Mattias Bjärnemalm"; blogNameReplace["Mattias tycker och tänker"] = "Mattias"; blogNameReplace["Josef säger..."] = "Josef"; blogNameReplace["Under den svarta natthimlen"] = "Peter Soilander"; blogNameReplace["Farmorgun i Norrtälje"] = "Farmor Gun"; blogNameReplace["lindahls blogg"] = "Johan Lindahl"; blogNameReplace["kamferdroppar"] = "Charlotte Wiberg"; blogNameReplace["Kulturbloggen"] = "Rose-Mari Södergren"; blogNameReplace["Ett Otygs funderingar och betraktelser"] = "Martin Otyg"; blogNameReplace["Jinges web och fotoblogg"] = "Jinge"; blogNameReplace["Högerkonspiration"] = "Wilhelm Svenselius"; blogNameReplace["piratbyran.org"] = "Piratbyrån"; blogNameReplace["ANGIE ROGER"] = "Angie Roger"; blogNameReplace["Lasses blogg"] = "Lasse Strömberg"; blogNameReplace["annarkia"] = "Annarkia"; blogNameReplace["Gontes förvirrade tankar i bloggvärlden"] = "Jonatan Kindh"; blogNameReplace["Rejås Blog"] = "Marcus Rejås"; Dictionary<string, double> blogWeight = new Dictionary<string, double>(); blogWeight["rickfalkvinge.se"] = 3.0; blogWeight["opassande.se"] = 3.0; blogWeight["christianengstrom"] = 3.0; blogWeight["rosettasten"] = 3.0; blogWeight["projo"] = 2.0; blogWeight["basic70.wordpress.com"] = 2.0; blogWeight["scriptorium.se"] = 2.0; blogWeight["teflonminne.se"] = 2.0; blogWeight["piratjanne"] = 3.0; blogWeight["kurvigheter.blogspot"] = 2.0; blogWeight["piratbyran.org"] = 2.0; // tekniskt sett inte pp, men... blogWeight["ravennasblogg.blogspot.com"] = 3.0; blogWeight["webhackande.se"] = 3.0; blogWeight["jinge"] = 0.5; // störig blogWeight["klaric.se"] = 0.001; // sd blogWeight["patrikohlsson.wordpress.com"] = 0.001; // sd blogWeight["funebo"] = 0.001; // sd blogWeight["astudillo"] = 0.001; // idiot blogWeight["wb.blogg.se"] = 0.001; // idiot blogWeight["fotolasse"] = 0.001; // kd double highestWeight = 3.0; double maximumAgeDays = 7.0; MediaEntries blogEntriesOriginal = MediaEntries.FromBlogKeyword("Piratjägarlagen", DateTime.Now.AddDays(-maximumAgeDays * highestWeight)); blogEntriesOriginal.Add (MediaEntries.FromBlogKeyword("Antipiratlagen", DateTime.Now.AddDays(-maximumAgeDays * highestWeight))); blogEntriesOriginal.Add(MediaEntries.FromBlogKeyword("IPRED1", DateTime.Now.AddDays(-maximumAgeDays * highestWeight))); blogEntriesOriginal.Add(MediaEntries.FromBlogKeyword("sanktionsdirektivet", DateTime.Now.AddDays(-maximumAgeDays * highestWeight))); Dictionary<string, bool> dupeCheck = new Dictionary<string, bool>(); foreach (MediaEntry entry in blogEntriesOriginal) { BlogEntry blogEntry = new BlogEntry(); blogEntry.entry = entry; blogEntry.ageAdjusted = new TimeSpan((long) ((DateTime.Now - entry.DateTime).Ticks / GetBlogWeight(blogWeight, entry.Url))); if (entry.Url.StartsWith ("http://knuff.se/k/")) { UrlTranslations.Create(entry.Url); } else if (blogEntry.ageAdjusted.Days < maximumAgeDays) { if (blogNameReplace.ContainsKey(entry.MediaName)) { blogEntry.entry = MediaEntry.FromBasic (new Activizr.Basic.Types.BasicMediaEntry(blogEntry.entry.Id, blogEntry.entry.KeywordId, blogNameReplace[entry.MediaName], true, blogEntry.entry.Title, blogEntry.entry.Url, blogEntry.entry.DateTime)); } if (!dupeCheck.ContainsKey(entry.Url)) { blogEntries.Add(blogEntry); dupeCheck[entry.Url] = true; } } } blogEntries.Sort(CompareBlogEntries); Dictionary<string, int> lookupSources = new Dictionary<string, int>(); foreach (BlogEntry entry in blogEntries) { if (blogResult.Length > 0) { blogResult += ", "; } blogResult += String.Format("<a href=\"{0}\" title=\"{1}\">{2}</a>", entry.entry.Url, HttpUtility.HtmlEncode (entry.entry.Title), HttpUtility.HtmlEncode (entry.entry.MediaName)); if (lookupSources.ContainsKey(entry.entry.MediaName)) { lookupSources[entry.entry.MediaName]++; if (lookupSources[entry.entry.MediaName] == 2) { // blogResult += " igen"; } else { // blogResult += " #" + lookupSources[entry.entry.MediaName].ToString(); } } else { lookupSources[entry.entry.MediaName] = 1; } } this.literalBlogOutput.Text = blogResult; MediaEntries oldMediaEntries = MediaEntries.FromOldMediaKeyword("Piratjägarlagen", DateTime.Now.AddDays(-maximumAgeDays / 2)); oldMediaEntries.Add (MediaEntries.FromOldMediaKeyword("Antipiratlagen", DateTime.Now.AddDays(-maximumAgeDays / 2))); oldMediaEntries.Add (MediaEntries.FromOldMediaKeyword("IPRED1", DateTime.Now.AddDays(-maximumAgeDays / 2))); oldMediaEntries.Add(MediaEntries.FromOldMediaKeyword("sanktionsdirektivet", DateTime.Now.AddDays(-maximumAgeDays * highestWeight))); foreach (MediaEntry entry in oldMediaEntries) { if (!entry.Url.Contains(".se/")) { continue; } if (oldMediaResult.Length > 0) { oldMediaResult += ", "; } oldMediaResult += String.Format("<a href=\"{0}\">{1} ({2})</a>", entry.Url, HttpUtility.HtmlEncode(entry.Title.Replace ("`", "'").Replace ("´", "'")), HttpUtility.HtmlEncode(entry.MediaName)); } this.literalOldMediaOutput.Text = oldMediaResult; }
static private int CompareBlogEntries(BlogEntry entry1, BlogEntry entry2) { TimeSpan result = entry1.ageAdjusted - entry2.ageAdjusted; if (result > new TimeSpan (0)) { return 1; } if (result < new TimeSpan (0)) { return -1; } return 0; }
public BlogEntry GetEntryForBlog(string blogid, string photoid) { lock (_blogphotolock) { IDbConnection dbcon = (IDbConnection) new SqliteConnection(DB_PATH); dbcon.Open(); IDbCommand dbcmd = dbcon.CreateCommand(); dbcmd.CommandText = String.Format( "select * from blogphoto where blogid='{0}' and photoid='{1}';", blogid, photoid); IDataReader reader = dbcmd.ExecuteReader(); BlogEntry blogentry = null; if (reader.Read()) { reader.GetString(0); // blog id reader.GetString(1); // photo id string title = reader.GetString(2); string desc = reader.GetString(3); blogentry = new BlogEntry(blogid, photoid, title, desc); } reader.Close(); dbcmd.Dispose(); dbcon.Close(); return blogentry; } }
private static void DispatchGet(HttpListenerContext context) { var request = context.Request; var response = context.Response; response.ContentType = "text/html"; var query = HttpUtility.ParseQueryString(request.Url.Query); int postID = 0; int editorID = 0; int currentPage = 1; if (query["page"] != null) { int.TryParse(query["page"], out currentPage); } if (query["post"] != null) { int.TryParse(query["post"], out postID); currentPage = 0; } if (query["editor"] != null) { int.TryParse(query["editor"], out editorID); } using (var sw = new StreamWriter(response.OutputStream, Encoding.UTF8)) { var indexPage = new IndexPage(markdown); indexPage.Query = query; indexPage.CurrentPage = currentPage; indexPage.NumberOfPages = (int)Math.Floor((double)GetEntryCount(editorID) / ServerSettings.Default.NumberOfPostsPerPage - 0.0001) + 1; if (indexPage.CurrentPage > indexPage.NumberOfPages) indexPage.CurrentPage = indexPage.NumberOfPages; int startPost = 0; int numPosts = ServerSettings.Default.NumberOfPostsPerPage; if (indexPage.CurrentPage > 0) { startPost = numPosts * (indexPage.CurrentPage - 1); } using (var cmd = db.CreateCommand()) { cmd.CommandText = @"SELECT `Entries`.`ID`, `Entries`.`Text`, `Entries`.`TimeStamp`, `Writers`.`Name` FROM `Entries`,`Writers` WHERE `Entries`.`Editor`=`Writers`.`ID`" + (postID != 0 ? "AND `Entries`.`ID` = @postId \n" : "") + (editorID != 0 ? "AND `Entries`.`Editor` = @editorId \n" : "") + @" ORDER BY `Entries`.`TimeStamp` DESC LIMIT @start, @count"; cmd.Parameters.AddWithValue("@start", startPost); cmd.Parameters.AddWithValue("@count", numPosts); cmd.Parameters.AddWithValue("@editorId", editorID); cmd.Parameters.AddWithValue("@postId", postID); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { var entry = new BlogEntry(); entry.ID = reader.GetInt32(0); entry.Text = reader.GetString(1); entry.CreationDate = DateTime.FromBinary(reader.GetInt64(2)); entry.Author = reader.GetString(3); indexPage.Entries.Add(entry); } } } sw.Write(indexPage.TransformText()); sw.Flush(); } }
/// <summary>Required method for Designer support - do not modify the contents of this method with the code editor.</summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); // // connect // this.Create_BlogEntry_connect = new BlogDemoContext.ConnectionDelegate(GetConnection); // // testVar // this.testVar = new BlogDemoContext(Create_BlogEntry_connect); // // abstractTypeVar // this.abstractTypeVar = null; // // lbl // this.lblCreate = new System.Windows.Forms.Label(); this.lblCreate.Dock = System.Windows.Forms.DockStyle.Top; this.lblCreate.Name = "lblCreate"; this.lblCreate.Text = "Enter data to Create BlogEntry by:"; // // btn // this.btnCreate = new System.Windows.Forms.Button(); this.btnCreate.Location = new System.Drawing.Point(400, 10); this.btnCreate.Name = "btnCreate"; this.btnCreate.TabIndex = 3; this.btnCreate.Text = "Create"; this.btnCreate.UseVisualStyleBackColor = true; this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); // // dgv // this.dgvCreate = new System.Windows.Forms.DataGridView(); this.dgvCreate.Dock = System.Windows.Forms.DockStyle.Top; this.dgvCreate.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvCreate.Name = "dgvCreate"; this.dgvCreate.TabIndex = 0; this.dgvCreate.Columns.Add("BlogEntry_Id", "BlogEntry_Id"); this.dgvCreate.Columns.Add("entryTitle", "entryTitle"); this.dgvCreate.Columns.Add("entryBody", "entryBody"); this.dgvCreate.Columns.Add("postedDate_MDYValue", "postedDate_MDYValue"); this.dgvCreate.Columns.Add("userId", "userId"); this.dgvCreate.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.dgvCreate.Height = 75; // // pnlDisplay // this.pnlDisplay = new System.Windows.Forms.Panel(); this.pnlDisplay.Dock = System.Windows.Forms.DockStyle.Top; this.pnlDisplay.AutoSize = true; this.pnlDisplay.Location = new System.Drawing.Point(0, 0); this.pnlDisplay.Name = "pnlDisplay"; this.pnlDisplay.AutoScroll = true; this.pnlDisplay.TabIndex = 1; this.pnlDisplay.Controls.Add(this.btnCreate); // // this // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.Controls.Add(this.pnlDisplay); this.Controls.Add(this.dgvCreate); this.Controls.Add(this.lblCreate); this.Name = "icCreateBlogEntryInputControl"; this.Size = new System.Drawing.Size(530, 490); ((System.ComponentModel.ISupportInitialize)this.dgvCreate).EndInit(); this.ResumeLayout(false); }
public static void WriteGetEntryResult(this DataOutputStream output, BlogEntry value) { if (value == null) throw new ArgumentNullException("value"); output.WriteInt32(value.ID); output.WriteString(value.Title); output.WriteString(value.Body); output.WriteDateTime(value.DTCreated.ToDateTime()); }
/// <summary>Required method for Designer support - do not modify the contents of this method with the code editor.</summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.editMode = false; // // lblNeedToSave // this.lblNeedToSave = new System.Windows.Forms.Label(); this.lblNeedToSave.Location = new System.Drawing.Point(0, 10); this.lblNeedToSave.Name = "lblNeedToSave"; this.lblNeedToSave.Size = new System.Drawing.Size(200, 15); this.lblNeedToSave.Text = ""; // // btnCancel // this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel.Location = new System.Drawing.Point(300, 10); this.btnCancel.Name = "btnCancel"; this.btnCancel.TabIndex = 6; this.btnCancel.Text = "Cancel"; this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // // btnSave // this.btnSave = new System.Windows.Forms.Button(); this.btnSave.Location = new System.Drawing.Point(400, 10); this.btnSave.Name = "btnSave"; this.btnSave.TabIndex = 7; this.btnSave.Text = "Save"; this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // pnlSave // this.pnlSave = new System.Windows.Forms.Panel(); this.pnlSave.Dock = System.Windows.Forms.DockStyle.Top; this.pnlSave.AutoSize = true; this.pnlSave.Location = new System.Drawing.Point(0, 0); this.pnlSave.Name = "pnlSave"; this.pnlSave.AutoScroll = true; this.pnlSave.TabIndex = 5; this.pnlSave.Controls.Add(this.btnSave); this.pnlSave.Controls.Add(this.btnCancel); this.pnlSave.Controls.Add(this.lblNeedToSave); this.pnlSave.Visible = false; // // lblSelectionMode // this.lblSelectionMode = new System.Windows.Forms.Label(); this.lblSelectionMode.Location = new System.Drawing.Point(0, 10); this.lblSelectionMode.Name = "lblSelectionMode"; this.lblSelectionMode.Text = "SelectionMode:"; // // cbxSelectionMode // this.cbxSelectionMode = new System.Windows.Forms.ComboBox(); this.cbxSelectionMode.Location = new System.Drawing.Point(100, 10); this.cbxSelectionMode.Name = "cbxSelectionMode"; this.cbxSelectionMode.Size = new System.Drawing.Size(200, 15); this.cbxSelectionMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbxSelectionMode.TabIndex = 2; this.cbxSelectionMode.SelectedIndexChanged += new System.EventHandler(this.cbxSelectionMode_SelectedIndexChanged); this.cbxSelectionMode.Items.Add("BlogEntry_Id"); // // lblCurrentObject // this.lblCurrentObject = new System.Windows.Forms.Label(); this.lblCurrentObject.Location = new System.Drawing.Point(0, 45); this.lblCurrentObject.Width = 300; this.lblCurrentObject.Name = "lblCurrentObject"; this.lblCurrentObject.Text = "There is no selected BlogEntry."; // // dgvCurrentObject // this.dgvCurrentObject = new System.Windows.Forms.DataGridView(); this.dgvCurrentObject.Dock = System.Windows.Forms.DockStyle.Top; this.dgvCurrentObject.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvCurrentObject.Location = new System.Drawing.Point(0, 265); this.dgvCurrentObject.Name = "dgvCurrentObject"; this.dgvCurrentObject.Size = new System.Drawing.Size(500, 150); this.dgvCurrentObject.TabIndex = 4; this.dgvCurrentObject.Columns.Add("BlogEntry_Id", "BlogEntry_Id"); this.dgvCurrentObject.Columns["BlogEntry_Id"].Visible = false; this.dgvCurrentObject.Columns.Add("entryTitle", "entryTitle"); this.dgvCurrentObject.Columns["entryTitle"].Visible = false; this.dgvCurrentObject.Columns.Add("entryBody", "entryBody"); this.dgvCurrentObject.Columns["entryBody"].Visible = false; this.dgvCurrentObject.Columns.Add("postedDate_MDYValue", "postedDate_MDYValue"); this.dgvCurrentObject.Columns["postedDate_MDYValue"].Visible = false; this.dgvCurrentObject.Columns.Add("userId", "userId"); this.dgvCurrentObject.Columns["userId"].Visible = false; this.dgvCurrentObject.Visible = false; this.dgvCurrentObject.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(this.dgvCurrentObject_CellBeginEdit); this.Controls.Add(this.pnlSave); this.Controls.Add(this.dgvCurrentObject); // // connect // this.Select_BlogEntry_connect = new BlogDemoContext.ConnectionDelegate(GetConnection); // // testVar // this.testVar = new BlogDemoContext(Select_BlogEntry_connect); // // abstractTypeVar // this.abstractTypeVar = null; // // lbl // this.lblSelect = new System.Windows.Forms.Label(); this.lblSelect.Dock = System.Windows.Forms.DockStyle.Top; this.lblSelect.Name = "lblSelect"; this.lblSelect.Text = "Enter data to Select BlogEntry by:"; // // btn // this.btnSelect = new System.Windows.Forms.Button(); this.btnSelect.Location = new System.Drawing.Point(400, 10); this.btnSelect.Name = "btnSelect"; this.btnSelect.TabIndex = 3; this.btnSelect.Text = "Select"; this.btnSelect.UseVisualStyleBackColor = true; this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click); // // dgv // this.dgvSelect = new System.Windows.Forms.DataGridView(); this.dgvSelect.Dock = System.Windows.Forms.DockStyle.Top; this.dgvSelect.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvSelect.Name = "dgvSelect"; this.dgvSelect.TabIndex = 0; this.dgvSelect.Columns.Add("BlogEntry_Id", "BlogEntry_Id"); this.dgvSelect.Columns.Add("entryTitle", "entryTitle"); this.dgvSelect.Columns.Add("entryBody", "entryBody"); this.dgvSelect.Columns.Add("postedDate_MDYValue", "postedDate_MDYValue"); this.dgvSelect.Columns.Add("userId", "userId"); this.dgvSelect.ScrollBars = System.Windows.Forms.ScrollBars.Both; this.dgvSelect.Height = 75; // // pnlDisplay // this.pnlDisplay = new System.Windows.Forms.Panel(); this.pnlDisplay.Dock = System.Windows.Forms.DockStyle.Top; this.pnlDisplay.AutoSize = true; this.pnlDisplay.Location = new System.Drawing.Point(0, 0); this.pnlDisplay.Name = "pnlDisplay"; this.pnlDisplay.AutoScroll = true; this.pnlDisplay.TabIndex = 1; this.pnlDisplay.Controls.Add(this.btnSelect); // // this // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.Controls.Add(this.pnlDisplay); this.Controls.Add(this.dgvSelect); this.Controls.Add(this.lblSelect); this.Name = "icSelectBlogEntryInputControl"; this.Size = new System.Drawing.Size(530, 490); ((System.ComponentModel.ISupportInitialize)this.dgvSelect).EndInit(); this.ResumeLayout(false); this.dgvCurrentObject.Height = this.dgvSelect.Height; this.pnlDisplay.Controls.Add(this.lblCurrentObject); this.pnlDisplay.Controls.Add(this.cbxSelectionMode); this.pnlDisplay.Controls.Add(this.lblSelectionMode); if (this.cbxSelectionMode.Items.Count > 0) { this.cbxSelectionMode.SelectedIndex = 0; } }
public void InsertEntryToBlog(BlogEntry blogentry) { if (HasBlogPhoto(blogentry.Blogid, blogentry.Photoid)) return; lock (_blogphotolock) { RunNonQuery(String.Format( "insert into blogphoto (blogid, photoid, title, desc)" + " values ('{0}','{1}','{2}','{3}');", blogentry.Blogid, blogentry.Photoid, EscapeStr(blogentry.Title), EscapeStr(blogentry.Desc))); } }
public ArrayList GetAllBlogEntries() { lock (_blogphotolock) { IDbConnection dbcon = (IDbConnection) new SqliteConnection(DB_PATH); dbcon.Open(); IDbCommand dbcmd = dbcon.CreateCommand(); dbcmd.CommandText = "select * from blogphoto;"; IDataReader reader = dbcmd.ExecuteReader(); ArrayList blogentries = new ArrayList(); while (reader.Read()) { string blogid = reader.GetString(0); // blog id string photoid = reader.GetString(1); string title = reader.GetString(2); string desc = reader.GetString(3); BlogEntry blogentry = new BlogEntry(blogid, photoid, title, desc); blogentries.Add(blogentry); } reader.Close(); dbcmd.Dispose(); dbcon.Close(); return blogentries; } }
protected void Page_Load(object sender, EventArgs e) { string blogResult = string.Empty; string oldMediaResult = string.Empty; List<BlogEntry> blogEntries = new List<BlogEntry>(); Dictionary<string, string> blogNameReplace = new Dictionary<string, string>(); blogNameReplace["Erik Laakso | På Uppstuds"] = "Erik Laakso"; blogNameReplace["opassande"] = "Opassande"; blogNameReplace["Tommy k Johanssons blogg om datorer & Internet"] = "Tommy K Johansson"; blogNameReplace["MinaModerataKarameller..."] = "Mina Moderata Karameller"; blogNameReplace["d y s l e s b i s k ."] = "Dyslesbisk"; blogNameReplace["syrrans granne"] = "Syrrans Granne"; blogNameReplace["SURGUBBEN"] = "Surgubben"; blogNameReplace["Henrik-Alexandersson.se"] = "Hax"; blogNameReplace["BIOLOGY & POLITICS"] = "Biology & Politics"; blogNameReplace["Blogge Bloggelito - regeringsblogg"] = "Blogge Bloggelito"; blogNameReplace["drottningsylt"] = "Drottningsylt"; blogNameReplace["RADIKALEN"] = "Radikalen"; blogNameReplace["Idéer, tankar och reflektionerHeit…"] = "Idéer Tankar Reflektioner"; blogNameReplace["stationsvakt"] = "Stationsvakt"; blogNameReplace["Framtidstanken - Accelererande för…"] = "Framtidstanken"; blogNameReplace["CONJOINER"] = "Conjoiner"; blogNameReplace["..:: josephzohn | gås blogger ::.."] = "Josephzohn"; blogNameReplace["S I N N E R"] = "Sinner"; blogNameReplace["mp) blog från Staffanstorp"] = "Olle (mp) från Staffanstorp"; blogNameReplace["Oväsentligheter ... ?? ???"] = "Oväsentligheter"; blogNameReplace["SJÖLANDER"] = "Sjölander"; blogNameReplace["UPPSALAHANSEN - en og en halv nordmann i sverige"] = "Uppsala-Hansen"; blogNameReplace["se|com|org|nu)"] = "Lex Orwell"; blogNameReplace["s) blogg"] = "John Johansson (s)"; blogNameReplace["m) 3.0"] = "Edvin Ala(m) 3.0"; blogNameReplace["PLIKTEN FRAMFÖR ALLT"] = "Plikten framför allt"; blogNameReplace["*Café Liberal"] = "Café Liberal"; blogNameReplace["Disruptive - En blogg om entreprenörskap, riskkapital och webb 2.0"] = "Disruptive"; blogNameReplace["C)KER"] = "Törnqvist tänker och tycker"; blogNameReplace["serier mot FRA)"] = "Inte så PK (Serier mot FRA)"; blogNameReplace["BÄSTIGAST.SNYGGAST.SNÄLLAST.ÖDMJUKAST"] = "Johanna Wiström"; blogNameReplace["LOKE - KULTUR & POLITIK"] = "Loke kultur & politik"; blogNameReplace["Webnewspaper)"] = "The Awkward Swedeblog"; blogNameReplace["SOCIALIST OCH BAJARE- Livets passion"] = "Nicke Grozdanovski"; blogNameReplace["MÅRTENSSON"] = "Mårtensson"; blogNameReplace["FRADGA"] = "Fradga"; blogNameReplace["UD/RK Samhälls Debatt"] = "UD/RK Samhällsdebatt"; blogNameReplace["GRETAS SVAMMEL"] = "Gretas Svammel"; blogNameReplace["ISAK ENGQVIST"] = "Isak Engqvist"; blogNameReplace["Smålandsposten - Blogg - Marcus Svensson"] = "Marcus Svensson (Smålandsposten)"; blogNameReplace["f.d. Patrik i Politiken)"] = "Mittenradikalen"; Dictionary<string, double> blogWeight = new Dictionary<string, double>(); blogWeight["rickfalkvinge.se"] = 3.0; blogWeight["opassande.se"] = 3.0; blogWeight["christianengstrom"] = 3.0; blogWeight["rosettasten"] = 3.0; blogWeight["projo"] = 2.0; blogWeight["basic70.wordpress.com"] = 2.0; blogWeight["scriptorium.se"] = 2.0; blogWeight["teflonminne.se"] = 2.0; blogWeight["kurvigheter.blogspot"] = 2.0; blogWeight["ravennasblogg.blogspot.com"] = 3.0; blogWeight["webhackande.se"] = 3.0; blogWeight["jinge"] = 0.5; // störig blogWeight["klaric.se"] = 0.1; // sd blogWeight["patrikohlsson.wordpress.com"] = 0.1; // sd double highestWeight = 3.0; double maximumAgeDays = 3.0; MediaEntries blogEntriesOriginal = MediaEntries.FromBlogKeyword("FRA", DateTime.Now.AddDays(-maximumAgeDays * highestWeight)); Dictionary<string, bool> dupeCheck = new Dictionary<string, bool>(); foreach (MediaEntry entry in blogEntriesOriginal) { BlogEntry blogEntry = new BlogEntry(); blogEntry.entry = entry; blogEntry.ageAdjusted = new TimeSpan((long) ((DateTime.Now - entry.DateTime).Ticks / GetBlogWeight(blogWeight, entry.Url))); if (entry.Url.StartsWith ("http://knuff.se/k/")) { UrlTranslations.Create(entry.Url); } else if (blogEntry.ageAdjusted.Days < maximumAgeDays) { if (blogNameReplace.ContainsKey(entry.MediaName)) { blogEntry.entry = MediaEntry.FromBasic (new Activizr.Basic.Types.BasicMediaEntry(blogEntry.entry.Id, blogEntry.entry.KeywordId, blogNameReplace[entry.MediaName], true, blogEntry.entry.Title, blogEntry.entry.Url, blogEntry.entry.DateTime)); } if (!dupeCheck.ContainsKey(entry.Url)) { blogEntries.Add(blogEntry); dupeCheck[entry.Url] = true; } } } blogEntries.Sort(CompareBlogEntries); Dictionary<string, int> lookupSources = new Dictionary<string, int>(); foreach (BlogEntry entry in blogEntries) { if (blogResult.Length > 0) { blogResult += " | "; } blogResult += String.Format("<a href=\"{0}\" title=\"{1}\">{2}</a>", entry.entry.Url, HttpUtility.HtmlEncode (entry.entry.Title), HttpUtility.HtmlEncode (entry.entry.MediaName)); if (lookupSources.ContainsKey(entry.entry.MediaName)) { lookupSources[entry.entry.MediaName]++; if (lookupSources[entry.entry.MediaName] == 2) { blogResult += " igen"; } else { blogResult += " #" + lookupSources[entry.entry.MediaName].ToString(); } } else { lookupSources[entry.entry.MediaName] = 1; } } this.literalBlogOutput.Text = blogResult; MediaEntries oldMediaEntries = MediaEntries.FromOldMediaKeyword("FRA", DateTime.Now.AddDays(-maximumAgeDays / 2)); foreach (MediaEntry entry in oldMediaEntries) { if (!entry.Url.Contains(".se/")) { continue; } if (oldMediaResult.Length > 0) { oldMediaResult += " | "; } oldMediaResult += String.Format("<a href=\"{0}\">{1} ({2})</a>", entry.Url, HttpUtility.HtmlEncode(entry.Title.Replace ("`", "'").Replace ("´", "'")), HttpUtility.HtmlEncode(entry.MediaName)); } this.literalOldMediaOutput.Text = oldMediaResult; }
public BlogSelectedPhoto(Photo photo, BlogEntry blogentry, string path) : base(photo, path) { this.blogentry = blogentry; }