Exemplo n.º 1
0
        public void OnRitualStart()
        {
            isStart = true;

            //pause all text plot
            foreach (var playingPlot in parent.playingPlot)
            {
                if (playingPlot is Text)
                {
                    var textPlayingPlot = playingPlot as Text;
                    textPlayingPlot.Pause();
                    onPlotFinish += () => textPlayingPlot.UnPause();
                    onPlotBreak  += () => textPlayingPlot.UnPause();
                }
            }

            //hang the prefab on the page obj
            foreach (var item in Services.pageState.GetGameState("Ritual_Empty").relatedObj)
            {
                if (item.CompareTag("PageObj"))
                {
                    if (ritualPrefab == null)
                    {
                        ritualPrefab = GameObject.Instantiate(FileImporter.GetRitual(name), item.transform);
                    }

                    break;
                }
            }
        }
Exemplo n.º 2
0
        public ImporterHelper()
        {
            // Create importer
            DiagnosticsTextFileImporter = FileImporter
                                          .ForTextFile()
                                          .WithFixedWidthColumns()
                                          .IgnoringFirstLine(false)
                                          .HasColumn(0, 5)
                                          .HasColumn(6, 7)
                                          .HasColumn(14, 1)
                                          .HasColumn(16, 60)
                                          .HasColumn(77)
                                          .AdaptTo <Icd10Diagnostic>((e, columns) =>
            {
                e.Order = int.Parse(columns[0].Trim());

                // Get code and add point
                var code = columns[1].Trim();
                e.Code   = (code.Length > 3 ? code.Insert(3, ".") : code);

                // Boolean is true if marked as "1", which is billable.
                e.ValidForSubmission = columns[2].Trim() == "1";

                // Code Descriptions
                e.ShortDescription = columns[3].Trim();
                e.LongDescription  = columns[4].Trim();
            });
        }
