Esempio n. 1
0
        public static void InsertTest()
        {
            string body = "-你是谁fdfd😚😎😋🤥🤗😋fdfdf😉🙂🤗fdfdfd";

            PostMST entity = new PostMST
            {
                MemberName  = "17704007627",
                CurrentType = 30,
                Image       = string.Empty,
                Body        = body,
                PostKey     = Guid.NewGuid(),
                CreateTime  = DateTime.Now,
                Remark      = "谁😚😎😋🤥",
            };

            int flag = DMS.Create <PostMST>()
                       .Insert(entity);


            //for (int i = 0; i < 2; i++)
            //{
            //    pro_PostMST_Insert param = new pro_PostMST_Insert()
            //    {
            //        MemberName = "17704007627",
            //        CurrentType = 30,
            //        Image = "201712/201712941238110228975616.jpg",
            //        Body = i + body,
            //        PostKey = Guid.NewGuid(),
            //        CreateTime = DateTime.Now,
            //    };
            //    DMSStoredProcedureHandler s = new DMSStoredProcedureHandler();
            //    string errMsg = string.Empty;
            //    bool result = s.ExecuteNoQuery(param, ref errMsg);

            //    if (result)
            //    {
            //    }
            //}
        }
Esempio n. 2
0
        /// <summary>
        /// 定时任务
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task <SendTaskReply> SendTaskMessage(SendTaskRequest request, ServerCallContext context)
        {
            SendTaskReply result = new SendTaskReply();

            List <TaskMessage> listTasks = DMS.Create <TaskMessage>().Where(p => p.SendStatu == 0 && p.SendTime <= DateTime.Now && p.DeleteFlag == false).ToList();
            int            success = 0, err = 0;
            string         msg  = string.Empty;
            RabbitMQHelper help = new RabbitMQHelper();

            listTasks.ForEach(p =>
            {
                try
                {
                    if (p.TaskMessageType == EnumTaskMessageType.Notice)
                    {
                        Notice notice = new Notice()
                        {
                            SendMessage     = p.SendMessage,
                            Users           = p.Users,
                            TagMessage      = p.TagMessage,
                            Title           = p.Title,
                            Body            = p.Body,
                            TaskMessageType = p.TaskMessageType,
                            UserType        = p.UserType,
                            TaskMessageID   = p.TaskMessageID
                        };
                        help.Send <Notice>("Notice", notice);
                    }
                    else
                    {
                        Activity activity = new Activity()
                        {
                            SendMessage     = p.SendMessage,
                            Users           = p.Users,
                            TagMessage      = p.TagMessage,
                            CurrentType     = p.CurrentType,
                            Relation        = p.RelationID,
                            TaskMessageType = p.TaskMessageType,
                            UserType        = p.UserType,
                            TaskMessageID   = p.TaskMessageID
                        };
                        help.Send <Activity>("Activity", activity);
                    }

                    success++;
                }
                catch (Exception ex)
                {
                    err++;
                    msg = ex.Message;
                }
            });
            //更新状态
            DMS.Create <TaskMessage>().Edit(new TaskMessage()
            {
                SendStatu = 1
            }, p => p.SendStatu == 0 && p.SendTime <= DateTime.Now && p.DeleteFlag == false);
            result.SuccessCount = success;
            result.ErrCount     = err;
            result.ErrMsg       = msg;
            return(Task.FromResult <SendTaskReply>(result));
        }