Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SearchCommand" /> class.
        /// </summary>
        /// <param name="maxRunsText">The maximum runs text.</param>
        /// <param name="city">The city.</param>
        /// <param name="state">The state.</param>
        /// <param name="zip">The zip.</param>
        /// <param name="namesFilePath">The names text file path.</param>
        /// <param name="options">The options.</param>
        public SearchCommand(string maxRunsText, string city, string state, string zip, string namesFilePath, CommandLineOptions options)
        {
            int.TryParse(maxRunsText, out int maxRuns);
            _maxRuns          = maxRuns;
            _city             = city;
            _state            = state;
            _zip              = zip;
            _namesFilePath    = namesFilePath;
            _resultOutputPath = Program.SearchResultsDirectory;
            _options          = options;

            this.Repository           = Program.Repository;
            this.Configuration        = Program.Configuration;
            this.FindPersonController = new FindPersonController(this.Configuration);
            this.Import             = new Import();
            this.Export             = new Export();
            this.Mapper             = MapperFactory.Get();
            this.SerializerSettings = JsonSerializerSettingsFactory.Get();


            //Default Value
            this.SearchWaitMs = 60000;
            var waitMs = Configuration.GetValue <string>("SearchSettings:WaitMs");

            int.TryParse(waitMs, out this.SearchWaitMs);


            this.PeopleSearch = new PeopleSearch(Repository, FindPersonController, SerializerSettings, Mapper, Export, _resultOutputPath, SearchWaitMs);
        }
Example #2
0
        public ImportControllerTest()
        {
            var provider = new ServiceCollection()
                           .AddMemoryCache()
                           .BuildServiceProvider();

            var memoryCache = provider.GetService <IMemoryCache>();

            var builder = new DbContextOptionsBuilder <ApplicationDbContext>();

            builder.UseInMemoryDatabase("test");
            var options = builder.Options;
            var context = new ApplicationDbContext(options);

            var services = new ServiceCollection();

            _appSettings = new AppSettings();

            // Add Background services
            services.AddSingleton <IHostedService, UpdateBackgroundQueuedHostedService>();
            services.AddSingleton <IUpdateBackgroundTaskQueue, UpdateBackgroundTaskQueue>();

            var serviceProvider = services.BuildServiceProvider();

            // get the background helper
            _bgTaskQueue = serviceProvider.GetRequiredService <IUpdateBackgroundTaskQueue>();

            _scopeFactory = serviceProvider.GetRequiredService <IServiceScopeFactory>();
            _import       = new FakeIImport(new FakeSelectorStorage(new FakeIStorage()));
        }
Example #3
0
        public FileHandler(Window parent, IInfo info, ILastFileHandler lfh, UndoManager undo)
        {
            this.parent = parent;
            this.info   = info;
            this.lfh    = lfh;
            this.undo   = undo;

            FileState = new FileState();
            FileState.FileStateInternalChanged += (s, e) => OnFileStateChanged();

            open = new XMLImport();
            save = new XMLExport();

            saveFileDialog   = new SaveFileDialog();
            openFileDialog   = new OpenFileDialog();
            exportFileDialog = new SaveFileDialog();
            importFileDialog = new OpenFileDialog();

            saveFileDialog.AddLegacyFilter(save.Filter);
            openFileDialog.AddLegacyFilter(open.Filter);

            FileOpened += (s, e) => MaybeUpgradeTtVersion();

            SetLastPath(info.Settings.Get("files.lastpath", ""));
        }
Example #4
0
        public static void Load(this Worksheet self, IImport import)
        {
            self.Cells[0, 0].Value = string.Empty;
            var attributes = import.GetAttributes();

            for (int i = 0; i < attributes.Count; i++)
            {
                self.Cells[0, i + 1].Value = attributes[i];
            }
            var obj = import.GetObjects();

            for (int i = 0; i < obj.Count; i++)
            {
                self.Cells[i + 1, 0].Value = obj[i];
            }
            var context = import.GetContext();

            for (int i = 0; i < context.Count; i++)
            {
                for (int j = 0; j < context[i].Count; j++)
                {
                    self.Cells[i + 1, j + 1].Value = context[i][j];
                }
            }
        }