Exemplo n.º 3
0
        public void ImportDecodesWithMissingGageHeight()
        {
            FileUtility.CleanTempPath();
            var fn1 = FileUtility.GetTempFileName(".pdb");

            Console.WriteLine(fn1);
            var svr = new SQLiteServer(fn1);
            var db  = new TimeSeriesDatabase(svr, Reclamation.TimeSeries.Parser.LookupOption.TableName);

            Logger.EnableLogger();

            var tmpDir = CopyTestDecodesFileToTempDirectory("decodes_mabo_missing_gh.txt");
            var ratingTableFileName = CreateTempRatingTable("mabo.csv", 2.37, 2.8, x => (x * 10));
            var c = new CalculationSeries("instant_mabo_q");

            c.Expression = "FileRatingTable(mabo_gh,\"" + ratingTableFileName + "\")";
            db.AddSeries(c);

            FileImporter import = new FileImporter(db);

            import.Import(tmpDir, RouteOptions.Outgoing, computeDependencies: true, searchPattern: "*.txt");
            db.Inventory();

            var s = db.GetSeriesFromTableName("instant_mabo_q");

            s.Read();
            Assert.IsTrue(s.CountMissing() == 0);
            Assert.IsTrue(s.Count > 0, "No flow data computed");
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create()
        {
            IFormFile file = Request.Form.Files[0];

            string webRootPath    = _hostingEnvironment.WebRootPath;
            int    importerId     = Int32.Parse(Request.Form["DbImportTypeId"]);
            var    dbImporterType = _importerResolver.GetDbImporterTypeById(importerId);
            Action <FileStream, IFormFile, string> readFileAction = (stream, formFile, extension) => {
                _importer = _importerResolver.Resolve(dbImporterType.ImporterClass, new object[] { stream, file, extension, _context });
            };

            FileImporter.Import(file, webRootPath, readFileAction);

            var dbImport = new DbImport()
            {
                ImportedDate     = DateTime.Now,
                ImportedFileName = file.FileName,
                DbImportTypeId   = importerId,
                PatientsCount    = _importer.Imported.Count()
            };

            _context.Add(dbImport);
            SaveItemsInDatabase();
            await _context.SaveChangesAsync();

            return(Json(new { result = _importer.Imported.Count() }));
        }
Exemplo n.º 5
0
        private void MainForm_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                string[] fileDrop = (string[])e.Data.GetData(DataFormats.FileDrop);

                if (null != fileDrop)
                {
                    string filename = fileDrop.GetValue(0).ToString();

                    UsageDataMessage currentMessage = FileImporter.ReadMessage(filename);

                    using (StringWriter w = new StringWriter())
                    {
                        using (XmlTextWriter xmlWriter = new XmlTextWriter(w))
                        {
                            xmlWriter.Formatting = Formatting.Indented;
                            DataContractSerializer serializer = new DataContractSerializer(typeof(UsageDataMessage));
                            serializer.WriteObject(xmlWriter, currentMessage);
                        }
                        FileContents.Text = w.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                FileContents.Text = ex.ToString();
            }
        }
Exemplo n.º 6
0
        private void mImportButton_Click(object sender, EventArgs e)
        {
            if (FileImporter.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            if (!File.Exists(FileImporter.FileName))
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(mScriptEditor.Text))
            {
                const string message = "Are you sure you want to open this file? "
                                       + "The current script will be replaced with the file you selected.";
                DialogResult result =
                    MessageBox.Show(message, "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.No)
                {
                    return;
                }
            }

            mScriptEditor.Text = File.ReadAllText(FileImporter.FileName);
        }
Exemplo n.º 7
0
        //OnFirstTime contructor collecting data from file
        //TODO: read data from database
        public MockRateRepository(IConfiguration config)
        {
            var dir           = config["ImportPath"];
            var daysShowCount = config["DaysShowCount"];

            _fileImpoerter = new FileImporter(dir, daysShowCount);
        }
Exemplo n.º 8
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     This is a 4 step process 1. gather the file paths for each service into a collection of
        ///     service names to file paths 2. for each file parse the parameter names seen by a single
        ///     service into unique column names 3. for each file write the data obtained from a single
        ///     service call into a the target files as a new row under their appropriate column 4.
        ///     repeat steps 2 and 3 foreach service.
        /// </summary>
        ///
        /// <remarks>   Ahaynes, 12/12/2016. </remarks>
        ///
        /// ### <param name="args"> . </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        private static void StartProc()
        {
            ServiceLogger.WriteLine();
            FileImporter fileImporter = new FileImporter();

            //Write column headers for the call log only once
            CallLogBuilder.WriteColumnHeaders();
            //itterate through each service
            foreach (KeyValuePair <string, List <string> > kvp in serviceFilePaths)
            {
                //itterate through each file for this service
                foreach (string filePath in kvp.Value)
                {
                    //gather parameter names used in all calls of a service into the serviceColumns collection
                    fileImporter.ImportColumns(kvp.Key, filePath);
                }

                //print column headers to their appropriate files
                DataSheetBuilder.WriteColumnHeaders(kvp.Key);
                UsageStatisticsBuilder.WriteColumnHeaders(kvp.Key);

                //itterate through each file for this service again
                foreach (string filePath in kvp.Value)
                {
                    //Gather data per service call adding counts to the count collections (columnNullCount, columnEmptyCount, columnSeenCount)
                    //prints data per service call to the call log and data sheets
                    fileImporter.ImportValues(kvp.Key, filePath);
                }
                //print all of the statistics of a service to the usage statics sheet at once
                UsageStatisticsBuilder.AppendRowToFile(kvp.Key);
                // clear the collections for this service, they are no longer needed in memory
                ClearServiceCollections(kvp);
            }
        }
Exemplo n.º 9
0
        // GET: api/Preview/5
        public IEnumerable <Contragent> Get(string id)
        {
            string root         = System.Web.HttpContext.Current.Server.MapPath("~/Files/");
            string fileFullName = root + id;

            if (!System.IO.File.Exists(fileFullName))
            {
                var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content      = new StringContent(string.Format("Файл не найден на сервере. ID = {0}", id)),
                    ReasonPhrase = "Файл не найден на сервере"
                };
                throw new HttpResponseException(resp);
            }

            var FileImporter = new FileImporter(fileFullName);

            if (!FileImporter.TestImport())
            {
                var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content      = new StringContent(string.Format("При импорте данных из файла произошла ошибка. Сообщение = {0}.", FileImporter.LastError)),
                    ReasonPhrase = "При импорте данных из файла произошла ошибка"
                };
                throw new HttpResponseException(resp);
            }

            return(FileImporter.GetAllContragents());
        }
        public static void Should_Import_ReturnLoadedData_WhenInputIsValid()
        {
            // Arrange
            string[] input = new string[]
            {
                "Tree,Girth,Height,Volume",
                "1,8.3,70,10.3"
            };

            var expected = new DataItem
                           (
                "1",
                "8.3",
                "70",
                "10.3"
                           );

            var fileProvider = Substitute.For <IFileProvider>();

            fileProvider.ReadAllLines(Arg.Any <string>()).Returns(input);

            var fileSanitiser = new FileSanitiser(fileProvider);
            var fileLoader    = new FileLoader();

            var sut = new FileImporter(fileLoader, fileSanitiser);

            // Act
            var actual = sut.ReturnLoadedData(input);

            // Assert
            actual.Should().BeEquivalentTo(expected);
        }
        public void import_and_parse_each_line_of_code()
        {
            var expectedLine1    = Any.Length();
            var expectedLine2    = Any.Length();
            var expectedFileName = "expectedFileName";

            var parserStub = new Mock <IParser <string, int> >();

            parserStub.Setup(p => p.ParseSingle("a")).Returns(expectedLine1);
            parserStub.Setup(p => p.ParseSingle("b")).Returns(expectedLine2);
            var fileImportAdapterStub = new Mock <FileImportAdapter>();

            fileImportAdapterStub.Setup(f => f.ReadFileToArray(expectedFileName))
            .Returns(new List <string> {
                "a", "b"
            }.ToArray());
            var fileImporter = new FileImporter <int>(parserStub.Object,
                                                      fileImportAdapterStub.Object);

            var result = fileImporter.ReadFileToArray(expectedFileName);

            Assert.AreEqual(2, result.Length);
            Assert.AreEqual(expectedLine1, result[0]);
            Assert.AreEqual(expectedLine2, result[1]);
        }
