public async Task <ActionResult> ListImportQueue(ImportParameters parameters)
        {
            var filter = new ImportQueueFilter()
            {
                FilterMessage = parameters.FilterMessage,
                ImportStatus  = (enums.ImportStatus)parameters.ImportStatusId.GetValueOrDefault(),
                Action        = ImportAction.ImportQueue
            };

            filter.InitialiseFromJson(parameters);

            var results = await ImportViewModel.GetModel(DataContext, filter);

            var jQueryResult = new JQueryDataTableResultModel(results.TotalRecords, results.TotalDisplayRecords);

            // Iterate through the results and put them in a format that can be used by jQuery datatables
            if (results.ImportQueue.CurrentPage.Any())
            {
                foreach (var result in results.ImportQueue.CurrentPage)
                {
                    jQueryResult.aaData.Add(result.ToJQueryDataTableResult());
                }
            }
            return(Json(jQueryResult));
        }
示例#2
0
        public ActionResult DeleteImport(int Id)
        {
            var import = new Import {
                Id = Id
            };
            List <ScanViewModel> LscanviewModel = new List <ScanViewModel>();

            using (var context = new ScanDbContext())
            {
                LscanviewModel = context.Database
                                 .SqlQuery <ScanViewModel>("GETScanViewModel")
                                 .ToList();
            }
            List <ScanViewModel> scanViewModels = LscanviewModel.Where(s => s.importID == Id).ToList();
            ImportViewModel      importmodel    = new ImportViewModel()
            {
                Id       = import.Id,
                ClientId = import.ClientId,
                Scans    = scanViewModels,
                Type     = import.Type,
                Date     = import.Date.ToShortDateString()
            };

            db.Entry(import).State = EntityState.Deleted;
            db.SaveChanges();

            return(Json(importmodel));
        }
 private void LoadContentsOfGpxFile(HttpPostedFileBase file, ImportViewModel importViewModel)
 {
     try
     {
         GpxTrack track = GpxEngine.GetGpxTrackFromFile(file);
         if (track != null)
         {
             ExerciseSession session = ExerciseSession.Create(track);
             _db.ExerciseSessions.AddOrUpdate(s => s.Name, session);
             _db.SaveChanges();
             importViewModel.FilesImported++;
         }
         else
         {
             importViewModel.FilesFailed.Add(new FailedFile
             {
                 Filename     = file.FileName,
                 ErrorMessage = "File could not be processed."
             });
         }
     }
     catch (Exception e)
     {
         _log.Error(string.Format("Failed to import file {0} with message: {1}", file.FileName, e.Message));
         importViewModel.FilesFailed.Add(new FailedFile
         {
             Filename     = file.FileName,
             ErrorMessage = e.Message
         });
     }
 }
 private async Task <ImportViewModel> GetModelFromParameters()
 {
     return(ImportViewModel.GetModel(
                DataContext,
                new ImportQueueFilter(),
                Parameters.Action).Result);
 }
示例#5
0
        public ImportPage()
        {
            viewModel = new ImportViewModel(this);

            this.BindingContext = viewModel;
            InitializeComponent();
        }
示例#6
0
 public ActionResult ImportSchedule(ImportViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             //import based on model.ScheduleList
             if (model.ScheduleList.Count != 0)
             {
                 //import parameter -> list of checked items
                 var scheduleDTOList = _scheduleMaper.MapBack(model.ScheduleList.Where(s => s.Check == true)).ToList();
                 _scheduleService.UpdateSchedule(scheduleDTOList);
             }
             //upload items from file to view
             if (model.UploadedFile != null)
             {
                 model.ScheduleList = GetUploadedList(model.UploadedFile);
             }
         }
     }
     catch (AirportServiceException ex)
     {
         ModelState.AddModelError("ImportModelException", ex.Message);
     }
     return(View(model));
 }
