예제 #1
0
        public MyResult Create(string par0, string par1)
        {
            Assembly asmb   = Assembly.GetAssembly(typeof(ServiceReturn));
            Type     type   = asmb.GetType(par0);
            object   obj    = JsonConvert.DeserializeObject(par1, type);
            object   newObj = DBBase.Create(obj);

            if (type == typeof(ETask))
            {
                ETask task = (ETask)obj;
                if (MySession.UserID != task.ExecutorID && task.ExecutorID != 0)
                {
                    EUser         myuser     = DBBase.Get <EUser>(MySession.UserID);
                    EUser         excuteuser = DBBase.Get <EUser>(task.ExecutorID);
                    List <string> ulist      = new List <string>();
                    ulist.Add(excuteuser.PushClientID);
                    PushMessageToList.PushToList(task.Title, "指派人" + myuser.Name, ulist, true);
                }
            }
            else if (type == typeof(EPlan))
            {
                EPlan       plan       = (EPlan)obj;
                EProject    project    = DBBase.Get <EProject>(plan.ProjectID);
                EUserSearch userSearch = new EUserSearch()
                {
                    IsDefault = false, Name = project.Name + "-" + plan.Name, UserID = MySession.UserID, ProjectID = plan.ProjectID, PlanID = plan.ID
                };
                DBBase.Create(userSearch);
            }
            return(ServiceResult(newObj));
        }
예제 #2
0
        public MyResult TaskProcess(int par0, int par1, int par2, string par3)
        {
            ETask task = DBBase.Get <ETask>(par0);

            task.ExecutorID = par1;
            task.State      = par2;
            ETaskTransfer taskTransfer = new ETaskTransfer()
            {
                TaskID           = task.ID,
                AppointPersonID  = MySession.UserID,
                AssignedPersonID = par1,
                CreateTime       = System.DateTime.Now,
                ToState          = task.State,
                Note             = par3
            };

            DBBase.Change(task);
            DBBase.Create(taskTransfer);

            if (MySession.UserID != task.ExecutorID && task.ExecutorID != 0)
            {
                EUser         myuser     = DBBase.Get <EUser>(MySession.UserID);
                EUser         excuteuser = DBBase.Get <EUser>(task.ExecutorID);
                List <string> ulist      = new List <string>();
                ulist.Add(excuteuser.PushClientID);
                PushMessageToList.PushToList(task.Title, "指派人" + myuser.Name, ulist, true);
            }

            return(ServiceResult(task.ID));
        }
예제 #3
0
        static void SendRemind(object sender, System.Timers.ElapsedEventArgs e)
        {
            List <ETask> taskList = DBBase.QueryCustom <ETask>("select * from task where IsReminded=0 and Remind<>'' and Remind is not null");

            foreach (var t in taskList)
            {
                try
                {
                    DateTime remindTime = t.BeginTime.Date.AddHours(int.Parse(t.Remind));
                    if (DateTime.Now > remindTime)
                    {
                        t.IsReminded = true;
                        DBBase.Change(t);

                        EUser         excuteuser = DBBase.Get <EUser>(t.ExecutorID);
                        List <string> ulist      = new List <string>();
                        ulist.Add(excuteuser.PushClientID);
                        PushMessageToList.PushToList("你有一个任务需要办理", t.Title, ulist, true);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(t.Title + " 任务提醒出错" + ex.StackTrace);
                }
            }
        }
예제 #4
0
        public string TestPush(string id, string content)
        {
            List <string> ulist = new List <string>();

            ulist.Add(id);
            PushMessageToList.PushToList("haili:任务", content, ulist, true);
            return("ok");
        }
예제 #5
0
        public MyResult SendMessage(string par0)
        {
            Type     type   = typeof(EMessage);
            object   obj    = JsonConvert.DeserializeObject(par0, type);
            EMessage newObj = DBBase.Create(obj) as EMessage;

            //发送推送
            EUser myuser = DBBase.Get <EUser>(newObj.SenderID);

            if (newObj.Type == MessageType.OneToOne)
            {
                //接收者加个提示
                ENewTips tips = new ENewTips()
                {
                    UserID = newObj.ReceiverID, Type = newObj.Type, OwnerID = newObj.SenderID
                };
                DBBase.Create(tips);
                //推送给接收者
                EUser         excuteuser = DBBase.Get <EUser>(newObj.ReceiverID);
                List <string> ulist      = new List <string>();
                ulist.Add(excuteuser.PushClientID);
                PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, false);
                PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, true);
            }
            else if (newObj.Type == MessageType.Project)
            {
                List <EUser>  teamUsers = DBBase.QueryCustom <EUser>("select * from user where ID in(select UserID from projectteam where ProjectID=" + newObj.ReceiverID + ")");
                List <string> ulist     = new List <string>();
                foreach (var u in teamUsers)
                {
                    ulist.Add(u.PushClientID);
                    //每个人加个提示
                    ENewTips tips = new ENewTips()
                    {
                        UserID = u.ID, Type = newObj.Type, OwnerID = newObj.ReceiverID
                    };
                    DBBase.Create(tips);
                }
                //推送给所有接收者
                PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, false);
                PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, true);
            }

            return(ServiceResult("ok"));
        }