/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns></returns> public override object Clone() { FuelType obj = new FuelType(); obj.Name = this.Name; obj.Price = this.Price; obj.Co2Emission = this.Co2Emission; return(obj); }
/// <summary> /// Creates project. /// </summary> /// <param name="name">Project's name.</param> /// <param name="folderPath">Project's folder path.</param> /// <param name="description">Proejct's description.</param> /// <returns>Created project</returns> public static Project CreateProject(string name, string folderPath, string description, CapacitiesInfo capacitiesInfo, OrderCustomPropertiesInfo orderCustomPropertiesInfo, FuelTypesInfo fuelTypesInfo /*serivces*/, IProjectSaveExceptionHandler logHandler) { WorkspaceHandler workspaceHandler = new WorkspaceHandler(logHandler); if (name == null) throw new ArgumentNullException("name"); if (folderPath == null) throw new ArgumentNullException("folderPath"); if (description == null) throw new ArgumentNullException("description"); if (!CheckMaximumLengthConstraint(orderCustomPropertiesInfo)) throw new ApplicationException(Properties.Messages.Error_OrderCustomPropTooLong); bool isDBCreated = false; string dbPath = ""; try { name = name.Trim(); // make project configuration path string projCfgPath = System.IO.Path.Combine(folderPath, name); projCfgPath += ProjectConfiguration.FILE_EXTENSION; string databasePath = ProjectConfiguration.GetDatabaseFileName(name); // create project configuration ProjectConfiguration projConfig = new ProjectConfiguration(name, folderPath, description, databasePath, null, DateTime.Now); projConfig.Validate(); projConfig.Save(); dbPath = projConfig.DatabasePath; DatabaseEngine.DeleteDatabase(dbPath); // create database DatabaseEngine.CreateDatabase(dbPath, SchemeVersion.CreationScript); isDBCreated = true; Project project = new Project(projCfgPath, capacitiesInfo, orderCustomPropertiesInfo, workspaceHandler); foreach (FuelTypeInfo fuelTypeInfo in fuelTypesInfo) { FuelType projectFuelType = new FuelType(); projectFuelType.Name = fuelTypeInfo.Name; projectFuelType.Price = fuelTypeInfo.Price; projectFuelType.Co2Emission = fuelTypeInfo.Co2Emission; project.FuelTypes.Add(projectFuelType); } project.Save(); workspaceHandler.Handled = true; return project; } catch(Exception ex) { Logger.Info(ex); if (isDBCreated) DatabaseEngine.DeleteDatabase(dbPath); throw; } }
/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns></returns> public override object Clone() { FuelType obj = new FuelType(); obj.Name = this.Name; obj.Price = this.Price; obj.Co2Emission = this.Co2Emission; return obj; }