Esempio n. 1
0
        public List<Offer> getOffer(string ProductName,string userID)
        {
            List<Offer> offerCollection = new List<Offer>();
            AzureDcClient client = new AzureDcClient();
            offerType[] offers = client.getOffer(ProductName, userID);

            foreach (offerType o in offers)
            {
                Offer offer = new Offer();
                offer.OfferName = ProductName;
                offer.OfferPrice = o.offerPrice;
                offer.units = o.units;
                offer.StoreName = o.storeName;

                var distinctoffers = (from off in offerCollection
                                      where off.StoreName == o.storeName
                                      select off.StoreName);
                if (distinctoffers.Count() == 0)
                    offerCollection.Add(offer);
            }

            return offerCollection;

            //List<Offer> offerCollection = new List<Offer>();
            //MongoDatabase db = ConnectToMongoDB();
            //var product = db.GetCollection<RawBsonDocument>("Offer");

            //var query = Query.EQ("OfferName", ProductName);

            //var offers = product.Find(query);

            //foreach (var value in offers)
            //{
            //    Offer offer = new Offer();
            //    offer.OfferName = ProductName;
            //    offer.OfferPrice = value[3].ToString();
            //    offer.units = value[4].ToString();
            //    offer.StoreName = value[1].ToString();
            //    offerCollection.Add(offer);
            //}

            //return offerCollection;
        }
Esempio n. 2
0
        public static void GetPushOffer()
        {
            string timestamp = DateTime.UtcNow.Date.Month.ToString() + "/" + DateTime.UtcNow.Date.Day.ToString() + "/" + DateTime.UtcNow.Date.Year.ToString();
            int count = 0;
            MongoDatabase db = ConnectToMongoDB();
            var offer = db.GetCollection<RawBsonDocument>("Offer");

            var query = Query.EQ("timestamp", timestamp);
            var offers = offer.Find(query);

            Console.WriteLine("Pushing Offer data");

            foreach (var value in offers)
            {
                count++;
                AzureDcClient client = new AzureDcClient();
                offerType TCOffer = new offerType();
                TCOffer.storeName = value[1].ToString();
                TCOffer.offerName = value[2].ToString();
                TCOffer.offerPrice = value[3].ToString();
                TCOffer.units = value[4].ToString();
                //TCOffer.userid = value[5].ToString();
                //TCOffer.timeStamp = value[6].ToString();
                client.InsertOffer(TCOffer, value[5].ToString());
            }

            Console.WriteLine("Offer data pushed. Total of " + count + " offers inserted\n");

            //AzureDcClient client = new AzureDcClient();
            //offerType TCOffer = new offerType();
            //TCOffer.storeName = "BJs";
            //TCOffer.offerName = "onion";
            //TCOffer.offerPrice = "2.2$";
            //TCOffer.units = "1LB";
            ////TCOffer.userid = value[5].ToString();
            ////TCOffer.timeStamp = value[6].ToString();
            //client.InsertOffer(TCOffer, "brinky");
        }
Esempio n. 3
0
        public bool authenticateUser(string username, string password)
        {
            AzureDcClient client = new AzureDcClient();
            bool response = client.authenticateUser(username, password);

            return response;

            //authenticateUserRequest req = new authenticateUserRequest("ss", "ss");

            //StarterDelegateClient client = new StarterDelegateClient();
            //bool res = client.authenticateUser(username, password);

            //MongoDatabase db = ConnectToMongoDB();
            //var users = db.GetCollection<RawBsonDocument>("User");

            //var query = Query.And(Query.EQ("username",username), Query.EQ("password",password));

            //var user = users.Find(query);
            //if (user != null && user.Count()>0)
            //{
            //    return true;
            //}
        }
Esempio n. 4
0
        public static void GetPushProduct()
        {
            string timestamp = DateTime.UtcNow.Date.Month.ToString() + "/" + DateTime.UtcNow.Date.Day.ToString() + "/" + DateTime.UtcNow.Date.Year.ToString();
            int count = 0;
            MongoDatabase db = ConnectToMongoDB();
            var product = db.GetCollection<RawBsonDocument>("Product");

            var query = Query.EQ("timestamp", timestamp);
            var products = product.Find(query);

            Console.WriteLine("Pushing Product data");

            foreach (var value in products)
            {
                count++;
                AzureDcClient client = new AzureDcClient();
                client.InsertProduct(value[2].ToString(), value[5].ToString());
                //Console.WriteLine(value[2].ToString() + " , " + value[5].ToString());
            }

            Console.WriteLine("Product data pushed. Total of " + count + " products inserted\n");

            //AzureDcClient client = new AzureDcClient();
            //client.InsertProduct("Potato", "brinky");
            //client.InsertProduct("Onion", "brinky");
            //client.InsertProduct("tomato", "brinky");
        }
