Ejemplo n.º 1
0
        public async Task <IActionResult> Dispatcher(DispatcherGridOptions options, CommandType command)
        {
            if (command == CommandType.Save)
            {
                return(Ok());
            }

            if (command == CommandType.Clear)
            {
                options.Page   = 1;
                options.Filter = new DispatcherFilter();
                options.SetSortOptionsDefault();
            }

            var filter = new DispatcherGridFilter();

            filter.Init(options.Filter);

            //var user = await _authService.GetCurrentUser();

            //filter.ApplyPermission(user);

            if (command == CommandType.None || command == CommandType.Clear)
            {
                filter.Configure();
            }

            var grid = new ActionGrid <DispatcherGrid, DispatcherGridModel, DispatcherFilter>(_db.Connection, options, filter);

            var data = await grid.Render();

            if (command == CommandType.Page)
            {
                return(Ok(new
                {
                    isEmptyFilter = filter.IsEmptyFilter(),
                    DataSource = data,
                }));
            }

            return(Ok(new
            {
                FilterInfo = filter.GetVisibleFilters(options.VisibleFilters),
                Filter = options.Filter,
                isEmptyFilter = false,
                SortOptions = options.SortOptions,
                AllColumns = grid.GetAllColumns,
                VisibleColumns = grid.GetVisibleColumns,
                DataSource = data,
                IsSelectedAll = options.IsSelectedAll,
                SelectedRows = grid.GetSelectedRows,
                Data = new
                {
                    DataSource = await _commonService.GetDepoEventDataSource()
                }
            }));
        }
Ejemplo n.º 2
0
 private void btnEditRepo_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     if (ActionGrid.GetFocusedRow() is DocActions item)
     {
         frmDocActions frm = new frmDocActions(item, "", item.RefId)
         {
             MethodType = MethodType.Edit
         };
         frm.ShowDialog();
     }
 }
Ejemplo n.º 3
0
 private void btnEditRepo_ButtonPressed(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     if (ActionGrid.GetFocusedRow() is DocActions item)
     {
         frmDocActions frm = new frmDocActions(tableName: "WorkOrders", refId: WOId, label: WorkOrders?.Employees?.EmployeeName + " - " + WorkOrders?.PPEs?.EquipmentTypes?.EquipmentType)
         {
             DocActions = item,
             MethodType = MethodType.Edit,
         };
         frm.ShowDialog();
     }
 }
Ejemplo n.º 4
0
        public async Task <IActionResult> JournalGetChild(JournalGridOptions options, [FromBody] int parentId)
        {
            var grid = new ActionGrid <JournalGrid, JournalGridModel, JournalGridFilter>(_db.Connection, options)
            {
                MapResult = (row, result) =>
                {
                    result["id"] = parentId + "E_" + row.Id;
                    result.Add("parentId", "M_" + parentId);
                    result.Add("childCount", row.Count);
                    result.Add("hasInspection", row.HasInspection);
                }
            };

            return(Ok(await grid.GetChildRows(Sql.SqlQueryCach["Journal.GridGetChildByParentId"], parentId)));
        }
