Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Controls.RestrictRotation(true);

            //events
            btnPause.Clicked         += btnPause_Clicked;
            btnCancel.Clicked        += btnCancel_Clicked;
            uploader                  = new UploadVehicle(onDuplicateResponse, onVehicleInsertSuccess, onImageFileError, onUploadWorkCompleted, onMobileUploadIDRetrieved, onUploadError);
            uploader.progressChanged += new UploadVehicle.progressChangedHandler(progressHasChanged);

            //initialize progress bars
            pbPrepareImage.SetProgress(0f, false);
            pbTotal.SetProgress(0f, false);
            pbCurrentVehicle.SetProgress(0f, false);

            //load dealers/vehicles from database
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                listDealerVehicles = new UploadDB(sqlConn).GetDealersToUpload(UploadID);

            //Load Images to check - this has to run on the UI thread for Orientation to work...
            listOfImagesToCheck = CalculateMaxForPrepageImages();

            //start the upload
            uploadThread = new Thread(StartUpload);

            //check for duplicates
            DuplicateCheck();
        }
Esempio n. 2
0
        private int getTotalDuplicateCount()
        {
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                VehicleDB             vdb             = new VehicleDB(sqlConn);
                List <DuplicateCheck> vehiclesToCheck = new List <DuplicateCheck>();

                foreach (UploadDealerVehiclesList dealerVehicles in listDealerVehicles)
                {
                    foreach (int id in dealerVehicles.VehicleIDs)
                    {
                        Vehicle vehicle = vdb.GetVehicle(id);
                        vehiclesToCheck.Add(new DuplicateCheck()
                        {
                            DealershipID = dealerVehicles.DealershipID, StockNumber = vehicle.StockNumber, VIN = vehicle.VIN
                        });
                    }
                }

                if (vehiclesToCheck.Count > 0)
                {
                    return(uploader.GetTotalDuplicatesFound(vehiclesToCheck));
                }
            }

            return(0);
        }
Esempio n. 3
0
        private void deleteImage()
        {
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                new VehicleImagesDB(sqlConn).RemoveImage(vehicleid, currentFileNumber);

            btnArray [currentFileNumber].SetBackgroundImage(UIImage.FromBundle("nophoto.png"), UIControlState.Normal);
            LoadImagesFromDatabase();
        }
Esempio n. 4
0
        private Vehicle LoadVehicleFromDatabase()
        {
            Vehicle v = new Vehicle();

            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                v = new VehicleDB(sqlConn).GetVehicle(vehicleid);

            return(v);
        }
Esempio n. 5
0
        private void SaveVehicle()
        {
            Vehicle v = GetVehicleValues();

            if (v != null)
            {
                using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                    new VehicleDB(sqlConn).SaveVehicle(v);
            }
        }
Esempio n. 6
0
        private void LoadImagesFromDatabase()
        {
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                listVehicleImages = new VehicleImagesDB(sqlConn).GetImagesList(vehicleid);

            foreach (Image image in listVehicleImages)
            {
                Console.WriteLine("filePath = " + image.FileName);
            }
        }
Esempio n. 7
0
        private void LoadDealers()
        {
            List <UploadDealerVehiclesList> listOfDealers = new List <UploadDealerVehiclesList> ();

            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                listOfDealers = new UploadDB(sqlConn).GetDealersToUpload(UploadID);

            tvDealers.Delegate   = new TableViewDelegate(this, listOfDealers);
            tvDealers.DataSource = new TableViewDataSource(this, listOfDealers);
            tvDealers.ReloadData();
        }
Esempio n. 8
0
        private void LoadVehicles()
        {
            List <VehicleWithImages> listOfVehicles = new List <VehicleWithImages> ();

            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                listOfVehicles = new VehicleDB(sqlConn).GetVehicleList(selectedDealershipID, true);

            tvChangeVehicles.Delegate   = new TableViewDelegate(this, listOfVehicles);
            tvChangeVehicles.DataSource = new TableViewDataSource(this, listOfVehicles);
            tvChangeVehicles.ReloadData();
        }