Exemplo n.º 12
0
        private bool MoveEntities(string newPath)
        {
            DirectoryInfo newDir = new DirectoryInfo(newPath);

            if (!newDir.Exists)
            {
                ErrorLogger.Append(new Exception("Can't move Servers/Networks to not existing dir: " + newPath));
                return(false);
            }

            foreach (EntityViewModel entityViewModel in Entities)
            {
                string currEntityPath = Path.Combine(App.ServerPath, entityViewModel.Entity.Name);
                string newEntityPath  = Path.Combine(newPath, entityViewModel.Entity.Name);

                entityViewModel.StartImport();
                new Thread(() =>
                {
                    //Directory.Move(currEntityPath,newEntityPath);
                    FileImporter fileImporter         = new FileImporter();
                    fileImporter.CopyProgressChanged += entityViewModel.CopyProgressChanged;
                    fileImporter.DirectoryMove(currEntityPath, newEntityPath, true);
                    Console.WriteLine("Finished moving entity files for entity " + entityViewModel.Name);
                    entityViewModel.FinishedCopying();
                }).Start();
            }

            AppSettingsSerializer.AppSettings.ServerPath = newPath;
            AppSettingsSerializer.SaveSettings();
            return(true);
        }
Exemplo n.º 13
0
 public WebFormHandler(UserConnection userConnection, IWebFormImportParamsGenerator importParamsGenerator,
                       IWebFormProcessHandlersFactory factory, FileImporter fileImporter)
 {
     _userConnection               = userConnection;
     ImportParamsGenerator         = importParamsGenerator;
     WebFormProcessHandlersFactory = factory;
     FileImporter = fileImporter;
 }
