Esempio n. 1
0
        /// <summary>
        /// 行业圈子讨论新增
        /// </summary>
        /// <param name="topicInfo">讨论对象</param>
        /// <param name="noticeUserView">提醒人对象</param>
        /// <returns></returns>
        public bool Insert(TopicInfo topicInfo, NoticeUserView noticeUserView)
        {
            Contract.Requires <ArgumentNullException>(topicInfo != null, "参数topicInfo:不能为空");
            bool          result   = false;
            List <string> sqls     = new List <string>();
            string        message  = string.Empty;
            string        message1 = string.Empty;
            string        message2 = string.Empty;

            /*------------------------------微博初始化值-----------------------------------*/
            //有效性
            topicInfo.Valid = ((int)MiicValidTypeSetting.Valid).ToString();
            //评论总数
            topicInfo.MessageCount = 0;
            /*------------------------------用户初始化值-----------------------------------*/

            sqls.Add(DBService.InsertSql(topicInfo, out message1));

            if (noticeUserView != null)
            {
                foreach (var item in noticeUserView.Noticers.AsEnumerable())
                {
                    sqls.Add(DBService.InsertSql <NoticeInfo>(new NoticeInfo()
                    {
                        ID            = Guid.NewGuid().ToString(),
                        NoticerID     = item.UserID,
                        NoticerName   = item.UserName,
                        Source        = ((int)noticeUserView.NoticeSource).ToString(),
                        NoticeType    = ((int)noticeUserView.NoticeType).ToString(),
                        PublisherID   = topicInfo.CreaterID,
                        PublisherName = topicInfo.CreaterName,
                        PublishID     = topicInfo.ID,
                        PublishTime   = topicInfo.CreateTime,
                        ReadStatus    = ((int)MiicReadStatusSetting.UnRead).ToString()
                    }, out message2));
                }
            }

            try
            {
                result = dbService.excuteSqls(sqls, out message);
            }
            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
                });
            }
            if (result == true)
            {
                InsertCache(topicInfo);
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 行业圈子讨论更新
        /// </summary>
        /// <param name="topicInfo">讨论对象</param>
        /// <param name="noticeUserView">提醒人对象</param>
        /// <returns></returns>
        public bool Update(TopicInfo topicInfo, NoticeUserView noticeUserView)
        {
            Contract.Requires <ArgumentNullException>(topicInfo != null, "参数topicInfo:不能为空");
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(topicInfo.ID), "参数topicInfo.ID:不能为空");
            bool          result   = false;
            List <string> sqls     = new List <string>();
            string        message  = string.Empty;
            string        message1 = string.Empty;
            string        message2 = string.Empty;

            try
            {
                TopicInfo tempTopicInfo = ((ICommon <TopicInfo>) this).GetInformation(topicInfo.ID);
                sqls.Add(DBService.UpdateSql <TopicInfo>(topicInfo, out message1));

                if (noticeUserView != null)
                {
                    //@人员
                    foreach (var item in noticeUserView.Noticers.AsEnumerable())
                    {
                        sqls.Add(DBService.InsertSql <NoticeInfo>(new NoticeInfo()
                        {
                            ID            = Guid.NewGuid().ToString(),
                            NoticerID     = item.UserID,
                            NoticerName   = item.UserName,
                            Source        = ((int)noticeUserView.NoticeSource).ToString(),
                            NoticeType    = ((int)noticeUserView.NoticeType).ToString(),
                            PublisherID   = topicInfo.CreaterID,
                            PublisherName = topicInfo.CreaterName,
                            PublishID     = topicInfo.ID,
                            PublishTime   = topicInfo.CreateTime,
                            ReadStatus    = ((int)MiicReadStatusSetting.UnRead).ToString()
                        }, out message2));
                    }
                }

                result = dbService.excuteSqls(sqls, out message);
            }
            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
                });
            }
            if (result == true)
            {
                DeleteCache(true, o => o.ID == topicInfo.ID, o => o.TopicID == topicInfo.ID);
            }
            return(result);
        }
Esempio n. 3
0
    public bool Submit(TopicInfo topicInfo, NoticeUserView noticeUserView)
    {
        bool      result   = false;
        TopicInfo tempInfo = ((ICommon <TopicInfo>)ImessageInfo).GetInformation(topicInfo.ID);

        if (tempInfo == null)
        {
            topicInfo.CreateTime  = DateTime.Now;
            topicInfo.CreaterName = this.UserName;
            topicInfo.CreaterID   = this.UserID;
            result = ImessageInfo.Insert(topicInfo, noticeUserView);
        }
        else
        {
            result = ImessageInfo.Update(topicInfo, noticeUserView);
        }
        return(result);
    }
Esempio n. 4
0
    public async Task Send(string publishID, string title, NoticeUserView noticeUser)
    {
        MiicSafeCollection <string> noticerIDs = new MiicSafeCollection <string>();
        string userID   = Context.RequestCookies["MiicID"].Value;
        string userName = Context.RequestCookies["MiicUserName"].Value;

        foreach (var userIDItem in noticeUser.Noticers)
        {
            foreach (var item in users.Where(o => o == userIDItem.UserID))
            {
                noticerIDs.Add(item);
            }
        }
        if (noticerIDs.Count > 0)
        {
            DataTable dt = ((NoticeInfoDao)InoticeInfo).GetUnReadNoticeID(new GetUnreadNoticeView()
            {
                PublishID   = publishID,
                Source      = ((int)noticeUser.NoticeSource).ToString(),
                NoticeType  = ((int)noticeUser.NoticeType).ToString(),
                PublisherID = userID,
                NoticerID   = noticerIDs.AsEnumerable().ToList()
            });
            Task[] list       = new Task[noticerIDs.Count];
            int    index      = 0;
            Task   taskResult = null;
            try
            {
                foreach (var item in dt.AsEnumerable())
                {
                    foreach (var noticer in noticerIDs)
                    {
                        if (item[Config.Attribute.GetSqlColumnNameByPropertyName <NoticeInfo, string>(o => o.NoticerID)].ToString() == noticer)
                        {
                            list[index] = Clients.User(noticer).Recieve(new { ID = item[Config.Attribute.GetSqlColumnNameByPropertyName <NoticeInfo, string>(o => o.ID)].ToString(), PublishID = publishID, Title = title, UserID = userID, UserName = userName });
                            index++;
                        }
                    }
                }
                await(taskResult = Task.WhenAll(list));
            }
            catch (Exception ex)
            {
                Config.IlogicLogService.Write(new LogicLog()
                {
                    AppName       = Config.AppName,
                    ClassName     = ClassName,
                    NamespaceName = NamespaceName,
                    MethodName    = MethodBase.GetCurrentMethod().Name,
                    Message       = "Hub Error:" + ex.Message,
                    Oper          = Config.Oper
                });
                foreach (var extask in taskResult.Exception.InnerExceptions)
                {
                    Config.IlogicLogService.Write(new LogicLog()
                    {
                        AppName       = Config.AppName,
                        ClassName     = ClassName,
                        NamespaceName = NamespaceName,
                        MethodName    = MethodBase.GetCurrentMethod().Name,
                        Message       = ex.Message,
                        Oper          = Config.Oper
                    });
                }
            }
        }
    }