public RebuildPropertyFile(string path) { try { var stream = new FileStream(path, FileMode.Open, FileAccess.Read); var reader = XmlReader.Create(stream); var file = new PropertyFile(); file.ReadXML(reader); reader.Close(); stream.Close(); stream = new FileStream(path + ".part", FileMode.Create, FileAccess.Write); XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8); writer.Formatting = Formatting.Indented; file.WriteXML(writer); writer.Close(); stream.Close(); } catch (Exception) { failed = true; if (File.Exists(path + ".part")) { File.Delete(path + ".part"); } return; } File.Replace(path + ".part", path, path + ".backup"); File.Delete(path + ".backup"); }
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (this.DataContext != null && this.DataContext.GetType() == typeof(DatabaseIndexData)) { DatabaseIndexData index = (DatabaseIndexData)this.DataContext; Dictionary <uint, Property> propertyContainer; try { MemoryStream byteStream = new MemoryStream(index.Data); propertyFile = new PropertyFile(); propertyFile.Read(byteStream); propertyContainer = propertyFile.Values; PathFileEntry = new PathFile(); PathFileEntry.Load(propertyFile.Values); ContainerGrid.DataContext = PathFileEntry; } catch (Exception ex) { Exception subEx = ex.InnerException; while (subEx != null) { // exceptionMessage += subEx.Message + Environment.NewLine; subEx = ex.InnerException; } } } }
byte[] generateLocale(PropertyFile file, string group, string instance) { // Create a .locale file from placeholder text if there are any <text> // tags with no instance or table ID var locale = new StringBuilder(); uint locale_index = 0; var locale_name = "auto_" + group + "_" + instance; foreach (var prop1 in file.Values.Values) { var arr = prop1 as ArrayProperty; if (arr == null) { continue; } foreach (var prop in arr.Values) { var text = prop as TextProperty; if (text != null && text.InstanceId == 0 && text.TableId == 0) { if (locale_index == 0) { locale.Append("# This file generated from " + group + "/" + instance + ".prop.xml by SporeMaster.\n"); } text.TableId = NameRegistry.Files.toHash(locale_name); text.InstanceId = ++locale_index; locale.AppendFormat("0x{0:X8} {1}\n", text.InstanceId, text.PlaceholderText); } } } return(Encoding.UTF8.GetBytes(locale.ToString())); }
void CachePropKeys() { _cacheProperties.Clear(); _cacheInstances.Clear(); _cacheGroups.Clear(); // loads up local cache. double cache is required because it will add values from props later on _cacheInstances = DatabaseManager.Instance.LoadedInstanceIds; // get instance GroupId's from the GroupContainer foreach (uint groupContainer in DatabaseManager.Instance.LoadedGroupIds) { if (!_cacheGroups.Contains(groupContainer)) { _cacheGroups.Add(groupContainer); } } // build up cache for prop files (is a bit more complex due to the value arrays) IEnumerable <DatabaseIndex> propitems = DatabaseManager.Instance.Where(item => item.TypeId == 0xb1b104); foreach (DatabaseIndex item in propitems) { PropertyFile file = new PropertyFile(); byte[] data = item.GetIndexData(true); using (MemoryStream byteStream = new MemoryStream(data)) { file.Read(byteStream); } Dictionary <uint, Property> propertyCollection; propertyCollection = file.Values; foreach (KeyValuePair <uint, Property> prop in propertyCollection) { if (_cacheProperties.Contains(prop.Key) == false) // add Prop key Name { _cacheProperties.Add(prop.Key); } if (prop.Value is ArrayProperty) // add Values from prop array's, these are all instance id's! { ArrayProperty arr = prop.Value as ArrayProperty; try { foreach (KeyProperty subProp in arr.Values) { if (_cacheInstances.Contains(subProp.InstanceId) == false && subProp.InstanceId != 0) { _cacheInstances.Add(subProp.InstanceId); } } } catch { } } } } _cacheReady = true; // set ready flag for threads to continue... }
void writePropFile(string groupName, string instanceName, string inputFileName, Stream output, out byte[] locale) { // Convert .prop.xml to binary .prop file and write it to output var reader = XmlReader.Create(File.OpenText(inputFileName)); var file = new PropertyFile(); file.ReadXML(reader); reader.Close(); locale = generateLocale(file, groupName, instanceName); file.Write(output); }
private void btnAddProperty_Click(object sender, RoutedEventArgs e) { ViewAddProperty dlg = new ViewAddProperty(); if (dlg.ShowDialog().GetValueOrDefault(false)) { AddProperty(dlg.PropertyId, PropertyFile.AddProperty(dlg.PropertyId, dlg.PropertyType, dlg.IsArray)); Value_PropertyChanged(this, new EventArgs()); dataGrid1.Items.Refresh(); } }
static Config() { String confPath = LocalUserPath() + "\\Config.dat"; Settings = new PropertyFile(confPath); if (!Settings.Exists()) { Settings.Put("Interval", "3"); Settings.Put("Username", ""); Settings.Put("Password", ""); } }
public void Read() { var file = new PropertyFile().LoadFromFile("Configuration\\PropertyFileTestData.property"); Assert.AreEqual("http\\://en.wikipedia.org/", file["website"]); Assert.AreEqual(@"Welcome to Wikipedia!", file["message"]); Assert.AreEqual("This is the value that could be looked up with the key \"key with spaces\".", file["key with spaces"]); Assert.AreEqual("Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;", file["DbConnectionString"]); }
private void writePropFile(byte[] data, string fn) { PropertyFile file = new PropertyFile(); file.Read(new MemoryStream(data)); stripGeneratedLocaleReferences(file); var output = File.Create(fn + ".xml"); XmlTextWriter writer = new XmlTextWriter(output, Encoding.UTF8); writer.Formatting = Formatting.Indented; file.WriteXML(writer); writer.Flush(); output.Close(); }
public Task Publish(string file, string secretId, CancellationToken token) { file.VerifyNotEmpty(nameof(file)); secretId .VerifyNotEmpty(nameof(secretId)) .VerifyAssert(x => x.All(y => char.IsLetterOrDigit(y) || y == '-' || y == '.'), $"Invalid secret ID"); using IDisposable scope = _logger.BeginScope(new { Command = nameof(Publish), File = file, SecretId = secretId }); PropertyFile db = PropertyFile.ReadFromFile(file, true); new PropertySecret(db.Properties).WriteToSecret(secretId); _logger.LogInformation($"Publishing database \"{file}\" to secret Id=\"{secretId}\"."); return(Task.CompletedTask); }
public Task Set(string file, string key, string value, CancellationToken token) { file.VerifyNotEmpty(nameof(file)); key.VerifyNotEmpty(nameof(key)); value.VerifyNotEmpty(nameof(value)); using IDisposable scope = _logger.BeginScope(new { Command = nameof(Set), File = file, Key = key, Value = value }); PropertyFile db = PropertyFile.ReadFromFile(file, true); db.Properties[key] = value; db.WriteToFile(); _logger.LogInformation($"Set property {key}={value} from database {db.File}..."); return(Task.CompletedTask); }
public Task List(string file, CancellationToken token) { file.VerifyNotEmpty(nameof(file)); using IDisposable scope = _logger.BeginScope(new { Command = nameof(List), File = file }); PropertyFile db = PropertyFile.ReadFromFile(file, true); string line = db.Properties .Select((x, i) => $"({i}) {x.Key}=\"{x.Value}\"") .Prepend($"Listing properties from database {db.File}...") .Prepend("") .Aggregate(string.Empty, (a, x) => a += x + Environment.NewLine); _logger.LogInformation(line); return(Task.CompletedTask); }
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; List <TGIRecord> foundItems = TGIRegistry.Instance.Instances.Cache.Values.ToList(); int completed = 0; IEnumerable <DatabaseIndex> propitems = DatabaseManager.Instance.Where(item => item.TypeId == 0xb1b104); int count = propitems.Count(); foreach (DatabaseIndex item in propitems) { if (worker.CancellationPending) { e.Cancel = true; return; } try { byte[] data = item.GetIndexData(true); using (MemoryStream byteStream = new MemoryStream(data)) { PropertyFile file = new PropertyFile(); file.Read(byteStream); foreach (KeyProperty prop in file.Values.Values.Where(p => p is KeyProperty)) { //if the value is found remove it from the list. foundItems.RemoveAll(r => r.Id == prop.InstanceId); } foreach (ArrayProperty prop in file.Values.Values.Where(p => p is ArrayProperty)) { foreach (KeyProperty propi in prop.Values.Where(p => p is KeyProperty)) { foundItems.RemoveAll(r => r.Id == propi.InstanceId); } } } } catch { } worker.ReportProgress((int)(((float)completed++ / (float)count) * 100)); } e.Result = foundItems; }
public Task Delete(string file, string key, CancellationToken token) { file.VerifyNotEmpty(nameof(file)); key.VerifyNotEmpty(nameof(key)); using IDisposable scope = _logger.BeginScope(new { Command = nameof(Delete), File = file, Key = key }); PropertyFile db = PropertyFile.ReadFromFile(file, true); _logger.LogInformation($"Delete property {key} from database {file}..."); bool removed = db.Properties.Remove(key); if (removed) { db.WriteToFile(file); } _logger.LogInformation($"Property {(removed ? "was removed" : "was not found")}"); return(Task.CompletedTask); }
public Task Get(string file, string key, CancellationToken token) { file.VerifyNotEmpty(nameof(file)); key.VerifyNotEmpty(nameof(key)); using IDisposable scope = _logger.BeginScope(new { Command = nameof(Get), File = file, Key = key }); PropertyFile db = PropertyFile.ReadFromFile(file, true); _logger.LogInformation($"Get property {key} from database {db.File}..."); if (!db.Properties.TryGetValue(key, out string?value)) { _logger.LogInformation($"Key {key} not found"); } else { _logger.LogInformation($"Property {key}={value}"); } return(Task.CompletedTask); }
private void stripGeneratedLocaleReferences(PropertyFile file) { // Effectively, we are undoing the work of PackagePack.generateLocale() foreach (var prop1 in file.Values.Values) { var arr = prop1 as ArrayProperty; if (arr == null) { continue; } foreach (var prop in arr.Values) { var text = prop as TextProperty; if (text != null && (NameRegistry.Files.toName(text.TableId).StartsWith("auto_") || NameRegistry.Files.toName(text.TableId).EndsWith("_auto"))) { text.InstanceId = 0; text.TableId = 0; } } } }
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (this.DataContext != null && this.DataContext.GetType() == typeof(DatabaseIndexData)) { DatabaseIndexData index = (DatabaseIndexData)this.DataContext; Dictionary <uint, Property> propertyContainer; try { using (MemoryStream byteStream = new MemoryStream(index.Data)) { propertyFile = new PropertyFile(); propertyFile.Read(byteStream); propertyContainer = propertyFile.Values; pnlImages.Children.RemoveRange(0, pnlImages.Children.Count); displayProperties = new List <PropertyModel>(); ReloadDisplayProperties(propertyContainer); } } catch (Exception ex) { tbxError.Visibility = System.Windows.Visibility.Visible; dataGrid1.Visibility = System.Windows.Visibility.Collapsed; string exceptionMessage = ex.Message + Environment.NewLine; Exception subEx = ex.InnerException; while (subEx != null) { exceptionMessage += subEx.Message + Environment.NewLine; subEx = ex.InnerException; } tbxError.Text = exceptionMessage + Environment.NewLine + ex.StackTrace; } } }
public static PropertyFileModel ToModel(this PropertyFile entity) { return(entity.MapTo <PropertyFile, PropertyFileModel>()); }
private void Load() { _SoundEntryCollection = new SoundEntryCollection(); BGMFilesDB.InitializeBGMDB(_SmashProjectManager.CurrentProject.GameVersion, _SmashProjectManager.CurrentProject.IsSwitch); BGMStageDB.InitializeBGMMyMusicDB(_SmashProjectManager.CurrentProject.GameVersion, _SmashProjectManager.CurrentProject.IsSwitch); _PropertyFile = new PropertyFile(_SmashProjectManager, _SoundEntryCollection, "data/sound/config/bgm_property.mpb"); _SoundEntryCollection.GenerateSoundEntriesBGMDictionary(); _UISoundDBFile = new UISoundDBFile(_SmashProjectManager, _SoundEntryCollection, "data/param/ui/ui_sound_db.bin"); _SoundEntryCollection.GenerateSoundEntriesDictionary(); _MyMusicFile = new MyMusicFile(_SmashProjectManager, _SoundEntryCollection, "data/sound/config/bgm_mymusic.mmb"); //Generation SoundMSBT dictionaries _SoundMSBTFiles = new List <SoundMSBTFile>(); foreach (ResourceCollection resCol in _SmashProjectManager.ResourceDataCollection) { if (!resCol.CachedFilteredResources.ContainsKey("ui/message/sound.msbt")) { continue; } SoundMSBTFile soundMSBTFile = new SoundMSBTFile(_SmashProjectManager, _SoundEntryCollection, resCol.PartitionName + "/ui/message/sound.msbt"); _SoundMSBTFiles.Add(soundMSBTFile); } //Generate Dictionaries _SoundEntryCollection.GenerateStagesDictionaries(); //Check stage sound integrity between MyMusic Stages and SoundDB Stages. //General rule: All BGMS present in MyMusic stages must be in SoundDB, the opposite isnt true. foreach (MyMusicStage myMusicStage in _SoundEntryCollection.MyMusicStages) { if (myMusicStage.BGMStage.BGMDBID != null) { //From MyMusic List <BGMEntry> bgmsMyMusic = new List <BGMEntry>(); foreach (MyMusicStageBGM myMusicStageBGM in myMusicStage.BGMs) { //if(myMusicStageBGM.unk4 == 0x0) //Filter songs bgmsMyMusic.Add(myMusicStageBGM.BGMEntry); } //From SoundDB List <BGMEntry> bgmsSoundDB = new List <BGMEntry>(); foreach (SoundDBStageSoundEntry sDBStageSoundEntry in _SoundEntryCollection.SoundDBStagesPerID[(int)myMusicStage.BGMStage.BGMDBID].SoundEntries) { if (sDBStageSoundEntry.SoundEntry == null) { LogHelper.Warning(string.Format("SOUNDID '{0}' have an issue with one of its associated stages.", sDBStageSoundEntry.SoundID)); continue; } foreach (SoundEntryBGM sEntryBGM in sDBStageSoundEntry.SoundEntry.BGMFiles) { bgmsSoundDB.Add(sEntryBGM.BGMEntry); } } //HACK FOR KK foreach (SoundEntry sEntry in _SoundEntryCollection.SoundEntries) { if (!sEntry.InSoundTest) { foreach (SoundEntryBGM sEntryBGM in sEntry.BGMFiles) { if (sEntryBGM.BGMEntry != null) { bgmsSoundDB.Add(sEntryBGM.BGMEntry); } } } } //Compare foreach (BGMEntry sEntryBGM in bgmsMyMusic) { if (!bgmsSoundDB.Contains(sEntryBGM)) { //throw new Exception(string.Format("Error sound integrity between MyMusic Stages and SoundDB Stages for stage '{0}': '{1}' was not present.", myMusicStage.BGMStage.Label, sEntryBGM.BGMTitle)); LogHelper.Error(string.Format("Error sound integrity between MyMusic Stages and SoundDB Stages for stage '{0}': '{1}' was not present.", myMusicStage.BGMStage.Label, sEntryBGM.BGMTitle)); } } } } Initialize(); }
public ImportResponse ImportProductsFromXlsx(Stream stream, string path) { ImportResponse IR = new ImportResponse(); var currentUser = _workContext.CurrentAccountUser; IList <Core.Domain.Properties.Property> properties = new List <Core.Domain.Properties.Property>(); using (var xlPackage = new ExcelPackage(stream)) { var worksheet = xlPackage.Workbook.Worksheets.FirstOrDefault(); if (worksheet == null) { throw new Exception("没有找到excel表格"); } #region 导入的资产字段集合 var excelProperty = new[] { "资产名称", "产权单位", "资产类别", "地址", "建筑面积(平方米)", "土地面积(平方米)", "房产性质", "土地性质", "账面价格(万元)", "取得时间", "使用年限(年)", "使用方", "自用面积(平方米)", "出租面积(平方米)", "出借面积(平方米)", "闲置面积(平方米)", "不动产证", "房产证", "土地证", "空间位置", "空间范围", "资产封面", "图片附件", "其他附件", "备注" }; #endregion //数据插入 int row = 2; StringBuilder sb = new StringBuilder(); while (true) { #region 循环记录 try { bool allColumnsAreEmpty = true; for (var i = 1; i <= excelProperty.Length; i++) { if (worksheet.Cells[row, i].Value != null && !String.IsNullOrEmpty(worksheet.Cells[row, i].Value.ToString())) { allColumnsAreEmpty = false; break; } } if (allColumnsAreEmpty) { break; } List <Point> points = new List <Point>(); var property = new Core.Domain.Properties.Property() { FromExcelImport = true }; if (worksheet.Cells[row, GetColumnIndex(excelProperty, "资产名称")].Value != null) { property.Name = worksheet.Cells[row, GetColumnIndex(excelProperty, "资产名称")].Value.ToString(); } else { throw new Exception("资产名称不能为空"); } #region 产权单位 if (currentUser.IsParentGovernmentorAuditor()) { if (worksheet.Cells[row, GetColumnIndex(excelProperty, "产权单位")].Value != null) { var governmentName = worksheet.Cells[row, GetColumnIndex(excelProperty, "产权单位")].Value.ToString(); var government = _governmentService.GetGovernmentUnitByName(governmentName); if (government == null) { property.Government = currentUser.Government; } else { if (government.ParentGovernmentId != currentUser.Government.Id) { throw new Exception("所填写产权单位并非当前账号直接下级部门"); } else { property.Government = government; } } } } else { property.Government = currentUser.Government; } #endregion #region 资产类别导入 if (worksheet.Cells[row, GetColumnIndex(excelProperty, "资产类别")].Value != null) { switch (worksheet.Cells[row, GetColumnIndex(excelProperty, "资产类别")].Value.ToString()) { case "房屋": property.PropertyType = PropertyType.House; break; case "土地": property.PropertyType = PropertyType.Land; break; case "房屋对应土地": property.PropertyType = PropertyType.LandUnderHouse; break; case "其他": default: property.PropertyType = PropertyType.Others; break; } } else { throw new Exception("资产类别不能为空"); } #endregion #region 基本属性录入 if (worksheet.Cells[row, GetColumnIndex(excelProperty, "地址")].Value != null) { property.Address = worksheet.Cells[row, GetColumnIndex(excelProperty, "地址")].Value.ToString(); } else { throw new Exception("资产地址不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "建筑面积(平方米)")].Value != null) { try { property.ConstructArea = Convert.ToDouble(worksheet.Cells[row, GetColumnIndex(excelProperty, "建筑面积(平方米)")].Value); } catch { throw new Exception("建筑面积必须是一个数字"); } } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "土地面积(平方米)")].Value != null) { try { property.LandArea = Convert.ToDouble(worksheet.Cells[row, GetColumnIndex(excelProperty, "土地面积(平方米)")].Value); } catch { throw new Exception("土地面积必须是一个数字"); } } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "账面价格(万元)")].Value != null) { try { // property.Price = Convert.ToDouble(worksheet.Cells[row, GetColumnIndex(excelProperty, "账面价格(万元)")].Value); } catch { throw new Exception("账面价值必须是一个数字"); } } else { throw new Exception("资产账面价格不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "取得时间")].Value != null) { try { property.GetedDate = Convert.ToDateTime(worksheet.Cells[row, GetColumnIndex(excelProperty, "取得时间")].Value); } catch { throw new Exception("取得时间不是一个标准的日期格式"); } } else { throw new Exception("资产取得时间不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "使用年限(年)")].Value != null) { try { // property.LifeTime = Convert.ToInt32(worksheet.Cells[row, GetColumnIndex(excelProperty, "使用年限(年)")].Value); } catch { throw new Exception("使用年限必须是一个数字"); } } else { throw new Exception("使用年限不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "使用方")].Value != null) { property.UsedPeople = worksheet.Cells[row, GetColumnIndex(excelProperty, "使用方")].Value.ToString(); } else { throw new Exception("使用方不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "自用面积(平方米)")].Value != null) { try { // property.CurrentUse_Self = Convert.ToDouble(worksheet.Cells[row, GetColumnIndex(excelProperty, "自用面积(平方米)")].Value); } catch { throw new Exception("自用面积必须是一个数字"); } } else { throw new Exception("自用面积不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "出租面积(平方米)")].Value != null) { try { // property.CurrentUse_Rent = Convert.ToDouble(worksheet.Cells[row, GetColumnIndex(excelProperty, "出租面积(平方米)")].Value); } catch { throw new Exception("出租面积必须是一个数字"); } } else { throw new Exception("出租面积不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "出借面积(平方米)")].Value != null) { try { // property.CurrentUse_Lend = Convert.ToDouble(worksheet.Cells[row, GetColumnIndex(excelProperty, "出借面积(平方米)")].Value); } catch { throw new Exception("出借面积必须是一个数字"); } } else { throw new Exception("出借面积不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "闲置面积(平方米)")].Value != null) { try { // property.CurrentUse_Idle = Convert.ToDouble(worksheet.Cells[row, GetColumnIndex(excelProperty, "闲置面积(平方米)")].Value); } catch { throw new Exception("闲置面积必须是一个数字"); } } else { throw new Exception("闲置面积不能为空"); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "不动产证")].Value != null) { property.EstateId = worksheet.Cells[row, GetColumnIndex(excelProperty, "不动产证")].Value.ToString(); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "房产证")].Value != null) { property.ConstructId = worksheet.Cells[row, GetColumnIndex(excelProperty, "房产证")].Value.ToString(); } if (worksheet.Cells[row, GetColumnIndex(excelProperty, "土地证")].Value != null) { property.LandId = worksheet.Cells[row, GetColumnIndex(excelProperty, "土地证")].Value.ToString(); } #endregion #region 空间位置录入 var location = ""; var extent = ""; //点 if (worksheet.Cells[row, GetColumnIndex(excelProperty, "空间位置")].Value != null) { try { location = worksheet.Cells[row, GetColumnIndex(excelProperty, "空间位置")].Value.ToString(); var point = Newtonsoft.Json.JsonConvert.DeserializeObject <Point>(location); var wkt = "POINT(" + point.lng + " " + point.lat + ")"; property.Location = DbGeography.FromText(wkt); } catch { throw new Exception("空间位置获取失败"); } } else { throw new Exception("空间位置不能为空"); } //面 if (worksheet.Cells[row, GetColumnIndex(excelProperty, "空间范围")].Value != null) { try { extent = worksheet.Cells[row, GetColumnIndex(excelProperty, "空间范围")].Value.ToString(); var ewkt = "POLYGON (("; points = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Point> >(extent); foreach (var point in points) { ewkt += point.lng + " " + point.lat + ","; } ewkt = ewkt.Substring(0, ewkt.Length - 2) + "," + points[0].lng + " " + points[0].lat + "))"; property.Extent = DbGeography.FromText(ewkt); } catch { throw new Exception("空间位置获取失败"); } } #endregion #region 添加Logo、图片附件、其他附件 var logoName = ""; if (worksheet.Cells[row, GetColumnIndex(excelProperty, "资产封面")].Value != null) { logoName = worksheet.Cells[row, GetColumnIndex(excelProperty, "资产封面")].Value.ToString(); } else { throw new Exception("资产封面不能为空"); } var imgArr = new string[] { }; if (worksheet.Cells[row, GetColumnIndex(excelProperty, "图片附件")].Value != null) { imgArr = worksheet.Cells[row, GetColumnIndex(excelProperty, "图片附件")].Value.ToString().Split(';'); } var otherFileArr = new string[] { }; if (worksheet.Cells[row, GetColumnIndex(excelProperty, "其他附件")].Value != null) { otherFileArr = worksheet.Cells[row, GetColumnIndex(excelProperty, "其他附件")].Value.ToString().Split(';'); } var files = System.IO.Directory.GetFiles(path); var pictures = new List <Picture>(); var otherFiles = new List <Core.Domain.Media.File>(); foreach (var file in files) { if (file.Split('\\')[file.Split('\\').Length - 1] == logoName) { #region 资产封面导入 var fileName = System.IO.Path.GetFileName(file); var fileStream = new FileStream(file, FileMode.Open); var fileBinary = new byte[fileStream.Length]; fileStream.Read(fileBinary, 0, fileBinary.Length); var picture = _pictureService.InsertPicture(fileBinary, "image/jpeg", "", "", fileName); var url = _pictureService.GetPictureUrl(picture); var propertyPicture = new PropertyPicture { Picture = picture, Property = property, IsLogo = true }; property.Pictures.Add(propertyPicture); _propertyService.UpdateProperty(property); fileStream.Flush(); fileStream.Close(); #endregion } else if (imgArr.Contains(file.Split('\\')[file.Split('\\').Length - 1])) { #region 图片附件 var fileName = System.IO.Path.GetFileName(file); var fileStream = new FileStream(file, FileMode.Open); var fileBinary = new byte[fileStream.Length]; fileStream.Read(fileBinary, 0, fileBinary.Length); var picture = _pictureService.InsertPicture(fileBinary, "image/jpeg", "", "", fileName); var url = _pictureService.GetPictureUrl(picture); pictures.Add(picture); fileStream.Flush(); fileStream.Close(); #endregion } else if (otherFileArr.Contains(file.Split('\\')[file.Split('\\').Length - 1])) { #region 其他附件 var fileName = System.IO.Path.GetFileName(file); var ext = System.IO.Path.GetExtension(file); var fileStream = new FileStream(file, FileMode.Open); var fileBinary = new byte[fileStream.Length]; fileStream.Read(fileBinary, 0, fileBinary.Length); var otherFile = _fileService.InsertFile(fileBinary, fileName, ext, ""); var url = _fileService.GetFileUrl(otherFile); otherFiles.Add(otherFile); fileStream.Flush(); fileStream.Close(); #endregion } } foreach (var p in pictures) { var propertyPicture = new PropertyPicture { Picture = p, Property = property, IsLogo = false }; property.Pictures.Add(propertyPicture); _propertyService.UpdateProperty(property); } foreach (var f in otherFiles) { var propertyFile = new PropertyFile { File = f, Property = property }; property.Files.Add(propertyFile); _propertyService.UpdateProperty(property); } #endregion property.Region = _propertyService.GetPropertyRegion(property.Location); #region 资产逻辑验证 var sum = 0; if (property.PropertyType == PropertyType.House) { if (property.ConstructArea < sum) { throw new Exception("建筑面积应大于自用、出租、出借、闲置面积之和"); } } if (property.PropertyType == PropertyType.Land) { if (property.LandArea < sum) { throw new Exception("土地面积应大于自用、出租、出借、闲置面积之和"); } } if (!string.IsNullOrEmpty(property.EstateId) && (!string.IsNullOrEmpty(property.ConstructId) || !string.IsNullOrEmpty(property.LandId))) { throw new Exception("不动产证和房产土地证不应同时填写"); } // property.HasConstructID = !string.IsNullOrEmpty(property.EstateId) || !string.IsNullOrEmpty(property.ConstructId); //是否拥有房产证 // property.HasLandID = !string.IsNullOrEmpty(property.EstateId) || !string.IsNullOrEmpty(property.LandId); //是否土地证 #endregion properties.Add(property); _propertyService.InsertProperty(property); } catch (Exception e) { sb.AppendLine(string.Format("第{0}行数据导入失败,错误原因为:{1}。", row, e.Message)); } finally { row++; } #endregion } foreach (var property in properties) { try { //添加一个资产插入申请 var propertyNewRecord = new PropertyNewCreate() { Property = property, Title = property.Name, State = PropertyApproveState.Start, ProcessDate = DateTime.Now, SuggestGovernmentId = currentUser.Government.Id }; _propertyNewCreateService.InsertPropertyNewCreate(propertyNewRecord); } catch (Exception e) { sb.AppendLine(string.Format("名称为 {0} 的导入失败,错误原因为:{1}。", property.Name, e.Message)); } finally { sb.AppendLine("成功导入资产" + properties.Count() + "条。"); } } IR.AppendLine = sb.ToString(); IR.Count = properties.Count(); return(IR); } }
public Dictionary <uint, Property> GetParentProperties(Dictionary <uint, Property> returnProperties, Dictionary <uint, Property> parentProperties) { if (returnProperties == null) { returnProperties = new Dictionary <uint, Property>(); } //add keys that didn't exist yet foreach (uint index in parentProperties.Keys) { if (!returnProperties.ContainsKey(index) && index != 0x00B2CCCB) { //This property specifies behavior bundles to exclude - instead of adding this property, remove all the bundles from the appropriate arrays returnProperties.Add(index, parentProperties[index]); } } if (parentProperties.ContainsKey(0x00B2CCCB)) { Property parentProperty = parentProperties[0x00B2CCCB]; KeyProperty parentPropertyValue = parentProperty as KeyProperty; //search the currently opened package for this type/instance group id. if it doesn't exist, find it in the default simcity packages DatabaseIndex parentIndex = null; if (DatabaseManager.Instance.Indices.Exists(i => i.InstanceId == parentPropertyValue.InstanceId && i.TypeId == parentPropertyValue.TypeId && i.GroupContainer == parentPropertyValue.GroupContainer)) { parentIndex = DatabaseManager.Instance.Indices.First(i => i.InstanceId == parentPropertyValue.InstanceId && i.TypeId == parentPropertyValue.TypeId && i.GroupContainer == parentPropertyValue.GroupContainer); } else { string folderEcoGamePath = Properties.Settings.Default.SimCityFolder + @"\SimCityUserData\EcoGame\"; DirectoryInfo folderEcoGame = new DirectoryInfo(folderEcoGamePath); //search the simcity data packages for this type/instance group id. if it doesn't exist, find it in the default simcity packages FileInfo[] scriptsFiles = folderEcoGame.GetFiles("SimCity-Scripts_*.package", SearchOption.TopDirectoryOnly); FileInfo scriptsFile = scriptsFiles.First(sf => sf.LastWriteTime == scriptsFiles.Max(sf2 => sf2.LastWriteTime)); DatabasePackedFile ScriptsPackage = DatabasePackedFile.LoadFromFile(scriptsFile.FullName); parentIndex = ScriptsPackage.Indices.FirstOrDefault(i => i.InstanceId == parentPropertyValue.InstanceId && i.TypeId == parentPropertyValue.TypeId && i.GroupContainer == parentPropertyValue.GroupContainer); } // if(parentIndex != null) // { byte[] data = parentIndex.GetIndexData(true); using (Stream s = new MemoryStream(data, 0, data.Length)) { PropertyFile propertyFile = new PropertyFile(); propertyFile.Read(s); return(GetParentProperties(returnProperties, propertyFile.Values)); } throw new Exception("Inheritance not found!"); return(returnProperties); } else { return(returnProperties); } }
/// <summary> /// Set an object property value from the state of the given control. /// /// Extend this function to support reading new types of properties. /// </summary> /// <param name="aObject"></param> private static void SetObjectPropertyValueFromControl(T aObject, PropertyInfo aInfo, Control aControl) { if (aInfo.PropertyType == typeof(int)) { NumericUpDown ctrl = (NumericUpDown)aControl; aInfo.SetValue(aObject, (int)ctrl.Value); } else if (aInfo.PropertyType == typeof(float)) { NumericUpDown ctrl = (NumericUpDown)aControl; aInfo.SetValue(aObject, (float)ctrl.Value); } else if (aInfo.PropertyType.IsEnum) { // Instantiate our enum object enumValue = Activator.CreateInstance(aInfo.PropertyType); // Parse our enum from combo box enumValue = Enum.Parse(aInfo.PropertyType, ((ComboBox)aControl).SelectedItem.ToString()); //enumValue = ((ComboBox)aControl).SelectedValue; // Set enum value aInfo.SetValue(aObject, enumValue); } else if (aInfo.PropertyType == typeof(bool)) { CheckBox ctrl = (CheckBox)aControl; aInfo.SetValue(aObject, ctrl.Checked); } else if (aInfo.PropertyType == typeof(string)) { TextBox ctrl = (TextBox)aControl; aInfo.SetValue(aObject, ctrl.Text); } else if (aInfo.PropertyType == typeof(PropertyFile)) { Button ctrl = (Button)aControl; PropertyFile value = new PropertyFile { FullPath = ctrl.Text }; aInfo.SetValue(aObject, value); } else if (aInfo.PropertyType == typeof(PropertyComboBox)) { ComboBox ctrl = (ComboBox)aControl; if (ctrl.SelectedItem != null) { // Apparently you can still get the SelectedValue even when no ValueMember was set string currentItem = ctrl.SelectedValue.ToString(); PropertyComboBox value = (PropertyComboBox)aInfo.GetValue(aObject); // Make sure the value actually changed before doing anything // Shall we do that for every control? if (value.CurrentItem != currentItem) { value.CurrentItem = currentItem; //Not strictly needed but makes sure the set method is called aInfo.SetValue(aObject, value); // aObject.OnPropertyChanged(aInfo.Name); } } } else if (aInfo.PropertyType == typeof(PropertyButton)) { Button ctrl = (Button)aControl; PropertyButton value = new PropertyButton { Text = ctrl.Text }; aInfo.SetValue(aObject, value); } else if (aInfo.PropertyType == typeof(PropertyCheckedListBox)) { CheckedListBox ctrl = (CheckedListBox)aControl; PropertyCheckedListBox value = (PropertyCheckedListBox)aInfo.GetValue(aObject); List <string> checkedItems = new List <string>(); foreach (string item in ctrl.CheckedItems) { checkedItems.Add(item); } value.CheckedItems = checkedItems; //value.CurrentItem = currentItem; //Not strictly needed but makes sure the set method is called aInfo.SetValue(aObject, value); // //aObject.OnPropertyChanged(aInfo.Name); } //TODO: add support for other types here }
public TileSession(string path) { file = new PropertyFile(path); file.Load(); }
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; System.Collections.Concurrent.ConcurrentBag <DatabaseIndex> foundItems = new System.Collections.Concurrent.ConcurrentBag <DatabaseIndex>(); //List<DatabaseIndex> foundItems = new List<DatabaseIndex>(); int completed = 0; IEnumerable <DatabaseIndex> propitems = DatabaseManager.Instance.Where(item => item.TypeId == 11645188); int count = propitems.Count(); Object[] args = e.Argument as Object[]; String searchText = args[0] as String; String propertyIDText = args[1] as String; uint propertyID = 0; if (!String.IsNullOrEmpty(propertyIDText)) { if (propertyIDText.StartsWith("0x")) { propertyIDText = propertyIDText.Remove(0, 2); } propertyID = UInt32.Parse(propertyIDText, System.Globalization.NumberStyles.AllowHexSpecifier); } if (searchText == null) { searchText = ""; } int propType = (int)args[2]; //foreach (DatabaseIndex item in propitems) Func <KeyValuePair <uint, Property>, bool> searchExpression = null; if (searchText == "") { searchExpression = pair => pair.Key == propertyID; } else { switch (propType) { case 0: //key searchExpression = pair => (propertyID == 0 || pair.Key == propertyID) && ((pair.Value is KeyProperty && ((KeyProperty)pair.Value).InstanceId.ToHex().Contains(searchText)) || (pair.Value is ArrayProperty && ((ArrayProperty)pair.Value).Values.Count(val => val is KeyProperty && ((KeyProperty)val).InstanceId.ToHex().Contains(searchText)) != 0)); break; case 1: //number searchExpression = pair => (propertyID == 0 || pair.Key == propertyID) && ((pair.Value is Int32Property && ((Int32Property)pair.Value).Value.ToString() == searchText) || (pair.Value is UInt32Property && ((UInt32Property)pair.Value).Value.ToString() == searchText) || (pair.Value is FloatProperty && ((FloatProperty)pair.Value).Value.ToString() == searchText) || (pair.Value is ArrayProperty && ((ArrayProperty)pair.Value).Values.Count(val => (val is Int32Property && ((Int32Property)val).Value.ToString() == searchText) || (val is UInt32Property && ((UInt32Property)val).Value.ToString() == searchText) || (val is FloatProperty && ((FloatProperty)val).Value.ToString() == searchText)) != 0)); break; case 2: //bool searchExpression = pair => (propertyID == 0 || pair.Key == propertyID) && (pair.Value is BoolProperty && ((BoolProperty)pair.Value).Value.ToString().Equals(searchText, StringComparison.CurrentCultureIgnoreCase)); break; } } Parallel.ForEach(propitems, (item, loopstate) => { if (worker.CancellationPending) { e.Cancel = true; loopstate.Stop(); //return; } byte[] data = item.GetIndexData(true); using (MemoryStream byteStream = new MemoryStream(data)) { PropertyFile file = new PropertyFile(); file.Read(byteStream); int pcount = 0; pcount = file.Values.Count(searchExpression);; if (pcount > 0) { foundItems.Add(item); } } worker.ReportProgress((int)(((float)completed++ / (float)count) * 100)); }); e.Result = foundItems; }
private void mnuInstanceIds_Click(object sender, RoutedEventArgs e) { if (Properties.Settings.Default.LocaleFile != string.Empty) { try { Dictionary <uint, string> itemNames = new Dictionary <uint, string>(); foreach (DatabaseIndex index in view) { //for all property files, see if the name property exists if (index.TypeId == 0x00b1b104) { using (MemoryStream byteStream = new MemoryStream(index.GetIndexData(true))) { PropertyFile propertyFile = new PropertyFile(); propertyFile.Read(byteStream); if (!itemNames.ContainsKey(index.InstanceId)) { if (propertyFile.Values.ContainsKey(0x09FB78CB)) { ArrayProperty arrprop = propertyFile.Values[0x09FB78CB] as ArrayProperty; TextProperty prop = arrprop.Values[0] as TextProperty; string name = LocaleRegistry.Instance.GetLocalizedString(prop.TableId, prop.InstanceId); itemNames.Add(index.InstanceId, name.Replace("'", "''")); } else if (propertyFile.Values.ContainsKey(0x0A09F5FA)) { ArrayProperty arrprop = propertyFile.Values[0x0A09F5FA] as ArrayProperty; TextProperty prop = arrprop.Values[0] as TextProperty; string name = LocaleRegistry.Instance.GetLocalizedString(prop.TableId, prop.InstanceId); itemNames.Add(index.InstanceId, name.Replace("'", "''")); } else if (propertyFile.Values.ContainsKey(0x09B711C3)) { ArrayProperty arrprop = propertyFile.Values[0x09B711C3] as ArrayProperty; TextProperty prop = arrprop.Values[0] as TextProperty; string name = LocaleRegistry.Instance.GetLocalizedString(prop.TableId, prop.InstanceId); itemNames.Add(index.InstanceId, name.Replace("'", "''")); } else if (propertyFile.Values.ContainsKey(0x0E28B5BC)) { ArrayProperty arrprop = propertyFile.Values[0x0E28B5BC] as ArrayProperty; TextProperty prop = arrprop.Values[0] as TextProperty; string name = LocaleRegistry.Instance.GetLocalizedString(prop.TableId, prop.InstanceId); itemNames.Add(index.InstanceId, name.Replace("'", "''")); } else if (propertyFile.Values.ContainsKey(0x0E28B5D5)) { ArrayProperty arrprop = propertyFile.Values[0x0E28B5D5] as ArrayProperty; TextProperty prop = arrprop.Values[0] as TextProperty; string name = LocaleRegistry.Instance.GetLocalizedString(prop.TableId, prop.InstanceId); itemNames.Add(index.InstanceId, name.Replace("'", "''")); } } } } } foreach (KeyValuePair <uint, string> name in itemNames) { TGIRegistry.Instance.Instances.InsertRecord(new TGIRecord() { Id = name.Key, Name = name.Value, Comments = name.Value }); } ReloadPackages(); } catch (Exception ex) { System.Windows.MessageBox.Show(string.Format("An error occurred while attempting to load instance names from your locale file: {0}", ex.Message), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { System.Windows.MessageBox.Show("The Locale File is not specified in the application settings!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { if (this.DataContext != null && this.DataContext.GetType() == typeof(DatabaseIndexData)) { Decals.Clear(); index = (DatabaseIndexData)this.DataContext; Dictionary <uint, Property> propertyContainer; try { MemoryStream byteStream = new MemoryStream(index.Data); propertyFile = new PropertyFile(); propertyFile.Read(byteStream); propertyContainer = propertyFile.Values; DecalDictionaryEntry = new DecalImageDictionary(); DecalDictionaryEntry.Load(propertyContainer); gridDetails.DataContext = DecalDictionaryEntry; DecalDictionaryEntry.DecalImages.ForEach(d => d.RefreshPreview()); Decals.AddRange(DecalDictionaryEntry.DecalImages); var expression = txtMaterialId.GetBindingExpression(TextBox.TextProperty); if (expression != null) { expression.UpdateTarget(); } expression = txtTextureSizeX.GetBindingExpression(TextBox.TextProperty); if (expression != null) { expression.UpdateTarget(); } expression = txtTextureSizeY.GetBindingExpression(TextBox.TextProperty); if (expression != null) { expression.UpdateTarget(); } expression = txtAtlasSizeX.GetBindingExpression(TextBox.TextProperty); if (expression != null) { expression.UpdateTarget(); } expression = txtAtlasSizeY.GetBindingExpression(TextBox.TextProperty); if (expression != null) { expression.UpdateTarget(); } } catch (Exception ex) { Exception subEx = ex.InnerException; while (subEx != null) { // exceptionMessage += subEx.Message + Environment.NewLine; subEx = ex.InnerException; } } } }
public static PropertyFile ToEntity(this PropertyFileModel model, PropertyFile destination) { return(model.MapTo(destination)); }
private void mnuCopy_Click(object sender, RoutedEventArgs e) { //check if current index is a valid menu item if (this.DataContext.GetType() == typeof(DatabaseIndexData)) { DatabaseIndexData menuItemIndex = (DatabaseIndexData)this.DataContext; menuItemIndex.Index.IsModified = true; if (menuItemIndex.Index.InstanceType == (uint)PropertyFileTypeIds.Menu2) { SaveFileDialog dialog = new SaveFileDialog(); if (dialog.ShowDialog().GetValueOrDefault(false)) { List <DatabaseIndex> indices = new List <DatabaseIndex>(); menuItemIndex.Index.ModifiedInstanceId = TGIRandomGenerator.GetNext(); indices.Add(menuItemIndex.Index); PropertyFile menuFile = new PropertyFile(menuItemIndex.Index); #region Extract Icon if (menuFile.Values.ContainsKey(PropertyConstants.menuIcon)) { KeyProperty iconProperty = (KeyProperty)menuFile.Values[PropertyConstants.menuIcon]; DatabaseIndex iconIndex = DatabaseIndex.FindIndex(iconProperty.TypeId, null, null, iconProperty.InstanceId, true, false); iconIndex.ModifiedInstanceId = TGIRandomGenerator.GetNext(); indices.Add(iconIndex); iconProperty.InstanceId = iconIndex.ModifiedInstanceId.Value; menuItemIndex.Index.ModifiedData = new ModifiedPropertyFile() { PropertyFile = menuFile }; menuFile.Values[PropertyConstants.menuIcon] = iconProperty; } #endregion #region Extract Marquee Image if (menuFile.Values.ContainsKey(PropertyConstants.menuMarqueeImage)) { KeyProperty marqueeProperty = (KeyProperty)menuFile.Values[PropertyConstants.menuMarqueeImage]; DatabaseIndex marqueeIndex = DatabaseIndex.FindIndex(marqueeProperty.TypeId, null, null, marqueeProperty.InstanceId, true, false); marqueeIndex.ModifiedInstanceId = TGIRandomGenerator.GetNext(); indices.Add(marqueeIndex); marqueeProperty.InstanceId = marqueeIndex.ModifiedInstanceId.Value; menuItemIndex.Index.ModifiedData = new ModifiedPropertyFile() { PropertyFile = menuFile }; menuFile.Values[PropertyConstants.menuMarqueeImage] = marqueeProperty; } #endregion #region Extract Ecogame Unit if (menuFile.Values.ContainsKey(PropertyConstants.menuUnit)) { KeyProperty unitProperty = (KeyProperty)menuFile.Values[PropertyConstants.menuUnit]; DatabaseIndex unitIndex = DatabaseIndex.FindIndex((uint)TypeIds.PropertyFile, null, 0xe0, unitProperty.InstanceId, false, true); PropertyFile unitFile = new PropertyFile(unitIndex); unitFile.FlattenParentInheritance(); #region Extract Unit Display if (unitFile.Values.ContainsKey(PropertyConstants.ecoGameUnitDisplayModel)) { KeyProperty unitDisplayProperty = (KeyProperty)unitFile.Values[PropertyConstants.ecoGameUnitDisplayModel]; DatabaseIndex unitDisplayIndex = DatabaseIndex.FindIndex((uint)TypeIds.PropertyFile, null, 0xe1, unitDisplayProperty.InstanceId, false, true); unitDisplayIndex.ModifiedInstanceId = TGIRandomGenerator.GetNext(); unitDisplayProperty.InstanceId = unitDisplayIndex.ModifiedInstanceId.Value; unitFile.Values[PropertyConstants.ecoGameUnitDisplayModel] = unitDisplayProperty; PropertyFile unitDisplayFile = new PropertyFile(unitDisplayIndex); #region Extract LODs if (unitDisplayFile.Values.ContainsKey(PropertyConstants.UnitLOD1)) { KeyProperty LOD1Property = (KeyProperty)unitDisplayFile.Values[PropertyConstants.UnitLOD1]; DatabaseIndex LOD1Index = DatabaseIndex.FindIndex(LOD1Property.TypeId, null, null, LOD1Property.InstanceId, true, false); LOD1Index.ModifiedInstanceId = TGIRandomGenerator.GetNext(); indices.Add(LOD1Index); LOD1Property.InstanceId = LOD1Index.ModifiedInstanceId.Value; unitDisplayFile.Values[PropertyConstants.UnitLOD1] = LOD1Property; } if (unitDisplayFile.Values.ContainsKey(PropertyConstants.UnitLOD2)) { KeyProperty LOD2Property = (KeyProperty)unitDisplayFile.Values[PropertyConstants.UnitLOD2]; DatabaseIndex LOD2Index = DatabaseIndex.FindIndex(LOD2Property.TypeId, null, null, LOD2Property.InstanceId, true, false); LOD2Index.ModifiedInstanceId = TGIRandomGenerator.GetNext(); indices.Add(LOD2Index); LOD2Property.InstanceId = LOD2Index.ModifiedInstanceId.Value; unitDisplayFile.Values[PropertyConstants.UnitLOD2] = LOD2Property; } if (unitDisplayFile.Values.ContainsKey(PropertyConstants.UnitLOD3)) { KeyProperty LOD3Property = (KeyProperty)unitDisplayFile.Values[PropertyConstants.UnitLOD3]; DatabaseIndex LOD3Index = DatabaseIndex.FindIndex(LOD3Property.TypeId, null, null, LOD3Property.InstanceId, true, false); LOD3Index.ModifiedInstanceId = TGIRandomGenerator.GetNext(); indices.Add(LOD3Index); LOD3Property.InstanceId = LOD3Index.ModifiedInstanceId.Value; unitDisplayFile.Values[PropertyConstants.UnitLOD3] = LOD3Property; } if (unitDisplayFile.Values.ContainsKey(PropertyConstants.UnitLOD4)) { KeyProperty LOD4Property = (KeyProperty)unitDisplayFile.Values[PropertyConstants.UnitLOD4]; DatabaseIndex LOD4Index = DatabaseIndex.FindIndex(LOD4Property.TypeId, null, null, LOD4Property.InstanceId, true, false); LOD4Index.ModifiedInstanceId = TGIRandomGenerator.GetNext(); indices.Add(LOD4Index); LOD4Property.InstanceId = LOD4Index.ModifiedInstanceId.Value; unitDisplayFile.Values[PropertyConstants.UnitLOD4] = LOD4Property; } #endregion unitDisplayIndex.ModifiedData = new ModifiedPropertyFile() { PropertyFile = unitDisplayFile }; unitDisplayIndex.IsModified = true; indices.Add(unitDisplayIndex); } #endregion unitIndex.ModifiedInstanceId = TGIRandomGenerator.GetNext(); unitIndex.ModifiedData = new ModifiedPropertyFile() { PropertyFile = unitFile }; unitIndex.IsModified = true; indices.Add(unitIndex); unitProperty.InstanceId = unitIndex.ModifiedInstanceId.Value; menuItemIndex.Index.ModifiedData = new ModifiedPropertyFile() { PropertyFile = menuFile }; menuFile.Values[PropertyConstants.menuUnit] = unitProperty; } #endregion DatabasePackedFile.SaveAs(dialog.FileName, indices); } } else { MessageBox.Show("This only works for menu items..."); } } }