Esempio n. 9
0
            public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
            {
                UploadDealerVehiclesList dealer = list[indexPath.Row];

                Controls.YesNoDialog("Confirm Delete", "Would you like to remove all of the vehicles for " + dealer.DealerName + "?", delegate {
                    using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                        new UploadDB(sqlConn).RemoveDealerFromUpload(dealer.UploadID, dealer.DealershipID);
                    controller.LoadDealers();
                }, delegate {
                    return;
                });
            }
Esempio n. 10
0
 private void Cancel()
 {
     Controls.YesNoDialog("Confirm Cancel", "Are you sure you want to cancel?",
                          delegate {
         if (!originChangeVehicle)
         {
             using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                 new VehicleDB(sqlConn).DeleteVehicle(vehicleid);
         }
         NavigationController.PopViewController(true);
     },
                          delegate { return; });
 }
Esempio n. 11
0
        private void SaveTires(List <Tire> listTires)
        {
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                TireDB tdb = new TireDB(sqlConn);

                tdb.RemoveAllTires(vehicleid);
                foreach (Tire tire in listTires)
                {
                    tdb.AddTire(tire);
                }
            }

            Controls.OkDialog("Success", "Tires Saved Successfully", Done);
        }
Esempio n. 12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Controls.RestrictRotation(true);

            SQLiteBoostDB.CheckAndCreateDatabase();

            this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("bg.jpg"));

            labelSelectedDealer = GetLabel("No Dealer Selected");

            UIScrollView scrollView = new UIScrollView(new CoreGraphics.CGRect(this.View.Bounds.X, 60f, this.View.Bounds.Width, this.View.Bounds.Height));

            scrollView.AddSubview(new EditGroup(GetDealershipGroup()).View);
            scrollView.AddSubview(new EditGroup(GetButtons()).View);

            nfloat ypos = 0f;

            foreach (UIView view in scrollView.Subviews)
            {
                view.Frame = new CoreGraphics.CGRect(view.Bounds.X + 5f, ypos + 10f, this.View.Bounds.Width - 10f, view.Bounds.Height);
                ypos      += view.Bounds.Height + 10f;
            }

            //makes height of scroller the total ypos of groups + 60 for the top bar + 10 for margin at bottom
            scrollView.ContentSize = new CoreGraphics.CGSize(scrollView.Bounds.Width, ypos + 60f + 10f);

            this.View.AddSubview(scrollView);

            assetsRequireDownload = getAssetsRequired();

            if (assetsRequireDownload)
            {
                showAssetsDialog();
            }

            bool dealershipWarningShown = (bool)NSUserDefaults.StandardUserDefaults.BoolForKey("DealershipWarningShown");

            if (!dealershipWarningShown)
            {
                List <Vehicle> listAllVehicles = new List <Vehicle>();
                using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                    listAllVehicles = new VehicleDB(sqlConn).GetAllVehicles();

                if (listAllVehicles.Count(v => v.DealershipID == null || v.DealershipID == 0) > 0)
                {
                    Controls.OkDialog("Vehicles Without Dealership", "Boost IT has recently changed so that you must select a dealership before creating a vehicle.  You have vehicles that were created without a dealership assigned to them on your device.  You will not be able to upload these vehicles until you go into \"Change a Vehicle\" and select a dealer for each vehicle.\n\n Vehicles not assigned to a dealership will be marked with \"(**)\" on the \"Change a Vehicle\" page.", delegate { NSUserDefaults.StandardUserDefaults.SetBool(true, "DealershipWarningShown"); });
                }
            }
        }
Esempio n. 13
0
        private void bw_DownloadVehicles(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            if (selectedVehicleIds.Count <= 0)
            {
                throw new Exception("No vehicles selected");
            }

            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                foreach (int vehicleId in selectedVehicleIds)
                {
                    Download.DownloadVehicle(sqlConn, vehicleId, dealershipId);
                }
            }
        }
Esempio n. 14
0
        public static void SaveImage(int fileNumber, string filePath, int vehicleid)
        {
            Image image = new Image();

            image.VehicleID  = vehicleid;
            image.FileNumber = fileNumber;
            image.FileName   = filePath;

            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                VehicleImagesDB vidb = new VehicleImagesDB(sqlConn);
                vidb.RemoveImage(vehicleid, fileNumber);
                vidb.AddImage(image);
            }
        }