Exemplo n.º 14
0
        public void ImportDecodesAndProcessWithFlagLimits()
        {
            Logger.EnableLogger();
            FileUtility.CleanTempPath();
            var fn1 = FileUtility.GetTempFileName(".pdb");

            Console.WriteLine(fn1);
            var svr = new SQLiteServer(fn1);
            var db  = new TimeSeriesDatabase(svr, Reclamation.TimeSeries.Parser.LookupOption.TableName);

            var tmpDir = CopyTestDecodesFileToTempDirectory("decodes_lapo.txt");

            var rtlapo = CreateTempRatingTable("lapo.csv", new double[] { 3.50, 3.54, 3.55, 5.54 },
                                               new double[] { 1, 2, 3, 10 });
            // set limits  gh: low=3.53, high 3.6,  rate of change/hour 1
            Quality q = new Quality(db);

            q.SaveLimits("instant_lapo_gh", 3.6, 3.53, 1.0);
            q.SaveLimits("instant_lapo_q", 5, 1.1, 0);

            var site = db.GetSiteCatalog();

            site.AddsitecatalogRow("lapo", "", "OR");
            db.Server.SaveTable(site);
            var c = new CalculationSeries("instant_lapo_q");

            c.SiteID     = "lapo";
            c.Expression = "FileRatingTable(%site%_gh,\"" + rtlapo + "\")";
            db.AddSeries(c);

            //SeriesExpressionParser.Debug = true;
            FileImporter import = new FileImporter(db);

            import.Import(tmpDir, RouteOptions.None, computeDependencies: true, searchPattern: "*.txt");
            db.Inventory();


            var s             = db.GetSeriesFromTableName("instant_lapo_gh");
            var expectedFlags = new string[] { "", "", "", "+", "", "", "", "-" };

            for (int i = 0; i < s.Count; i++)
            {
                Assert.AreEqual(expectedFlags[i], s[i].Flag, " flag not expected ");
            }

            s = db.GetSeriesFromTableName("instant_lapo_q");
            s.Read();
            Assert.IsTrue(s.Count > 0, "No flow data computed lapo");
            s.WriteToConsole(true);
            // computed flows should be: 2 2 2 10 2 2 1
            expectedFlags = new string[] { "", "", "", "+", "", "", "", "-" }; //q>=1 and q<= 5
            for (int i = 0; i < s.Count; i++)
            {
                Assert.AreEqual(expectedFlags[i], s[i].Flag.Trim(), " Flag check on Flow (Q) ");
            }

            SeriesExpressionParser.Debug = false;
        }
Exemplo n.º 15
0
        public bool CloneNetwork(NetworkViewModel viewModel, List <string> usedEntityNames)
        {
            if (viewModel.CurrentStatus != ServerStatus.STOPPED)
            {
                StopNetwork(viewModel, false);
                while (viewModel.CurrentStatus != ServerStatus.STOPPED)
                {
                    Thread.Sleep(500);
                }
            }
            try
            {
                DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(App.ServerPath, viewModel.Name));
                if (!directoryInfo.Exists)
                {
                    ErrorLogger.Append(
                        new DirectoryNotFoundException("Could not find Directory " + directoryInfo.FullName));
                    return(false);
                }
                string newName = RefineName(viewModel.Name + "-Clone", usedEntityNames);

                //Better to use a object copy function
                string  oldNetworkJson = JsonConvert.SerializeObject(viewModel.Network);
                Network newNetwork     = JsonConvert.DeserializeObject <Network>(oldNetworkJson);

                newNetwork.Name = newName;
                newNetwork.UID  = Guid.NewGuid().ToString();
                NetworkViewModel newNetworkViewModel = new NetworkViewModel(newNetwork);

                string newNetworkPath = Path.Combine(App.ServerPath, newName);
                newNetworkViewModel.StartImport();
                Application.Current.Dispatcher?.Invoke(() => ServerManager.Instance.Entities.Add(newNetworkViewModel));
                ApplicationManager.Instance.MainViewModel.SelectedEntity = newNetworkViewModel;

                //Create server directory
                Directory.CreateDirectory(newNetworkPath);

                //Import server files
                Thread copyThread = new Thread(() =>
                {
                    FileImporter fileImporter         = new FileImporter();
                    fileImporter.CopyProgressChanged += newNetworkViewModel.CopyProgressChanged;
                    fileImporter.DirectoryCopy(directoryInfo.FullName, newNetworkPath, true, new List <string> {
                        "server.jar"
                    });
                    Console.WriteLine("Finished copying server files for server " + newNetworkPath);
                    newNetworkViewModel.FinishedCopying();
                });
                copyThread.Start();

                return(true);
            }
            catch (Exception e)
            {
                ErrorLogger.Append(e);
                return(false);
            }
        }