示例#7
0
        public void UpdateImport(ImportViewModel importViewModel)
        {
            var      existedImport = _importService.GetImportWithProductsById(importViewModel.Id);
            Provider provider      = null;

            if (_providersService.EntityExist(importViewModel.Provider))
            {
                provider = _providersService.GetEntityById(importViewModel.Provider.Id);
            }

            List <ImportProduct> products = new List <ImportProduct>(importViewModel.Products?.Count ?? 0);

            foreach (var product in importViewModel.Products)
            {
                if (_productsService.EntityExist(product.ProductId.Value))
                {
                    var importProduct = new ImportProduct();
                    importProduct.Product = _productsService.GetEntityById(product.ProductId.Value);
                    importProduct.Count   = product.Count;
                    products.Add(importProduct);
                }
            }

            existedImport.CreatedDate = importViewModel.CreatedDate;
            existedImport.ImportDate  = importViewModel.ImportDate;
            existedImport.FinishDate  = importViewModel.FinishDate;
            existedImport.Status      = importViewModel.Status;
            existedImport.Provider    = provider;

            _importProductsService.DeleteEntityRange(existedImport.Products);

            existedImport.Products = products;

            _service.UpdateEntity(existedImport);
        }
        public ActionResult ImportPOST()
        {
            if (!Services.Authorizer.Authorize(Permissions.Import, T("Not allowed to import.")))
            {
                return(new HttpUnauthorizedResult());
            }

            var actions   = _importActions.OrderByDescending(x => x.Priority).ToList();
            var viewModel = new ImportViewModel {
                Actions = actions.Select(x => new ImportActionViewModel {
                    Editor = x.UpdateEditor(Services.New, this)
                }).Where(x => x != null).ToList()
            };

            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var context     = new ImportActionContext();
            var executionId = _importExportService.Import(context, actions);

            return(!String.IsNullOrEmpty(executionId)
                ? RedirectToAction("ImportResult", new { executionId = context.ExecutionId })
                : RedirectToAction("Import"));
        }
示例#9
0
        public async Task <IActionResult> Import(ImportViewModel model)
        {
            var currentUser = await User.GetApplicationUser(_userManager);

            var league = _leaguesRepository.GetUserAuthorizedLeague(currentUser, model.LeagueId);

            if (league == null)
            {
                return(NotFound());
            }

            var matches = new[] { model.File }.SelectMany(f =>
            {
                using (var stream = f.OpenReadStream())
                {
                    return(CsvReader.ReadFromStream(stream).Select(line => new
                    {
                        Date = DateTimeOffset.ParseExact(line[model.DateIndex - 1], model.DateTimeFormat, null),
                        FirstPlayerEmail = line[model.FirstPlayerEmailIndex - 1].ToLower().Trim(),
                        FirstPlayerScore = Convert.ToInt32(line[model.FirstPlayerScoreIndex - 1]),
                        SecondPlayerEmail = line[model.SecondPlayerEmailIndex - 1].ToLower().Trim(),
                        SecondPlayerScore = Convert.ToInt32(line[model.SecondPlayerScoreIndex - 1]),
                        Factor =
                            model.FactorIndex.HasValue && !string.IsNullOrEmpty(line[model.FactorIndex.Value - 1])
                                ? Convert.ToDouble(line[model.FactorIndex.Value - 1])
                                : (double?)null
                    }).ToList());
                }
            }).ToList();

            var uniqueEmails =
                matches.Select(m => m.FirstPlayerEmail).Concat(matches.Select(m => m.SecondPlayerEmail)).Distinct();

            var users = await GetUsers(uniqueEmails, currentUser, league);

            foreach (var match in matches)
            {
                _context.Match.Add(new Match
                {
                    Id                = Guid.NewGuid(),
                    CreatedByUser     = currentUser,
                    Date              = match.Date,
                    FirstPlayer       = users[match.FirstPlayerEmail],
                    FirstPlayerScore  = match.FirstPlayerScore,
                    SecondPlayer      = users[match.SecondPlayerEmail],
                    SecondPlayerScore = match.SecondPlayerScore,
                    Factor            = match.Factor,
                    League            = league
                });
            }

            _context.SaveChanges();

            var leagueId = league.Id;

            return(RedirectToAction(nameof(Index), new
            {
                leagueId
            }));
        }
