Пример #1
0
        public static CBB.ExceptionHelper.OperationResult AddActivity(Member mym, ActivityType type, String Title, String Content, bool OnlySaveLastContent)
        {
            try
            {
                MongoDatabase md = MongoDBHelper.MongoDB;
                MongoCollection<ActivityHolder> mc = md.GetCollection<ActivityHolder>("Activity");
                ActivityHolder obj = mc.FindOne(Query.And(Query.EQ("MemberID", mym.ID), Query.EQ("Date", DateTime.Now.Date.ToString())));

                //如果当天没有动态,则新增
                if (obj == null)
                {
                    obj = new ActivityHolder();
                    obj.Date = DateTime.Now.Date.ToString();
                    obj.MemberID = mym.ID;
                    obj.MemberType = mym.MemberType;
                    obj.Activitys = new List<Activity>();
                    obj.Sex = obj.Sex;
                }
                obj.LastOperationTime = DateTime.Now;
                obj.MemberInfomation = mym.MemberInfomation;

                Activity at = null;
                //如果已有相同类别活动,则更新原有活动
                bool alreadyhas = false;
                foreach (Activity atobj in obj.Activitys)
                {
                    if (atobj.type == type)
                    {
                        at = atobj;
                        alreadyhas = true;
                    }
                }
                //否则新增活动
                if (at == null) at = new Activity();

                at.type = type;
                at.ActivityCount++;
                at.Title = Title.Replace("@COUNT", at.ActivityCount.ToString());
                if (at.Content == null) at.Content = new List<string>();
                if (OnlySaveLastContent)
                {
                    at.Content.Clear();
                }

                at.Content.Add(Content);
                at.CreatedTime = DateTime.Now;

                if (!alreadyhas)
                    obj.Activitys.Add(at);

                mc.Save(obj);
                //审核关键字
                //刘安注释,因为会引起图片路径的误判
                //new Moooyo.BiZ.FilterWord.FilterWordController().FilterText(Content, ActivityHolder.GetCollectionName(), obj.ID, "Activitys." + (obj.Activitys.Count - 1) + ".Content." + (at.Content.Count -1));
                string[] arr = Content.Split('|');
                string outtext = String.Empty;
                Moooyo.BiZ.FilterWord.FilterWordController fwc =  new Moooyo.BiZ.FilterWord.FilterWordController();
                bool istrial = false;  //是否要审核
                bool isshift = false;  //是否要更改

                foreach (string i in arr)
                {
                    if (i.IndexOf(".jpg") != -1)
                    {
                        outtext = outtext  +  i + "|";
                    }
                    else
                    {
                        #region
                        string temptext = i;
                        List<string> listdelete = fwc.FilterText(ref temptext, CBB.CheckHelper.FilterWord.word_type.delete);
                        string temptexdelete = temptext;
                        List<string> listshift = fwc.FilterText(ref temptext, CBB.CheckHelper.FilterWord.word_type.shift);
                        List<string> listtrial = fwc.FilterText(ref temptext, CBB.CheckHelper.FilterWord.word_type.trial);
                        if (null != listshift && listshift.Count > 0)
                        {
                            outtext = outtext + "内容审核中..." + "|";
                            if (!istrial)
                                istrial = true;
                            if (!isshift)
                                isshift = true;

                        }
                        else if (null != listtrial && listtrial.Count > 0)
                        {
                            outtext = outtext + temptexdelete + "|";
                            if (!istrial)
                                istrial = true;
                        }
                        else if (null != listdelete && listdelete.Count > 0)
                        {
                            outtext = outtext + temptexdelete + "|";
                            if (!isshift)
                            {
                                isshift = true;
                            }
                        }
                        else
                        {
                            outtext = outtext + i + "|";
                        }
                        # endregion
                    }
                }
                if (istrial && isshift)
                {
                    fwc.AddFilterText(Content, ActivityHolder.GetCollectionName(), obj.ID, "Activitys." + (obj.Activitys.Count - 1) + ".Content." + (at.Content.Count - 1), true, outtext);
                }
                else
                {
                    if (istrial && !isshift)
                    {
                        fwc.AddFilterText(Content, ActivityHolder.GetCollectionName(), obj.ID, "Activitys." + (obj.Activitys.Count - 1) + ".Content." + (at.Content.Count - 1), false, "");
                    }
                    else if (!istrial && isshift)
                    {
                        fwc.UpdateFilterText(ActivityHolder.GetCollectionName(), obj.ID, "Activitys." + (obj.Activitys.Count - 1) + ".Content." + (at.Content.Count - 1), outtext);
                    }

                }

                return new CBB.ExceptionHelper.OperationResult(true);
            }
            catch (System.Exception err)
            {
                throw new CBB.ExceptionHelper.OperationException(
                    CBB.ExceptionHelper.ErrType.SystemErr,
                    CBB.ExceptionHelper.ErrNo.DBOperationError,
                    err);
            }
        }
