コード例 #1
0
ファイル: CSVService.cs プロジェクト: YaroslavYanshin/CSVtoDB
        protected override void OnStart(string[] args)
        {
            string sourceFolder = ConfigurationManager.AppSettings["CSVSourceFolder"];

            _controller = new CSVController(sourceFolder);
            _controller.Run();
        }
コード例 #2
0
        private static void ReadCSV(string path)
        {
            Console.Clear();
            path = Path.GetFullPath(path);
            var files = Directory.GetFiles(path, "*.csv");

            foreach (var item in files)
            {
                try
                {
                    CSVController objCSVController = new CSVController();
                    objCSVController.source = @item;

                    Task <List <string> > task = objCSVController.LinesFile();
                    task.Wait();
                    var result = task.Result;
                    Program.list.AddRange(result);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(string.Format("Error  al leer el archivo {0} : Exepción :{1}", item, ex.Message));
                }
            }
            Console.Clear();
        }
コード例 #3
0
ファイル: CSVView.cs プロジェクト: damon0609/DamonTool
 public override void Init()
 {
     csvCtrl = controller as CSVController;
     list    = csvCtrl.csvList;
     foreach (var item in list)
     {
         Button01 btn = new Button01(item.name);
         buttons.Add(btn);
     }
     for (int i = 0; i < buttons.Count; i++)
     {
         Button01 btn = buttons[i];
         btn.style    = label;
         btn.onClick += () => { Debug.Log(btn.label); };
         if (i % 2 == 0)
         {
             btn.drawer += r => {
                 if (GUILayout.Button(btn.label + "---"))
                 {
                     btn.onClick();
                 }
             };
         }
     }
 }
コード例 #4
0
        public void TestCargarEstudiantes()
        {
            // Arrange
            //Creamos httpContextMock and serverMock:
            var httpContextMock = new Mock <HttpContextBase>();
            var serverMock      = new Mock <HttpServerUtilityBase>();

            //Mock el path original
            serverMock.Setup(x => x.MapPath("./ArchivoCSV")).Returns(Path.GetFullPath("../../ArchivoCSVtest"));

            //Mockeamos el objeto HTTPContext.Server con el servidor ya mockeado:
            httpContextMock.Setup(x => x.Server).Returns(serverMock.Object);

            //Creo el controlador y su contexto
            CSVController controller = new CSVController();

            controller.ControllerContext = new ControllerContext(httpContextMock.Object, new RouteData(), controller);

            //Insertamos el csv
            string     filePath   = Path.GetFullPath("../../ArchivoCSVtest/listaEstudianteTest.csv");
            FileStream fileStream = new FileStream(filePath, FileMode.Open);

            //Cargamos el mock
            Mock <HttpPostedFileBase> uploadedFile = new Mock <HttpPostedFileBase>();

            uploadedFile.Setup(x => x.FileName).Returns("listaEstudianteTest.csv");
            uploadedFile.Setup(x => x.ContentType).Returns("listaEstudianteTest.csv");
            uploadedFile.Setup(x => x.InputStream).Returns(fileStream);
            HttpPostedFileBase[] httpPostedFileBases = { uploadedFile.Object };
            // Act
            ViewResult result = controller.Index(httpPostedFileBases[0]) as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #5
0
ファイル: CSVWindow.cs プロジェクト: damon0609/DamonTool
    private void OnEnable()
    {
        CSVModel model = new CSVModel();

        mCSVController = new CSVController(model);
        view           = new CSVView(mCSVController, "csv");
        view.Init();
    }
コード例 #6
0
        public static List <Airline> GetAllAirlines(List <Country> countries)
        {
            string APIKey = "cada26-b8f8e3";

            try
            {
                HttpClient httpClient = new HttpClient();
                var        result     = httpClient.GetAsync($"https://aviation-edge.com/v2/public/airlineDatabase?key={APIKey}").Result;
                string     body       = result.Content.ReadAsStringAsync().Result;

                List <AEAirline>   allAirlines  = JsonSerializer.Deserialize <List <AEAirline> >(body);
                List <AirlineName> goodAirlines = CSVController.GetFlightRadarAirlineNames();

                List <Airline> currentAirlines = new List <Airline>();
                foreach (var airline in allAirlines)
                {
                    if (!goodAirlines.Exists(an => an.Name.ToLower() == airline.Name.ToLower()))
                    {
                        continue;
                    }

                    if (airline.Active != "active")
                    {
                        continue;
                    }

                    var foundCountry = countries.FirstOrDefault(co => co.CountryISO == airline.CountryISO);

                    if (foundCountry == null)
                    {
                        foundCountry    = new Country();
                        foundCountry.Id = Guid.Empty;
                    }


                    Airline newAirline = new Airline
                    {
                        CountryId = foundCountry.Id,
                        IATA      = airline.IATA,
                        ICAO      = airline.ICAO,
                        Callsign  = airline.Callsign,
                        Active    = true,
                        Name      = airline.Name
                    };
                    currentAirlines.Add(newAirline);
                }
                return(currentAirlines);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            }
        }
コード例 #7
0
        public void TestGuia()
        {
            // Arrange
            Init("*****@*****.**");
            CurrentUser.setCurrentUser("*****@*****.**", "Superusuario", "0000000001", "0000000001");
            CSVController controller = new CSVController();
            // Act
            ViewResult result = controller.GuiaHorarios() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
コード例 #8
0
        public void TestCargaClases()
        {
            // Arrange
            //Creo el controlador y su contexto
            CSVController controller = new CSVController();
            var           file       = @"../../ArchivoCSVtest/listaClaseTest.csv";
            var           fileMalo   = @"../../ArchivoCSVtest/listaClaseTestMalo.csv";
            // Act
            var result     = controller.cargarListaClase(file);
            var resultMalo = controller.cargarListaClase(fileMalo);

            // Assert
            Assert.IsTrue(result.Item1);      //camino feliz
            Assert.IsFalse(resultMalo.Item1); //camino feliz
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: YaroslavYanshin/CSVtoDB
        static void Main(string[] args)
        {
            string        sourceFolder = ConfigurationManager.AppSettings["CSVSourceFolder"];
            CSVController controller   = new CSVController(sourceFolder);

            controller.Run();

            Console.WriteLine("\nTo stop watching and exit press '0'");
            while (Console.ReadKey(true).KeyChar != '0')
            {
                ;
            }
            controller.Stop();
            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();
        }