示例#10
0
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            ViewBag.ControllerName = (String)RouteData.Values["controller"];
            ViewBag.ActionName     = RouteData.Values["action"].ToString().ToLower();

            ViewBag.HttpKeys = Request.QueryString.AllKeys;
            ViewBag.Query    = Request.QueryString;

            model = new ImportViewModel
            {
                Account        = AccountInfo,
                Settings       = SettingsInfo,
                UserResolution = UserResolutionInfo,
                ControllerName = ControllerName,
                ActionName     = ActionName
            };

            #region Метатеги
            ViewBag.Title       = UserResolutionInfo.Title;
            ViewBag.Description = "Импорт продукции";
            ViewBag.KeyWords    = "Импорт, интеграция";
            #endregion
        }
        public async Task <ActionResult> Import(ImportViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            XDocument document;

            try
            {
                document = XDocument.Load(viewModel.UploadFile.InputStream);
            }
            catch (Exception)
            {
                ModelState.AddModelError("UploadFile", "Received invalid XML.");
                return(View(viewModel));
            }

            var userId = GetUserId();

            await Task.Run(() => new TelemetryClient().TrackEvent("ImportFilters"));

            //Use MongoDb to temporarily store instead of the session.
            var mongoDbComponent = new MongoDbComponent();
            var collection       = mongoDbComponent.MessageFilters;

            var filterComponent = new MessageFilterComponent();
            var id = await collection.InsertAsync(filterComponent.FromXml(document, userId));

            return(RedirectToAction("ImportReview", new { id = id }));
        }
示例#12
0
        public async Task <ActionResult> ListImportExceptions(ImportExceptionParameters parameters)
        {
            ImportExceptionParametersValidator
            .ValidateImportExceptionParameters(parameters, ImportExceptionParametersValidator.ImportQueueIdentifier);

            var filter = new ImportQueueFilter(parameters.ImportQueueId.GetValueOrDefault())
            {
                ExceptionType = parameters.ExceptionType,
                FilterMessage = parameters.FilterMessage,
                Action        = ImportAction.ImportQueueItem
            };

            filter.InitialiseFromJson(parameters);

            var results = await ImportViewModel.GetModel(DataContext, filter);

            var jQueryResult = new JQueryDataTableResultModel(results);

            // Iterate through the results and put them in a format that can be used by jQuery datatables
            if (!results.HasExceptions())
            {
                return(Json(jQueryResult));
            }
            jQueryResult.TotalSuccess = results.Exceptions.TotalSuccess;
            jQueryResult.TotalFail    = results.Exceptions.TotalFail;

            foreach (var result in results.Exceptions.CurrentPage)
            {
                jQueryResult.aaData.Add(result.ToJQueryDataTableResult());
            }
            return(Json(jQueryResult));
        }
示例#13
0
        // GET: Scan

        public ActionResult Diff()
        {
            List <Import>          imports  = new List <Import>();
            List <ImportViewModel> Limports = new List <ImportViewModel>();

            imports = this.db.Import.ToList();
            List <ScanViewModel> LscanviewModel = new List <ScanViewModel>();

            using (var context = new ScanDbContext())
            {
                LscanviewModel = context.Database
                                 .SqlQuery <ScanViewModel>("GETScanViewModel")
                                 .ToList();
            }
            foreach (Import import in imports)
            {
                ImportViewModel importViewModel = new ImportViewModel()
                {
                    Id       = import.Id,
                    ClientId = import.ClientId,
                    //Assort = LassortViewModel,
                    Scans = LscanviewModel.Where(i => i.importID == import.Id).ToList(),
                    Date  = import.Date.ToShortDateString(),
                    Type  = import.Type
                };
                Limports.Add(importViewModel);
            }


            return(View("Import", Limports));
        }
示例#14
0
 public IActionResult Index(ImportViewModel form = null)
 {
     if (form == null)
     {
         form = new ImportViewModel();
     }
     return(View("Index", JsonConvert.SerializeObject(form)));
 }
示例#15
0
 public ImportViewModel GetImportViewModel()
 {
     if ((ImportViewModel)ImportVM == null)
     {
         ImportVM = new ImportViewModel(UIController.Get().WindowFactory);
     }
     return((ImportViewModel)ImportVM);
 }
示例#16
0
        public ImportWindow(ImportViewModel importViewModel)
        {
            InitializeComponent();

            this.DataContext = importViewModel;

            ContentRendered += ImportWindow_ContentRendered;
        }
        public ImportWindow()
        {
            InitializeComponent();
            ImportViewModel vm = new ImportViewModel();

            DataContext  = vm;
            vm.Finished += OnImportFinished;
        }
示例#18
0
        public ImportPage()
        {
            InitializeComponent();

            ImportViewModel viewModel = new ImportViewModel(this, ctrProducts, ctrlSelected, ctrProducts.spProductType, ctrProducts.svProductList, ctrlSelected.lbList, crtlRequest.ugRequestList);

            this.DataContext = viewModel;
        }
示例#19
0
        public IActionResult Index()
        {
            var model = new ImportViewModel
            {
                AreYouSerious = false
            };

            return(View(model));
        }