Esempio n. 5
0
 public static void flushTC()
 {
     AzureDcClient client = new AzureDcClient();
     client.flush("flush");
 }
Esempio n. 6
0
        public static void GetPushUser()
        {
            string timestamp = DateTime.UtcNow.Date.Month.ToString() + "/" + DateTime.UtcNow.Date.Day.ToString() + "/" + DateTime.UtcNow.Date.Year.ToString();
            int count = 0;
            MongoDatabase db = ConnectToMongoDB();
            var user = db.GetCollection<RawBsonDocument>("User");

            var query = Query.EQ("timestamp", timestamp);
            var users = user.Find(query);

            Console.WriteLine("Pushing user data");

            foreach (var value in users)
            {
                count++;
                AzureDcClient client = new AzureDcClient();
                client.InsertUser(value[1].ToString(), value[2].ToString());
            }

            Console.WriteLine("user data pushed. Total of " + count +" users inserted\n");

            //AzureDcClient client1 = new AzureDcClient();
            //client1.InsertUser("brinky", "brinky123");
        }
Esempio n. 7
0
        public static void GetPushTransaction()
        {
            string timestamp = DateTime.UtcNow.Date.Month.ToString() + "/" + DateTime.UtcNow.Date.Day.ToString() + "/" + DateTime.UtcNow.Date.Year.ToString();
            int count = 0;
            MongoDatabase db = ConnectToMongoDB();
            var transaction = db.GetCollection<RawBsonDocument>("Transaction");

            var query = Query.EQ("timestamp", timestamp);
            var transactions = transaction.Find(query);

            Console.WriteLine("Pushing Transaction data");

            foreach (var value in transactions)
            {
                AzureDcClient client = new AzureDcClient();
                transactionsType tr = new transactionsType();
                tr.name = value[1].ToString();
                tr.cost = Double.Parse(value[2].ToString());
                tr.quantity = value[3].ToString();
                tr.storeID = Double.Parse(value[4].ToString());
                client.InsertTransaction(tr, value[5].ToString());
            }

            Console.WriteLine("Product Transaction pushed. Total of " + count + " transactions inserted\n");
        }
Esempio n. 8
0
        public List<string> getProducts(string userID)
        {
            List<string> productCollection = new List<string>();
            List<Product> offerCollection = new List<Product>();
            AzureDcClient client = new AzureDcClient();
            string[] products = client.getProduct(userID);

            foreach (string product in products)
            {
                if (!productCollection.Contains(product))
                    productCollection.Add(product);
            }

            return productCollection;

            //List<string> productCollection = new List<string>();
            //MongoDatabase db = ConnectToMongoDB();
            //var product = db.GetCollection<RawBsonDocument>("Product");

            //IEnumerable<BsonValue> products = product.Distinct("ProductName");

            //foreach (var value in products)
            //{
            //    productCollection.Add(value.AsString);
            //}

            //return productCollection;
        }
Esempio n. 9
0
        public void InsertData(Transaction transaction,string userID)
        {
            transactionsType tr = new transactionsType();
            tr.name = transaction.Name;
            tr.ID = transaction.ID;
            tr.cost = transaction.cost;
            tr.quantity = transaction.quantity;
            tr.storeID = transaction.storeID;

            AzureDcClient client = new AzureDcClient();
            string res = client.InsertTransaction(tr, userID);

            //MongoDatabase db = ConnectToMongoDB();
            //var collection = db.GetCollection<BsonDocument>("Transaction");
            //var id3 = ObjectId.GenerateNewId();

            //BsonDocument transaction = new BsonDocument()
            //    .Add("_id", id3)
            //    .Add("name", tr.Name)
            //    .Add("cost", tr.cost)
            //    .Add("storeID", tr.storeID)
            //    .Add("quantity", tr.quantity);

            //collection.Insert(transaction);
        }