Пример #2
0
        public static CBB.ExceptionHelper.OperationResult AddActivityRelatedToMe(String mid, Member fromMember, ActivityType type, String Title, String Content, bool OnlySaveLastContent)
        {
            //如果是自己对自己的操作,则直接返回,不保存关联动态。
            if (mid == fromMember.ID) return new CBB.ExceptionHelper.OperationResult(true);

            try
            {
                MongoDatabase md = MongoDBHelper.MongoDB;
                MongoCollection<ActivityHolderRelatedToMe> mc = md.GetCollection<ActivityHolderRelatedToMe>(ActivityHolderRelatedToMe.GetCollectionName());
                ActivityHolderRelatedToMe obj = mc.FindOne(Query.And(Query.EQ("MemberID", mid), Query.EQ("FromMemberID", fromMember.ID), Query.EQ("Date", DateTime.Now.Date.ToString())));

                //如果当天没有动态,则新增
                if (obj == null)
                {
                    obj = new ActivityHolderRelatedToMe();
                    obj.Date = DateTime.Now.Date.ToString();
                    obj.MemberID = mid;
                    obj.FromMemberID = fromMember.ID;
                    obj.Activitys = new List<Activity>();
                }
                obj.LastOperationTime = DateTime.Now;
                obj.FromMemberInfomation = fromMember.MemberInfomation;

                Activity at = null;
                //如果已有相同类别活动,则更新原有活动
                bool alreadyhas = false;
                foreach (Activity atobj in obj.Activitys)
                {
                    if (atobj.type == type)
                    {
                        at = atobj;
                        alreadyhas = true;
                    }
                }
                //否则新增活动
                if (at == null) at = new Activity();

                at.type = type;
                at.ActivityCount++;
                at.Title = Title.Replace("@COUNT", at.ActivityCount.ToString());
                if (at.Content == null) at.Content = new List<string>();
                if (OnlySaveLastContent)
                {
                    at.Content.Clear();
                }

                at.Content.Add(Content);
                at.CreatedTime = DateTime.Now;

                if (!alreadyhas)
                    obj.Activitys.Add(at);

                mc.Save(obj);
                //审核关键字
                string[] arr = Content.Split('|');
                string outtext = String.Empty;
                Moooyo.BiZ.FilterWord.FilterWordController fwc = new Moooyo.BiZ.FilterWord.FilterWordController();
                bool istrial = false;  //是否要审核
                bool isshift = false;  //是否要更改

                foreach (string i in arr)
                {
                    ObjectId objid;
                    if (i.IndexOf(".jpg") != -1 || ObjectId.TryParse(i,out objid))
                    {
                        outtext = outtext + i + "|";
                    }
                    else
                    {
                        #region
                        string temptext = i;
                        List<string> listdelete = fwc.FilterText(ref temptext, CBB.CheckHelper.FilterWord.word_type.delete);
                        string temptexdelete = temptext;
                        List<string> listshift = fwc.FilterText(ref temptext, CBB.CheckHelper.FilterWord.word_type.shift);
                        List<string> listtrial = fwc.FilterText(ref temptext, CBB.CheckHelper.FilterWord.word_type.trial);
                        if (null != listshift && listshift.Count > 0)
                        {
                            outtext = outtext + "内容审核中..." + "|";
                            if (!istrial)
                                istrial = true;
                            if (!isshift)
                                isshift = true;

                        }
                        else if (null != listtrial && listtrial.Count > 0)
                        {
                            outtext = outtext + temptexdelete + "|";
                            if (!istrial)
                                istrial = true;
                        }
                        else if (null != listdelete && listdelete.Count > 0)
                        {
                            outtext = outtext + temptexdelete + "|";
                            if (!isshift)
                            {
                                isshift = true;
                            }
                        }
                        else
                        {
                            outtext = outtext + i + "|";
                        }
                        # endregion
                    }
                }
                if (istrial && isshift)
                {
                    fwc.AddFilterText(Content, ActivityHolderRelatedToMe.GetCollectionName(), obj.ID, "Activitys." + (obj.Activitys.Count - 1) + ".Content." + (at.Content.Count - 1), true, outtext);
                }
                else
                {
                    if (istrial && !isshift)
                    {
                        fwc.AddFilterText(Content, ActivityHolderRelatedToMe.GetCollectionName(), obj.ID, "Activitys." + (obj.Activitys.Count - 1) + ".Content." + (at.Content.Count - 1), false, "");
                    }
                    else if (!istrial && isshift)
                    {
                        fwc.UpdateFilterText(ActivityHolderRelatedToMe.GetCollectionName(), obj.ID, "Activitys." + (obj.Activitys.Count - 1) + ".Content." + (at.Content.Count - 1), outtext);
                    }

                }

                //增加计数器
                BiZ.MemberManager.MemberManager.ModifyUnReadActivitysAboutMeCount(mid, MemberManager.StatusModifyType.Add);

                return new CBB.ExceptionHelper.OperationResult(true);
            }
            catch (System.Exception err)
            {
                throw new CBB.ExceptionHelper.OperationException(
                    CBB.ExceptionHelper.ErrType.SystemErr,
                    CBB.ExceptionHelper.ErrNo.DBOperationError,
                    err);
            }
        }