示例#20
0
        protected async override void OnExecute(object parameter)
        {
            if (this.cremaAppHost.GetService(typeof(IDataBase)) is IDataBase dataBase)
            {
                var dialog = await ImportViewModel.CreateInstanceAsync(this.authenticator, dataBase);

                dialog?.ShowDialog();
            }
        }
示例#21
0
        public async Task <ActionResult> Import([FromBody] ImportViewModel model) =>
        await _db.ResultAsJson(async (conn, tran) => {
            foreach (var credential in model.Credentials)
            {
                credential.CredentialID = Guid.NewGuid().ToString();
                await conn.ExecuteAsync(SqlStatements.Insert, credential, tran);
            }

            return(Json(new { done = true }));
        });
        public async Task <IActionResult> CreateImport()
        {
            var departments = await _departmentService.FindAllAsync();

            var viewModel = new ImportViewModel {
                Departments = departments
            };

            return(View(viewModel));
        }
示例#23
0
        public async Task <ActionResult> ImportSummary(ImportExceptionParameters parameters)
        {
            var importView = await ImportViewModel.GetModel(DataContext,
                                                            new ImportQueueFilter(parameters.ImportQueueId.GetValueOrDefault())
            {
                Action = ImportAction.Summary
            });

            return(PartialView("_ImportSummary", importView));
        }
示例#24
0
 public static void UpdateImport(this Import import, ImportViewModel importViewModel)
 {
     import.ID          = importViewModel.ID;
     import.CreatedDate = importViewModel.CreatedDate;
     import.CreatedBy   = importViewModel.CreatedBy;
     import.UpdatedDate = importViewModel.UpdatedDate;
     import.UpdatedBy   = importViewModel.UpdatedBy;
     import.Status      = importViewModel.Status;
     import.Description = importViewModel.Description;
 }
示例#25
0
        public IActionResult Process(ImportViewModel viewModel)
        {
            var events = _starter.StartParse(viewModel.startFile, viewModel.endFile);

            foreach (var item in events)
            {
                _eventRepository.Create(item);
            }
            return(View(new ImportViewModel()));
        }
示例#26
0
        public ViewResult Index()
        {
            var model = new ImportViewModel();

            model.BaseUrl      = ConfigurationManager.AppSettings["PublicServiceBaseUrl"];
            model.Token        = ConfigurationManager.AppSettings["PublicServiceToken"];
            model.LedgerList   = new SelectList(_db.Query(new GetAllLedgersQuery()).Where(l => l.IsActive), "Ledger", "LedgerDesc");
            model.AccountsList = new SelectList(_db.Query(new GetAllAccountsQuery()), "Id", "Desc");
            return(View(model));
        }
示例#27
0
        /// <summary>
        /// Constructor used to create a view by using a controler.
        /// </summary>
        /// <param name="Manager"></param>
        public ImportView(ImportViewModel Manager)
        {
            this.Manager   = Manager;
            this.IsLoading = false;

            InitializeComponent();
            this.Import_type_comboBox.Items.AddRange(new object[] { "Ajouter", "Ecraser" });
            this.progressBar.Minimum = 1;
            this.progressBar.Step    = 1;
        }
        public IActionResult StartImport(ImportViewModel model)
        {
            var client = GetExternalRepositoryClient();

            client.StartImport(model.ExternalRepositoryCheckBoxes.Where(x => x.IsChecked).Select(x => x.Id).ToList());
            return(View("ImportStatus",
                        new ImportViewModel
            {
                ExternalRepositoryCheckBoxes = model.ExternalRepositoryCheckBoxes.Where(x => x.IsChecked).ToList()
            }));
        }
示例#29
0
        public ActionResult FileFields(int parentId, int id, FormCollection collection)
        {
            var model = new ImportViewModel();

            TryUpdateModel(model);

            model.SetCorrespondingFieldName(collection);
            var settings = model.GetImportSettingsObject(parentId, id);

            return(Json(MultistepActionHelper.GetFileFields(settings, new FileReader(settings))));
        }
示例#30
0
        public ActionResult Import(ImportViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            StartImport(model.ISSNs, JournalsImportMode.InsertOnly);

            return(RedirectToAction("Imported"));
        }
 protected void ImportDialog(ImportViewModel vm)
 {
     Messenger.Raise(new TransitionMessage(typeof(Views.ImportWindow), vm, TransitionMode.Modal, "Import"));
 }
示例#32
0
 public ActionResult Import()
 {
     var model = new ImportViewModel();
     return View(model);
 }