Esempio n. 15
0
        private void loadData()
        {
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                VehicleAssetsDB vadb = new VehicleAssetsDB(sqlConn);
                listArea     = vadb.GetDamageAreas(categoryid);
                listType     = vadb.GetDamageTypes(categoryid);
                listAreaType = vadb.GetDamageAreaTypes();
            }

            if (damageid > 0)
            {
                using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                    damage = new DamageDB(sqlConn).GetDamage(damageid);
            }
        }
Esempio n. 16
0
        /*public void dealershipSelected(string name, string value)
         * {
         *      Console.WriteLine ("selected dealer=" + value);
         *      Dealership dealer = listOfDealers.FirstOrDefault (d => d.DealershipName == value);
         *      if (dealer == null) {
         *              Controls.OkDialog ("Invalid Dealer", "Selected dealer does not exist, please select a different dealer.");
         *              return;
         *      }
         *
         *      LaunchUploadVehiclesProgress (dealer.DealershipID, dealer.DealershipName, (listOfDealers.Count() == 1) ? false : true);
         * }*/

        private void LaunchUploadVehiclesProgress(int DealershipID, string DealershipName, bool showDealerScreen = false)
        {
            //insert into UploadDealer table
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                new UploadDB(sqlConn).InsertUploadDealer(UploadID, DealershipID, DealershipName, selectedVehicleIds);

            if (showDealerScreen)
            {
                NavigationController.PushViewController(new UploadListDealers(UploadID), true);
            }
            else
            {
                NavigationController.PushViewController(new UploadProgress(UploadID), true);
            }
        }
Esempio n. 17
0
        private void SaveDamage()
        {
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                DamageDB ddb = new DamageDB(sqlConn);
                if (damageid > 0)
                {
                    ddb.UpdateDamage(damage);
                }
                else
                {
                    ddb.AddDamage(damage);
                }
            }

            Controls.OkDialog("Success", "Damage Saved Successfully", Done);
        }
Esempio n. 18
0
        public ListScreenFeatures(string[] ListOfData, int VehicleID, int CategoryID, List <AvailableFeature> listOfFeatures) : base("ListScreenFeatures", null)
        {
            list         = ListOfData;
            vehicleid    = VehicleID;
            categoryid   = CategoryID;
            listFeatures = listOfFeatures;
            List <Feature> listSelectedFeatures = new List <Feature>();

            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                listSelectedFeatures = new VehicleFeaturesDB(sqlConn).GetSelectedFeatures(vehicleid, categoryid);

            foreach (Feature feature in listSelectedFeatures)
            {
                selectedFeatures.Add(feature.FeatureName);
            }
        }
Esempio n. 19
0
        private List <ImageForUpload> CalculateMaxForPrepageImages()
        {
            List <ImageForUpload> list = new List <ImageForUpload>();

            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                VehicleImagesDB vidb = new VehicleImagesDB(sqlConn);
                DamageDB        ddb  = new DamageDB(sqlConn);

                foreach (UploadDealerVehiclesList dealerVehicles in listDealerVehicles)
                {
                    foreach (int VehicleId in dealerVehicles.VehicleIDs)
                    {
                        List <Image>  listOfImages            = vidb.GetImagesList(VehicleId);
                        List <Damage> listOfDamagesWithImages = ddb.GetDamagesWithImages(VehicleId);

                        if ((listOfImages == null || listOfImages.Count <= 0) && (listOfDamagesWithImages == null || listOfDamagesWithImages.Count <= 0))
                        {
                            continue;
                        }

                        foreach (Image image in listOfImages)
                        {
                            if (!image.FileName.Contains("http://"))
                            {
                                list.Add(new ImageForUpload()
                                {
                                    vehicleId = VehicleId, dealershipId = dealerVehicles.DealershipID, fileNumber = image.FileNumber, filePath = image.FileName, damageId = 0
                                });
                            }
                        }

                        foreach (Damage dmg in listOfDamagesWithImages)
                        {
                            if (!dmg.FileName.Contains("http://"))
                            {
                                list.Add(new ImageForUpload()
                                {
                                    vehicleId = VehicleId, dealershipId = dealerVehicles.DealershipID, filePath = dmg.FileName, damageId = dmg.ID
                                });
                            }
                        }
                    }
                }
            }
            return(list);
        }
