public bool Insert(MyCenterNewsModel model)
 {
     try
     {
         return(handler.Insert(model));
     }
     catch (Exception ex)
     {
         logger.Log(Level.Error, string.Format("方法:{0},错误:{1}", "MyCenterNewsManager.Insert", ex.Message), model);
         return(false);
     }
 }
예제 #2
0
        public static bool Insert(SqlConnection connection, MyCenterNewsModel model)
        {
            if (model != null)
            {
                string strSql = " INSERT INTO Gungnir..tbl_My_Center_News({0}) VALUES({1}) ";

                Dictionary <string, object> dicParams = new Dictionary <string, object>();

                if (!string.IsNullOrEmpty(model.UserObjectID))
                {
                    dicParams.Add("UserObjectID", model.UserObjectID);
                }
                if (!string.IsNullOrEmpty(model.News))
                {
                    dicParams.Add("News", model.News);
                }
                if (!string.IsNullOrEmpty(model.Type))
                {
                    dicParams.Add("Type", model.Type);
                }
                if (DateTime.Compare(model.CreateTime, DateTime.MinValue) > 0)
                {
                    dicParams.Add("CreateTime", model.CreateTime);
                }
                if (DateTime.Compare(model.UpdateTime, DateTime.MinValue) > 0)
                {
                    dicParams.Add("UpdateTime", model.UpdateTime);
                }
                if (!string.IsNullOrEmpty(model.Title))
                {
                    dicParams.Add("Title", model.Title);
                }
                if (!string.IsNullOrEmpty(model.HeadImage))
                {
                    dicParams.Add("HeadImage", model.HeadImage);
                }
                if (!string.IsNullOrEmpty(model.IOSKey))
                {
                    dicParams.Add("IOSKey", model.IOSKey);
                }
                if (!string.IsNullOrEmpty(model.IOSValue))
                {
                    dicParams.Add("IOSValue", model.IOSValue);
                }
                if (!string.IsNullOrEmpty(model.androidKey))
                {
                    dicParams.Add("androidKey", model.androidKey);
                }
                if (!string.IsNullOrEmpty(model.androidValue))
                {
                    dicParams.Add("androidValue", model.androidValue);
                }
                //if (DateTime.Compare(model.BeginShowTime, DateTime.MinValue) > 0) { dicParams.Add("BeginShowTime", model.BeginShowTime); }
                dicParams.Add("isdelete", model.isdelete);

                StringBuilder       strSqlField = new StringBuilder();          //字段
                StringBuilder       strSqlWhere = new StringBuilder();          //条件
                List <SqlParameter> sqlParams   = new List <SqlParameter>();    //参数值

                for (int i = 0; i < dicParams.Count; i++)
                {
                    var dicKey   = dicParams.ElementAt(i).Key;
                    var dicValue = dicParams.ElementAt(i).Value;
                    sqlParams.Add(new SqlParameter("@" + dicKey, dicValue));

                    strSqlField.AppendFormat("{0},", dicKey);
                    strSqlWhere.AppendFormat("{0},", "@" + dicKey);
                }
                strSql = string.Format(strSql, strSqlField.ToString().TrimEnd(','), strSqlWhere.ToString().TrimEnd(','));
                return(SqlHelper.ExecuteNonQuery(connection, CommandType.Text, strSql, sqlParams.ToArray()) > 0 ? true : false);
            }
            return(false);
        }
        public bool Insert(MyCenterNewsModel model)
        {
            Func <SqlConnection, bool> action = (connection) => MyCenterNewsDAL.Insert(connection, model);

            return(dbManager.Execute(action));
        }
예제 #4
0
        /// <summary>
        /// 异步插入审核通知
        /// </summary>
        public void InsertMyCenterNewsAsync(IEnumerable <int> IDs)
        {
            try
            {
                Guid _UserObjectID = Guid.Empty;
                IEnumerable <ArticleComment> _ArticleComment = manager.GetByIDs(IDs);
                bool IsInsertNews = false,    //是否可以插入推送
                     IsQuestionReply = false; //是否为问题或提问的回复
                string _IOSKey = "", _IOSValue = "", _AndroidKey = "", _AndroidValue = "";

                foreach (var item in _ArticleComment)
                {
                    #region app key value 转换

                    if (item.PType == 0 && item.ParentID > 0)  //文章回复,只推送文章评论的回复
                    {
                        IsInsertNews = true;

                        _AndroidKey   = "cn.TuHu.Activity.Found.DiscoveryH5Activity";
                        _AndroidValue = "[{'PKID':" + item.PKID + ",'Category':'" + item.Category + "','Title':'" + item.Title + "','keyboard':1,'AddClick':false}]";
                        _IOSKey       = "THDiscoverCommentVC";
                        _IOSValue     = "{ \"pkid\":" + item.PKID + ", \"categoryName\":\"" + item.Category + " \", \"mytitle\": \"" + item.Title + "\"}";
                    }
                    else if ((item.PType == 1 && item.ParentID > 0) || (item.PType == 2 && (item.ParentID > 0 && item.TopID > 0)))  //专题相关,排除专题提问本身
                    {
                        IsInsertNews = true;

                        if (item.ParentID > 0 && item.TopID > 0)
                        {
                            IsQuestionReply = true;
                        }                                                                    //专题问题评论的回复

                        _AndroidKey   = "cn.TuHu.Activity.NewFound.Found.DiscoveryCommentResListAtivity";
                        _AndroidValue = "[{'answerId':" + item.ID + ",'questionType':4}]";
                        _IOSKey       = "Tuhu.THAnswerVC";
                        _IOSValue     = "{ \"answerID\":" + item.ID + ", \"type\":\"4\"}";
                    }
                    else if (item.PType == 2 && item.ParentID == 0 && item.TopID == 0)  //说说相关
                    {
                        //TODO: 暂无说说评论无推送
                    }
                    else if (item.PType == 3) //全局问题相关
                    {
                        IsInsertNews = true;

                        if (item.ParentID > 0 && item.TopID > 0)
                        {
                            IsQuestionReply = true;
                        }                                                                    //全局问题评论回复

                        _AndroidKey   = "cn.TuHu.Activity.NewFound.Found.DiscoveryCommentResListAtivity";
                        _AndroidValue = "[{'answerId':" + item.ID + ",'questionType':3}]";
                        _IOSKey       = "Tuhu.THAnswerVC";
                        _IOSValue     = "{ \"answerID\":" + item.ID + ", \"type\":\"3\"}";
                    }
                    #endregion

                    if (IsInsertNews && !string.IsNullOrEmpty(item.UserInfos))
                    {
                        string[] UserInfosArr = item.UserInfos.Split('|');

                        if (UserInfosArr != null)
                        {
                            Guid.TryParse(UserInfosArr[1], out _UserObjectID);
                        }

                        MyCenterNewsModel model = new MyCenterNewsModel()
                        {
                            UserObjectID = _UserObjectID.ToString("D"),
                            News         = " ",
                            Type         = "3私信",
                            CreateTime   = DateTime.Now,
                            UpdateTime   = DateTime.Now,
                            Title        = UserNameForPhone(item.UserName) + (item.PType == 0 ? " 回复了你的评论!" : (IsQuestionReply ? " 回复了你的发言!" : " 回答了你的提问!")),
                            HeadImage    = item.UserHead,
                            isdelete     = false,
                            IOSKey       = _IOSKey,
                            IOSValue     = _IOSValue,
                            androidKey   = _AndroidKey,
                            androidValue = _AndroidValue
                        };
                        bool result = InvokeMyCenterNewsManager.Insert(model);
                    }
                }
            }
            catch { }
        }