示例#1
0
        public void GetToDoList(string userName)
        {
            List<TodoMessageDto> result = null;

            using (var context = new TodoDBEntities())
            {
                var user = context.Users.FirstOrDefault(x => x.UserName == userName);

                result = context.TodoMessages.AsEnumerable().
                    Select(x => new TodoMessageDto
                    {
                        Id = x.ID,
                        IsCompleted = x.IsCompleted,
                        Message = x.Message,
                        Person = x.Person,
                        Priority = (PriorityType)(x.PriorityID ?? 1),
                        IsOwn = user != null && x.UserID == user.ID,
                        Owner = x.Users != null ? x.Users.UserName : "******"
                    }).OrderBy(x => x.IsOwn).ToList();
            }

            using (var callback = new TodoServiceCallbackClient())
                callback.OnGetToDoListComplete(userName, result);
        }
示例#2
0
        private void RunPriorityWorkflow(string userName, IEnumerable<TodoMessageDto> list)
        {
            Dictionary<string, object> workflowInputArguments = new Dictionary<string, object>
             {
                 { "UserName", userName },
                 { "TodoMessages", list }
             };

            WorkflowApplication wfApp = new WorkflowApplication(TodoService.PriorityWorkflow.Value, workflowInputArguments);

            wfApp.Completed = (workflowCompletedArgs) =>
            {
                using (var callback = new TodoServiceCallbackClient())
                    callback.OnUpdateToDoMessagesComplete(userName, true);
            };

            wfApp.Run();
        }
示例#3
0
        public void GetPersonsList(string userName, string personKey)
        {
            //if (string.IsNullOrWhiteSpace(personKey))

            List<string> result = null;

            using (var context = new TodoDBEntities())
            {
                result = context.TodoMessages.Where(x => x.Person.IndexOf(personKey) != -1).Select(x => x.Person).Distinct().ToList();
            }

            using (var callback = new TodoServiceCallbackClient())
                callback.OnGetPersonsListComplete(userName, result);
        }
示例#4
0
        public void RemoveToDoMessages(string userName, IEnumerable<int> ids)
        {
            //if (!ValidateEnumerableParam(ids)) return;

            using (var context = new TodoDBEntities())
            {
                context.ExecuteStoreCommand(@"delete from TodoMessages  where ID in (" + string.Join(",", ids).PadRight(1) + ")");
                context.SaveChanges();
            }

            using (var callback = new TodoServiceCallbackClient())
                callback.OnRemoveToDoMessagesComplete(userName, true);
        }