Exemplo n.º 16
0
        private void UpdateContact(Entity contact, Dictionary <string, string> contactValues)
        {
            UserConnection   userConnection        = Get <UserConnection>("UserConnection");
            var              importParamsGenerator = new BaseImportParamsGenerator();
            ImportParameters parameters            = importParamsGenerator.GenerateParameters(contact.Schema, contactValues);
            var              fileImporter          = new FileImporter(userConnection);

            fileImporter.ImportWithParams(parameters);
        }
Exemplo n.º 17
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>   Import column names. </summary>
 ///
 /// <remarks>   Ahaynes, 12/13/2016. </remarks>
 ///
 /// <param name="serviceName">  Name of the service. </param>
 /// <param name="fileLine">     The file line. </param>
 /// <param name="fileImporter"> The parent class instance. </param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 internal void ImportColumnNames(string serviceName, string fileLine, FileImporter fileImporter)
 {
     PushParameterArrayGroupName(fileLine);
     PushParameterGroupName(fileLine);
     BuildColumnHeaders(fileLine, serviceName);
     PopParameterArrayGroupName(fileLine);
     PopParameterGroupName(fileLine);
     lineInfo.previousLine = fileLine;
 }
Exemplo n.º 18
0
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>   Import column values. </summary>
 ///
 /// <remarks>   Ahaynes, 12/13/2016. </remarks>
 ///
 /// <param name="serviceName">  Name of the service. </param>
 /// <param name="fileLine">     The file line. </param>
 /// <param name="fileImporter"> The parent class instance. </param>
 ///
 /// <returns>   True if it succeeds, false if it fails. </returns>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 internal bool ImportColumnValues(string serviceName, string fileLine, FileImporter fileImporter)
 {
     PushParameterArrayGroupName(fileLine);
     PushParameterGroupName(fileLine);
     GetColumnValues(fileLine, serviceName);
     PopParameterArrayGroupName(fileLine);
     PopParameterGroupName(fileLine);
     lineInfo.previousLine = fileLine;
     return(ProccessServiceCallEnd(serviceName, fileLine, fileImporter));
 }
Exemplo n.º 19
0
        public void SimpleRecursive_wafi()
        {
            var c = new CalculationSeries("instant_wafi_ch");

            c.Expression = "GenericWeir(wafi_ch,0,16.835,1.5)";
            db.AddSeries(c);

            FileImporter fi = new FileImporter(db);

            fi.Import(dir, true, true, "*.wafi");
        }
Exemplo n.º 20
0
    protected void importap_Click(object sender, EventArgs e)
    {
        string adresafizicaserver = Server.MapPath("~");

        IMostreDB    mostre   = (IMostreDB) new MostreDB();
        FileImporter importer = new FileImporter(StaticDataHelper.FCCLDbContext, adresafizicaserver);

        importer.DoRemoteImport(mostre);

        BindData();
    }
Exemplo n.º 21
0
        public static void Part1()
        {
            var fileIo = new FileImporter <string>(new NullParser());
            var keypad = new Keypad();

            keypad.PrintKeypad();
            var keypadFollower = new KeypadFollower(new Coordinate(1, 1), keypad);
            var processor      = new KeypadProcessor(fileIo, keypadFollower);

            processor.Process("../../input.txt");
        }
