Пример #1
0
        static void Main()
        {
            var vendors  = DAOMySQL.GetVendors();
            var measures = DAOMySQL.GetMeasures();
            var products = DAOMySQL.GetData();

            DAOMsSQL.SetData(vendors, measures, products);

            ExcelReader.MyExtract();
            List <List <SaleInfo> > sales = ExcelReader.ReadAllExcells();

            DAOMsSQL.SetDataFromXls(sales); //1va

            PDFCreator.CreatePDF();         //2ra

            List <XMLReportInfo> info = DAOMsSQL.XMLPersiter();

            XMLReader.GenerateSalesReportXMLByVendor(info); //3ta
            XMLReader.GenerateSalesReportXMLMontly(info);   //5ta


            MongoWorker.SaveData();//4ta

            //SQLITE.GenerateTaxes();
            //SQLITE.FillSQLITEProducts();
            // SQLITE.FillExcelFile();
        }
Пример #2
0
        public static void ImportXMLToMongoAndSQLServer(string mongoConnectionString, string pathToXML)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var xmlDoc          = new XmlReportReader <CarTechnicalExpensesReport>(pathToXML);
            var technicalReport = xmlDoc.ReadDocument("Reports.ReportModels");
            var mongoWorker     = new MongoWorker(mongoConnectionString);

            mongoWorker.ImportXMLCarsEntry(technicalReport);
            SQLServerWorker.ImportXMLCarExpenses(technicalReport);
        }
Пример #3
0
 public static bool Auth(LoginModel model)
 {
     MongoWorker _mongo = new MongoWorker();
     var doc = _mongo.GetDocument<User>(MongoCollections.UserCollection, Query.EQ("Email", model.Email));
     if (doc != null)
     {
         string hash = Encoding.UTF8.GetString(SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(doc.ID.ToString() + model.Password)));
         if (hash == doc.Password)
         {
             return true;
         }
     }
     return false;
 }
Пример #4
0
        public static void FillSQLITEProducts()
        {
            List <FullIProductInformation> info = MongoWorker.getData();

            using (VendorsDB dbLite = new VendorsDB())
            {
                foreach (var item in info)
                {
                    dbLite.Products.Add(new Product()
                    {
                        productName       = item.ProductName,
                        ProductID         = item.ProductId,
                        vendorName        = item.VendorName,
                        totalIncomes      = item.TotalIncomes,
                        totalQuantitySold = item.TotalQuantitySold
                    });
                }
                dbLite.SaveChanges();
            }
        }
Пример #5
0
 public static bool Register(RegisterModel model)
 {
     MongoWorker _mongo = new MongoWorker();
     if (!_mongo.ExistsDocument<User>(MongoCollections.UserCollection, Query.EQ("Email", model.Email)))
     {
         ObjectId id = ObjectId.GenerateNewId();
         User user = new User()
         {
             DisplayName = model.DisplayName,
             Email = model.Email,
             ID = id,
             Password = Encoding.UTF8.GetString(SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(id.ToString() + model.Password)))
         };
         var resp = _mongo.InsertDocument<User>(MongoCollections.UserCollection, user);
         return resp.Ok;
     }
     else
     {
         return false;
     }
 }
        public static void ImportMongoDBData(string connectionString = null)
        {
            MongoWorker mongoData;

            if (connectionString != null)
            {
                mongoData = new MongoWorker(connectionString);
            }
            else
            {
                mongoData = new MongoWorker();
            }

            // Fill Manufactures
            var allManufacturers = mongoData.GetAllManufacturers();

            foreach (var manufacturer in allManufacturers)
            {
                data.Manufacturers.Add(new Manufacturer()
                {
                    Name = manufacturer.Name
                });
                data.Manufacturers.SaveChanges();
            }

            // Fill Towns
            var allTowns = mongoData.GetAllTowns();

            foreach (var town in allTowns)
            {
                data.Towns.Add(new Town()
                {
                    Name = town.Name
                });
                data.Towns.SaveChanges();
            }

            // Fill Vehicle Types
            var allVehicleTypes = mongoData.GetAllVehicleTypes();

            foreach (var type in allVehicleTypes)
            {
                data.VehicleTypes.Add(new VehicleType()
                {
                    Name = type.Name,
                });
                data.VehicleTypes.SaveChanges();
            }

            // Fill Fuel Types
            var allFuelTypes = mongoData.GetAllFuelTypes();

            foreach (var fuel in allFuelTypes)
            {
                data.Fueltypes.Add(new FuelType()
                {
                    Name = fuel.Name
                });
                data.Fueltypes.SaveChanges();
            }

            // Fill Models
            var allModels = mongoData.GetAllModels();

            foreach (var model in allModels)
            {
                data.Models.Add(new Model()
                {
                    FuelConsumption = model.FuelConsumption,
                    Name            = model.Name,
                    NumberOfWheels  = model.NumberOfWheels,
                });
                data.Models.SaveChanges();
            }

            // Fill Vehicles
            var allVehicles = mongoData.GetAllVehicles();

            foreach (var vehicle in allVehicles)
            {
                int vehicleTypeId =
                    data.VehicleTypes.SearchFor(x => x.Name == vehicle.VehicleType.Name).Select(x => x.Id).First();
                int manufacturerId =
                    data.Manufacturers.SearchFor(x => x.Name == vehicle.Manufacturer.Name).Select(x => x.Id).First();
                int modelId = data.Models.SearchFor(x => x.Name == vehicle.Model.Name).Select(x => x.Id).First();

                int fuelTypeId = data.Fueltypes.SearchFor(x => x.Name == vehicle.FuelType.Name).Select(x => x.Id).First();

                var driverModel = new Driver()
                {
                    FirstName  = vehicle.Driver.FirstName,
                    MiddleName = vehicle.Driver.MiddleName,
                    LastName   = vehicle.Driver.LastName
                };

                var vehicleModel = new Vehicle()
                {
                    VehicleTypeId      = vehicleTypeId,
                    ManufacturerId     = manufacturerId,
                    ModelId            = modelId,
                    YearOfManifacturer = vehicle.YearOfManifacturer,
                    FuelTypeId         = fuelTypeId
                };

                data.Vehicles.Add(vehicleModel);
                data.Vehicles.SaveChanges();

                driverModel.VehicleId = vehicleModel.Id;
                data.Drivers.Add(driverModel);
                data.Drivers.SaveChanges();
            }

            // Fill Routes
            var allRoutes = mongoData.GetAllRoutes();

            foreach (var route in allRoutes)
            {
                var startTown = data.Towns.SearchFor(x => x.Name == route.StartTown.Name).FirstOrDefault().Id;
                var endTown   = data.Towns.SearchFor(x => x.Name == route.EndTown.Name).FirstOrDefault().Id;

                data.Routes.Add(
                    new Route()
                {
                    StartTownId = startTown,
                    EndTownId   = endTown,
                    Distance    = route.Distance,
                });

                data.Routes.SaveChanges();
            }

            // Fill VehicleRoutes
            var allVehicleRoutes = mongoData.GetAllVehicleRoutes();

            foreach (var vehicleRoute in allVehicleRoutes)
            {
                data.VehicleRoutes.Add(
                    new VehicleRoute()
                {
                    RouteId   = vehicleRoute.RouteId,
                    VehicleId = vehicleRoute.VehicleId,
                    Date      = vehicleRoute.Date
                });

                data.VehicleRoutes.SaveChanges();
            }
        }