コード例 #1
0
        /// <summary>附加待办信息新的接收人</summary>
        /// <param name="applicationId">第三方系统帐号标识</param>
        /// <param name="taskCode">任务编号</param>
        /// <param name="receiverIds">接收者</param>
        /// <param name="notificationOptions">通知选项</param>
        public void SendAppendRange(string applicationId, string taskCode, string receiverIds, string notificationOptions)
        {
            TaskWorkInfo task = this.FindOneByTaskCode(applicationId, taskCode);

            if (task == null)
            {
                throw new Exception("【ApplicationId " + applicationId + " - TaskCode " + taskCode + "】任务不存在。");
            }

            string[] keys = receiverIds.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string key in keys)
            {
                if (!string.IsNullOrEmpty(key))
                {
                    task.AddReceiver(key);
                }
            }

            task.CreateDate = DateTime.Now;

            this.provider.Insert(task);

            // 发送通知
            this.Notification(task, receiverIds, notificationOptions);
        }
コード例 #2
0
        /// <summary>发送一对多的待办信息</summary>
        /// <param name="taskCode">任务编号</param>
        /// <param name="applicationId">第三方系统帐号标识</param>
        /// <param name="title">标题</param>
        /// <param name="content">详细信息地址</param>
        /// <param name="tags">标签</param>
        /// <param name="type">类型</param>
        /// <param name="senderId">发送者</param>
        /// <param name="receiverIds">接收者</param>
        /// <param name="notificationOptions">通知选项</param>
        public void SendRange(string applicationId, string taskCode, string type, string title, string content, string tags, string senderId, string receiverIds, string notificationOptions)
        {
            TaskWorkInfo task = new TaskWorkInfo();

            task.Id = StringHelper.ToGuid();

            task.ApplicationId = applicationId;
            task.TaskCode      = taskCode;

            task.Title    = title;
            task.Content  = content;
            task.Type     = type;
            task.Tags     = tags;
            task.SenderId = senderId;

            string[] keys = receiverIds.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string key in keys)
            {
                if (!string.IsNullOrEmpty(key))
                {
                    task.AddReceiver(key);
                }
            }

            task.CreateDate = DateTime.Now;

            this.Save(task);

            // 发送通知
            this.Notification(task, receiverIds, notificationOptions);
        }
コード例 #3
0
        /// <summary>发送一对一的待办信息</summary>
        /// <param name="taskCode">任务编号</param>
        /// <param name="applicationId">第三方系统帐号标识</param>
        /// <param name="title">标题</param>
        /// <param name="content">详细信息地址</param>
        /// <param name="tags">标签</param>
        /// <param name="type">类型</param>
        /// <param name="senderId">发送者</param>
        /// <param name="receiverId">接收者</param>
        /// <param name="notificationOptions">通知选项</param>
        public void Send(string applicationId, string taskCode, string type, string title, string content, string tags, string senderId, string receiverId, string notificationOptions)
        {
            TaskWorkInfo task = new TaskWorkInfo();

            task.Id = StringHelper.ToGuid();

            task.ApplicationId = applicationId;
            task.TaskCode      = taskCode;
            task.Title         = title;
            task.Content       = content;
            task.Type          = type;
            task.Tags          = tags;
            task.SenderId      = senderId;

            if (!string.IsNullOrEmpty(receiverId))
            {
                task.AddReceiver(receiverId);
            }

            task.CreateDate = DateTime.Now;

            this.Save(task);

            // 发送通知
            this.Notification(task, receiverId, notificationOptions);
        }
コード例 #4
0
        public void TestNotification()
        {
            string applicationId = "00000000-0000-0000-0000-000000000001";

            string taskCode = StringHelper.ToGuid();

            // 发送人标识
            string senderId = "00000000-0000-0000-0000-000000000001";

            // 接收人标识
            string receiverId = "00000000-0000-0000-0000-000000100000";

            TaskWorkInfo task = new TaskWorkInfo();

            task.Id = StringHelper.ToGuid();

            task.ApplicationId = applicationId;
            task.TaskCode      = taskCode;
            task.Title         = "测试通知";
            task.Content       = "{Url}";
            task.Type          = "4";
            task.Tags          = "测试";
            task.SenderId      = senderId;

            if (!string.IsNullOrEmpty(receiverId))
            {
                task.AddReceiver(receiverId);
            }

            task.CreateDate = DateTime.Now;

            // string notificationOptions = "{\"SMS\":{\"validationType\":\"用户注册\"},\"Getui\":{}}";
            string notificationOptions = "{\"Getui\":{}}";

            TasksContext.Instance.TaskWorkService.Notification(task, receiverId, notificationOptions);
        }