Exemplo n.º 22
0
        /// <summary>
        /// Gets called when the import file button is clicked.
        /// This opens a file dialog to import a file.
        /// If the import is succesful the program advances to the typing state.
        /// </summary>
        private void ButtonImportFile_Click(object sender, RoutedEventArgs e)
        {
            if (FileImporter.OnClickImportFile())
            {
                typer = new Typer();
                keyboardHandler.ConnectToTyper(typer);
                typer.LoadText(FileImporter.GetText());
                typer.InitializeTypingState();

                ChangeProgramState(ProgramState.typing);
            }
        }
Exemplo n.º 23
0
        public static void Part2()
        {
            var fileIo = new FileImporter <string>(new NullParser());
            var keypad = Keypad.DiamondKeypad();

            keypad.PrintKeypad();
            var keypadFollower = new KeypadFollower(new Coordinate(0, 3), keypad);
            var processor      = new KeypadProcessor(fileIo, keypadFollower);

            processor.Process("../../input.txt");
            Console.ReadKey();
        }
Exemplo n.º 24
0
    protected void importa_Click(object sender, EventArgs e)
    {
        string adresafizicaserver = Server.MapPath("~");
        string cale_import        = Server.MapPath("~/Downloads/");

        IMostreDB    mostre   = (IMostreDB) new MostreDB();
        FileImporter importer = new FileImporter(StaticDataHelper.FCCLDbContext, adresafizicaserver);

        importer.DoLocalImport(mostre, cale_import);

        BindData();
    }
Exemplo n.º 25
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Proccess service call end. </summary>
        ///
        /// <remarks>   Ahaynes, 12/13/2016. </remarks>
        ///
        /// <param name="serviceName">  Name of the service. </param>
        /// <param name="fileLine">     The file line. </param>
        /// <param name="fileImporter"> The parent class instance. </param>
        ///
        /// <returns>   True if end of service, false if not. </returns>
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        private bool ProccessServiceCallEnd(string serviceName, string fileLine, FileImporter fileImporter)
        {
            bool result = false;

            if (fileLine.StartsWith(Id_EndOfServiceCall))
            {
                result = true;
                AddDateTimeToColumnInfo(serviceName, fileLine);
                Program.serviceColumns[serviceName][Program.Header_PartnerID]   = fileImporter.partnerName;
                Program.serviceColumns[serviceName][Program.Header_ServiceName] = serviceName;
            }
            return(result);
        }
Exemplo n.º 26
0
        static void Main()
        {
            var triangleParser = new TriangleParser
            {
                ReadHorizontal = false  // Part 1 : true, Part 2 : false
            };
            var filereader = new FileImporter <Triangle>(triangleParser);
            var processor  = new TriangleProcessor(filereader);

            processor.Process("..\\..\\input.txt");
            Console.Write("Valid : " + processor.GetResult());
            Console.ReadKey();
        }
