Esempio n. 1
0
        /// <summary>
        /// This method adds objects to distributed list
        /// </summary>
        /// <param name="customer"> Instances of Customer that will be added to
        /// distributed list</param>
        private static void AddObjectsToDatatype(Customer[] customers)
        {
            IDistributedList <Customer> list = _cache.DataTypeManager.GetList <Customer>(_datatype);

            //Add Bulk into Distributed List
            list.AddRange(customers);

            // Print output on console.
            Console.WriteLine("\nObjects are added to distributed list.");
        }
Esempio n. 2
0
        public static void LoadDataInCache()
        {
            var             currentLine          = string.Empty;
            string          baseDataRelativePath = @"../../../../Data";
            string          filepath             = GetAbsolutePath($"{baseDataRelativePath}/taxi-fare-full.csv");
            List <TaxiTrip> dataList             = new List <TaxiTrip>();
            int             i = 0;

            using (StreamReader r = new StreamReader(filepath))
            {
                while ((currentLine = r.ReadLine()) != null)
                {
                    string[] incomingData = currentLine.Split(",");
                    TaxiTrip data         = new TaxiTrip();

                    data.RateCode       = float.Parse(incomingData[0]);
                    data.PassengerCount = float.Parse(incomingData[1]);
                    data.TripTime       = float.Parse(incomingData[2]);
                    data.TripDistance   = float.Parse(incomingData[3]);
                    data.FareAmount     = float.Parse(incomingData[4]);

                    dataList.Add(data);

                    if (dataList.Count > 100)
                    {
                        //Remove first entries and move sliding window
                        if (TrainingData.Count > dataList.Count)
                        {
                            TrainingData.RemoveRange(0, dataList.Count);
                        }

                        TrainingData.AddRange(dataList);
                        //publish message for notifying data upate
                        Topic.Publish(new Message("DataSet has been updated."), DeliveryOption.All);
                        dataList.Clear();
                        Console.WriteLine("Chunk of data has been added:" + i);
                        i++;
                        //Sleep for 5 minutes
                        Thread.Sleep(30000);
                    }
                }
            }
        }