コード例 #5
0
        public void TestSave()
        {
            string taskCode = DigitalNumberContext.Generate("Key_Guid");

            string id = DigitalNumberContext.Generate("Key_Guid");

            if (TasksContext.Instance.TaskWorkService.IsExist(id))
            {
                throw new Exception("任务已存在, 测试失败.");
            }

            // -------------------------------------------------------
            // 新增任务
            // -------------------------------------------------------

            TaskWorkInfo param = new TaskWorkInfo();

            param.Id = id;

            param.ApplicationId = appKey;
            param.TaskCode      = taskCode;
            param.Title         = string.Format("测试任务 - 编号{0}", taskCode);
            param.Content       = DateTime.Now.ToString();
            param.Type          = "1";
            param.Tags          = "测试";
            param.SenderId      = "00000000-0000-0000-0000-000000000001";

            param.AddReceiver("00000000-0000-0000-0000-000000000001");
            param.AddReceiver("00000000-0000-0000-0000-000000000002");
            param.AddReceiver("00000000-0000-0000-0000-000000000003");
            param.AddReceiver("00000000-0000-0000-0000-000000000004");

            param.CreateDate = DateTime.Now;

            param = TasksContext.Instance.TaskWorkService.Save(param);

            // -------------------------------------------------------
            // 修改任务
            // -------------------------------------------------------

            Assert.AreNotEqual(param.Content, "http://localhost/api/test/");

            param.Content = "http://localhost/api/test/";

            param = TasksContext.Instance.TaskWorkService.Save(param);

            param = TasksContext.Instance.TaskWorkService.FindOne(id);

            Assert.AreEqual(param.Content, "http://localhost/api/test/");

            // -------------------------------------------------------
            // 清理
            // -------------------------------------------------------

            if (TasksContext.Instance.TaskWorkService.IsExist(id))
            {
                TasksContext.Instance.TaskWorkService.Delete(id);
            }

            param = TasksContext.Instance.TaskWorkService.FindOne(id);

            Assert.IsNull(param);
        }
コード例 #6
0
        // -------------------------------------------------------
        // 保存 删除
        // -------------------------------------------------------

        #region 函数:Save(XmlDocument doc)
        /// <summary>保存记录</summary>
        /// <param name="doc">Xml 文档对象</param>
        /// <returns>返回操作结果</returns>
        public string Send(XmlDocument doc)
        {
            TaskWorkInfo param = new TaskWorkInfo();

            param = (TaskWorkInfo)AjaxUtil.Deserialize(param, doc);

            XmlNodeList nodes = doc.SelectNodes("/request/receivers/receiver");

            IAccountInfo account = MembershipManagement.Instance.AccountService[param.SenderId];

            if (account == null)
            {
                // 如果默认状态下没有填写发送者标识(SenderId), 则根据填写的发送者的登录名信息查找相关标识信息.
                XmlNode senderNode = doc.SelectSingleNode("/request/sender/loginName");

                if (senderNode == null)
                {
                    return("{\"message\":{\"returnCode\":1,\"value\":\"未找到发送人信息【id:" + param.SenderId + "】。\"}}");
                }
                else
                {
                    account = MembershipManagement.Instance.AccountService.FindOneByLoginName(senderNode.InnerText);

                    if (account == null)
                    {
                        return("{\"message\":{\"returnCode\":1,\"value\":\"未找到发送人信息【loginName:" + senderNode.InnerText + "】。\"}}");
                    }
                    else
                    {
                        param.SenderId = account.Id;
                    }
                }
            }

            foreach (XmlNode node in nodes)
            {
                if (node.SelectSingleNode("id") != null)
                {
                    account = MembershipManagement.Instance.AccountService[node.SelectSingleNode("id").InnerText];

                    if (account == null)
                    {
                        return("{\"message\":{\"returnCode\":1,\"value\":\"未找到接收人信息【id:" + node.SelectSingleNode("id").InnerText + "】。\"}}");
                    }
                }
                else if (node.SelectSingleNode("loginName") != null)
                {
                    account = MembershipManagement.Instance.AccountService.FindOneByLoginName(node.SelectSingleNode("loginName").InnerText);

                    if (account == null)
                    {
                        return("{\"message\":{\"returnCode\":1,\"value\":\"未找到接收人信息,【loginName:" + node.SelectSingleNode("loginName").InnerText + "】。\"}}");
                    }
                }
                else
                {
                    account = null;

                    return("{\"message\":{\"returnCode\":1,\"value\":\"未找到接收人标识的参数。\"}}");
                }

                if (node.SelectSingleNode("isFinished") == null)
                {
                    param.AddReceiver(account.Id);
                }
                else
                {
                    int isFinished = Convert.ToInt32(node.SelectSingleNode("isFinished").InnerText);

                    DateTime finishTime = new DateTime(2000, 1, 1);

                    if (isFinished == 1)
                    {
                        if (node.SelectSingleNode("finishTime") == null)
                        {
                            return("{\"message\":{\"returnCode\":1,\"value\":\"" + account.Name + "已完成的,但是未找到完成时间。\"}}");
                        }

                        finishTime = Convert.ToDateTime(node.SelectSingleNode("finishTime").InnerText);
                    }

                    param.AddReceiver(account.Id, false, isFinished, finishTime);
                }
            }

            if (param.ReceiverGroup.Count == 0)
            {
                return("{\"message\":{\"returnCode\":1,\"value\":\"必须填写接收人信息。\"}}");
            }

            if (string.IsNullOrEmpty(param.Title))
            {
                return("{\"message\":{\"returnCode\":1,\"value\":\"必须填写标题信息。\"}}");
            }

            this.service.Save(param);

            return("{\"message\":{\"returnCode\":0,\"value\":\"发送成功。\"}}");
        }