public static VehicleInformation FromDtoToDomainObject(
            VehicleInformationDto source)
        {
            VehicleInformation target = new VehicleInformation(source.Vin);

            target.Engine       = EngineAssembler.FromDtoToObject(source.Engine);
            target.VehicleModel = source.VehicleModel;
            return(target);
        }
        public static VehicleInformationDto FromDomainObjectToDto(
            VehicleInformation source)
        {
            VehicleInformationDto target = new VehicleInformationDto();

            target.Engine       = EngineAssembler.FromObjectToDto(source.Engine);
            target.VehicleModel = source.VehicleModel;
            target.Vin          = source.Vin;
            return(target);
        }
Exemplo n.º 3
0
        public void UploadVehicleInformationTest()
        {
            var vehicle = new VehicleInformationDto()
            {
                ItemID          = 1,
                Lane            = "A",
                Slot            = "123",
                Start           = "Yes",
                BranchCode      = 123,
                StockNo         = "12345678",
                VIN             = "WBA8E9C5XGK646786",
                VehicleYear     = "2000",
                VehicleMake     = "Honda",
                VehicleModel    = "Accord",
                Transmission    = "AT",
                RunAndDrive     = "Yes",
                OdoBrand        = "Actual",
                Odometer        = "10000",
                PrimaryDamage   = "Front End",
                SecondaryDamage = "Front End",
                VehicleTitle    = "Clear",
                LossType        = "Water",
                SaleDocument    = "Clear",
                AuctionDate     = System.DateTime.Now
            };

            vehicle.VehicleInformationImage = new VehicleInformationImage[10];
            for (int image = 1; image <= 10; image++)
            {
                var large = "https://cvis.iaai.com/thumbnail?imageKeys=18693774~SID~I" + image;
                var thumb = "https://cvis.iaai.com/resizer?imageKeys=18693774~SID~I" + image;
                vehicle.VehicleInformationImage[image - 1] = new VehicleInformationImage()
                {
                    ThumbnailURL = thumb, LargeURL = large
                };
            }

            var vehicles = new List <VehicleInformationDto>();

            vehicles.Add(vehicle);

            var request = new VehicleUploadRequest()
            {
                UserRequestInfo = User, VehicleInformationList = vehicles.ToArray()
            };
            var uploadStockList = Client.UploadVehicleInformation(request);

            Assert.IsTrue(uploadStockList.WasSuccessful);
        }