Example #5
0
        public MainViewModel()
        {
            this._Logger          = ServiceLocator.Current.GetInstance <ILog>();
            this._resourceManager = ServiceLocator.Current.GetInstance <IResourceManager>();
            this._resourceManager.InitialiseResources(false);
            this._Settings = (Settings)this._resourceManager.GetResourcePayload(ResourceName.Mapping_Settings);
            if (this._Settings == null)
            {
                this._Settings = new Settings();
            }
            else
            {
                this._LocalImportPath = this._Settings.ListOfSettings.Where(i => i.Name == "Import_Folder").Select(i => i.Data).FirstOrDefault();
                this.RemoteImportPath = this._Settings.ListOfSettings.Where(i => i.Name == "Remote_Import_Folder").Select(i => i.Data).FirstOrDefault();
                this.ExportPath       = this._Settings.ListOfSettings.Where(i => i.Name == "Export_Folder").Select(i => i.Data).FirstOrDefault();
            }

            this.isPrecheckEnabled = true;
            this.isAllChecked      = false;
            this.isReadCloud       = true;
            this._DBActions        = ServiceLocator.Current.GetInstance <IDBActions>();

            this.isFlushDB = true;
            this.isImport  = true;

            this._Importer = ServiceLocator.Current.GetInstance <IImport>();
            this._Exporter = ServiceLocator.Current.GetInstance <IExport>();

            if (this._RemoteImportPath != null)
            {
                this.PreChecks();
            }
        }
        static void DataImport(IImport import)
        {
            var cts = new CancellationTokenSource();

            cts.CancelAfter(4000);


            var ct = cts.Token;

            Task importTask = import.ImportXmlFilesAsync(@"C:\data", ct);

            while (!importTask.IsCompleted)
            {
                Console.Write(".");
                if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Q)
                {
                    try
                    {
                        cts.Cancel();
                        importTask.Wait();
                    }
                    catch (AggregateException ex)
                    {
                        Console.WriteLine(ex.Flatten());
                    }
                }
                Console.WriteLine(importTask.Status);
                Thread.Sleep(250);
            }
        }
Example #7
0
 public ImportCli(IImport importService, AppSettings appSettings, IConsole console, IExifToolDownload exifToolDownload)
 {
     _importService    = importService;
     _appSettings      = appSettings;
     _console          = console;
     _exifToolDownload = exifToolDownload;
 }
Example #8
0
        public HttpResponseMessage Upload()
        {
            HttpPostedFile file = HttpContext.Current.Request.Files["school"];

            ErrMsg         msg    = new ErrMsg();
            IImport        import = ExcelFactory.Instance().GetExcelImporter(new eh.impls.configurations.ExcelConfiguration(1, 0, 0), msg);
            IList <School> list   = SchoolDto.ToList(import.Import <SchoolDto>(file.InputStream));

            if (msg.Count != 0)
            {
                return(ToJson(msg.GetErrors(), status_code: 0, msg: "fail"));
            }
            else
            {
                try
                {
                    Service.Add(list);
                    return(ToJson("success"));
                }
                catch (SqlException ex)
                {
                    msg.AddErrMsg(ex.Message);
                    return(ToJson(msg.GetErrors(), status_code: 0, msg: "fail"));
                }
            }
        }
Example #9
0
 public void do_import_does_not_write_data_into_server_if_sourceConnectionString_empty()
 {
     _source.GetConnectionString().Returns(string.Empty);
     sut = new Import(_source, _target, _reader, _writer);
     sut.DoImport("ehasan", null);
     Assert.AreEqual(false, _writer.IsDataSaved);
 }
Example #10
0
        internal void Import()
        {
            var importers = info.GetRegistered <IImport>();

            if (importers.Length == 0)
            {
                info.Logger.Error("Keine Importer gefunden, Import nicht möglich!");
                return;
            }

            if (!NotifyIfUnsaved())
            {
                return;
            }
            if (importFileDialog.ShowDialog(parent) == DialogResult.Ok)
            {
                IImport import = importers[importFileDialog.CurrentFilterIndex - 1];
                info.Logger.Info("Öffne Datei " + importFileDialog.FileName);
                Timetable = import.Import(importFileDialog.FileName, info);
                if (Timetable == null)
                {
                    return;
                }
                info.Logger.Info("Datei erfolgeich geöffnet!");
                FileState.Opened   = true;
                FileState.Saved    = true;
                FileState.FileName = importFileDialog.FileName;
                undo.ClearHistory();
            }
        }
