public async Task <IActionResult> AddComment(CommentViewModel commentViewModel) { if (ModelState.IsValid) { Comment comment = new Comment(); CommentContent commentContent = new CommentContent(); //Add Comment ApplicationUser usr = await _userManager.GetUserAsync(User); comment.UserId = usr.Id; await _db.Comment.AddAsync(comment); await _db.SaveChangesAsync(); //Add Content commentContent.CommentId = comment.CommentID; commentContent.Body = commentViewModel.CommentContent.Body; commentContent.CommentTimeStamp = DateTime.Now; await _db.CommentContent.AddAsync(commentContent); await _db.SaveChangesAsync(); } return(RedirectToAction("Index")); }
public override int GetHashCode() { return(RestaurantID.GetHashCode() ^ FromUserID.GetHashCode() ^ CommentContent.GetHashCode() ^ CommentTime.GetHashCode()); }
public ActionResult AddOrEditCC(CommentContent c) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { if (c.CommentContentID == 0) { db.CommentContents.Add(new CommentContent() { CommentOptionID = c.CommentOptionID, CommentContent1 = c.CommentContent1, CommentContentID = c.CommentContentID, }); db.SaveChanges(); return(Json(new { success = true, message = "調查主題新增成功" }, JsonRequestBehavior.AllowGet)); } else { db.Entry(c).State = EntityState.Modified; db.SaveChanges(); return(Json(new { success = true, message = "調查主題修改成功" }, JsonRequestBehavior.AllowGet)); } } }
public Task Upload(Tag tag, CommentContent comment, DigitalSignature digitalSignature, TimeSpan miningTime, CancellationToken token) { if (tag == null) { throw new ArgumentNullException(nameof(tag)); } if (comment == null) { throw new ArgumentNullException(nameof(comment)); } if (digitalSignature == null) { throw new ArgumentNullException(nameof(digitalSignature)); } return(_coreManager.VolatileSetStream(ContentConverter.ToStream(comment, 0), TimeSpan.FromDays(360), token) .ContinueWith(task => { MulticastClue MulticastClue; try { var miner = new Miner(CashAlgorithm.Version1, -1, miningTime); MulticastClue = new MulticastClue("ChatMessage", tag, DateTime.UtcNow, task.Result, digitalSignature, miner, token); } catch (MinerException) { return; } _coreManager.UploadMetadata(MulticastClue); })); }
private static void TestOthers(BuildDocumenter documenter, TestOptions options, ReferenceEngineSettings engineSettings) { if (tocType == CustomTocType.ReferenceRoot) { return; } //string libraryDir = Path.Combine(sampleDir, @"SampleTestLibraryCLR\"); //string outputDir = Path.Combine(libraryDir, @"Output\"); //string projectDoc = Path.Combine(outputDir, "Project.xml"); string sourceFile = @"F:\SandcastleAssist\Main\Samples\HelpersSamples.sln"; ReferenceVsNetSource vsSource = new ReferenceVsNetSource(); ReferenceVsNetItem vsItem = new ReferenceVsNetItem( new BuildFilePath(sourceFile)); //vsItem.XamlSyntax = false; vsItem.AddInclude("{41A48F1C-3E52-4995-B181-363EDBC02CA0}"); vsSource.Add(vsItem); CommentContent comments = vsSource.Comments; CommentItem projItem = new CommentItem("R:Project", CommentItemType.Project); projItem.Value.Add(new CommentPart("Summary of the project", CommentPartType.Summary)); comments.Add(projItem); CommentItem nsItem = new CommentItem("N:TestLibraryCLR", CommentItemType.Namespace); nsItem.Value.Add(new CommentPart("Summary of the namespace", CommentPartType.Summary)); comments.Add(nsItem); ReferenceGroup apiGroup = new ReferenceGroup( "Test CPP-CLR Library", Guid.NewGuid().ToString(), vsSource); apiGroup.RunningHeaderText = "Sandcastle Helpers: C++/CLR Library"; apiGroup.VersionType = ReferenceVersionType.AssemblyAndFile; if (engineSettings.RootNamespaceContainer) { apiGroup.RootNamespaceTitle = "Testing C++/CLR Library"; } //ReferenceContent apiContent = apiGroup.Content; //apiContent.FrameworkType = BuildFrameworkType.Framework20; //apiGroup.AddItem(projectDoc, null); //apiContent.AddItem(Path.Combine(outputDir, "SampleLibraryCLR.xml"), // Path.Combine(outputDir, "SampleLibraryCLR.dll")); //apiContent.AddDependency(Path.Combine(outputDir, "")); documenter.AddGroup(apiGroup); }
public void ImplicitOperatorToCommentContent_NullItem_ReturnsNull() { // arrange, act CommentContent commentContent = (CommentItem)null; // assert Assert.That(commentContent, Is.Null); }
public Task SetUnicastCommentMessage(Signature targetSignature, CommentContent comment, AgreementPublicKey agreementPublicKey, DigitalSignature digitalSignature, CancellationToken token) { this.Check(); lock (_lockObject) { return(_messageManager.Upload(targetSignature, comment, agreementPublicKey, digitalSignature, token)); } }
public Task SetMulticastCommentMessage(Tag tag, CommentContent comment, DigitalSignature digitalSignature, TimeSpan miningTime, CancellationToken token) { this.Check(); lock (_lockObject) { return(_messageManager.Upload(tag, comment, digitalSignature, miningTime, token)); } }
/// <summary> /// Initializes a new instance of the <see cref="ReferenceSource"/> class /// with parameters copied from the specified instance of the /// <see cref="ReferenceSource"/> class, a copy constructor. /// </summary> /// <param name="source"> /// An instance of the <see cref="ReferenceSource"/> class from which the /// initialization parameters or values will be copied. /// </param> /// <exception cref="ArgumentNullException"> /// If the parameter <paramref name="source"/> is <see langword="null"/>. /// </exception> protected ReferenceSource(ReferenceSource source) : base(source) { _title = source._title; _tocContent = source._tocContent; _commentContent = source._commentContent; _typeFilters = source._typeFilters; _attributeFilters = source._attributeFilters; }
/// <overloads> /// Initializes a new instance of the <see cref="ReferenceSource"/> class. /// </overloads> /// <summary> /// Initializes a new instance of the <see cref="ReferenceSource"/> class /// with the default parameters. /// </summary> protected ReferenceSource() { _title = String.Format("ReferenceSource{0:x}", Guid.NewGuid().ToString().GetHashCode()); _tocContent = new HierarchicalTocContent(); _commentContent = new CommentContent(); _typeFilters = new ReferenceRootFilter(false); _attributeFilters = new ReferenceRootFilter(true); }
/// <summary> /// Adds the New post to the Database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void PostClick(object sender, EventArgs e) { bool GroupExist = false; int GroupID = 0; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ToString())) { conn.Open(); string sql = "select ReplyGroupID FROM FORUM_POST where PostID=@PostID"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.Add(new SqlParameter("@PostID", Request.QueryString["PostID"])); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { if (dr["ReplyGroupID"] != System.DBNull.Value) { GroupExist = true; GroupID = (int)dr["ReplyGroupID"]; } else { GroupExist = false; } } dr.Close(); if (GroupExist == false) { sql = "insert into FORUM_GROUP (DateCreated) Output inserted.GroupID Values (GETDATE())"; cmd = new SqlCommand(sql, conn); GroupID = (int)cmd.ExecuteScalar(); sql = "update FORUM_POST set ReplyGroupID=@ReplyGroup where PostID=@PostID"; cmd = new SqlCommand(sql, conn); cmd.Parameters.Add(new SqlParameter("@ReplyGroup", GroupID)); cmd.Parameters.Add(new SqlParameter("@PostID", Request.QueryString["PostID"])); cmd.ExecuteNonQuery(); } TextBox txt = (TextBox)CommentContent.FindControl("CommentBox"); sql = "insert into FORUM_GROUP_ITEM (GroupID, ReplyText, UserID, DatePosted) Values (@GroupID, @ReplyText, @UserID, GetDate())"; cmd = new SqlCommand(sql, conn); cmd.Parameters.Add(new SqlParameter("@GroupID", GroupID)); cmd.Parameters.Add(new SqlParameter("@ReplyText", txt.Text)); cmd.Parameters.Add(new SqlParameter("@UserID", Session["UserID"])); cmd.ExecuteNonQuery(); txt.Text = ""; FillComments(); } }
public Task SetUnicastCommentMessage(Signature targetSignature, CommentContent comment, AgreementPublicKey agreementPublicKey, DigitalSignature digitalSignature, CancellationToken token) { this.Check(); lock (_lockObject) { return(Task.Run(() => { this.Action(AmoebaFunctionType.SetUnicastCommentMessage, (targetSignature, comment, agreementPublicKey, digitalSignature), token); })); } }
public Task SetMulticastCommentMessage(Tag tag, CommentContent comment, DigitalSignature digitalSignature, TimeSpan miningTimeSpan, CancellationToken token) { this.Check(); lock (_lockObject) { return(Task.Run(() => { this.Action(AmoebaFunctionType.SetMulticastCommentMessage, (tag, comment, digitalSignature, miningTimeSpan), token); })); } }
public override bool Equals(object obj) { if (obj == null || !(obj is ERRestaurantComment)) { return(false); } return(RestaurantID.Equals((obj as ERRestaurantComment).RestaurantID) & FromUserID.Equals((obj as ERRestaurantComment).FromUserID) & CommentContent.Equals((obj as ERRestaurantComment).CommentContent) & CommentTime.Equals((obj as ERRestaurantComment).CommentTime)); }
protected void Page_Load(object sender, EventArgs e) { // 댓글달기 CommentContent commentTempalte = (CommentContent)LoadControl(CommentConst.PARAM_COMMENT_CONTROL_PATH); commentTempalte.ArticleNo = BlogManager.GetInstance().BlogBaseModel.PrivacyModel.GuestBoardArticleNo; commentTempalte.IsWriteComment = commentTempalte.SurelyVisible = BlogManager.GetInstance().BlogBaseModel.PrivacyModel.CanWriteGuestBoard; this.Controls.Add(commentTempalte); }
public ReferenceContent() { _contentVersion = new Version(1, 0, 0, 0); _contentId = Guid.NewGuid().ToString(); _frameworkType = BuildFrameworkType.Framework20; _dependencies = new DependencyContent(); _tocContent = new HierarchicalTocContent(); _commentContent = new CommentContent(); _typeFilters = new ReferenceRootFilter(false); _attributeFilters = new ReferenceRootFilter(true); }
public virtual IList <CommentContent> LoadComments(CommentItem addedComment = null) { var comments = CommentManager.GetEntryComments(CurrentEntry, int.MaxValue).Select(x => CommentManager.GetCommentContent(x)).ToList(); //if a comment has been added but is not coming back yet (i.e. being indexed), fake it if (addedComment != null && comments.All(comment => comment.Uri.ItemID != addedComment.ID)) { CommentContent newComment = addedComment; comments.Insert(0, newComment); } return(comments); }
public ActionResult DeleteCC(int id) { using (BusinessDataBaseEntities db = new BusinessDataBaseEntities()) { //CommentContent c = db.CommentContents.Where(x => x.CommentContentID == id).FirstOrDefault<CommentContent>(); CommentContent cc = db.CommentContents.Find(id); db.CommentContents.Remove(cc); db.SaveChanges(); return(Json(new { success = true, message = "刪除成功" }, JsonRequestBehavior.AllowGet)); } }
public override bool Equals(object obj) { Comment comment = obj as Comment; if (comment == null) { return(false); } return(Nickname == comment.Nickname && Email == comment.Email && CommentContent.Trim() == comment.CommentContent.Trim() && CommentedGameRefID == comment.CommentedGameRefID && PublishDate.Equals(PublishDate)); }
public ReferenceContent(ReferenceContent source) : base(source) { _isLoaded = source._isLoaded; _contentId = source._contentId; _contentVersion = source._contentVersion; _contentFile = source._contentFile; _contentDir = source._contentDir; _frameworkType = source._frameworkType; _tocContent = source._tocContent; _dependencies = source._dependencies; _commentContent = source._commentContent; _typeFilters = source._typeFilters; _attributeFilters = source._attributeFilters; }
public ActionResult _InsertAjaxEditing() { var item = new CommentContent(); if (TryUpdateModel(item)) { if (ModelState.IsValid) { CH.Create <CommentContent>(item); } } //Rebind the grid List <CommentContent> list = CH.GetAllData <CommentContent>(); return(View(new GridModel(list))); }
public async Task <IActionResult> Update(CommentContent commentContent) { if (ModelState.IsValid) { //Add Comment //Add Content commentContent.CommentTimeStamp = DateTime.Now; await _db.CommentContent.AddAsync(commentContent); await _db.SaveChangesAsync(); } return(RedirectToAction("Index")); }
public void CheckAuth() { if (Session["Auth"] != null) { if ((bool)Session["Auth"] == true) { Button btn = (Button)CommentContent.FindControl("Postbtn"); btn.Enabled = true; TextBox txt = (TextBox)CommentContent.FindControl("CommentBox"); txt.Enabled = true; } else { Button btn = (Button)CommentContent.FindControl("Postbtn"); btn.Enabled = false; TextBox txt = (TextBox)CommentContent.FindControl("CommentBox"); txt.Enabled = false; } } }
public Task Upload(Signature targetSignature, CommentContent comment, AgreementPublicKey agreementPublicKey, DigitalSignature digitalSignature, CancellationToken token) { if (targetSignature == null) { throw new ArgumentNullException(nameof(targetSignature)); } if (comment == null) { throw new ArgumentNullException(nameof(comment)); } if (digitalSignature == null) { throw new ArgumentNullException(nameof(digitalSignature)); } return(_coreManager.VolatileSetStream(ContentConverter.ToCryptoStream(comment, 1024 * 256, agreementPublicKey, 0), TimeSpan.FromDays(360), token) .ContinueWith(task => { _coreManager.UploadMetadata(new UnicastClue("MailMessage", targetSignature, DateTime.UtcNow, task.Result, digitalSignature)); })); }
public void ImplicitOperatorToCommentContent_ItemWithCorrectFields_ReturnsNull() { // arrange using (var db = new Db { CreateDbItem() }) { var entry = db.GetItem("/sitecore/content/" + EntryName); CommentItem commentItem = entry; // act CommentContent commentContent = commentItem; // assert Assert.That(commentContent.Uri, Is.EqualTo(entry.Uri)); Assert.That(commentContent.AuthorName, Is.EqualTo(AuthorName)); Assert.That(commentContent.AuthorWebsite, Is.EqualTo(AuthorWebsite)); Assert.That(commentContent.AuthorEmail, Is.EqualTo(AuthorEmail)); Assert.That(commentContent.Text, Is.EqualTo(CommentText)); } }
public object Create(object request, ISpecimenContext context) { if (!(request is ParameterInfo parameterInfo)) { return(new NoSpecimen()); } if (parameterInfo.ParameterType != typeof(TypeComments)) { return(new NoSpecimen()); } return(_hasComments ? new TypeComments( new [] { new Comment("summary", new[] { CommentContent.NewText(Guid.NewGuid().ToString()) }, new CommentParameter[0]), new Comment("remarks", new[] { CommentContent.NewText(Guid.NewGuid().ToString()) }, new CommentParameter[0]), new Comment("example", new[] { CommentContent.NewText(Guid.NewGuid().ToString()) }, new CommentParameter[0]) } ) : new TypeComments(Enumerable.Empty <Comment>())); }
public override ReferenceContent Create(BuildGroupContext groupContext) { BuildExceptions.NotNull(groupContext, "groupContext"); BuildContext context = groupContext.Context; BuildLogger logger = null; if (context != null) { logger = context.Logger; } if (!this.IsInitialized) { throw new BuildException(String.Format( "The content source '{0}' is not yet initialized.", this.Title)); } if (!this.IsValid) { if (logger != null) { logger.WriteLine(String.Format( "The content group source '{0}' is invalid.", this.Title), BuildLoggerLevel.Warn); } return(null); } ReferenceContent content = new ReferenceContent(_sourcePath); content.Load(); CommentContent sourceComments = this.Comments; if (_overrideComments == null) { // Provide other user-supplied information to the content... if (sourceComments != null && !sourceComments.IsEmpty) { // Merge the comments, overriding any existing... CommentContent importComments = content.Comments; if (importComments == null || importComments.IsEmpty) { content.Comments = sourceComments; } else { for (int i = 0; i < sourceComments.Count; i++) { CommentItem sourceItem = sourceComments[i]; if (!sourceItem.IsEmpty) { importComments.Add(sourceItem); } } } } } else if (_overrideComments.Value) { content.Comments = sourceComments; } HierarchicalTocContent hierarchicalToc = this.HierarchicalToc; if (_overrideHierarchicalToc == null) { if (hierarchicalToc != null && !hierarchicalToc.IsEmpty) { content.HierarchicalToc = hierarchicalToc; } } else if (_overrideHierarchicalToc.Value) { content.HierarchicalToc = hierarchicalToc; } ReferenceRootFilter typeFilters = this.TypeFilters; ReferenceRootFilter attributeFilters = this.AttributeFilters; if (_overrideFilters == null) { if (typeFilters != null && !typeFilters.IsEmpty) { content.TypeFilters = typeFilters; } if (attributeFilters != null && !attributeFilters.IsEmpty) { content.AttributeFilters = attributeFilters; } } else if (_overrideFilters.Value) { content.TypeFilters = typeFilters; content.AttributeFilters = attributeFilters; } return(content); }
public CommentsList(ICommentsListCore commentsListCore, ICommentManager commentManager) { CommentsListCore = commentsListCore ?? new CommentsListCore(CurrentBlog, CurrentEntry); CommentManager = commentManager ?? ManagerFactory.CommentManagerInstance; Comments = new CommentContent[0]; }
private bool OnExecuteSingle(BuildContext context) { BuildLogger logger = context.Logger; ReferenceGroupContext groupContext = context.GroupContexts[_group.Id] as ReferenceGroupContext; if (groupContext == null) { throw new BuildException( "The group context is not provided, and it is required by the build system."); } ReferenceContent content = _group.Content; if (content == null) { if (logger != null) { logger.WriteLine("StepReferenceInit: There is no content associated with the reference group.", BuildLoggerLevel.Error); } return(false); } BuildFrameworkType frameworkType = content.FrameworkType; if (frameworkType == BuildFrameworkType.Null || frameworkType == BuildFrameworkType.None) { if (logger != null) { logger.WriteLine("StepReferenceInit: There is no valid framework type specified for this reference group.", BuildLoggerLevel.Error); } return(false); } BuildFramework framework = BuildFrameworks.GetFramework(frameworkType); if (framework == null) { if (logger != null) { logger.WriteLine("StepReferenceInit: The specified framework type for this reference group is not installed.", BuildLoggerLevel.Error); } return(false); } string workingDir = context.WorkingDirectory; groupContext.Framework = framework; string commentDir = groupContext.CommentFolder; string assemblyDir = groupContext.AssemblyFolder; if (String.IsNullOrEmpty(commentDir)) { commentDir = "Comments"; } if (!Path.IsPathRooted(commentDir)) { commentDir = Path.Combine(workingDir, commentDir); } if (!Directory.Exists(commentDir)) { Directory.CreateDirectory(commentDir); } if (String.IsNullOrEmpty(assemblyDir)) { assemblyDir = "Assemblies"; } if (!Path.IsPathRooted(assemblyDir)) { assemblyDir = Path.Combine(workingDir, assemblyDir); } if (!Directory.Exists(assemblyDir)) { Directory.CreateDirectory(assemblyDir); } string dependencyDir = groupContext.DependencyFolder; if (String.IsNullOrEmpty(dependencyDir)) { dependencyDir = "Dependencies"; } if (!Path.IsPathRooted(dependencyDir)) { dependencyDir = Path.Combine(workingDir, dependencyDir); } if (!Directory.Exists(dependencyDir)) { Directory.CreateDirectory(dependencyDir); } groupContext.CommentDir = commentDir; groupContext.AssemblyDir = assemblyDir; groupContext.DependencyDir = dependencyDir; // Copy the comments to the expected directory... int itemCount = content.Count; List <string> commentFiles = new List <string>(itemCount); CommentContent commentContent = content.Comments; if (commentContent != null && !commentContent.IsEmpty) { string commentFile = Path.Combine(commentDir, groupContext["$CommentsFile"]); // If there is a valid file or there is an attached file... BuildFilePath filePath = commentContent.ContentFile; if (filePath != null && filePath.Exists) { if (commentContent.IsLoaded) { commentContent.Save(); } File.Copy(filePath.Path, commentFile); } else { commentContent.SaveCopyAs(commentFile); } File.SetAttributes(commentFile, FileAttributes.Normal); commentFiles.Add(commentFile); } for (int i = 0; i < itemCount; i++) { ReferenceItem item = content[i]; if (item == null || item.IsEmpty) { continue; } string commentsFile = item.Comments; if (!String.IsNullOrEmpty(commentsFile)) { string fileName = Path.GetFileName(commentsFile); fileName = Path.Combine(commentDir, fileName); if (commentsFile.Length != fileName.Length || String.Equals(commentsFile, fileName, StringComparison.OrdinalIgnoreCase) == false) { File.Copy(commentsFile, fileName, true); File.SetAttributes(fileName, FileAttributes.Normal); commentFiles.Add(fileName); } } string assemblyFile = item.Assembly; if (!String.IsNullOrEmpty(assemblyFile)) { string fileName = Path.GetFileName(assemblyFile); fileName = Path.Combine(assemblyDir, fileName); if (assemblyFile.Length != fileName.Length || String.Equals(assemblyFile, fileName, StringComparison.OrdinalIgnoreCase) == false) { File.Copy(assemblyFile, fileName, true); File.SetAttributes(fileName, FileAttributes.Normal); } } } // Finally, store the list of extracted comment file to its context... groupContext.CommentFiles = commentFiles; // 1. Copy the dependencies to the expected directory... ReferenceProjectVisitor dependencyResolver = new ReferenceProjectVisitor(); dependencyResolver.Initialize(context); dependencyResolver.Visit(_group); dependencyResolver.Uninitialize(); return(true); }
private void ReadContents(XmlReader reader) { if (reader.IsEmptyElement) { return; } string startElement = reader.Name; while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (String.Equals(reader.Name, "content", StringComparison.OrdinalIgnoreCase)) { switch (reader.GetAttribute("type").ToLower()) { case "comments": if (_commentContent == null) { _commentContent = new CommentContent(); } if (reader.IsEmptyElement) { string sourceFile = reader.GetAttribute("source"); if (!String.IsNullOrEmpty(sourceFile)) { _commentContent.ContentFile = new BuildFilePath(sourceFile); _commentContent.Load(); } } else { if (reader.ReadToDescendant(CommentContent.TagName)) { _commentContent.ReadXml(reader); } } break; case "dependencies": if (_dependencies == null) { _dependencies = new DependencyContent(); } if (!reader.IsEmptyElement && reader.ReadToDescendant( DependencyContent.TagName)) { _dependencies.ReadXml(reader); } break; case "hierarchicaltoc": if (_tocContent == null) { _tocContent = new HierarchicalTocContent(); } if (!reader.IsEmptyElement && reader.ReadToDescendant( HierarchicalTocContent.TagName)) { _tocContent.ReadXml(reader); } break; } } } else if (reader.NodeType == XmlNodeType.EndElement) { if (String.Equals(reader.Name, startElement, StringComparison.OrdinalIgnoreCase)) { break; } } } }