Ejemplo n.º 5
0
 private void btnDelRepo_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     if (ActionGrid.GetFocusedRow() is DocActions item)
     {
         if (MessageBox.Show("Do you want to delete this?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
         {
             return;
         }
         try
         {
             UnitOfWork unitOfWork = new UnitOfWork();
             unitOfWork.DocActionsRepo.Delete(x => x.Id == item.Id);
             unitOfWork.Save();
             Details(unitOfWork.WorkOrdersRepo.Find(x => x.Id == item.RefId));
         }
         catch (Exception exception)
         {
             MessageBox.Show(exception.Message, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Ejemplo n.º 6
0
 private void btnDelRepo_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     if (MessageBox.Show("Do you want to delete this?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
     {
         return;
     }
     try
     {
         using (UnitOfWork unitOfWork = new UnitOfWork())
         {
             if (ActionGrid.GetFocusedRow() is DocActions item)
             {
                 unitOfWork.DocActionsRepo.Delete(m => m.Id == item.Id);
                 unitOfWork.Save();
             }
             this.ActionGridControl.DataSource = unitOfWork.DocActionsRepo.Get(m => m.RefId == id && m.TableName == tableName);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message, exception.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 7
0
 public void LoadActions()
 {
     ActionBindingSource.DataSource = new UnitOfWork().DocActionsRepo.Get(m => m.RefId == WOId && m.TableName == "WorkOrders");
     ActionGrid.RefreshData();
 }
Ejemplo n.º 8
0
        public async Task <IActionResult> GetJournalTablePdf([FromBody] JournalTableRequest req)
        {
            await CheckPermission();

            var html = @"<html><head>
                <style type='text/css'>
                .task {
                    width: 100%;
                    border-collapse: collapse;
                    border: 1px solid black;
                }
                .task td {
                    padding: 5px;
                    border: 1px solid black;
                }
                .task th {
                    padding: 5px;
                    background-color: #909090;
                    border: 1px solid black;
                }
                </style></head><body>";

            var tr          = new TaskRepository(_logger);
            var ir          = new InspectionRepository(_logger);
            var serviceTask = new TaskService(_logger);

            html += "<br /><h2>Задачи</h2>";

            var filter = new JournalGridFilter();

            filter.Init(req.Options.Filter);

            var grid       = new ActionGrid <JournalGrid, JournalGridModel, JournalFilter>(_db.Connection, req.Options, filter);
            var gridResult = await grid.GetResultRows();

            if (gridResult.Count() == 0)
            {
                html += "<br /><h4>Список задач отсутствует</h4>";
            }
            else
            {
                html += "<table class='task'><tr><th>№ задачи</th><th>Вагон</th><th>Местоположение</th><th>Оборудование</th><th>Типовая неисправность</th><th>Описание</th><th>Метка</th><th>Время</th><th>Автор</th><th>Комментарий</th></tr>";

                foreach (var task in gridResult)
                {
                    var history = await serviceTask.AddHistoryData(task.Id);

                    var trainTask = await tr.GetTrainTaskForPdf(task.Id);

                    if (trainTask != null)
                    {
                        string comments     = null;
                        var    taskComments = history.OrderBy(h => h.Date).Where(h => h.Type == "Comment" && h.Text != null && h.Text != trainTask.Description);

                        foreach (var comment in taskComments)
                        {
                            comments += $"<i>{comment.Date.ToString("MM.dd.yy")}</i>: {comment.Text}<br />";
                        }

                        html += "<tr><td>" + trainTask.Id + "</td><td>" + trainTask.CarriageSerial + "</td><td>" + trainTask.Location +
                                "</td><td>" + trainTask.Equipment + "</td><td>" + trainTask.Fault + "</td><td>" + trainTask.Description +
                                "</td><td>" + trainTask.Label + "</td><td>" + trainTask.Created +
                                "</td><td>" + trainTask.UserName + "</td></td><td>" + comments + "</td></tr>";
                    }
                }

                html += "</table>";
            }

            var output = _pdfConverter.Convert(new HtmlToPdfDocument
            {
                GlobalSettings =
                {
                    ColorMode   = ColorMode.Color,
                    Orientation = Orientation.Landscape,
                    PaperSize   = PaperKind.A4,
                },
                Objects =
                {
                    new ObjectSettings
                    {
                        PagesCount     = true,
                        HtmlContent    = html,
                        WebSettings    = { DefaultEncoding = "utf-8" },
                        FooterSettings ={ FontName                             = "Arial", FontSize = 9, Right = "[page]", Line = false},
                    }
                }
            });

            return(File(output, "application/pdf", "journal_" + new Random().Next(0, 10000) + ".pdf"));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Journal(JournalGridOptions options, CommandType command)
        {
            if (command == CommandType.Save)
            {
                return(Ok());
            }

            if (command == CommandType.Clear)
            {
                options.Page   = 1;
                options.Filter = new JournalFilter();
                options.SetSortOptionsDefault();
                options.SetSelectedRowsDefault();
            }

            var filter = new JournalGridFilter();

            filter.Init(options.Filter);

            if (filter.IsEmptyFilter())
            {
                options.SetSelectedRowsDefault();
            }

            //var user = await _authService.GetCurrentUser();

            //filter.ApplyPermission(user);

            if (command == CommandType.None || command == CommandType.Clear)
            {
                filter.Configure();
            }

            var grid = new ActionGrid <JournalGrid, JournalGridModel, JournalFilter>(_db.Connection, options, filter)
            {
                MapResult = (row, result) =>
                {
                    var rowId = row.HasInspection ? "M_" + row.Id : "E_" + row.Id;
                    result["id"] = rowId;
                    result.Add("parentId", null);
                    result.Add("childCount", row.Count);
                    result.Add("hasInspection", row.HasInspection);
                    //result.Add("isSelected", options.IsSelectedRow(rowId));
                }
            };

            filter.IsEmptyFilter();

            var data = await grid.Render();

            if (command == CommandType.Page)
            {
                return(Ok(new
                {
                    isEmptyFilter = filter.IsEmptyFilter(),
                    DataSource = data,
                }));
            }

            return(Ok(new
            {
                FilterInfo = filter.GetVisibleFilters(options.VisibleFilters),
                Filter = options.Filter,
                isEmptyFilter = filter.IsEmptyFilter(),
                SortOptions = options.SortOptions,
                AllColumns = grid.GetAllColumns,
                VisibleColumns = grid.GetVisibleColumns,
                DataSource = data,
                IsSelectedAll = options.IsSelectedAll,
                SelectedRows = grid.GetSelectedRows,
                Data = new
                {
                    DataSource = await _commonService.GetAllReference()
                }
            }));
        }