Exemplo n.º 4
0
        public PartialViewResult VinCheck(string vin)
        {
            VehicleInformation  info   = null;
            VtsWebServiceClient client = new VtsWebServiceClient();

            try
            {
                VehicleInformationDto dto = client.GetVehicleInformationByVin(vin);
                info = VehicleInformationAssembler.FromDtoToDomainObject(dto);
            }
            catch (FaultException)
            {
                return(PartialView("_UnsupportedVehiclePartialView", info));
            }
            catch (NotSupportedException)
            {
                return(PartialView("_UnsupportedVehiclePartialView", info));
            }
            return(PartialView("_VinCheckResultPartialView", info));
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            VtsWebService         svc = new VtsWebService();
            VehicleInformationDto d   = svc.GetVehicleInformationByVin("VF7CH9HZC39864291");

            d.ToString();

            /*List<string> vins = new List<string>()
             * {
             *  "VF7LCKFUC74631358",
             *  "VF7DERHZB76139931",
             *  "VF7EB4HWG13182473",
             *  "VF3321PA212372875",
             *  "VF7AFRHWB12806391"
             * };
             * svc.AssociateVehiclesWithUser(vins, "dummy", Sha256Hash.Calculate("dummy"));*/
            //svc.ProvideAccessToVehicleForClientUsingEmail(4, "*****@*****.**", "dummy", Sha256Hash.Calculate("dummy"));
            //Emailer.NotifyClientAboutRegistration("*****@*****.**", "newClient", "newPassword");

            /*AnalyticDataAutoUpdateTester tester = new AnalyticDataAutoUpdateTester();
             * tester.Test();*/

            /*VtsWebService s = new VtsWebService();
             * List<int> res = s.GetAvailableAnalyticStatisticsTypesForVehicle("VF33CNFUB82601182");
             * List<AnalyticStatisticsValueDto> vals = s.GetAnalyticStatisticsPerVehicle("VF33CNFUB82601182", 1034);*/

            /*List<SystemNewsDto> result = new List<SystemNewsDto>();
             * using (VTSDatabase database = new VTSDatabase())
             * {
             *  foreach (SystemNews newsEntity in database.SystemNews.
             *      OrderByDescending(s => s.DatePublished).Take(5))
             *  {
             *      result.Add(SystemNewsAssembler.FromEntityToDto(newsEntity));
             *  }
             * }
             *
             * VtsWebServiceClient cl = new VtsWebServiceClient();
             * List<SystemNewsDto> n = cl.NewsGetAll().ToList();
             * n.ToArray();*/


            /*string filename = @"g:\tmp\11_12_2013_good.uvts.zip";
             * FileStream fs = File.Open(filename, FileMode.Open);
             * byte[] bytez = ReadFully(fs);
             *
             *
             * MemoryStream ms1 = new MemoryStream(bytez);
             * ms1.Position = 0;
             *
             * ZipInputStream stream = new ZipInputStream(ms1);
             * MemoryStream output = new MemoryStream();
             * byte[] buffer = new byte[4096];
             * StreamUtils.Copy(stream, output, buffer);
             * byte[] bytes = ReadFully(stream);
             * MemoryStream ms = new MemoryStream(bytes);
             * ms.Position = 0;*/


            /*string vin = "VF7SA5FV8BW634809"; //VF34C5FWF55360488 VF7LCKFUC74631358
             * VehicleCharacteristicsManager manager = new VehicleCharacteristicsManager();
             * VTS.Shared.DomainObjects.VehicleCharacteristics chars = manager.GetVehicleCharacteristicsForVin(vin, SupportedLanguage.English);
             * VehicleInfoRecognizer rec = new VehicleInfoRecognizer(vin, chars);
             * VehicleInformation info = rec.Recognize();*/

            /*FileStream stream = new FileStream(@"c:\Users\Yama\Desktop\pegAll.vts", FileMode.Open);
             * PortableDataFactory factory = new PortableDataFactory(stream);
             * PortableData data = factory.Create();
             * List<PsaDataset> datasets = FormDatasets(data);
             * VtsWebServiceClient client = new VtsWebServiceClient();
             * //client.UploadDataset(PsaDatasetAssembler.FromDomainObjectToDto(datasets[0]));
             * Persist(datasets);*/

            /*List<AnalyticRuleSettingsDto> result = GetAnalyticRuleSettingsDefaultByTypes(
             *  new List<int>() { 1001, 1034 }, 2, 216);*/
        }