Esempio n. 20
0
        public void dealershipSelected(string name, string value)
        {
            Console.WriteLine("selected dealer create vehicle=" + value);
            Dealership dealer = listOfDealers.FirstOrDefault(d => d.DealershipName == value);

            if (dealer == null)
            {
                Controls.OkDialog("Invalid Dealer", "Selected dealer does not exist, please select a different dealer.");
                return;
            }

            Vehicle v = LoadVehicleFromDatabase();

            v.DealershipID = dealer.DealershipID;
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                new VehicleDB(sqlConn).SaveVehicle(v);
        }
Esempio n. 21
0
        private void bw_ExplodeVIN(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            int selectedDealershipID = (int)NSUserDefaults.StandardUserDefaults.IntForKey("SelectedDealershipID");
            int userID = (int)NSUserDefaults.StandardUserDefaults.IntForKey("UserID");

            if (userID <= 0)
            {
                throw new Exception("Invalid User ID. User ID=" + userID + ".");
            }
            if (selectedDealershipID <= 0)
            {
                throw new Exception("Invalid Selected Dealership ID. SelectedDealershipID=" + selectedDealershipID + ".");
            }

            //explode the vehicle using PCL
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                new ExplodeVIN(sqlConn).DoExplosion(vehicleid, userID, selectedDealershipID);
        }
Esempio n. 22
0
        private void setElementValues()
        {
            //load tires values
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                TireDB tdb = new TireDB(sqlConn);

                List <Tire> list = tdb.GetTireList(vehicleid);
                if (list.Count <= 0)
                {
                    return;
                }

                foreach (Tire tire in list)
                {
                    setTire(tire);
                }
            }
        }
Esempio n. 23
0
        private long CalculateMaxProgressValue(List <ImageForUpload> listImages)
        {
            long retval = 0;

            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                DamageDB ddb = new DamageDB(sqlConn);
                TireDB   tdb = new TireDB(sqlConn);
                PaintDB  pdb = new PaintDB(sqlConn);

                foreach (UploadDealerVehiclesList dealerVehicles in listDealerVehicles)
                {
                    foreach (int VehicleId in dealerVehicles.VehicleIDs)
                    {
                        //add 20kB for each car (ws call to insert vehicle 10k + ws call to commit vehicle 10k + ws call to insert features 10k)
                        retval += 30720;                         //30k - 30*1024

                        //only 1 service call is made for tires/paint/damages - add 10k for each
                        if (ddb.GetDamageCount(VehicleId) >= 1)
                        {
                            retval += 10240;
                        }
                        if (tdb.GetTireCount(VehicleId) >= 1)
                        {
                            retval += 10240;
                        }
                        if (pdb.GetPaintCount(VehicleId) >= 1)
                        {
                            retval += 10240;
                        }

                        List <ImageForUpload> listImagesForVehicle = listImages.Where(i => i.vehicleId == VehicleId).ToList();
                        foreach (ImageForUpload ifu in listImagesForVehicle)
                        {
                            //add 10kB for each image (ws call to insert image)
                            retval += 10240;                             //10k - 10*1024
                            retval += ifu.fileSize;
                        }
                    }
                }
            }

            return(retval);
        }