Example #11
0
        private void LoadLine()
        {
            if (tt.Stations.Count != 0)
            {
                return;
            }
            if (info.Timetable.Type == TimetableType.Network)
            {
                throw new Exception("Streckendateien können bei Netzwerk-Fahrplänen nicht geladen werden!");
            }

            IImport timport = new XMLImport();
            IImport simport = new NonDefaultFiletypes.XMLStationsImport();

            using (var ofd = new OpenFileDialog())
            {
                ofd.AddLegacyFilter(timport.Filter, simport.Filter);

                if (ofd.ShowDialog(this) == DialogResult.Ok)
                {
                    IImport import = Path.GetExtension(ofd.FileName) == ".fpl" ? timport : simport;
                    var     ntt    = import.Import(ofd.FileName, info);
                    foreach (var station in ntt.Stations)
                    {
                        tt.AddStation(station, Timetable.LINEAR_ROUTE_ID);
                    }
                    // ntt will be destroyed by decoupling stations, do not use afterwards!
                }
            }

            UpdateStations();
        }
Example #12
0
        public AppEngine(IExcel iExcel, IEventAggregator iAgregator, IOutput iOutput, IImport import, IBudgetRepository repository)
        {
            _IExcel      = iExcel;
            _iAggregator = iAgregator;
            _iOutput     = iOutput;
            _import      = import;
            _repository  = repository;

            _iAggregator.SubsribeEvent(this);

            string path       = _repository.Options.Item.CategoryPath;
            string reportPath = _repository.Options.Item.DocumentPath;

            _repository.Categories.Load(path);
            _repository.Reports.Load(reportPath);
            _iOutput.ShowReports(_repository.Reports.Item.Reports);
            _iAggregator.PublishEvent(new PathChangedEvent()
            {
                Path = path
            });

            MenuItem menuStructure = MenuFactory.GetMenu();

            _iOutput.AttachMenu(menuStructure);

            ProceedEditRules();
        }
Example #13
0
        public async Task <IActionResult> Connect([Bind("ID, Credential, Issues")] Project project)
        {
            if (ModelState.IsValid)
            {
                importService = ImportFactory.GetImportFrom("jira");
                //importService.Connect(new Credential()
                //{
                //    Uri = "https://queryexport.atlassian.net",
                //    Username = "******",
                //    Password = "******"
                //});
                //if (project.ID == 0)
                //{
                //    _context.Add(project);
                //    await _context.SaveChangesAsync();
                //}
                importService.Connect(new Credential()
                {
                    Uri      = project.Credential.Uri,
                    Username = project.Credential.Username,
                    Password = project.Credential.Password
                });

                var res = await importService.GetIssuesForProject();

                project.Issues = res;

                _context.Add(project);
                await _context.SaveChangesAsync();
            }
            return(RedirectToAction("Index"));
        }
Example #14
0
        public Import(VolumeDatabase db)
        {
            this.database = db;
            this.import   = null;

            BuildGui();
            btnImport.Sensitive = false;             // will be enabled on file selection
        }
        /// <summary>
        /// Sets the import location.
        /// </summary>
        /// <param name="importLocation">The import location.</param>
        public virtual void SetImportLocation(IImport importLocation)
        {
            Debug.Assert(importLocation != null);
            Debug.Assert(!IsLocationAssigned || ImportLocation == importLocation);

            _ImportLocation    = importLocation;
            IsLocationAssigned = true;
        }
Example #16
0
 public void Setup()
 {
     _source = Substitute.For <IData>();
     _target = Substitute.For <IData>();
     _reader = Substitute.For <IReader>();
     _writer = new SqlBulkCopyDataWriterFake();
     sut     = new Import(_source, _target, _reader, _writer);
 }
Example #17
0
        public Import(VolumeDatabase db)
        {
            this.database = db;
            this.import = null;

            BuildGui();
            btnImport.Sensitive = false; // will be enabled on file selection
        }
Example #18
0
        /// <summary>
        /// 验证数据
        /// </summary>
        public virtual void ValidationValueAfter()
        {
            IImport <TEntity> import = ServiceContainer.GetService <IImport <TEntity> >();

            if (import != null)
            {
                import.ValidationValueAfter(ExcelGlobalDTO);
            }
        }
Example #19
0
 private IEnumerable<Transaction> BuildTransaction(IImport import)
 {
     return
         from row in import.GetData()
         where row.Amount != 0M
         let account = GetAccount(row) ?? row.IdentifyAccount(_context.Patterns) ?? UnclassifedDestination
         let description = GetDescription(row)
         where account != null
         select AsTransaction(row, account, description);
 }
Example #20
0
        public View(IImport dl, IDeclineData d, IMethod m, IChart c, IExport e)
        {
            dataImport  = dl;
            declineData = d;
            method      = m;
            chart       = c;
            dataExport  = e;

            dataView = new SortedDictionary <DateTime, double>();
        }
