Ejemplo n.º 1
0
    private void GetTasks()
    {
        var tasks        = ScheduledTask.ByEmployee(this.ApplicationUser, this.Company.Id).Where(t => t.Expiration >= Constant.Now.AddYears(-1)).ToList();
        var printedTasks = new List <ScheduledTask>();

        tasks = tasks.OrderByDescending(t => t.Expiration).ToList();
        foreach (var task in tasks)
        {
            if (printedTasks.Any(t => t.Action == task.Action && t.Equipment.Id == task.Equipment.Id && task.TaskType == t.TaskType))
            {
                continue;
            }

            printedTasks.Add(task);
        }

        printedTasks      = printedTasks.Where(t => t.Expiration <= DateTime.Now).ToList();
        this.PendentTasks = printedTasks.Count;
    }
Ejemplo n.º 2
0
    private void RenderScheludedTasksList()
    {
        var searchItems  = new List <string>();
        var tasksJson    = new StringBuilder("[");
        var tasks        = ScheduledTask.ByEmployee(this.user, this.company.Id).Where(t => t.Expiration >= Constant.Now.AddYears(-1)).ToList();
        var printedTasks = new List <ScheduledTask>();
        var res          = new StringBuilder();

        tasks = tasks.OrderByDescending(t => t.Expiration).ToList();
        bool first = true;

        foreach (var task in tasks)
        {
            if (printedTasks.Any(t => t.Action == task.Action && t.Equipment.Id == task.Equipment.Id && task.TaskType == t.TaskType))
            {
                continue;
            }

            printedTasks.Add(task);
            res.Append(task.Row(this.Dictionary));
            if (first)
            {
                first = false;
            }
            else
            {
                tasksJson.Append(",");
            }

            if (!searchItems.Contains(task.Equipment.Description))
            {
                searchItems.Add(task.Equipment.Description);
            }
            ;

            if (!searchItems.Contains(task.Responsible.FullName))
            {
                searchItems.Add(task.Responsible.FullName);
            }
            ;

            if (task.Provider != null)
            {
                if (!searchItems.Contains(task.Provider.Description))
                {
                    searchItems.Add(task.Provider.Description);
                }
                ;
            }

            var text = string.Empty;
            switch (task.TaskType)
            {
            case "M":
                text = task.Internal == "I" ? Dictionary["Item_EquipmentMaintenance_Label_Internal"] : Dictionary["Item_EquipmentMaintenance_Label_External"];
                break;

            case "V":
                text = task.Internal == "I" ? Dictionary["Item_EquipmentVerification_Label_Internal"] : Dictionary["Item_EquipmentVerification_Label_External"];
                break;

            case "C":
                text = task.Internal == "I" ? Dictionary["Item_EquipmentCalibration_Label_Internal"] : Dictionary["Item_EquipmentCalibration_Label_External"];
                break;

            case "I":
                text = Dictionary["Item_Incident"];
                break;

            case "A":
                text = Dictionary["Item_IncidentAction"];
                break;

            case "X":
                text = Dictionary["Item_Indicador"];
                break;

            case "O":
                text = Dictionary["Item_Objetivo"];
                break;

            case "B":
                text = Dictionary["Item_BusinessRisk"];
                break;
            }

            if (!searchItems.Contains(text))
            {
                searchItems.Add(text);
            }
            ;
            tasksJson.Append(task.JsonRow(this.Dictionary));
        }

        this.LtScheduledTasks.Text = res.ToString();
        tasksJson.Append("]");
        this.Tasks = tasksJson.ToString();
        var searchItem = new StringBuilder();

        first = true;
        foreach (string item in searchItems.OrderBy(s => s))
        {
            if (first)
            {
                first = false;
            }
            else
            {
                searchItem.Append(",");
            }

            searchItem.AppendFormat(CultureInfo.InvariantCulture, @"""{0}""", GisoFramework.Tools.JsonCompliant(item));
        }

        this.master.SearcheableItems = searchItem.ToString();
    }