public MySQLExporter(VGCore core, List <MakerObj> MakerObjObjects, List <ModelObj> modelsObjects,
                             List <ModelTypeObj> modelTypesObjects, List <CarDetailsObj> carDetailsObjects, string server = "megraso.de",
                             string database = "h26346_cardata", bool ssl = true,
                             long port       = 3306, string user = "******", string password = "******")
        {
            this.SqlServer   = server;
            this.SqlDatabase = database;
            this.Sqlssl      = ssl;
            this.SqlPort     = port;
            this.SqlUser     = user;
            this.SqlPassword = password;

            this.MakersObjList     = MakerObjObjects;
            this.modelObjList      = modelsObjects;
            this.modelTypeObjList  = modelTypesObjects;
            this.carDetailsObjList = carDetailsObjects;

            this.Core = core;

            Initialize();
            _sqlCarMaker = new SQLCarMaker(this);

            _sqlCarModel = new SQLCarModel(this);

            _sqlCarModelType = new SQLCarModelType(this);

            _sqlCarDetail = new SQLCarDetails(this);
        }
Exemple #2
0
        public void Add_CarDetails()
        {
            foreach (CarDetailsObj obj in _mySqlExporter.carDetailsObjList)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(obj.Maker))
                    {
                        obj.Maker = Core.Conf.MakerName;
                    }
                    long makerId = SQLCarMaker.GetMakerId(obj.Maker);
                    long modelId = SQLCarModel.GetModelId(obj.Series);
                    long typeId  = SQLCarModelType.GetModelTypeId(obj.ModelTypeName);

                    //long id = GetCarDetailsId(makerId, modelId, typeId, obj.ModelTypeName);
                    long id = GetCarDetailsId(obj.HSN, obj.TSN, obj.ModelTypeName);
                    if (id == -1)
                    {
                        Insert_CarDetails(obj, makerId, modelId, typeId);
                    }
                    else
                    {
                        Update_CarDetails(obj, makerId, modelId, typeId, id);
                    }
                }
                catch (Exception ex)
                {
                    if (Core != null && Core.Log != null)
                    {
                        Core.Log.Error(string.Format("SQLCarDetails::Add_CarDetails : {0}", ex.Message));
                    }
                    else
                    {
                        throw new Exception("SQLCarDetails::Add_CarDetails", ex);
                    }
                }
            }
        }
        public void Add_CarModelTypes()
        {
            foreach (ModelTypeObj obj in _mySqlExporter.modelTypeObjList)
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(obj.MakerName))
                    {
                        obj.MakerName = Core.Conf.MakerName;
                    }
                    long makerId = SQLCarMaker.GetMakerId(obj.MakerName);
                    long modelId = SQLCarModel.GetModelId(obj.ModelName);

                    long modelTypeId = GetModelTypeId(obj.ModelTypeName);
                    if (modelTypeId == -1)
                    {
                        Insert_CarModelType(obj, makerId, modelId);
                    }
                    else
                    {
                        Update_CarModelType(obj, makerId, modelId, modelTypeId);
                    }

                    SetModelYears(obj);
                }
                catch (Exception ex)
                {
                    if (Core != null && Core.Log != null)
                    {
                        Core.Log.Error(string.Format("SQLCarModelType::Add_CarModelTypes : {0}", ex.Message));
                    }
                    else
                    {
                        throw new Exception("SQLCarModelType::Add_CarModelTypes", ex);
                    }
                }
            }
        }