Ejemplo n.º 1
0
        /// <summary>
        /// 查询当前登录人员对指定行业圈子信息的点赞信息
        /// </summary>
        /// <param name="communityBehaviorView">用户行为(点赞)视图</param>
        /// <returns>点赞信息</returns>
        public PraiseInfo GetUserPraiseInfo(MyCommunityBehaviorView communityBehaviorView)
        {
            Contract.Requires <ArgumentNullException>(communityBehaviorView != null, "参数communityBehaviorView:不能为空");
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(communityBehaviorView.PublishID), "参数communityBehaviorView.PublishID:不能为空");
            PraiseInfo result  = null;
            string     message = string.Empty;
            MiicConditionCollections condition = communityBehaviorView.visitor(this);
            MiicColumn            praiseAll    = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <PraiseInfo>());
            MiicColumnCollections columns      = new MiicColumnCollections();

            columns.Add(praiseAll);
            try
            {
                result = items.Find(o => o.PublishID == communityBehaviorView.PublishID && o.PraiserID == communityBehaviorView.LoginUserID);
                if (result == null)
                {
                    DataTable dt = dbService.GetInformations <PraiseInfo>(columns, condition, out message);
                    if (dt != null && dt.Rows.Count == 1)
                    {
                        result = new PraiseInfo()
                        {
                            ID          = dt.Rows[0][Config.Attribute.GetSqlColumnNameByPropertyName <PraiseInfo, string>(o => o.ID)].ToString(),
                            PraiserID   = dt.Rows[0][Config.Attribute.GetSqlColumnNameByPropertyName <PraiseInfo, string>(o => o.PraiserID)].ToString(),
                            PraiserName = dt.Rows[0][Config.Attribute.GetSqlColumnNameByPropertyName <PraiseInfo, string>(o => o.PraiserName)].ToString(),
                            PraiseTime  = (DateTime?)dt.Rows[0][Config.Attribute.GetSqlColumnNameByPropertyName <PraiseInfo, DateTime?>(o => o.PraiseTime)],
                            PublishID   = dt.Rows[0][Config.Attribute.GetSqlColumnNameByPropertyName <PraiseInfo, string>(o => o.PublishID)].ToString(),
                            SortNo      = (int?)dt.Rows[0][Config.Attribute.GetSqlColumnNameByPropertyName <PraiseInfo, int?>(o => o.SortNo)]
                        };
                    }
                    else
                    {
                        result = null;
                    }

                    if (result != null)
                    {
                        InsertCache(result);
                    }
                }
                else
                {
                    string serializer = Config.Serializer.Serialize(result);
                    result = Config.Serializer.Deserialize <PraiseInfo>(serializer);
                }
            }
            catch (Exception ex)
            {
                Config.IlogicLogService.Write(new LogicLog()
                {
                    AppName       = Config.AppName,
                    ClassName     = ClassName,
                    NamespaceName = NamespaceName,
                    MethodName    = MethodBase.GetCurrentMethod().Name,
                    Message       = ex.Message,
                    Oper          = Config.Oper
                });
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 判断当前用户是否对制定行业圈子信息收藏
        /// </summary>
        /// <param name="communityBehaviorView"></param>
        /// <returns></returns>
        public bool IsCollect(MyCommunityBehaviorView communityBehaviorView)
        {
            Contract.Requires <ArgumentNullException>(communityBehaviorView != null, "参数communityBehaviorView:不能为空");
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(communityBehaviorView.PublishID), "参数communityBehaviorView.PublishID:不能为空");
            bool   result  = false;
            string message = string.Empty;
            MiicConditionCollections condition = communityBehaviorView.visitor(this);
            MiicColumn collectID = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <CollectInfo>(),
                                                  Config.Attribute.GetSqlColumnNameByPropertyName <CollectInfo, string>(o => o.ID));

            try
            {
                int count = dbService.GetCount <CollectInfo>(collectID, condition, out message);
                if (count == 0)
                {
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                Config.IlogicLogService.Write(new LogicLog()
                {
                    AppName       = Config.AppName,
                    ClassName     = ClassName,
                    NamespaceName = NamespaceName,
                    MethodName    = MethodBase.GetCurrentMethod().Name,
                    Message       = ex.Message,
                    Oper          = Config.Oper
                });
            }
            return(result);
        }