Example #21
0
 public EntriesController(ApplicationDbContext context,
                          IImport import,
                          IServiceProvider serviceProvider,
                          UserManager <AppUser> userManager)
 {
     _import          = import;
     _context         = context;
     _userManager     = userManager;
     _serviceProvider = serviceProvider;
 }
Example #22
0
        public IEnumerable<Transaction> Process(IImport import, IDictionary<string, ImportRowOptions> mappings = null)
        {
            Result.Date = DateTimeServer.Now;
            Result.Name = import.Name;
            Result.ImportType = import.ImportType;

            _mappings = mappings;

            return BuildTransaction(import).Where(transaction => _context.General.Post(transaction));
        }
Example #23
0
        public void do_import_does__write_data_into_server_if_all_above_conditions_met()
        {
            _source.GetConnectionString().Returns("ConnectiontionString");
            _source.GetSql().Returns("Sql");
            _target.GetConnectionString().Returns("ConnectiontionString");

            sut = new Import(_source, _target, _reader, _writer);
            sut.DoImport("ehasan", null);
            Assert.AreEqual(true, _writer.IsDataSaved);
        }
Example #24
0
        private void SaveImportToDatabase()
        {
            Import <T> temp = new Import <T>().Where("import_month ={0} AND import_year={1}".Format(_import.ImportMonth, _import.ImportYear)).FirstOrDefault();

            if (temp == null)
            {
                _import.Add();
            }
            else
            {
                _import = temp;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ImportSearchesCommand" /> class.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="options">The options.</param>
        public ImportSearchesCommand(string path, CommandLineOptions options)
        {
            _path    = path;
            _options = options;

            this.Repository         = Program.Repository;
            this.Import             = new Import();
            this.Export             = new Export();
            this.Mapper             = MapperFactory.Get();
            this.SerializerSettings = JsonSerializerSettingsFactory.Get();

            this.ImportExport = new ImportExport(Repository, SerializerSettings, Mapper, Import, Export);
        }
Example #26
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportPeopleCommand" /> class.
        /// </summary>
        /// <param name="options">The options.</param>
        public ExportPeopleCommand(CommandLineOptions options)
        {
            _options = options;

            this.Repository         = Program.Repository;
            this.Import             = new Import();
            this.Export             = new Export();
            this.Mapper             = MapperFactory.Get();
            this.SerializerSettings = JsonSerializerSettingsFactory.Get();

            _fullPath = Path.Combine(Program.ExportDirectory, $"PeopleExport-{DateTime.Now}.csv");

            this.ImportExport = new ImportExport(Repository, SerializerSettings, Mapper, Import, Export);
        }
Example #27
0
 public ImportController(IImport import, AppSettings appSettings,
                         IUpdateBackgroundTaskQueue queue,
                         IHttpClientHelper httpClientHelper, ISelectorStorage selectorStorage,
                         IServiceScopeFactory scopeFactory, IWebLogger logger)
 {
     _appSettings           = appSettings;
     _import                = import;
     _bgTaskQueue           = queue;
     _httpClientHelper      = httpClientHelper;
     _selectorStorage       = selectorStorage;
     _hostFileSystemStorage = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
     _thumbnailStorage      = selectorStorage.Get(SelectorStorage.StorageServices.Thumbnail);
     _scopeFactory          = scopeFactory;
     _logger                = logger;
 }
Example #28
0
 public UploadController(IImport import, AppSettings appSettings,
                         ISelectorStorage selectorStorage, IQuery query,
                         IRealtimeConnectionsService connectionsService, IWebLogger logger,
                         IMetaExifThumbnailService metaExifThumbnailService)
 {
     _appSettings              = appSettings;
     _import                   = import;
     _query                    = query;
     _selectorStorage          = selectorStorage;
     _iStorage                 = selectorStorage.Get(SelectorStorage.StorageServices.SubPath);
     _iHostStorage             = selectorStorage.Get(SelectorStorage.StorageServices.HostFilesystem);
     _connectionsService       = connectionsService;
     _logger                   = logger;
     _metaExifThumbnailService = metaExifThumbnailService;
 }
Example #29
0
 public static Timetable?SafeImport(this IImport imp, string filename, IReducedPluginInterface pluginInterface, ILog?replaceLog = null)
 {
     try
     {
         using (var stream = File.Open(filename, FileMode.OpenOrCreate, FileAccess.Read))
             return(imp.Import(stream, pluginInterface, replaceLog));
     }
     catch (Exception ex)
     {
         var log = replaceLog ?? pluginInterface.Logger;
         log.Error(imp.GetType().Name + ": " + ex.Message);
         log.LogException(ex);
         return(null);
     }
 }
Example #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ImportExport" /> class.
        /// </summary>
        /// <param name="repository">The repository.</param>
        /// <param name="serializerSettings">The serializer settings.</param>
        /// <param name="mapper">The mapper.</param>
        /// <param name="import">The import.</param>
        /// <param name="export">The export.</param>
        public ImportExport(IEntityFrameworkRepository repository,
                            JsonSerializerSettings serializerSettings,
                            IMapper mapper,
                            IImport import,
                            IExport export)
        {
            this.Repository         = repository;
            this.SerializerSettings = serializerSettings;
            this.Mapper             = mapper;
            this.Import             = import;
            this.Export             = export;

            this.PersonSearchResultHelper = new PersonSearchResultHelper(repository, serializerSettings, mapper);
            this.PersonHelper             = new PersonHelper(repository, mapper);
        }
Example #31
0
        private static bool ImportHandler(YangStatement statement, IImport partial)
        {
            switch (statement.Keyword)
            {
            case "prefix":
                partial.Prefix = statement.Argument;
                return(true);

            case "revision-date":
                partial.Revision = statement.Argument;
                return(true);

            default:
                return(false);
            }
        }
Example #32
0
        public static void DataImport(IImport import)
        {
            var tcs = new CancellationTokenSource();
            CancellationToken ct = tcs.Token;

            Task importTask = import.ImportXmlFilesAsync(@"C:\data", ct);

            while (!importTask.IsCompleted)
            {
                Console.Write(".");
                if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Q)
                {
                    tcs.Cancel();
                }
                Thread.Sleep(250);
            }
        }
        public static void DataImport(IImport import)
        {
            var tcs = new CancellationTokenSource();
            CancellationToken ct = tcs.Token;

            Task importTask = import.ImportXmlFilesAsync(@"..\..\data", ct, new Progress <ImportProgress>(DisplayProgress));

            while (!importTask.IsCompleted)
            {
                if (Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Q)
                {
                    tcs.Cancel();
                }
                Thread.Sleep(250);
            }
            Console.WriteLine(importTask.Status);
        }
Example #34
0
        public void Init(ParsingContext context, ParseTreeNode parseNode, IGraphDS myGraphDS)
        {
            base.InitNode(context, parseNode, myGraphDS);
            _pluginManager.Discover();

            _componentName = parseNode.ChildNodes[1].Token.ValueString;

            if (base.CheckForComponent<IImport>(_componentName, context, parseNode.ChildNodes[1].Token.Location))
            {
                Dictionary<String, String> options;
                if (parseNode.ChildNodes[2].ChildNodes.Count > 0)
                {
                    options = ((OptionsNode)(parseNode.ChildNodes[2].AstNode)).Options;
                }
                else
                {
                    options = new Dictionary<String, String>();
                }

                _import = _pluginManager.GetAndInitializePlugin<IImport>(
                    _componentName,
                    base.PreparePluginOptions(options, _graphDS));
            }
        }
Example #35
0
        private void OnFcDatabaseSelectionChanged(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(fcDatabase.Filename)) {
                import = null;
                lblFormat.Text = LBL_FORMAT_EMPTY;
                btnImport.Sensitive = false;
                return;
            }

            string sourceDbPath = fcDatabase.Filename;
            string dbDataPath = PathUtil.GetDbDataPath(database);
            int buffSize = App.Settings.ScannerBufferSize;
            string ext = System.IO.Path.GetExtension(sourceDbPath);

            if (ext.Length == 0)
                import = null;
            else
                import = AbstractImport.GetImportByExtension(ext.Substring(1), sourceDbPath,
                                                              database, dbDataPath, buffSize);

            if (import == null) {
                lblFormat.Text = S._("Unknown format.");
                btnImport.Sensitive = false;
            } else {
                import.ProgressUpdate	+= OnImportProgressUpdate;
                import.ImportCompleted	+= OnImportCompleted;

                lblFormat.Text = import.Name;
                btnImport.Sensitive = true;
            }
        }
 public CatWebserviceWrapper(IImport service)
 {
     Webservice = service;
     WebserviceState = WebserviceWrapperState.Disconnected;
     RegisterServiceEvents();
 }