public Comment(string text, int id, int parentId, CommentCollection collection) { Id = id; this.parentId = parentId; collection.Add(this); this.collection = collection; this.text = text; }
public static CommentCollection SelectAll() { CommentCollection List = new CommentCollection(); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblComment_Select_SelectAll_hoangda")) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
public CommentCollection GetCommentsFor(string entryId) { Load(); CommentCollection filtered = new CommentCollection(); foreach (Comment c in Comments) { if (c.TargetEntryId == entryId) { filtered.Add(c); } } return(filtered); }
/// <summary> /// /// </summary> /// <param name="targetID"></param> /// <param name="type"></param> /// <param name="getCount">取最新的前N条 和 最旧的一条</param> /// <param name="isGetAll"></param> /// <returns></returns> public override CommentCollection GetComments(int targetID, CommentType type, int getCount, bool isGetAll) { using (SqlQuery query = new SqlQuery()) { if (isGetAll) { query.CommandText = "SELECT * FROM [bx_Comments] WHERE Type = @Type AND TargetID = @TargetID AND IsApproved = 1 ORDER BY CommentID ASC;"; } else { query.CommandText = @" SELECT TOP(@TopCount) * FROM [bx_Comments] WHERE Type = @Type AND TargetID = @TargetID AND IsApproved = 1 ORDER BY CommentID DESC; SELECT TOP 1 * FROM [bx_Comments] WHERE Type = @Type AND TargetID = @TargetID ORDER BY CommentID ASC; "; query.CreateTopParameter("@TopCount", getCount); } query.CreateParameter <int>("@TargetID", targetID, SqlDbType.Int); query.CreateParameter <int>("@Type", (int)type, SqlDbType.TinyInt); CommentCollection comments = new CommentCollection(); using (XSqlDataReader reader = query.ExecuteReader()) { if (isGetAll) { while (reader.Read()) { comments.Add(new Comment(reader)); } } else { while (reader.Read()) { comments.Insert(0, new Comment(reader)); } if (reader.NextResult()) { while (reader.Read()) { comments.Insert(0, new Comment(reader)); } } } return(comments); } } }
public void AddAnnotation(IAnnotation annotation) { if (annotation.Comments.Count != 0) { if (removedAnnotation == null || removedAnnotation != null && removedAnnotation.AnnotationId != annotation.AnnotationId) { CommentCollection.Add(annotation.Comments[0]); AnnotationCount = CommentCollection.Count.ToString(); } else if (removedAnnotation.AnnotationId == annotation.AnnotationId) { CommentCollection.Insert(removedIndex, annotation.Comments[0]); AnnotationCount = CommentCollection.Count.ToString(); } } }
public static CommentCollection SelectActive(int Top) { CommentCollection List = new CommentCollection(); SqlParameter[] obj = new SqlParameter[] { new SqlParameter("Top", Top) }; using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblComment_Select_SelectActive_hoangda", obj)) { while (rd.Read()) { List.Add(getFromReader(rd)); } } return(List); }
public void ProcessKeyword(Comment comment, ProcessKeywordMode mode) { //更新关键字模式,如果这个评论并不需要处理,直接退出 if (mode == ProcessKeywordMode.TryUpdateKeyword) { if (AllSettings.Current.ContentKeywordSettings.ReplaceKeywords.NeedUpdate <Comment>(comment) == false) { return; } } CommentCollection comments = new CommentCollection(); comments.Add(comment); ProcessKeyword(comments, mode); }
public static void Run() { // ExStart:1 // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } // Instantiate a Workbook Workbook workbook = new Workbook(); // Get a reference of comments collection with the first sheet CommentCollection comments = workbook.Worksheets[0].Comments; // Add a comment to cell A1 int commentIndex = comments.Add(0, 0); Comment comment = comments[commentIndex]; comment.Note = "First note."; comment.Font.Name = "Times New Roman"; // Load an image into stream Bitmap bmp = new Bitmap(dataDir + "image2.jpg"); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // Set image data to the shape associated with the comment comment.CommentShape.Fill.ImageData = ms.ToArray(); dataDir = dataDir + "commentwithpicture1.out.xlsx"; // Save the workbook workbook.Save(dataDir, Aspose.Cells.SaveFormat.Xlsx); // ExEnd:1 Console.WriteLine("\nProcess completed successfully.\nFile saved at " + dataDir); }
public override CommentCollection GetComments(IEnumerable <int> commentIds) { using (SqlQuery query = new SqlQuery()) { query.CommandText = "SELECT * FROM [bx_Comments] WHERE CommentID IN (@CommentIds);"; query.CreateInParameter <int>("@CommentIds", commentIds); CommentCollection comments = new CommentCollection(); using (XSqlDataReader reader = query.ExecuteReader()) { while (reader.Read()) { comments.Add(new Comment(reader)); } return(comments); } } }
public static void Run() { //Source directory string sourceDir = RunExamples.Get_SourceDirectory(); //Output directory string outputDir = RunExamples.Get_OutputDirectory(); // Instantiate a Workbook Workbook workbook = new Workbook(); //Add some text in cell A1 workbook.Worksheets[0].Cells["A1"].PutValue("Here"); // Get a reference of comments collection with the first sheet CommentCollection comments = workbook.Worksheets[0].Comments; // Add a comment to cell A1 int commentIndex = comments.Add(0, 0); Comment comment = comments[commentIndex]; comment.Note = "First note."; comment.Font.Name = "Times New Roman"; // Load an image into stream Bitmap bmp = new Bitmap(sourceDir + "sampleAddPictureToExcelComment.jpg"); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); // Set image data to the shape associated with the comment comment.CommentShape.Fill.ImageData = ms.ToArray(); // Save the workbook workbook.Save(outputDir + "outputAddPictureToExcelComment.xlsx", Aspose.Cells.SaveFormat.Xlsx); Console.WriteLine("AddPictureToExcelComment executed successfully.\r\n"); }
static private void ExportCommentsBody(Journal.OptionsRow or, ILJServer iLJ, SessionGenerateResponse sgr, int serverMaxID, int localMaxID, CommentCollection cc) { // note that the export comments body web request may be called more than once int maxID = localMaxID; while (maxID < serverMaxID) { Uri uri = new Uri(new Uri(or.ServerURL), string.Format(_exportcommentsbodypath, maxID + 1)); if (!or.IsUseJournalNull()) { uri = new Uri(uri.AbsoluteUri + string.Format("&authas={0}", or.UseJournal)); } HttpWebRequest w = HttpWebRequestFactory.Create(uri.AbsoluteUri, sgr.ljsession); socb(new SyncOperationEventArgs(SyncOperation.ExportCommentsBody, maxID - localMaxID, serverMaxID - localMaxID)); using (Stream s = w.GetResponse().GetResponseStream()) { System.Text.Encoding ec; if (System.Environment.Version.Major == 1) // .NET 2.0 utf8 cleans strings, so we don't have to { ec = new UTF8Clean(); } else { ec = System.Text.Encoding.UTF8; } StreamReader sr = new StreamReader(s, ec); XmlCommentReader xcr = new XmlCommentReader(sr); while (xcr.Read()) { cc.Add(xcr.Comment); } xcr.Close(); } maxID = cc.GetMaxID(); } }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); // Create directory if it is not already present. bool IsExists = System.IO.Directory.Exists(dataDir); if (!IsExists) { System.IO.Directory.CreateDirectory(dataDir); } //Instantiate a Workbook Workbook workbook = new Workbook(); //Get a reference of comments collection with the first sheet CommentCollection comments = workbook.Worksheets[0].Comments; //Add a comment to cell A1 int commentIndex = comments.Add(0, 0); Comment comment = comments[commentIndex]; comment.Note = "First note."; comment.Font.Name = "Times New Roman"; //Load an image into stream Bitmap bmp = new Bitmap(dataDir + "image2.jpg"); MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); //Set image data to the shape associated with the comment comment.CommentShape.FillFormat.ImageData = ms.ToArray(); //Save the workbook workbook.Save(dataDir + "commentwithpicture1.xlsx", Aspose.Cells.SaveFormat.Xlsx); }
public FakeBloggersPointService() { _posts.Add(_post); _comments.Add(_comment); _authors.Add(_author); }
static private void ExportCommentsMeta(Journal.OptionsRow or, ILJServer iLJ, SessionGenerateResponse sgr, ref int serverMaxID, int localMaxID, UserMapCollection umc, CommentCollection cc) { // this is a an unfortunately necessary step // we call export comments meta is to get the user map and to check if comment state has changed // it would be better to be able to provide a lastsync, but alas // see http://www.livejournal.com/developer/exporting.bml for more info int maxID = -1; while (maxID < serverMaxID) { Uri uri = new Uri(new Uri(or.ServerURL), string.Format(_exportcommentsmetapath, maxID + 1)); if (!or.IsUseJournalNull()) { uri = new Uri(uri.AbsoluteUri + string.Format("&authas={0}", or.UseJournal)); } HttpWebRequest w = HttpWebRequestFactory.Create(uri.AbsoluteUri, sgr.ljsession); using (Stream s = w.GetResponse().GetResponseStream()) { XmlTextReader xtr = new XmlTextReader(s); while (xtr.Read()) { if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "usermap") { string id = xtr.GetAttribute("id"); string user = xtr.GetAttribute("user"); if (id != null && user != null && !umc.ContainsID(XmlConvert.ToInt32(id))) { umc.Add(new UserMap(XmlConvert.ToInt32(id), user)); } } else if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "maxid") { xtr.Read(); serverMaxID = XmlConvert.ToInt32(xtr.Value); socb(new SyncOperationEventArgs(SyncOperation.ExportCommentsMeta, Math.Max(maxID, 0), serverMaxID)); } else if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "comment") { string id = xtr.GetAttribute("id"); string posterid = xtr.GetAttribute("posterid"); string state = xtr.GetAttribute("state"); if (posterid == null) { posterid = "0"; } if (state == null) { state = "A"; } if (id != null) { cc.Add(new Comment(XmlConvert.ToInt32(id), XmlConvert.ToInt32(posterid), state, 0, 0, string.Empty, string.Empty, DateTime.MinValue)); } } else if (xtr.NodeType == XmlNodeType.Element && xtr.Name == "h2") { xtr.Read(); if (xtr.Value == "Error" && !or.IsUseJournalNull()) { throw new ExpectedSyncException(ExpectedError.CommunityAccessDenied, null); } } } xtr.Close(); } maxID = cc.GetMaxID(); } }
/// <summary> /// /// </summary> /// <param name="targetID"></param> /// <param name="type"></param> /// <param name="getCount">取最新的前N条 和 最旧的一条</param> /// <param name="isGetAll"></param> /// <returns></returns> public override CommentCollection GetComments(int targetID, CommentType type, int getCount, bool isGetAll) { using (SqlQuery query = new SqlQuery()) { if (isGetAll) { query.CommandText = "SELECT * FROM [bx_Comments] WHERE Type = @Type AND TargetID = @TargetID AND IsApproved = 1 ORDER BY CommentID ASC;"; } else { query.CommandText = @" SELECT TOP(@TopCount) * FROM [bx_Comments] WHERE Type = @Type AND TargetID = @TargetID AND IsApproved = 1 ORDER BY CommentID DESC; SELECT TOP 1 * FROM [bx_Comments] WHERE Type = @Type AND TargetID = @TargetID ORDER BY CommentID ASC; "; query.CreateTopParameter("@TopCount", getCount); } query.CreateParameter<int>("@TargetID", targetID, SqlDbType.Int); query.CreateParameter<int>("@Type", (int)type, SqlDbType.TinyInt); CommentCollection comments = new CommentCollection(); using (XSqlDataReader reader = query.ExecuteReader()) { if (isGetAll) { while (reader.Read()) { comments.Add(new Comment(reader)); } } else { while (reader.Read()) { comments.Insert(0, new Comment(reader)); } if (reader.NextResult()) { while (reader.Read()) { comments.Insert(0, new Comment(reader)); } } } return comments; } } }
public override CommentCollection GetComments(IEnumerable<int> commentIds) { using (SqlQuery query = new SqlQuery()) { query.CommandText = "SELECT * FROM [bx_Comments] WHERE CommentID IN (@CommentIds);"; query.CreateInParameter<int>("@CommentIds", commentIds); CommentCollection comments = new CommentCollection(); using (XSqlDataReader reader = query.ExecuteReader()) { while (reader.Read()) { comments.Add(new Comment(reader)); } return comments; } } }
public override CommentCollection GetComments(string discussionLink, int pageNumber) { if (!Config.Discussions.Current.Enabled || discussionLink == null || discussionLink.Trim() == "") { throw new DiscussionUnavailableException("Discussion unavailable."); } string pendingKey = discussionLink + "-p" + pageNumber.ToString(); bool isPending = false; lock (pendingRequests) { if (pendingRequests.ContainsKey(pendingKey)) { isPending = true; } else { pendingRequests.Add(pendingKey, DateTime.Now); } } if (isPending) throw new DiscussionUnavailableException("Discussion request pending"); string directLink = discussionLink; if (pageNumber == 0) { pageNumber = 1; } CommentCollection comments = new CommentCollection(); System.Xml.XmlDocument xml = new XmlDocument(); discussionLink = discussionLink.Replace("&", "&"); discussionLink += "&xsl=xml&p=" + pageNumber; discussionLink += string.Format("&LOGIN_USERNAME={0}&LOGIN_PASSWORD={1}", this.SettingsCollection["LOGIN_USERNAME"], this.SettingsCollection["LOGIN_PASSWORD"]); discussionLink = Regex.Replace(discussionLink, "&r=\\d+", ""); CommentCollection container = new CommentCollection(); container.PageNumber = pageNumber; try { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(discussionLink); req.Timeout = 5000; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); using (StreamReader stream = new StreamReader(resp.GetResponseStream())) { xml.LoadXml(stream.ReadToEnd()); } XmlNode pages = xml.SelectSingleNode("/page/pages"); if (pages != null && pages.Attributes["total"] != null) { container.Pages = int.Parse(pages.Attributes.GetNamedItem("total").Value); container.PageNumber = int.Parse(pages.Attributes.GetNamedItem("current").Value); } else { container.Pages = 1; } int loopcount = 0; XmlNode profileLinkNode = xml.SelectSingleNode("/page/info/community/profile"); if (profileLinkNode == null) { throw new DiscussionUnavailableException(string.Format("<a href=\"{0}\">Discussion in the Open Forum</a>", directLink)); } string profileLink = xml.SelectSingleNode("/page/info/community/profile").Attributes.GetNamedItem("url").Value; profileLink += "?x_myspace_page=profile&u={0}"; foreach (XmlNode comment in xml.SelectNodes("/page/content/topic/message")) { if (loopcount++ == 0 && pageNumber == 1) { continue; } Comment c = new Comment(); c.PostDate = DateTime.ParseExact(comment.Attributes.GetNamedItem("date-ietf").Value, "ddd, dd MMM yyyy HH:mm:ss G\\MTzz00", CultureInfo.InvariantCulture); c.Body = comment.SelectSingleNode("content/message-body").InnerText; if (comment.SelectSingleNode("author/user") != null) { c.UserName = comment.SelectSingleNode("author/user").Attributes.GetNamedItem("name").Value; c.UserLink = string.Format(profileLink, comment.SelectSingleNode("author/user").Attributes.GetNamedItem("oid").Value); } else if (comment.SelectSingleNode("author/guest") != null) { c.UserName = string.Format("<{0}>", comment.SelectSingleNode("author/guest").Attributes.GetNamedItem("name").Value); c.UserLink = null; } container.Add(c); } if (container.Pages == 1) { container.TotalCount = loopcount; } else { int pageToGet = (container.PageNumber == container.Pages) ? 1 : container.Pages; discussionLink = Regex.Replace(discussionLink, "&p=\\d+", ""); discussionLink += "&p=" + pageToGet; req = (HttpWebRequest)HttpWebRequest.Create(discussionLink); req.Timeout = 5000; resp = (HttpWebResponse)req.GetResponse(); using (StreamReader stream = new StreamReader(resp.GetResponseStream())) { xml.LoadXml(stream.ReadToEnd()); } XmlNodeList commentList = xml.SelectNodes("/page/content/topic/message"); if (commentList != null) { if (pageToGet == container.Pages) { container.TotalCount = loopcount * (container.Pages - 1) + commentList.Count; } else { container.TotalCount = commentList.Count * (container.Pages - 1) + loopcount; } } } container.TotalCount--; //container.PostFormLink = this.GetPostFormLink(discussionLink); pendingRequests.Remove(pendingKey); } catch (WebException wex) { pendingRequests.Remove(pendingKey); throw new DiscussionUnavailableException(string.Format("<a href=\"{0}\">Discussion in the Open Forum</a>", directLink), wex); } catch (XmlException xmlex) { pendingRequests.Remove(pendingKey); throw new DiscussionUnavailableException(string.Format("<a href=\"{0}\">Discussion in the Open Forum</a>", directLink), xmlex); } finally { pendingRequests.Remove(pendingKey); } return container; }
CommentCollection InternalGetCommentsFor(string entryId, bool allComments) { CommentCollection commentsForEntry = new CommentCollection(); DateTime date = GetDateForEntry(entryId); if (date == DateTime.MinValue) return commentsForEntry; DayExtra extra = data.GetDayExtra(date); foreach (Comment cm in extra.Comments) { // check if the comment is for this entry, and is public or allComments are requested if (String.Compare(cm.TargetEntryId, entryId, true, CultureInfo.InvariantCulture) == 0 && (cm.IsPublic || allComments)) { commentsForEntry.Add(cm); } } return commentsForEntry; }
public Form1() { InitializeComponent(); NodeCollection nodes = new NodeCollection(); //for (int i = 0; i < 100000; i++) //{ nodes.Add(new NodeItem("PC", 0)); nodes.Add(new NodeItem("TGT", 1)); nodes.Add(new NodeItem("MRLY", 2)); ////} CommentCollection comments = new CommentCollection(); comments.Add(new CommentItem("NODE", "PC", "First Comment to NODE, Node Name is PC")); comments.Add(new CommentItem("NODE", "PC", "Second Comment to NODE, Node Name is PC")); //comments.Add(new CommentItem("NODE", "TGT", "Comment to MRTLY")); comments.Add(new CommentItem("NODE", "MRLY", "Comment to TGT")); AttributeCollection attributes = new AttributeCollection(); attributes.Add(new AttributeItem("Address", "NODE", "STRING", "A Node-hoz tartizó cím", "Address", "[0..64]")); attributes.Add(new AttributeItem("DeviceNetAddress", "NODE", "STRING", "DeviceNetAddress Node-hoz tartizó cím", "DeviceNet address", "[0..64]")); attributes.Add(new AttributeItem("UseAdapterSerialNumber", "NODE", "STRING", "Előírja hogy ha több adapter van a akkor melyiket használja", "Adapter Serial Number", "SerialNumber")); DataSet dataSet = new DataSet("Database"); //dataSet.BeginInit(); /*Nodes*/ /*NodeNameColumnPK, AddressColumn */ DataTable nodesDataTable = ToDataTable(nodes, "Nodes"); nodesDataTable.PrimaryKey = new DataColumn[] { nodesDataTable.Columns["Name"] }; dataSet.Tables.Add(nodesDataTable); /*Comments*/ /*Object - ObjectName PK, Content*/ DataTable commentsDataTable = ToDataTable(comments, "Comments"); nodesDataTable.PrimaryKey = new DataColumn[] { nodesDataTable.Columns["Object"], nodesDataTable.Columns["ObjectName"] }; dataSet.Tables.Add(commentsDataTable); /*Attriubtes*/ /*Object - Name PK, Type, ToolTip, ShowName, Unit, Comment*/ DataTable attributesDataTable = ToDataTable(attributes, "Attributes"); attributesDataTable.PrimaryKey = new DataColumn[] { attributesDataTable.Columns["Object"], attributesDataTable.Columns["Name"] }; dataSet.Tables.Add(attributesDataTable); /*Node View*/ /*Name, Comment*/ DataTable nodesViewDataTable = new DataTable("NodesView"); DataColumn nodeNameColumn = new DataColumn("Name", typeof(string)); nodesViewDataTable.Columns.Add(nodeNameColumn); DataColumn commentColumn = new DataColumn("Comment", typeof(string)); nodesViewDataTable.Columns.Add(commentColumn); //ForeignKeyConstraint commentFK = new ForeignKeyConstraint("First", // DataRelation commentRelation = new DataRelation("A", dataSet.Tables.Add(nodesViewDataTable); //var l = dataSet.GetChanges(); dataSet.AcceptChanges(); //var i = dataSet.GetChanges(); dataGridViewBackgorundText1.DataSource = dataSet; dataGridViewBackgorundText1.DataMember = "NodesView"; //ForeignKeyConstraint commentFK = new ForeignKeyConstraint("First", // DataRelation nodeCommentsRelation = //dataGridViewBackgorundText1.DataSource = dataSet.DefaultViewManager; //new NodeCollectionView() { new NodeItemView() }; //dataGridViewBackgorundText1.Da //dataGridViewBackgorundText1.AutoGenerateColumns = true; }
internal CommentCollection GetCommentsFor(string entryId, DataManager data) { Load(data); CommentCollection filtered = new CommentCollection(); foreach (Comment c in Comments) { if (c.TargetEntryId.ToUpper() == entryId.ToUpper()) { filtered.Add(c); } } return filtered; }
protected CommentCollection GetComments(Feed feed) { CommentCollection result; if (feedComments.TryGetValue(feed.ID, out result)) { return(result); } CommentType type = CommentBO.Instance.GetCommentType(feed.AppID, feed.ActionType); if (comments == null) { List <int> commentIDs = new List <int>(); foreach (Feed tempFeed in FeedList) { if (tempFeed.CommentIDs.Count == 0) { continue; } commentIDs.AddRange(tempFeed.CommentIDs); } CommentCollection temp = CommentBO.Instance.GetComments(commentIDs); CommentBO.Instance.ProcessKeyword(temp, ProcessKeywordMode.TryUpdateKeyword); WaitForFillSimpleUsers <Comment>(temp); comments = new Dictionary <CommentType, Dictionary <int, CommentCollection> >(); foreach (Comment comment in temp) { if (comment.IsApproved == false) { continue; } Dictionary <int, CommentCollection> tempComments; if (comments.TryGetValue(comment.Type, out tempComments) == false) { tempComments = new Dictionary <int, CommentCollection>(); CommentCollection tempItems = new CommentCollection(); tempItems.Add(comment); tempComments.Add(comment.TargetID, tempItems); comments.Add(comment.Type, tempComments); } else { CommentCollection tempItems; if (tempComments.TryGetValue(comment.TargetID, out tempItems) == false) { tempItems = new CommentCollection(); tempItems.Add(comment); tempComments.Add(comment.TargetID, tempItems); } else { tempItems.Add(comment); } } } } if (feed.ID == CommentFeedID && GetCommentCount > DefaultGetCommentCount) { int count = GetCommentCount - DefaultGetCommentCount; result = CommentBO.Instance.GetComments(feed.CommentTargetID, type, count, feed.CommentCount <= count); WaitForFillSimpleUsers <Comment>(result); CommentBO.Instance.ProcessKeyword(result, ProcessKeywordMode.TryUpdateKeyword); } else { Dictionary <int, CommentCollection> resultDic; if (comments.TryGetValue(type, out resultDic)) { if (resultDic.TryGetValue(feed.CommentTargetID, out result) == false) { result = new CommentCollection(); } } else { result = new CommentCollection(); } } feedComments.Add(feed.ID, result); SubmitFillUsers(); return(result); }
protected CommentCollection GetComments(Feed feed) { CommentCollection result; if (feedComments.TryGetValue(feed.ID, out result)) return result; CommentType type = CommentBO.Instance.GetCommentType(feed.AppID, feed.ActionType); if (comments == null) { List<int> commentIDs = new List<int>(); foreach (Feed tempFeed in FeedList) { if (tempFeed.CommentIDs.Count == 0) continue; commentIDs.AddRange(tempFeed.CommentIDs); } CommentCollection temp = CommentBO.Instance.GetComments(commentIDs); CommentBO.Instance.ProcessKeyword(temp, ProcessKeywordMode.TryUpdateKeyword); WaitForFillSimpleUsers<Comment>(temp); comments = new Dictionary<CommentType, Dictionary<int, CommentCollection>>(); foreach (Comment comment in temp) { if (comment.IsApproved == false) continue; Dictionary<int, CommentCollection> tempComments; if (comments.TryGetValue(comment.Type, out tempComments) == false) { tempComments = new Dictionary<int, CommentCollection>(); CommentCollection tempItems = new CommentCollection(); tempItems.Add(comment); tempComments.Add(comment.TargetID, tempItems); comments.Add(comment.Type, tempComments); } else { CommentCollection tempItems; if (tempComments.TryGetValue(comment.TargetID, out tempItems) == false) { tempItems = new CommentCollection(); tempItems.Add(comment); tempComments.Add(comment.TargetID, tempItems); } else { tempItems.Add(comment); } } } } if (feed.ID == CommentFeedID && GetCommentCount > DefaultGetCommentCount) { int count = GetCommentCount - DefaultGetCommentCount; result = CommentBO.Instance.GetComments(feed.CommentTargetID, type, count, feed.CommentCount <= count); WaitForFillSimpleUsers<Comment>(result); CommentBO.Instance.ProcessKeyword(result, ProcessKeywordMode.TryUpdateKeyword); } else { Dictionary<int, CommentCollection> resultDic; if (comments.TryGetValue(type, out resultDic)) { if (resultDic.TryGetValue(feed.CommentTargetID, out result) == false) result = new CommentCollection(); } else result = new CommentCollection(); } feedComments.Add(feed.ID, result); SubmitFillUsers(); return result; }