Exemplo n.º 6
0
        public void PushData()
        {
            clsLog.LogInfo("Pushing Stocks to LKQ");

            try
            {
                var vehicleList = new List<VehicleInformationDto>();

                //Get a list of non DDR Stock from database
                //Create a stroed proc to return datatable, loop thru it and populate vehicleList. See sample below

                /*
               ItemID, Lane, Slot, Start, AuctionDate, BranchCode, StockNo, VIN, VehicleYear, VehicleMake, VehicleModel, Transmission, 
               RunAndDrive, OdoBrand, Odometer, PrimaryDamage, SecondaryDamage, VehicleTitle, LossType, SaleDocument, 

               ThumbnailURL, LargeURL => TALK TO SAURIN ON HOW TO GENERATE URL
               */

                var connection = ConfigurationManager.ConnectionStrings["Connection"].ConnectionString;

                DataTable dt = new DataTable();

                using (SqlConnection con = new SqlConnection(connection))
                {
                    using (SqlCommand cmd = new SqlCommand("dyndata.dbo.SP_PUSHDATA", con))
                    {
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {

                            cmd.CommandType = CommandType.StoredProcedure;
                            da.Fill(dt);
                        }

                    }
                }

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    var vehicle = new VehicleInformationDto()
                    {
                        ItemID = Convert.ToInt32(dt.Rows[i]["ItemID"]),
                        Lane = dt.Rows[i]["Lane"].ToString().Trim(),
                        Slot = dt.Rows[i]["Slot"].ToString().Trim(),
                        Start = dt.Rows[i]["Start"].ToString(),
                        BranchCode = Convert.ToInt32(dt.Rows[i]["BranchCode"]),
                        StockNo = dt.Rows[i]["StockNo"].ToString().Trim(),
                        VIN = dt.Rows[i]["VIN"].ToString().Trim(),
                        VehicleYear = dt.Rows[i]["VehicleYear"].ToString().Trim(),
                        VehicleMake = dt.Rows[i]["VehicleMake"].ToString().Trim(),
                        VehicleModel = dt.Rows[i]["VehicleModel"].ToString().Trim(),
                        Transmission = dt.Rows[i]["Transmission"].ToString().Trim(),
                        RunAndDrive = dt.Rows[i]["RunAndDrive"].ToString().Trim(),
                        OdoBrand = dt.Rows[i]["OdoBrand"].ToString().Trim(),
                        Odometer = dt.Rows[i]["Odometer"].ToString().Trim(),
                        PrimaryDamage = dt.Rows[i]["PrimaryDamage"].ToString().Trim(),
                        SecondaryDamage = dt.Rows[i]["SecondaryDamage"].ToString().Trim(),
                        VehicleTitle = dt.Rows[i]["VehicleTitle"].ToString().Trim(),
                        LossType = dt.Rows[i]["LossType"].ToString().Trim(),
                        SaleDocument = dt.Rows[i]["SaleDocument"].ToString().Trim()
                    };
                    if (!dt.Rows[i]["livedate"].ToString().ToLower().Equals("tbd"))
                        vehicle.AuctionDate = DateTimeOffset.Parse(dt.Rows[i]["livedate"].ToString());

                    var dbThumbURL = dt.Rows[i]["ThumbnailURL"].ToString();
                    if (dbThumbURL != "")
                    {
                        var reg = new Regex("~R(.+?)TH0");
                        var match = reg.Match(dbThumbURL);
                        if (match.Success)
                            dbThumbURL = dbThumbURL.Replace(match.Value, "");

                        dbThumbURL = dbThumbURL.Replace("vis.iaai.com", "cvis.iaai.com");
                        vehicle.VehicleInformationImage = new VehicleInformationImage[10];
                        for (int image = 1; image <= 10; image++)
                        {
                            var large = dbThumbURL.Replace("height=240", "height=480").Replace("width=320", "width=640").Replace("~I1", "~I" + image.ToString());
                            var thumb = dbThumbURL.Replace("resizer", "thumbnail").Replace("&height=240&width=320", "").Replace("~I1", "~I" + image.ToString());
                            vehicle.VehicleInformationImage[image - 1] = new VehicleInformationImage() { ThumbnailURL = thumb, LargeURL = large };
                        }
                    }
                    vehicleList.Add(vehicle);
                }

                clsLog.LogInfo("PushData - ready to push " + vehicleList.Count + " records to remote");

                var index = 0;
                do
                {
                    var request = new VehicleUploadRequest() { VehicleInformationList = vehicleList.Skip(index).Take(500).ToArray(), UserRequestInfo = User };
                    var response = Client.UploadVehicleInformation(request);
                    if (!response.WasSuccessful)
                    {
                        clsLog.LogInfo("PushData - Error out while pushing data to remote from " + index.ToString());
                    }
                    else
                    {
                        clsLog.LogInfo("PushData - Pushed data to remote from " + index.ToString() + " to " + request.VehicleInformationList.Count());
                    }
                    index += 500;
                } while (index <= vehicleList.Count);

            }
            catch (Exception ex)
            {
                clsLog.LogInfo("PushData - Error ocurred while pushing data to remote. Error " + ex.Message);
            }
        }