Esempio n. 24
0
        private void LoadDataFromDB()
        {
            //******************************LOAD DATA FROM DB*********************************************
            using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
                VehicleAssetsDB vadb = new VehicleAssetsDB(sqlConn);

                listMakes           = vadb.GetMakes();
                listModels          = vadb.GetModels();
                listBodies          = vadb.GetBodies();
                listDrivetrains     = vadb.GetDrivetrains();
                listTransmissions   = vadb.GetTransmissions().Select(t => t.TransmissionName).ToArray();
                listExteriorColours = vadb.GetExteriorColours().Select(e => e.Colour).ToArray();
                listInteriorColours = vadb.GetInteriorColours().Select(i => i.Colour).ToArray();
                listDoors           = vadb.GetDoors().Select(d => d.NumberOfDoors).ToArray();
                listSeats           = vadb.GetSeats().Select(s => s.NumberOfSeats).ToArray();
                listFeatures        = vadb.GetAvailableFeatures();

                listInteriorFeatures   = listFeatures.Where(af => af.FeatureCategoryID == 2).Select(af => af.Feature).ToArray();
                listExteriorFeatures   = listFeatures.Where(af => af.FeatureCategoryID == 3).Select(af => af.Feature).ToArray();
                listSafetyFeatures     = listFeatures.Where(af => af.FeatureCategoryID == 4).Select(af => af.Feature).ToArray();
                listMechanicalFeatures = listFeatures.Where(af => af.FeatureCategoryID == 5).Select(af => af.Feature).ToArray();
            }

            //years
            int           nextYear     = DateTime.Now.Year + 1;
            List <string> listColYears = new List <string>();

            for (int i = nextYear; i >= nextYear - 45; i--)
            {
                listColYears.Add(i.ToString());
            }
            listYears = listColYears.ToArray();

            //engine
            List <string> listColEngine = new List <string>();

            for (double i = 0.1; i <= 13.0; i += 0.1)
            {
                listColEngine.Add(Math.Round(i, 1).ToString() + "L");
            }
            listEngine = listColEngine.ToArray();
        }
Esempio n. 25
0
        void UploadClick()
        {
            int selectedDealershipID = (int)NSUserDefaults.StandardUserDefaults.IntForKey("SelectedDealershipID");

            if (assetsRequireDownload)
            {
                showAssetsDialog();
            }
            else if (selectedDealershipID <= 0)
            {
                Controls.OkDialog("No Dealer Selected", "You must select a dealer before you can upload vehicles.", null);
            }
            else
            {
                int uploadID = 0;
                using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                    uploadID = new UploadDB(sqlConn).CreateUpload();

                NavigationController.PushViewController(new UploadList(uploadID, selectedDealershipID), true);
            }
        }
Esempio n. 26
0
        private void CreateVehicleClick()
        {
            int selectedDealershipID = (int)NSUserDefaults.StandardUserDefaults.IntForKey("SelectedDealershipID");

            if (assetsRequireDownload)
            {
                showAssetsDialog();
            }
            else if (selectedDealershipID <= 0)
            {
                Controls.OkDialog("No Dealer Selected", "You must select a dealer before you can create a vehicle.", null);
            }
            else
            {
                int vehicleId = 0;
                using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
                    vehicleId = new VehicleDB(sqlConn).AddVehicle(selectedDealershipID);

                this.NavigationController.PushViewController(new CreateVehicle(vehicleId), true);
            }
        }
Esempio n. 27
0
 void btnDoneTouchUpInside(object sender, EventArgs e)
 {
     using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath())) {
         VehicleFeaturesDB vfdb = new VehicleFeaturesDB(sqlConn);
         vfdb.RemoveAllFeaturesByCategory(vehicleid, categoryid);
         if (selectedFeatures != null && selectedFeatures.Count > 0)
         {
             foreach (string selectedFeature in selectedFeatures)
             {
                 AvailableFeature af = listFeatures.FirstOrDefault(f => f.FeatureCategoryID == categoryid && f.Feature == selectedFeature);
                 if (af != null)
                 {
                     vfdb.AddFeature(new Feature()
                     {
                         FeatureID = af.ID, FeatureCategoryID = af.FeatureCategoryID, FeatureName = af.Feature, VehicleID = vehicleid
                     });
                 }
             }
         }
     }
     DismissModalViewController(true);
 }
Esempio n. 28
0
 private bool getAssetsRequired()
 {
     using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
         return(new VehicleAssetsDB(sqlConn).AssetsRequireDownloading());
 }
Esempio n. 29
0
 private void bw_GetVehicleAssets(object sender, DoWorkEventArgs e)
 {
     using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
         new BoostIT.Tasks.GetVehicleAssets(sqlConn).LoadAssetsIntoDatabase();
 }
Esempio n. 30
0
 public void DeleteVehicle(int vehicleId)
 {
     using (Connection sqlConn = new Connection(SQLiteBoostDB.GetDBPath()))
         new VehicleDB(sqlConn).DeleteVehicle(vehicleId);
 }