// MainAsync
    public static async Task MainAsync(string[] args)
    {
        ConfigureConsole();

        // Usage Help if args equal '-h'
        // if (args.Contains("-h") | args.Contains("--help"))
        // {
        //     Console.WriteLine("Usage: -t {carro/moto} --modelos {s/n:default=n}  --show{only output} -q{quiet mode}}");
        // }

        var extractorService = new ExtractorService();

        string[] categorias = { "moto", "carro" };
        foreach (var categoria in categorias)
        {
            await MarcaModelo(categoria);
        }

        async Task MarcaModelo(string categoria)
        {
            extractorService.Categoria = categoria;
            await extractorService.ExtractAndRecordMarcas(categoria);

            var marcas = await extractorService.MarcasPorCategoria(categoria);

            foreach (var marca in marcas)
            {
                await extractorService.ExtractAndRecordModelosDeMarca(marca.Name);
            }
        }
    }
        public ContentResult GetCurrentProgress(string id)
        {
            this.ControllerContext.HttpContext.Response.AddHeader("cache-control", "no-cache");
            var currentProgress = ExtractorService.GetStatusMessage(id).ToString();

            return(Content(currentProgress));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Extract the informations from the txt files about the customers and their products.
        /// This application have some actions like extract, parse and save extracted data in database.
        /// </summary>
        public bool Start()
        {
            var clientes    = new ExtractorService <Cliente>(new Extractor.Extractor("ARQUIVO1.txt"), new ClienteParser()).ExtractParsedFiles();
            var produtos    = new ExtractorService <Produto>(new Extractor.Extractor("ARQUIVO2.txt"), new ProdutoParser()).ExtractParsedFiles();
            var transaction = new PedidoService().InsertPedidos(clientes, produtos);

            return(transaction);
        }
        public bool StartEnvironmentSetupProcess(Project model)
        {
            System.Web.HttpContext.Current.Session["Project"] = model.ProjectName;
            ExtractorService.AddMessage(model.id, string.Empty);
            ExtractorService.AddMessage(model.id.ErrorId(), string.Empty);
            ProcessEnvironment processTask = new ProcessEnvironment(extractorService.GenerateTemplateArifacts);

            processTask.BeginInvoke(model, new AsyncCallback(EndEnvironmentSetupProcess), processTask);
            return(true);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            while (true)
            {
                try {
                    ExtractorService extractorService = new ExtractorService();
                    extractorService.Execute();
                }
                catch (Exception ex) {
                    Console.WriteLine($"An error occured while extracing files: {ex}");
                }

                //TODO: Make sure setting 10 seconds as ExtractorExecutionInterval works fine (instead of using 9)
                Thread.Sleep(Config.Instance.ExtractorExecutionInterval);
            }
        }
        // End the extraction process
        public void EndEnvironmentSetupProcess(IAsyncResult result)
        {
            ProcessEnvironment processTask = (ProcessEnvironment)result.AsyncState;

            string[] strResult = processTask.EndInvoke(result);

            ExtractorService.RemoveKey(strResult[0]);
            if (ExtractorService.StatusMessages.Keys.Count(x => x == strResult[0] + "_Errors") == 1)
            {
                string errorMessages = ExtractorService.statusMessages[strResult[0] + "_Errors"];
                if (errorMessages != "")
                {
                    //also, log message to file system
                    string logPath     = Server.MapPath("~") + @"\Log";
                    string accountName = strResult[1];
                    string fileName    = string.Format("{0}_{1}.txt", "Extractor_", DateTime.Now.ToString("ddMMMyyyy_HHmmss"));

                    if (!Directory.Exists(logPath))
                    {
                        Directory.CreateDirectory(logPath);
                    }
                    System.IO.File.AppendAllText(Path.Combine(logPath, fileName), errorMessages);

                    //Create ISSUE work item with error details in VSTSProjectgenarator account
                    string  patBase64 = System.Configuration.ConfigurationManager.AppSettings["PATBase64"];
                    string  url       = System.Configuration.ConfigurationManager.AppSettings["URL"];
                    string  projectId = System.Configuration.ConfigurationManager.AppSettings["PROJECTID"];
                    string  issueName = string.Format("{0}_{1}", "Extractor_", DateTime.Now.ToString("ddMMMyyyy_HHmmss"));
                    IssueWI objIssue  = new IssueWI();
                    ExtractorService.logger.Info(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "\t Extractor_" + errorMessages + "\n");
                    string logWIT = "true"; //System.Configuration.ConfigurationManager.AppSettings["LogWIT"];
                    if (logWIT == "true")
                    {
                        objIssue.CreateIssueWI(patBase64, "4.1", url, issueName, errorMessages, projectId, "Extractor");
                    }
                }
            }
        }
Exemplo n.º 7
0
        public Form1()
        {
            InitializeComponent();

            extractor = new ExtractorService();
        }
Exemplo n.º 8
0
 public void Initializing()
 {
     _extractorService = new ExtractorService();
 }