public HttpResponseMessage PostReceiveTask(ReceiveTaskViewModel model,int id)
 {
     model.Id = id;
     if (helper.setReceiveTask(model, User.Identity.Name))
         return new HttpResponseMessage(HttpStatusCode.Accepted);
     else
         return new HttpResponseMessage(HttpStatusCode.Forbidden);
 }
Ejemplo n.º 2
0
 public ActionResult _ReceiveState(ReceiveTaskViewModel model)
 {
     helper.setReceiveTask(model, User.Identity.Name);
     if (model.ViewMode.Equals("mobile"))
     {
         return RedirectToAction("Mobile", new { id = model.Id });
     }
     else
     {
         return RedirectToAction("Index", new { id = -1 });
     }
 }
Ejemplo n.º 3
0
        public bool setReceiveTask(ReceiveTaskViewModel rtviewmodel, string username)
        {
            initService();
            initCore();
            if (CanUserAccessTask(rtviewmodel.Id, username))
            {
                core.submitReceiveTaskAnswer(rtviewmodel.Id, rtviewmodel.selectedMessages.First(), username);

                return true;
            }
            else
                return false;
        }
Ejemplo n.º 4
0
        public Models.JobsViewModels.ReceiveTaskViewModel getReceiveTask(int id, string username)
        {
            initService();
            if (CanUserAccessTask(id, username))
            {


                var task = taskStore.getTaskById(id);

                if (task.Type.Equals("R"))
                {
                    var processInstance = _db.P_ProcessInstance.Find(task.P_ProcessInstance_Id);
                    var process = _db.P_Processes.Find(processInstance.P_Process_Id);
                    bool tout = false;
                    if (task.SubmittedTaskProperties != null)
                    {
                        if (task.SubmittedTaskProperties.Equals("TimeOut!"))
                        {
                            tout = true;
                        }
                    }


                    DateTime doneDate = new DateTime();
                    if (task.DateSubmitted != null)
                    {
                        doneDate = task.DateSubmitted.Value;
                    }
                    ReceiveTaskViewModel model = new ReceiveTaskViewModel() { Id = task.Id, Name = task.Name, Done = task.Done, Seen = task.Seen, DoneDate = doneDate, ProcessStartDate = processInstance.DateStarted.Value, StartedByUser = processInstance.StartedByUser, TaskCreatedDate = task.DateCreated.Value, Timedout = tout, Version = process.WS_Project_Version, ProcessName = process.WS_Project.Name };

                    List<M_Message> mlist = new List<M_Message>();
                    if (task.Done)
                    {
                        if (!tout)
                        {
                            try
                            {
                                mlist.Add(messageStore.getMessageBymsgId(int.Parse(task.SubmittedTaskProperties)));
                            }
                            catch(Exception e)
                            {

                            }
                        }
                    }
                    else
                    {


                        //find to the task related messages
                       mlist = messageStore.getMessagesForReceiveStateTask(task.WFId, task.getTaskPropertiesAsListOfString());
                    }


                        // mlist.ForEach(m => model.Messages.Add(new MessagesViewModel { Message_Id = m.Id, Message_Type = m.Message_Type, Sender_Username = m.Sender_Username, Parameters = Json.Decode<Dictionary<string, string>>(m.Data) }));


                        foreach (var m in mlist)
                        {
                            IDictionary<string, dynamic> editableParameters = Newtonsoft.Json.JsonConvert.DeserializeObject<IDictionary<string, dynamic>>(m.Data);
                            MessagesViewModel mvm = new MessagesViewModel() { Message_Id = m.Id, Message_Type = m.Message_Type, Sender_Username = m.Sender_Username };
                            if (editableParameters != null)
                                foreach (var i in editableParameters)
                                {
                                    mvm.Parameters.Add(new TaskParameter(i.Key, i.Value));// { Name = i.Key, Value = i.Value });
                                }
                            model.Messages.Add(mvm);
                        }
                    
                  
                  //  mlist.ForEach(m => model.Messages.Add(new MessagesViewModel { Message_Id = m.Id, Message_Type = m.Message_Type, Sender_Username = m.Sender_Username, Parameters = new Dictionary<string, string>() }));


                    return model;
                }
            }

            return null;
        }