public HttpResponseMessage PostFunctionTask(FunctionTaskViewModel model, int id)
 {
     model.Id = id;
     if (helper.setFunctionTask(model, User.Identity.Name))
         return new HttpResponseMessage(HttpStatusCode.Accepted);
     else
         return new HttpResponseMessage(HttpStatusCode.Forbidden);
 }
Exemplo n.º 2
0
        public ActionResult _FunctionState(FunctionTaskViewModel model)
        {
            helper.setFunctionTask(model, User.Identity.Name);

            if (model.ViewMode.Equals("mobile"))
            {
                return RedirectToAction("Mobile", new { id = model.Id });
            }
            else
            {
                return RedirectToAction("Index", new { id = -1 });
            }
        }
Exemplo n.º 3
0
        public Models.JobsViewModels.FunctionTaskViewModel getFunctionTask(int id, string username)
        {
            initService();

            if (CanUserAccessTask(id, username))
            {
                T_Task task = taskStore.getTaskById(id);
                if (task.Type.Equals("F"))
                {

                    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;
                    }


                    FunctionTaskViewModel model = new FunctionTaskViewModel() { Id = task.Id, Name = task.Name, Done = task.Done, 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, Seen = task.Seen};

                    model.selectedTransiton = "";
                    string editableParametersString = "";
                    if (task.Done)
                    {
                        if (!tout)
                        {
                            model.selectedTransiton = task.SubmittedTaskProperties;

                            editableParametersString = task.SubmittedEditableParameters;
                        }
                    }
                    else
                    {
                        task.TaskProperties.ForEach(tp => model.Transitions.Add(new SelectListItem { Selected = false, Value = tp.Value, Text = tp.Value }));
                        editableParametersString = task.EditableParameters;
                    }
                    /*
                    var readableParameters = Json.Decode<Dictionary<string, JObject>>(task.ReadableParameters);
                    if (readableParameters != null)
                        foreach (var i in readableParameters)
                        {
                            model.ReadableParameters.Add(new TaskParameter(i.Key,i.Value));// { Name = i.Key, Value = i.Value });
                        }

                    var editableParameters = Json.Decode<Dictionary<string, JObject>>(task.EditableParameters);
                    if (editableParameters != null)
                        foreach (var i in Json.Decode<Dictionary<string, JObject>>(task.EditableParameters))
                        {
                            model.EditableParameters.Add(new TaskParameter(i.Key, i.Value));//{ Name = i.Key, Value = i.Value });
                        }*/
                    //var readableParameters = Json.Decode<IDictionary<string, dynamic>>(task.ReadableParameters);
                    IDictionary<string, dynamic> readableParameters = Newtonsoft.Json.JsonConvert.DeserializeObject<IDictionary<string, dynamic>>(task.ReadableParameters);
                    if (readableParameters != null)
                        foreach (var i in readableParameters)
                        {
                            model.ReadableParameters.Add(new TaskParameter(i.Key, i.Value));// { Name = i.Key, Value = i.Value });
                        }

                    if (editableParametersString == null)
                        editableParametersString = "";
                    // var editableParameters = Json.Decode<Dictionary<string, JObject>>(task.EditableParameters);
                    IDictionary<string, dynamic> editableParameters = Newtonsoft.Json.JsonConvert.DeserializeObject<IDictionary<string, dynamic>>(editableParametersString);

                    if (editableParameters != null)
                        foreach (var i in editableParameters)
                        {
                            model.EditableParameters.Add(new TaskParameter(i.Key, i.Value));// { Name = i.Key, Value = i.Value });
                        }

                    return model;
                }
            }
            return null;
        }
Exemplo n.º 4
0
        public bool setFunctionTask(FunctionTaskViewModel ftviewmodel, string username)
        {
            initService();
            initCore();
            if (CanUserAccessTask(ftviewmodel.Id, username))
            {
                

                Dictionary<string, dynamic> editableparameters = new Dictionary<string, dynamic>();
                ftviewmodel.EditableParameters.ForEach(tp => editableparameters.Add(tp.Name, tp.Value));

                core.submitFunctionTaskAnswer(ftviewmodel.Id, ftviewmodel.selectedTransiton, encodeEditableParameters(ftviewmodel.Id,editableparameters), username);

                return true;
            }

            return false;
        }