Exemplo n.º 27
0
 private void mImportButton_Click(object sender, EventArgs e)
 {
     if (FileImporter.ShowDialog() == DialogResult.OK)
     {
         if (File.Exists(FileImporter.FileName))
         {
             if (mScriptEditor.Document.Text.Length > 0 && MessageBox.Show("Are you sure you want to open this file? The current script will be replaced with the one from the file you selected.", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
             {
                 return;
             }
             mScriptEditor.Open(FileImporter.FileName);
         }
     }
 }
Exemplo n.º 28
0
        private void mnuAddChapterPages_Click(object sender, RoutedEventArgs e)
        {
            ListBoxAction <Core.MangaChapter>(lstFileChapters, (ch) =>
            {
                Microsoft.Win32.OpenFileDialog dlgOpenImages = new Microsoft.Win32.OpenFileDialog();
                dlgOpenImages.Filter          = "Supported Images|" + Core.FileImporter.BitmapSupportedImagesExtensions;
                dlgOpenImages.FileName        = "Open supported images";
                dlgOpenImages.CheckFileExists = true;
                dlgOpenImages.Multiselect     = true;
                dlgOpenImages.Title           = "Choose images to import:";

                if (dlgOpenImages.ShowDialog() == true)
                {
                    Core.FileImporter fileImporter = new Core.FileImporter();

                    float cutoff = float.Parse(txtPageMaxWidth.Text);
                    var numFix   = cbNumberFix.IsChecked ?? false;

                    Func <System.IO.FileSystemInfo, object> orderFunc = (si) => si.CreationTime;
                    if (rbByName.IsChecked ?? false)
                    {
                        orderFunc = (si) => numFix ? FileImporter.pad0AllNumbers(si.Name) : si.Name;
                    }


                    ch.autoPageNumbering = false;

                    List <FileImporterError> importErrors = new List <FileImporterError>();
                    winWorking.waitForTask(this, (updateFunc) =>
                    {
                        return(fileImporter.importImages(dlgOpenImages.FileNames, cutoff, orderFunc, importErrors, updateFunc));
                    },
                                           isProgressKnwon: true)
                    .ForEach(page => ch.Pages.Add(page));

                    ch.autoPageNumbering = true;
                    ch.updateChapterStats();


                    if (importErrors.Count > 0)
                    {
                        (new dlgImportErrors()
                        {
                            DataErrors = importErrors
                        }).ShowDialog();
                    }
                }
            });
        }
Exemplo n.º 29
0
        public void Run()
        {
            foreach (string fileToImportPath in FilesToImport())
            {
                var ms = new MemoryStream(File.ReadAllBytes(fileToImportPath));
                Action <FileStream, string> readAndSaveFileAction = (stream, fullPath) =>
                {
                    _importer = new ClinicLetterPdfFileImporter(stream, fullPath, _context);
                    string fileContent   = _importer.ReadFile();
                    var    dateExtractor = new ClnicLettersDateExtractor(fileContent);
                    var    rm2Number     = dateExtractor.ForRM2Number();
                    var    datesList     = dateExtractor.Dates();
                    var    patient       = _context.Patients
                                           .Include(p => p.PatientNACDates)
                                           .Where(p => p.RM2Number == rm2Number)
                                           .FirstOrDefault();
                    if (patient == null)
                    {
                        return;
                    }
                    if (patient.PatientNACDates.Count == 0)
                    {
                        var nacdate = new PatientNACDates()
                        {
                            PatientId = patient.ID
                        };
                        patient.PatientNACDates = new List <PatientNACDates>()
                        {
                            nacdate
                        };
                    }
                    if (patient.PatientNACDates.FirstOrDefault().FirstSeenAtNAC.Year == 1)
                    {
                        patient.PatientNACDates.FirstOrDefault().FirstSeenAtNAC = dateExtractor.EarliestDate();
                    }
                    patient.PatientNACDates.FirstOrDefault().LastObservationPoint = dateExtractor.LatestDate();
                    _context.Update(patient);
                    _context.PatientNACDates.UpdateRange(patient.PatientNACDates);
                    _context.SaveChanges();
                    Imported++;
                };

                FileImporter.Import(fileToImportPath, readAndSaveFileAction);
                if (_deleteImported)
                {
                    File.Delete(fileToImportPath);
                }
            }
        }
Exemplo n.º 30
0
        public void BugDailyForebay()
        {
            AddDailyCalculation("daily_clk_fb", "DailyMidnight(instant_%site%_fb)");
            AddDailyCalculation("daily_clk_af", "DailyMidnight(instant_%site%_af)");
            AddDailyCalculation("daily_clk_fd", "DailyAverage(instant_%site%_fb)");

            FileImporter fi = new FileImporter(db);

            fi.Import(dir, true, true, "*.clk");

            var s = db.GetCalculationSeries("clk", "fb", TimeInterval.Daily);

            s.Read();
            Assert.IsTrue(s.Count > 0);
        }