Beispiel #1
0
        /// <summary>
        ///     Converts rawData into a more enumerated value for easier operations
        /// </summary>
        /// <param name="rawData"></param>
        /// <returns></returns>
        public static ObservableCollection <TransformedData> TransformRawData(
            ObservableCollection <TriggeredEvent> rawData)
        {
            var transformedDataCollection = new ObservableCollection <TransformedData>();

            foreach (var e in rawData)
            {
                var transformedData = new TransformedData();
                transformedData.Day    = e.EventTime.Day;
                transformedData.Minute = e.EventTime.Minute;
                transformedData.Hour   = e.EventTime.Hour;
                transformedData.Year   = e.EventTime.Year;
                transformedData.Month  = e.EventTime.Month;
                if (e.EventType)
                {
                    transformedData.Value = 1;
                }
                else
                {
                    transformedData.Value = -1;
                }
                transformedDataCollection.Add(transformedData);
            }
            return(transformedDataCollection);
        }
        /// <summary>
        /// Metoda przekształcające dane
        /// </summary>
        /// <param name="input">Dane otrzymane z procesu Extract</param>
        /// <returns></returns>
        public object HandleData(object input)
        {
            Logger.Log("Starting transform operation.");
            var documents = input as List <HtmlDocument>;
            var output    = new TransformedData()
            {
                Reviews = new List <Review>()
            };

            output.Product = GetProduct(documents[0]);

            documents.RemoveAt(0);

            foreach (var document in documents)
            {
                var reviewNodes = document.DocumentNode.SelectNodes("//*[@class='review-box js_product-review']");
                if (reviewNodes == null)
                {
                    Debug.WriteLine($"Url has no reviews.");
                    return(output);
                }

                foreach (var node in reviewNodes)
                {
                    var review = GetReviewFromNode(node);
                    review.ProductCode = output.Product.Code;
                    output.Reviews.Add(review);
                }
            }

            return(output);
        }
Beispiel #3
0
        private static bool IsYesterday(TransformedData data)
        {
            DateTime yesterday;

            yesterday = DateTime.Now.AddDays(-1);
            if (data.Day == yesterday.Day && data.Month == yesterday.Month &&
                data.Year == yesterday.Year)
            {
                return(true);
            }
            return(false);
        }
Beispiel #4
0
        public PartialViewResult Index([FromQuery(Name = "Id")] string Id)
        {
            Models.DataManager.DataManagaerView dataManagaerView = new Models.DataManager.DataManagaerView();
            dataManagaerView.Id = Id;

            string text = System.IO.File.ReadAllText(Location.ConfLocation);
            Conf   conf = JsonConvert.DeserializeObject <Conf>(text);

            TransformedData main = new TransformedData();

            main.Load(conf.TransformedDataPath + "\\" + Id + "\\main.csv");
            main.Table.RemoveAt(0);

            dataManagaerView.TransformedData = main;

            return(PartialView(dataManagaerView));
        }
Beispiel #5
0
        public PartialViewResult Index([FromQuery(Name = "Id")] string Id)
        {
            string text = System.IO.File.ReadAllText(Location.ConfLocation);
            Conf   conf = JsonConvert.DeserializeObject <Conf>(text);

            Models.App.AppView appView = new Models.App.AppView();
            appView.Id = Id;

            TransformedData transformedData = new TransformedData();

            transformedData.Load(conf.TransformedDataPath + "\\" + Id + "\\main.csv");
            FilterOptions filterOptions = transformedData.GetFilterOptions();

            appView.FilterOptions = filterOptions;
            appView.Max           = transformedData.getMaxValor();
            appView.Min           = transformedData.getMinValor();

            return(PartialView(appView));
        }
Beispiel #6
0
        public string Grouping([FromQuery(Name = "Id")] string Id)
        {
            string text = System.IO.File.ReadAllText(Location.ConfLocation);
            Conf   conf = JsonConvert.DeserializeObject <Conf>(text);

            RawData main = new RawData();

            main.Load(conf.RawDataPath + "\\" + Id + "\\main.csv");

            TransformedData transformedData = TransformedData.ConvertRawtoTransformed(main);

            string content = "";

            foreach (string[] line in transformedData.Table)
            {
                content += string.Join(";", line) + Environment.NewLine;
            }

            System.IO.File.WriteAllText(conf.TransformedDataPath + "\\" + Id + "\\main.csv", content);

            return("ok");
        }
Beispiel #7
0
        public async Task <string> UploadConcatTransformedData([FromQuery(Name = "Id")] string Id)
        {
            string text = System.IO.File.ReadAllText(Location.ConfLocation);
            Conf   conf = JsonConvert.DeserializeObject <Conf>(text);

            var file     = Request.Form.Files[0];
            var filePath = Path.Combine(conf.TransformedDataPath + "/" + Id, "add.csv");

            using (var fileStream = new FileStream(filePath, FileMode.Create))
            {
                await file.CopyToAsync(fileStream);
            }

            TransformedData main = new TransformedData();

            main.Load(conf.TransformedDataPath + "\\" + Id + "\\main.csv");

            TransformedData add = new TransformedData();

            add.Load(conf.TransformedDataPath + "\\" + Id + "\\add.csv");

            main.Concat(add);

            System.IO.File.Delete(conf.TransformedDataPath + "\\" + Id + "\\main.csv");
            System.IO.File.Delete(conf.TransformedDataPath + "\\" + Id + "\\add.csv");

            string content = "";

            foreach (string[] line in main.Table)
            {
                content += string.Join(";", line) + Environment.NewLine;
            }

            System.IO.File.WriteAllText(conf.TransformedDataPath + "\\" + Id + "\\main.csv", content);

            return("ok");
        }