public string Compare(IPrimaryKeys pk) { var dt1 = new TableReader(schema1.TableName).Table; var dt2 = new TableReader(schema2.TableName).Table; return Compare(pk, dt1, dt2); }
private static void testCsvReader() { var reader = new CsvSourceReader(@"D:\myCsv.csv", "|"); var columns = new TableColumn[] { new TableColumn() { IndexInSource = 0 }, new TableColumn() { IndexInSource = 1 }, new TableColumn() { IndexInSource = 2 }, new TableColumn() { IndexInSource = 3 }, }; var table = new TableReader(reader, columns); table.StartRow = 2; //пустые строки перед началом нашей таблицы в файле table.IsFirstRowHeaders = true; //таблица имеет строку заголовков string headers = string.Join(";\t", table.SourceHeaders); var row = table.ToArray()[2]; string rowInfo = $"column 1 value:{row.GetCellValue<int>(0)}, type:{row.GetCellValue<int>(0).GetType()}" + Environment.NewLine + $"column 2 value:{row.GetCellValue<string>(1)}, type:{row.GetCellValue<string>(1).GetType()}" + Environment.NewLine + $"column 3 value:{row.GetCellValue<DateTime>(2)}, type:{row.GetCellValue<DateTime>(2).GetType()}" + Environment.NewLine + $"column 4 value:{row.GetCellValue<TimeSpan>(3)}, type:{row.GetCellValue<TimeSpan>(3).GetType()}" + Environment.NewLine; Console.WriteLine(headers); Console.WriteLine(rowInfo); Console.ReadLine(); }
public DataTable CreateImportDataTable(string tableName) { if (String.IsNullOrEmpty(tableName)) { throw new ArgumentNullException(nameof(tableName)); } DataTable dataTable = new DataTable(); TableReader tableReader = new TableReader(); // Get schema of passed table DataTable tableSchema = tableReader.ReadSchema(tableName); // Add columns for each field in returned schema foreach (DataRow row in tableSchema.Rows) { dataTable.Columns.Add((string)row["Field"], Type.GetType((string)row["Type"])); } return(dataTable); }
public static TableReader <TModel> CreateXlsxReader <TModel>(this TableFactory factory, IXLWorksheet worksheet, int startRowNumber, int startColumnNumber, int columnSize, bool hasHeader = false, ITypeConverterResolver typeConverterResolver = null, IPropertyMapper propertyMapper = null, IModelValidator modelValidator = null) where TModel : new() { var rowReader = new XlsxRowReader(worksheet, startRowNumber, startColumnNumber, columnSize); typeConverterResolver = typeConverterResolver ?? new DefaultTypeConverterResolver <TModel>(); propertyMapper = propertyMapper ?? new AutoIndexPropertyMapper(); modelValidator = modelValidator ?? new NullModelValidator(); var reader = new TableReader <TModel>(rowReader, typeConverterResolver, propertyMapper, modelValidator); reader.HasHeader = hasHeader; reader.ColumnSize = columnSize; return(reader); }
private static string GenerateRows(ITableSchema schema, TableReader reader) { var table = reader.Table; TableDataClause script = new TableDataClause(schema); StringBuilder builder = new StringBuilder(); foreach (DataRow row in table.Rows) { var pair = new ColumnPairCollection(row); builder.Append(script.INSERT(pair)).AppendLine(); } if (table.Rows.Count > 0) { builder.AppendLine(SqlScript.GO); } return(builder.ToString()); }
public void Generate() { foreach (var kvp in xlsxManager.tables) { TableReader table = kvp.Value; if (!table.hasLangField) { continue; } string langPath = Setting.Options.langDir + "/editor/" + table.tableName + ".xlsx"; LangTableData langTableData = new LangTableData(); langTableData.langPath = langPath; langTableData.ReaderLangTable(); langTableData.SetFields(table.dataStruct.fields); langTableData.SetDataList(table.dataList); langTableData.Sort("id"); langTableData.Save(); } }
public void Generate() { List <object[]> lines = new List <object[]>(); foreach (var kvp in xlsxManager.tables) { TableReader table = kvp.Value; lines.Add(new object[] { table.tableName.FirstLower(), table.tableName }); } TemplateSystem template = new TemplateSystem(File.ReadAllText(TemplatingFiles.Client.LangConfigLoaderList)); template.AddVariable("tables", lines.ToArray()); string content = template.Parse(); string path = OutPaths.Client.LangConfigLoaderList; PathHelper.CheckPath(path); File.WriteAllText(path, content); }
public bool Pack() { pack.Statement.AppendFormat("var dpo = new {0}()", dpoType.Name); PersistentObject dpo = (PersistentObject)Activator.CreateInstance(this.dpoType); DataTable dt = new TableReader(dpo.TableName).Table; if (dt.Rows.Count == 0) { return(false); } this.count = dt.Rows.Count; //Property property = new Property(typeof(string), "TableName"); //this.clss.AddProperty(property); //property.AddGet("return \"{0}\"", this.instance.TableName.Name); //property = new Property(typeof(Level), "Level"); //this.clss.AddProperty(property); //property.AddGet("return Level.{0}", this.instance.Level); int i = 0; foreach (DataRow dataRow in dt.Rows) { PackRecord(dataRow); if (i < dt.Rows.Count - 1) { pack.Statement.AppendFormat("dpo = new {0}()", dpoType.Name); } i++; } return(true); }
protected IColumnReader ExecuteTableReader(SqlCommand cmd) { IColumnReader reader; try { cmd.Connection.Open(); reader = TableReader.Load(cmd); } catch (Exception ex) { LogException(ex, cmd); throw; } finally { cmd.Connection.Close(); } LogVerbose(cmd); return(reader); }
private string ReadFieldsInterior(TableReader reader, List <PackageField> fields, int level) { List <string> ret = ReadFields(reader, fields, level); StringBuilder builder = new StringBuilder(); if (level <= 0) { builder.Append("["); } for (int i = 0; i < ret.Count; ++i) { if (i != 0) { builder.Append(","); } builder.Append(ret[i]); } if (level <= 0) { builder.Append("]"); } return(builder.ToString()); }
public override void InitUIData() { base.InitUIData(); m_ParentList = new List <Transform>(); m_ParentList.Add(selfTransform.FindChild("LayoutPoint")); m_SelfRectTrans = GetComponent <RectTransform>();//selfTransform.FindChild("LayoutPoint"); m_OriginalStarItem = selfTransform.FindChild("OriginalPanel/OriginalStarItem").gameObject; m_OriginalCaptionText = selfTransform.FindChild("OriginalPanel/OriginalCaptionText").gameObject; m_OriginalClickableText = selfTransform.FindChild("OriginalPanel/OriginalClickableText").gameObject; m_Background = selfTransform.FindChild("LayoutPoint/Background").GetComponent <RectTransform>(); m_TittleImage = selfTransform.FindChild("LayoutPoint/Background/TittleImage").GetComponent <RectTransform>(); m_TittleMask = selfTransform.FindChild("LayoutPoint/Background/TittleMask").GetComponent <RectTransform>(); m_LeftPoint = selfTransform.FindChild("LayoutPoint/Background/TittleMask/LeftPoint").GetComponent <RectTransform>(); m_RightPoint = selfTransform.FindChild("LayoutPoint/Background/TittleMask/RightPoint").GetComponent <RectTransform>(); m_TittleText = selfTransform.FindChild("LayoutPoint/Background/TittleImage/TittleText").GetComponent <Text>(); m_TittleText.text = GameUtils.getString("System_setting_content37"); m_Caption = selfTransform.FindChild("LayoutPoint/Background/TittleMask/Caption").GetComponent <RectTransform>(); m_CaptionPanel = m_Caption.FindChild("CaptionPanel"); m_ClickPanel = m_Caption.FindChild("ClickPanel"); m_TextPool = new ChainItemPool(4, m_OriginalStarItem, m_OriginalCaptionText, m_OriginalClickableText, m_RightPoint); m_CaptionTable = DataTemplate.GetInstance().m_CaptionTable; m_PlayerName = ObjectSelf.GetInstance().Name; m_Background.gameObject.SetActive(false); GameEventDispatcher.Inst.addEventListener(GameEventID.UI_InterfaceChange, OnInterfaceChange); GameEventDispatcher.Inst.addEventListener(GameEventID.UI_ReceiveCaptionMessage, LoadServerData); Inst = this; }
void SaveItems(string itemFile) { tItemDict = SortItemDict(tItemDict); if (itemFile != null && itemFile != "") { using (StreamWriter sw = new StreamWriter(itemFile)) { // save const TableReader.ItemConst_Save(sw.WriteLine, tableConst); // save item TableReader.DictItem_Save(sw.WriteLine, tItemDict); } using (SaveEncode encode = new SaveEncode(itemFile)) { // save const TableReader.ItemConst_Save(encode.WriteLine, tableConst); // save item TableReader.DictItem_Save(encode.WriteLine, tItemDict); } } AssetDatabase.Refresh(); int k = itemFile.IndexOf("Assets/"); if (k > 0) { itemFile = itemFile.Substring(k, itemFile.Length - k); } itemAsset = (TextAsset)AssetDatabase.LoadAssetAtPath(itemFile, typeof(TextAsset)); }
public override void InitUIData() { base.InitUIData(); LoadNumSprite(); m_TopDescriptionTextTempString = GameUtils.getString("shop_content16"); objectSelf = ObjectSelf.GetInstance(); m_VipReader = DataTemplate.GetInstance().m_VipTable; m_ExpSlider = selfTransform.FindChild("LeftPanel/VipExpProgressBar").gameObject.GetComponent <Slider>(); m_ScrollRect = selfTransform.FindChild("RightPanel").gameObject.GetComponent <ScrollRect>(); m_OriginalUnitImage = selfTransform.FindChild("OriginalTipsPanel/OriginalUnitImage").gameObject; m_OriginalTipsObject = selfTransform.FindChild("OriginalTipsPanel/OriginalTipsText").gameObject; m_VipLvPanel = selfTransform.FindChild("LeftPanel/VipLvPanel"); m_CenterPoint = selfTransform.FindChild("RightPanel/SubPanel/CenterPoint"); m_PrevPoint = selfTransform.FindChild("RightPanel/SubPanel/PrevPoint"); m_NextPoint = selfTransform.FindChild("RightPanel/SubPanel/NextPoint"); GameEventDispatcher.Inst.addEventListener(GameEventID.G_VipLevel_Update, RefreshPanel); }
// 读取语言表 public void ReaderLangTable() { if (File.Exists(langPath)) { state = LangStateType.None; TableReader tableReader = new TableReader(); tableReader.path = langPath; tableReader.Load(null, null, true); langTable = tableReader; fields = tableReader.dataStruct.fields; sheetName = tableReader.sheetName; for (int i = 0; i < tableReader.dataList.Count; i++) { Dictionary <string, string> data = tableReader.dataList[i]; Dictionary <string, string> common = tableReader.commentList[i]; LangRowData langRowData = new LangRowData(); langRowData.langTableData = this; langRowData.id = data[idKey]; foreach (DataField field in fields) { LangCellData langCellData = new LangCellData(); langCellData.field = field.field; langCellData.value = data[field.field]; langCellData.beforeComment = common[langCellData.field]; langRowData.AddCell(langCellData); } rowDatasById.Add(langRowData.id, langRowData); } } else { state = LangStateType.Add; } }
public static void ConvertSpriteAnimTable(Stream inStream, Stream outStream) { TableReader.ConvertTable( inStream, outStream, ReadSpriteAnim, WriteSpriteAnim, GetSpriteAnimSize); }
public void Init() { m_TableList.Clear(); m_TableTypeList.Clear(); m_HeroTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.hero_01", m_HeroTable); m_TableTypeList.Add("chuhan.gsp.client.hero_01", typeof(HeroTemplate)); m_HeroExpTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.heroexp_02", m_HeroExpTable); m_TableTypeList.Add("chuhan.gsp.client.heroexp_02", typeof(HeroexpTemplate)); m_PlayerExpTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.player_03", m_PlayerExpTable); m_TableTypeList.Add("chuhan.gsp.client.player_03", typeof(PlayerTemplate)); m_ChsTextTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.chstext_05", m_ChsTextTable); m_TableTypeList.Add("chuhan.gsp.client.chstext_05", typeof(ChsTextTemplate)); m_SkillTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.skill_06", m_SkillTable); m_TableTypeList.Add("chuhan.gsp.client.skill_06", typeof(SkillTemplate)); m_BufferTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.buff_07", m_BufferTable); m_TableTypeList.Add("chuhan.gsp.client.buff_07", typeof(BuffTemplate)); m_BuffGroupTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.buffgroup_08", m_BuffGroupTable); m_TableTypeList.Add("chuhan.gsp.client.buffgroup_08", typeof(BuffgroupTemplate)); m_StageTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.stage_11", m_StageTable); m_TableTypeList.Add("chuhan.gsp.client.stage_11", typeof(StageTemplate)); m_MonsterGroupTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.monstergroup_12", m_MonsterGroupTable); m_TableTypeList.Add("chuhan.gsp.client.monstergroup_12", typeof(MonstergroupTemplate)); m_MonsterTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.monster_13", m_MonsterTable); m_TableTypeList.Add("chuhan.gsp.client.monster_13", typeof(MonsterTemplate)); m_NormaldropTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.normaldrop_15", m_NormaldropTable); m_TableTypeList.Add("chuhan.gsp.client.normaldrop_15", typeof(NormaldropTemplate)); m_InnerdropTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.innerdrop_16", m_InnerdropTable); m_TableTypeList.Add("chuhan.gsp.client.innerdrop_16", typeof(InnerdropTemplate)); m_SkillupcostTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.skillupcost_17", m_SkillupcostTable); m_TableTypeList.Add("chuhan.gsp.client.skillupcost_17", typeof(SkillupcostTemplate)); m_SkillaiTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.skillai_18", m_SkillaiTable); m_TableTypeList.Add("chuhan.gsp.client.skillai_18", typeof(SkillaiTemplate)); m_HeroFuryTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.herofury_19", m_HeroFuryTable); m_TableTypeList.Add("chuhan.gsp.client.herofury_19", typeof(HerofuryTemplate)); m_InterfacemodelTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.interfacemodel_20", m_InterfacemodelTable); m_TableTypeList.Add("chuhan.gsp.client.interfacemodel_20", typeof(InterfacemodelTemplate)); m_LevelamendmentTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.levelamendment_21", m_LevelamendmentTable); m_TableTypeList.Add("chuhan.gsp.client.levelamendment_21", typeof(LevelamendmentTemplate)); m_ChapterTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.chapterinfo_23", m_ChapterTable); m_TableTypeList.Add("chuhan.gsp.client.chapterinfo_23", typeof(ChapterinfoTemplate)); m_BossboxTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.bossbox_25", m_BossboxTable); m_TableTypeList.Add("chuhan.gsp.client.bossbox_25", typeof(BossboxTemplate)); m_ItemTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.item_26", m_ItemTable); m_TableTypeList.Add("chuhan.gsp.client.item_26", typeof(ItemTemplate)); m_RunepassiveTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.runepassive_27", m_RunepassiveTable); m_TableTypeList.Add("chuhan.gsp.client.runepassive_27", typeof(RunepassiveTemplate)); m_BaseruneattributeTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.baseruneattribute_28", m_BaseruneattributeTable); m_TableTypeList.Add("chuhan.gsp.client.baseruneattribute_28", typeof(BaseruneattributeTemplate)); m_AddruneattributeTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.addruneattribute_29", m_AddruneattributeTable); m_TableTypeList.Add("chuhan.gsp.client.addruneattribute_29", typeof(AddruneattributeTemplate)); m_RunecostTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.runecost_30", m_RunecostTable); m_TableTypeList.Add("chuhan.gsp.client.runecost_30", typeof(RunecostTemplate)); m_ArtresourceTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.artresource_31", m_ArtresourceTable); m_TableTypeList.Add("chuhan.gsp.client.artresource_31", typeof(ArtresourceTemplate)); m_AttributetrainTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.attributetrain_32", m_AttributetrainTable); m_TableTypeList.Add("chuhan.gsp.client.attributetrain_32", typeof(AttributetrainTemplate)); m_ArtifactTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.artifact_33", m_ArtifactTable); m_TableTypeList.Add("chuhan.gsp.client.artifact_33", typeof(ArtifactTemplate)); m_ShopTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.shop_35", m_ShopTable); m_TableTypeList.Add("chuhan.gsp.client.shop_35", typeof(ShopTemplate)); m_VipTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.vip_39", m_VipTable); m_TableTypeList.Add("chuhan.gsp.client.vip_39", typeof(VipTemplate)); m_IllustratehandbookTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.illustratehandbook_40", m_IllustratehandbookTable); m_TableTypeList.Add("chuhan.gsp.client.illustratehandbook_40", typeof(IllustratehandbookTemplate)); m_MedalexchangeTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.medalexchange_41", m_MedalexchangeTable); m_TableTypeList.Add("chuhan.gsp.client.medalexchange_41", typeof(MedalexchangeTemplate)); m_LoginbonusTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.loginbonus_42", m_LoginbonusTable); m_TableTypeList.Add("chuhan.gsp.client.loginbonus_42", typeof(LoginbonusTemplate)); m_MysteriousshopTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.mysteriousshop_43", m_MysteriousshopTable); m_TableTypeList.Add("chuhan.gsp.client.mysteriousshop_43", typeof(MysteriousshopTemplate)); m_MonthcardTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.monthcard_45", m_MonthcardTable); m_TableTypeList.Add("chuhan.gsp.client.monthcard_45", typeof(MonthcardTemplate)); m_ExplorequestTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.explorequest_46", m_ExplorequestTable); m_TableTypeList.Add("chuhan.gsp.client.explorequest_46", typeof(ExplorequestTemplate)); m_HerocloneTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.heroclone_47", m_HerocloneTable); m_TableTypeList.Add("chuhan.gsp.client.heroclone_47", typeof(HerocloneTemplate)); m_AnimEventTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.animationevent_48", m_AnimEventTable); m_TableTypeList.Add("chuhan.gsp.client.animationevent_48", typeof(AnimEventTemplate)); m_UltimatetrialmonsterTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.ultimatetrialmonster_49", m_UltimatetrialmonsterTable); m_TableTypeList.Add("chuhan.gsp.client.ultimatetrialmonster_49", typeof(UltimatetrialmonsterTemplate)); m_UltimatetrialrewardTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.ultimatetrialreward_50", m_UltimatetrialrewardTable); m_TableTypeList.Add("chuhan.gsp.client.ultimatetrialreward_50", typeof(UltimatetrialrewardTemplate)); m_HeroRecruitTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.herorecruit_51", m_HeroRecruitTable); m_TableTypeList.Add("chuhan.gsp.client.herorecruit_51", typeof(HerorecruitTemplate)); m_RuintreasureTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.ruintreasure_52", m_RuintreasureTable); m_TableTypeList.Add("chuhan.gsp.client.ruintreasure_52", typeof(RuintreasureTemplate)); m_ResourceindexTemplate = new TableReader(); m_TableList.Add("chuhan.gsp.client.resourceindex_53", m_ResourceindexTemplate); m_TableTypeList.Add("chuhan.gsp.client.resourceindex_53", typeof(ResourceindexTemplate)); m_ActivitymissionTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.activitymission_55", m_ActivitymissionTable); m_TableTypeList.Add("chuhan.gsp.client.activitymission_55", typeof(ActivitymissionTemplate)); m_ExchangeTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.exchange_56", m_ExchangeTable); m_TableTypeList.Add("chuhan.gsp.client.exchange_56", typeof(ExchangeTemplate)); m_LegendexchargeTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.legendexcharge_57", m_LegendexchargeTable); m_TableTypeList.Add("chuhan.gsp.client.legendexcharge_57", typeof(LegendexchargeTemplate)); m_ShieldCharacterTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.shieldcharacter_58", m_ShieldCharacterTable); m_TableTypeList.Add("chuhan.gsp.client.shieldcharacter_58", typeof(ShieldcharacterTemplate)); m_RandnameTemplate = new TableReader(); m_TableList.Add("chuhan.gsp.client.randname_59", m_RandnameTemplate); m_TableTypeList.Add("chuhan.gsp.client.randname_59", typeof(RandnameTemplate)); m_NewbieguideTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.newbieguide_60", m_NewbieguideTable); m_TableTypeList.Add("chuhan.gsp.client.newbieguide_60", typeof(NewbieguideTemplate)); m_GameactivityTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.gameactivity_61", m_GameactivityTable); m_TableTypeList.Add("chuhan.gsp.client.gameactivity_61", typeof(GameactivityTemplate)); m_CaptionTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.runhorselight_62", m_CaptionTable); m_TableTypeList.Add("chuhan.gsp.client.runhorselight_62", typeof(RunhorselightTemplate)); m_BroadCastTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.broadcast_63", m_BroadCastTable); m_TableTypeList.Add("chuhan.gsp.client.broadcast_63", typeof(BroadcastTemplate)); m_PropsacessTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.propsaccess_65", m_PropsacessTable); m_TableTypeList.Add("chuhan.gsp.client.propsaccess_65", typeof(PropsaccessTemplate)); m_PropsjumpuiTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.propsjumpui_66", m_PropsjumpuiTable); m_TableTypeList.Add("chuhan.gsp.client.propsjumpui_66", typeof(PropsjumpuiTemplate)); m_HeroaddstageTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.heroaddstage_67", m_HeroaddstageTable); m_TableTypeList.Add("chuhan.gsp.client.heroaddstage_67", typeof(HeroaddstageTemplate)); m_AngerTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.angertable_69", m_AngerTable); m_TableTypeList.Add("chuhan.gsp.client.angertable_69", typeof(AngertableTemplate)); m_HerocultureTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.heroculture_70", m_HerocultureTable); m_TableTypeList.Add("chuhan.gsp.client.heroculture_70", typeof(HerocultureTemplate)); m_EquipmentqualityTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.equipmentquality_71", m_EquipmentqualityTable); m_TableTypeList.Add("chuhan.gsp.client.equipmentquality_71", typeof(EquipmentqualityTemplate)); m_EquipmentstrengthTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.equipmentstrength_72", m_EquipmentstrengthTable); m_TableTypeList.Add("chuhan.gsp.client.equipmentstrength_72", typeof(EquipmentstrengthTemplate)); m_MsTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.ms_73", m_MsTable); m_TableTypeList.Add("chuhan.gsp.client.ms_73", typeof(MsTemplate)); m_ShangdianTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.shangdian_76", m_ShangdianTable); m_TableTypeList.Add("chuhan.gsp.client.shangdian_76", typeof(ShangdianTemplate)); m_ShangdiandiaoluoTable = new TableReader(); m_TableList.Add("chuhan.gsp.client.shangdiandiaoluo_77", m_ShangdiandiaoluoTable); m_TableTypeList.Add("chuhan.gsp.client.shangdiandiaoluo_77", typeof(ShangdiandiaoluoTemplate)); m_Heroupgradexp = new TableReader(); m_TableList.Add("chuhan.gsp.client.heroupgradexp_68", m_Heroupgradexp); m_TableTypeList.Add("chuhan.gsp.client.heroupgradexp_68", typeof(HeroupgradexpTemplate)); m_GameConfig = new GameConfig(); m_TableList.Add("chuhan.gsp.client.config_10", m_GameactivityTable); //10表没有类型 就先传一个 解析的时候不用这个类型 m_TableTypeList.Add("chuhan.gsp.client.config_10", typeof(GameactivityTemplate)); //m_GameConfig = new GameConfig(); //m_GameConfig.LoadBinary("clientxml2/chuhan.gsp.client.config_10.bin"); }
private void Rollback_impl(TableReader reader, string fileName) { string fileTitle = fileName.Substring(0, fileName.LastIndexOf(".")); string filePath = Path.GetDirectoryName(fileName); IWorkbook workbook = new HSSFWorkbook(); ISheet sheet = workbook.CreateSheet("Sheet1"); int iRows = reader.ReadInt32(); //行数量 reader.ReadString(); //读取MD5 mCustoms.Clear(); List <PackageField> Fields = GetFields(reader); //读取表结构 int customNumber = reader.ReadInt32(); //自定义类数量 for (int i = 0; i < customNumber; ++i) { List <PackageField> fields = new List <PackageField>(); string str = reader.ReadString(); //读取自定义类名字 mCustoms[str] = GetFields(reader); //读取自定义类结构 } { IRow row0 = sheet.CreateRow(0); IRow row1 = sheet.CreateRow(1); IRow row2 = sheet.CreateRow(2); IRow row3 = sheet.CreateRow(3); for (int i = 0; i < Fields.Count; ++i) { PackageField field = Fields[i]; string str = field.Array ? "array" + field.Type : field.Type; row0.CreateCell(i).SetCellValue("注释(请自行粘贴)"); row1.CreateCell(i).SetCellValue("字段名(请自行粘贴)"); row2.CreateCell(i).SetCellValue("字段默认值(请自行粘贴)"); row3.CreateCell(i).SetCellValue(str); } } foreach (var pair in mCustoms) { StringBuilder builder = new StringBuilder(); builder.Append(@"__Class = {"); foreach (var field in pair.Value) { string str = @" __Field = ""__Index,__Type,__Array"","; str = str.Replace("__Field", field.Name); str = str.Replace("__Index", field.Index.ToString()); str = str.Replace("__Type", field.Type); str = str.Replace("__Array", field.Array ? "true" : "false"); builder.Append(str); } builder.Append(@" }"); builder = builder.Replace("__Class", pair.Key); FileUtil.CreateFile(string.Format("{0}/{1}.js", filePath, pair.Key), builder.ToString(), false); } for (int i = 0; i < iRows; ++i) { IRow row = sheet.CreateRow(i + START_ROW); List <string> strs = ReadFields(reader, Fields, 2); for (int j = 0; j < strs.Count; ++j) { row.CreateCell(j).SetCellValue(strs[j]); } } string rollbackFileName = fileTitle + ".xls"; FileUtil.DeleteFile(rollbackFileName); FileStream stream = new FileStream(rollbackFileName, FileMode.Create); workbook.Write(stream); stream.Close(); }
static void Export(Settings settings, List <CharacterMap> characterMaps, SKTypeface typeface) { foreach (var characterMap in characterMaps) { if (characterMap != null && characterMap.CharacterToGlyphMap != null) { if (settings.PngExport) { if (!settings.Quiet) { Log($"[Png] {typeface.FamilyName}, Name: {characterMap.Name}, PlatformID: {TableReader.GetPlatformID(characterMap.PlatformID)}, EncodingID: {TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}"); } var outputPath = $"charmap_({typeface.FamilyName})_{characterMap.Name}_({TableReader.GetPlatformID(characterMap.PlatformID)}-{TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}).png"; if (settings.OutputDirectory != null && !string.IsNullOrEmpty(settings.OutputDirectory.FullName)) { outputPath = Path.Combine(settings.OutputDirectory.FullName, outputPath); } using var stream = File.OpenWrite(outputPath); CharacterMapPngExporter.Save(characterMap.CharacterToGlyphMap, typeface, settings.PngTextSize, settings.PngCellSize, settings.PngColumns, stream); } if (settings.SvgExport) { if (!settings.Quiet) { Log($"[Svg] {typeface.FamilyName}, Name: {characterMap.Name}, PlatformID: {TableReader.GetPlatformID(characterMap.PlatformID)}, EncodingID: {TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}"); } var outputDirectory = ""; if (settings.OutputDirectory != null && !string.IsNullOrEmpty(settings.OutputDirectory.FullName)) { outputDirectory = settings.OutputDirectory.FullName; } outputDirectory = Path.Combine(outputDirectory, $"{typeface.FamilyName}_{characterMap.Name}_({TableReader.GetPlatformID(characterMap.PlatformID)}-{TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)})"); if (!Directory.Exists(outputDirectory)) { Directory.CreateDirectory(outputDirectory); } CharacterMapSvgExporter.Save(characterMap.CharacterToGlyphMap, typeface, settings.SvgTextSize, settings.SvgPathFill, outputDirectory, null); } if (settings.XamlExport) { if (!settings.Quiet) { Log($"[Xaml] {typeface.FamilyName}, Name: {characterMap.Name}, PlatformID: {TableReader.GetPlatformID(characterMap.PlatformID)}, EncodingID: {TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}"); } var outputPath = $"{typeface.FamilyName}_{characterMap.Name}_({TableReader.GetPlatformID(characterMap.PlatformID)}-{TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}).xaml"; if (settings.OutputDirectory != null && !string.IsNullOrEmpty(settings.OutputDirectory.FullName)) { outputPath = Path.Combine(settings.OutputDirectory.FullName, outputPath); } using var streamWriter = File.CreateText(outputPath); CharacterMapXamlExporter.Save(characterMap.CharacterToGlyphMap, typeface, settings.XamlTextSize, settings.XamlBrush, streamWriter); } } } }
private static string GenerateRows(TableSchema schema, TableReader reader) { var table = reader.Table; TableClause script = new TableClause(schema); StringBuilder builder = new StringBuilder(); foreach (DataRow row in table.Rows) builder.Append(script.INSERT(row)).AppendLine(); if (table.Rows.Count > 0) builder.AppendLine(TableClause.GO); return builder.ToString(); }
public void ExportCsvFile(Command cmd) { string path = cfg.GetValue<string>("csv.path", $"{Configuration.MyDocuments}\\csv"); string file; Func<TableName, string> fullName = tname => $"{path}\\{sname.Path}\\{dname.Name}\\{tname.ShortName}.csv"; if (tname != null) { stdio.WriteLine("start to generate {0} csv file", tname); file = fullName(tname); var dt = new SqlBuilder().SELECT.COLUMNS(cmd.Columns).FROM(tname).SqlCmd.FillDataTable(); using (var writer = file.NewStreamWriter()) { CsvFile.Write(dt, writer, true); } stdio.WriteLine("completed {0} => {1}", tname.ShortName, file); } else if (dname != null) { stdio.WriteLine("start to generate {0} csv to directory: {1}", dname, path); CancelableWork.CanCancel(cts => { var md = new MatchedDatabase(dname, cmd.wildcard, cfg.exportExcludedTables); TableName[] tnames = md.MatchedTableNames; foreach (var tn in tnames) { if (cts.IsCancellationRequested) return; try { file = fullName(tn); var dt = new TableReader(tn).Table; using (var writer = file.NewStreamWriter()) { CsvFile.Write(dt, writer, true); } stdio.WriteLine("generated for {0} at {1}", tn.ShortName, path); } catch (Exception ex) { stdio.ErrorFormat("failed to generate {0}, {1}", tn.ShortName, ex.Message); } } stdio.WriteLine("completed"); return; }); } else { stdio.ErrorFormat("warning: table or database is not seleted"); } }
public Writer(TableReader reader) { _reader = reader; }
public bool Pack() { pack.statements.AppendFormat("var dpo = new {0}()", dpoType.Name); PersistentObject dpo = (PersistentObject)Activator.CreateInstance(this.dpoType); DataTable dt = new TableReader(dpo.TableName).Table; if (dt.Rows.Count == 0) return false; this.count = dt.Rows.Count; //Property property = new Property(typeof(string), "TableName"); //this.clss.AddProperty(property); //property.AddGet("return \"{0}\"", this.instance.TableName.Name); //property = new Property(typeof(Level), "Level"); //this.clss.AddProperty(property); //property.AddGet("return Level.{0}", this.instance.Level); int i = 0; foreach (DataRow dataRow in dt.Rows) { PackRecord(dataRow); if (i < dt.Rows.Count - 1) pack.statements.AppendFormat("dpo = new {0}()", dpoType.Name); i++; } return true; }
private static void WriteToTextWriter(DataTable dt, WriteOptions options, TextWriter textWriter) { options = options ?? new WriteOptions(); using (var writer = new Writer(TableReader.Create(dt))) writer.Write(textWriter, options); }
static void Export(Settings settings, List <CharacterMap> characterMaps, SKTypeface typeface, ZipArchive zipArchive) { foreach (var characterMap in characterMaps) { if (characterMap != null && characterMap.CharacterToGlyphMap != null) { if (settings.PngExport) { if (!settings.Quiet) { Log($"[Png] {typeface.FamilyName}, Name: {characterMap.Name}, PlatformID: {TableReader.GetPlatformID(characterMap.PlatformID)}, EncodingID: {TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}"); } var outputPath = $"charmap_({typeface.FamilyName})_{characterMap.Name}_({TableReader.GetPlatformID(characterMap.PlatformID)}-{TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}).png"; var zipArchiveEntry = zipArchive.CreateEntry(outputPath); using var stream = zipArchiveEntry.Open(); CharacterMapPngExporter.Save(characterMap.CharacterToGlyphMap, typeface, settings.PngTextSize, settings.PngCellSize, settings.PngColumns, stream); } if (settings.SvgExport) { if (!settings.Quiet) { Log($"[Svg] {typeface.FamilyName}, Name: {characterMap.Name}, PlatformID: {TableReader.GetPlatformID(characterMap.PlatformID)}, EncodingID: {TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}"); } var outputDirectory = $"{typeface.FamilyName}_{characterMap.Name}_({TableReader.GetPlatformID(characterMap.PlatformID)}-{TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)})"; CharacterMapSvgExporter.Save(characterMap.CharacterToGlyphMap, typeface, settings.SvgTextSize, settings.SvgPathFill, outputDirectory, zipArchive); } if (settings.XamlExport) { if (!settings.Quiet) { Log($"[Xaml] {typeface.FamilyName}, Name: {characterMap.Name}, PlatformID: {TableReader.GetPlatformID(characterMap.PlatformID)}, EncodingID: {TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}"); } var outputPath = $"{typeface.FamilyName}_{characterMap.Name}_({TableReader.GetPlatformID(characterMap.PlatformID)}-{TableReader.GetEncodingID(characterMap.PlatformID, characterMap.EncodingID)}).xaml"; var zipArchiveEntry = zipArchive.CreateEntry(outputPath); using var streamWriter = new StreamWriter(zipArchiveEntry.Open()); CharacterMapXamlExporter.Save(characterMap.CharacterToGlyphMap, typeface, settings.XamlTextSize, settings.XamlBrush, streamWriter); } } } }
public PrivilegeData(RectTransform layoutObject, GameObject originalTipsText, TableReader dataReader) { m_TipsTextList = new List <Text>(); m_LayoutObject = layoutObject; m_OriginalTipsText = originalTipsText; m_DataReader = dataReader; }
public void Generate() { foreach (var kvp in xlsxManager.tables) { TableReader table = kvp.Value; Dictionary <string, DataField> fieldDict = new Dictionary <string, DataField>(); foreach (DataField field in table.dataStruct.fields) { bool isLangField = false; string fieldName = field.field; foreach (string langFieldPrefix in Setting.Options.langFieldPrefixs) { if (fieldName.StartsWith(langFieldPrefix)) { fieldName = fieldName.Replace(langFieldPrefix, string.Empty); isLangField = true; break; } } if (!fieldDict.ContainsKey(fieldName)) { DataField item = field.Clone(); item.field = fieldName; item.isLangField = isLangField; fieldDict.Add(fieldName, item); } } List <DataField> fieldList = new List <DataField>(fieldDict.Values); foreach (string lang in Setting.Options.langs) { string langFieldPrefix = lang.Replace("-", "_"); List <Dictionary <string, string> > dataList = new List <Dictionary <string, string> >(); foreach (Dictionary <string, string> line in table.dataList) { Dictionary <string, string> langLine = new Dictionary <string, string>(); foreach (DataField field in fieldList) { string value = string.Empty; string key = field.field; if (!line.ContainsKey(key)) { key = langFieldPrefix + "_" + field.field; if (!line.ContainsKey(key)) { key = "cn_" + field.field; } } if (line.ContainsKey(key)) { value = line[key]; } langLine.Add(field.field, value); } dataList.Add(langLine); } string langPath = Setting.Options.langDir + "/" + lang + "/" + table.tableName + ".xlsx"; LangTableData langTableData = new LangTableData(); langTableData.langPath = langPath; langTableData.SetFields(fieldList); langTableData.SetDataList(dataList); langTableData.Save(); } } }
public void ExportDataSetXml() { if (dname == null) { cerr.WriteLine("select a database first"); return; } string path = cmd.OutputPath(ConfigKey._GENERATOR_DS_PATH, $"{ConfigurationEnvironment.MyDocuments}\\ds"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (tname != null) { cout.WriteLine($"start to generate data file: {tname}"); var dt = new TableReader(tname).Table; dt.TableName = tname.ShortName; string file = Path.Combine(path, $"{tname.ShortName}.xml"); DataSet ds = dt.DataSet; ds.DataSetName = dname.Name; ds.WriteXml(file, XmlWriteMode.WriteSchema); cout.WriteLine($"completed {tname} => {file}"); } else if (dname != null) { cout.WriteLine($"start to generate data file to directory: {dname}"); CancelableWork.CanCancel(cts => { var md = new MatchedDatabase(dname, cmd); //cfg.exportExcludedTables); TableName[] tnames = md.TableNames(); DataSet ds = new DataSet { DataSetName = dname.Name, }; foreach (var tn in tnames) { if (cts.IsCancellationRequested) { return; } try { var dt = new TableReader(tn).Table.Copy(); dt.TableName = tn.ShortName; ds.Tables.Add(dt); cout.WriteLine($"generated for {tn.ShortName}"); } catch (Exception ex) { cerr.WriteLine($"failed to generate {tn.ShortName}, {ex.Message}"); } } string file = Path.Combine(path, $"{dname.Name}.xml"); ds.WriteXml(file, XmlWriteMode.WriteSchema); cout.WriteLine($"completed generated: {file}"); return; }); } else { cerr.WriteLine("warning: table or database is not seleted"); } }
internal void ForEachValue(TableReader cellDelegate) { if (_areas == null) return; foreach (var area in _areas) { int c = 0, r = 0; var nbrow = area.NbRow; var nbcol = area.NbCol; try { for (r = 1; r <= nbrow; r++) { if (area.HiddenRows[r]) continue; for (c = 1; c <= nbcol; c++) { if (area.HiddenCols[c] || (!_withNullCells && area.Data[r, c] == null)) continue; cellDelegate(area.Data[r, c], c == 1, c == nbcol); } } } catch (Exception ex) { ex.Data.Add(ex.Data.Count.ToString(), area.Data[r, c] == null ? null : "CellType: " + area.Data[r, c].GetType().ToString()); ex.Data.Add(ex.Data.Count.ToString(), area.Data[r, c] == null ? null : "CellValue: " + area.Data[r, c].ToString()); throw; } } }
private void PopulateGrid() { var tableReader = new TableReader(); dgvSchema.DataSource = tableReader.ReadSchema(_tableName); }
public void ExportCsvFile() { string path = this.cmd.OutputPath(ConfigKey._GENERATOR_CSV_PATH, $"{ConfigurationEnvironment.MyDocuments}\\csv"); string file; string fullName(TableName tname) => $"{path}\\{sname.Path}\\{dname.Name}\\{tname.ShortName}.csv"; if (tname != null) { cout.WriteLine("start to generate {0} csv file", tname); file = this.cmd.OutputFileName(); if (file == null) { file = fullName(tname); } var dt = new SqlBuilder().SELECT().COLUMNS(cmd.Columns).FROM(tname).SqlCmd.FillDataTable(); using (var writer = file.CreateStreamWriter(cmd.Append)) { CsvFile.Write(dt, writer, true); } cout.WriteLine("completed {0} => {1}", tname.ShortName, file); } else if (dname != null) { cout.WriteLine("start to generate {0} csv to directory: {1}", dname, path); CancelableWork.CanCancel(cts => { var md = new MatchedDatabase(dname, cmd); TableName[] tnames = md.TableNames(); foreach (var tn in tnames) { if (cts.IsCancellationRequested) { return; } try { file = fullName(tn); var dt = new TableReader(tn).Table; using (var writer = file.CreateStreamWriter(cmd.Append)) { CsvFile.Write(dt, writer, true); } cout.WriteLine("generated for {0} at {1}", tn.ShortName, path); } catch (Exception ex) { cerr.WriteLine($"failed to generate {tn.ShortName}, {ex.Message}"); } } cout.WriteLine("completed"); return; }); } else { cerr.WriteLine("warning: table or database is not seleted"); } }
private void ExtractStringList() { const string _File = "file"; const string _Line = "line"; const string _Col = "col"; const string _Type = "type"; const string _String = "string"; Dictionary <string, string> defaultColumns = new Dictionary <string, string> { [_File] = "File", [_Line] = "Line", [_Col] = "Col", [_Type] = "Type", [_String] = "String", }; string schema_name = cmd.GetValue("schema-name") ?? SchemaName.dbo; string table_name = cmd.GetValue("table-name"); bool allDirectories = cmd.Has("subdirectory"); string[] file_names = cmd.InputFiles(allDirectories); string[] excludes = cmd.Excludes; IDictionary <string, string> column_names = cmd.GetDictionary("column-names", defaultColumns); if (file_names == null) { cerr.WriteLine($"file name or directory is not defined, use option /in:file_name"); return; } if (file_names.Length == 0) { cerr.WriteLine($"file doesn't exist: \"{file_names}\""); return; } if (tname == null) { if (table_name == null) { cerr.WriteLine($"/table-name is not defined"); return; } if (dname == null) { cerr.WriteLine($"required to select a database"); return; } tname = new TableName(dname, schema_name, table_name); if (!tname.Exists()) { cerr.WriteLine($"table-name doesn't exist: {tname}"); return; } } DataTable dt = new TableReader(tname) { CaseSensitive = true, }.Table; StringDumper dumper = new StringDumper(tname) { Line = column_names[_Line], Column = column_names[_Col], Type = column_names[_Type], FileName = column_names[_File], Value = column_names[_String], }; dumper.Initialize(); StringExtractor extractor = new StringExtractor(dumper); if (!ValidateColumn <int>(dt, dumper.Line, "column-name", required: true)) { return; } if (!ValidateColumn <int>(dt, dumper.Column, "column-name", required: true)) { return; } if (!ValidateColumn <string>(dt, dumper.FileName, "column-name", required: false)) { return; } if (!ValidateColumn <string>(dt, dumper.Type, "column-name", required: false)) { return; } if (!ValidateColumn <string>(dt, dumper.Value, "column-name", required: false)) { return; } foreach (string file in file_names) { if (file.IsMatch(excludes)) { Console.WriteLine($"skip: {file}"); continue; } if (file.EndsWith("AssemblyInfo.cs")) { continue; } int count = extractor.Extract(file); if (count > 0) { cout.WriteLine($"{count} of strings were extracted in file: \"{file}\""); } else { cout.WriteLine($"no string found in file: \"{file}\""); } } bool commit = cmd.Has("submit-changes"); if (!commit) { return; } cout.WriteLine($"starting to save changes into table \"{tname}\""); try { TableWriter tableWriter = new TableWriter(tname); tableWriter.Save(dumper.Table); cout.WriteLine($"completed to save on table \"{tname}\" from \"{cmd.InputPath()}\""); } catch (Exception ex) { cerr.WriteLine($"failed to save in \"{tname}\" , {ex.AllMessages()}"); } }
public void CheckModify(TableReader langTable) { List <DataField> fields = new List <DataField>(); foreach (DataField field in langTable.dataStruct.fields) { string fieldName = field.field; foreach (string langFieldPrefix in Setting.Options.langFieldPrefixs) { if (fieldName.StartsWith(langFieldPrefix)) { field.isLangField = true; fields.Add(field); break; } } } bool hasModify = false; var xlsx = new FileInfo(path); using (var package = new ExcelPackage(xlsx)) { ExcelWorksheet ws = null; if (package.Workbook.Worksheets.Count > 0) { IEnumerator enumerator = package.Workbook.Worksheets.GetEnumerator(); while (enumerator.MoveNext() && ws == null) { if (string.IsNullOrEmpty(sheetName)) { ws = (ExcelWorksheet)enumerator.Current; } else { if (((ExcelWorksheet)enumerator.Current).Name == sheetName) { ws = (ExcelWorksheet)enumerator.Current; } } } } if (ws == null) { Log.Error($"没有找到sheet path:{path}, sheetName:{sheetName}"); return; } if (ws.Cells.Rows < 3) { Log.Error($" path:{path}, sheetName:{sheetName}, rows:{ws.Cells.Rows}, 行数小于3行, 必须要有(type, cn, field)"); return; } foreach (Dictionary <string, string> langRowData in langTable.dataList) { if (!langRowData.ContainsKey("id")) { return; } string id = langRowData["id"]; if (!id2RowDataDict.ContainsKey(id)) { continue; } Dictionary <string, string> sourceRowData = id2RowDataDict[id]; foreach (DataField field in fields) { if (sourceRowData.ContainsKey(field.field)) { if (langRowData[field.field] != sourceRowData[field.field]) { ExcelRange excelCell = ws.Cells[id2RowDict[id], fieldDict[field.field].index]; excelCell.Value = langRowData[field.field]; hasModify = true; ws.Comments.Add(excelCell, sourceRowData[field.field], "zf"); excelCell.Style.Fill.PatternType = ExcelFillStyle.Solid; excelCell.Style.Fill.BackgroundColor.SetColor(Color.Yellow); } } } } if (hasModify) { Process.Start("C:/Windows/System32/attrib.exe", " -R"); Process p = Process.Start("C:/Windows/System32/attrib.exe", $" -R {path}"); p.WaitForExit(); p.Close(); PathHelper.CheckPath(savePath); package.SaveAs(new FileInfo(savePath)); CopyCommand.Copy(savePath, path, true); } package.Dispose(); } }
public void xcopy(Command cmd) { if (cmd.HasHelp) { stdio.WriteLine("xcopy large size records, support table/database name wildcards"); stdio.WriteLine(" table must have same structure"); stdio.WriteLine("xcopy database1 [database2]"); stdio.WriteLine("xcopy table1 [table2]"); stdio.WriteLine(" /col:c1[=d1],c2[=d2],... copy selected columns (mapping)"); stdio.WriteLine(" /s compare table schema"); stdio.WriteLine("note that: to xcopy selected records of table, mkdir locator first, example:"); stdio.WriteLine(@" \local\NorthWind\Products> md ProductId<2000"); stdio.WriteLine(@" \local\NorthWind\Products> xcopy 1 \local\db"); return; } CancelableWork.CanCancel(cts => { PathBothSide both = new PathBothSide(mgr, cmd); var dname2 = mgr.GetPathFrom<DatabaseName>(both.ps2.Node); if (both.ps1.MatchedTables == null) return; foreach (var tname1 in both.ps1.MatchedTables) { if (cts.IsCancellationRequested) return; TableName tname2 = mgr.GetPathFrom<TableName>(both.ps2.Node); if (tname2 == null) tname2 = new TableName(dname2, tname1.SchemaName, tname1.ShortName); if (cmd.IsSchema) { string result = Compare.TableSchemaDifference(CompareSideType.compare, tname1, tname2); if (!string.IsNullOrEmpty(result)) { stdio.ErrorFormat("destination table is not compatible or doesn't exist"); continue; } } List<SqlBulkCopyColumnMapping> maps = new List<SqlBulkCopyColumnMapping>(); if (cmd.Columns.Length > 0) { SqlBulkCopyColumnMapping mapping; foreach (var column in cmd.Columns) { string[] items = column.Split('='); if (items.Length == 2) mapping = new SqlBulkCopyColumnMapping(items[0], items[1]); else mapping = new SqlBulkCopyColumnMapping(column, column); maps.Add(mapping); } } TableReader tableReader; if (both.ps1.Node.Item is Locator) { Locator locator = mgr.GetCombinedLocator(both.ps1.Node); string where = locator.Path; tableReader = new TableReader(tname1, where.Inject()); } else tableReader = new TableReader(tname1); int count = tableReader.Count; stdio.Write("copying {0}", tname1.Name); using (var progress = new ProgressBar { Count = count }) { TableBulkCopy bulkCopy = new TableBulkCopy(tableReader); bulkCopy.CopyTo(tname2, maps.ToArray(), cts, progress); if (cts.IsCancellationRequested) progress.Report(count); } if (!cts.IsCancellationRequested) stdio.WriteLine(", Done."); } }); }
private string ReadValue(TableReader reader, PackageField field, int oldLevel) { int level = oldLevel; if (field.Array) { --level; } if (field.Info != null) { if (field.Array) { int number = reader.ReadInt32(); StringBuilder builder = new StringBuilder(); if (level <= 0) { builder.Append("["); } for (int i = 0; i < number; ++i) { if (i != 0) { builder.Append(","); } builder.Append(field.Info.ReadValue(reader).ToString()); } if (level <= 0) { builder.Append("]"); } return(builder.ToString()); } else { return(field.Info.ReadValue(reader).ToString()); } } else { if (field.Array) { int number = reader.ReadInt32(); StringBuilder builder = new StringBuilder(); if (level <= 0) { builder.Append("["); } for (int i = 0; i < number; ++i) { if (i != 0) { builder.Append(","); } builder.Append(ReadFieldsInterior(reader, mCustoms[field.Type], level - 1)); } if (level <= 0) { builder.Append("]"); } return(builder.ToString()); } else { return(ReadFieldsInterior(reader, mCustoms[field.Type], level - 1)); } } }
public void ExportData(Command cmd) { if (tname != null) { stdio.WriteLine("start to generate {0} data file", tname); var dt = new TableReader(tname).Table; var file = xml.Write(tname, dt); stdio.WriteLine("completed {0} =>{1}", tname.ShortName, file); } else if (dname != null) { stdio.WriteLine("start to generate {0}", dname); var mt = new MatchedDatabase(dname, cmd.wildcard, cfg.exportExcludedTables); CancelableWork.CanCancel(cts => { foreach (var tname in mt.MatchedTableNames) { if (cts.IsCancellationRequested) return; stdio.WriteLine("start to generate {0}", tname); var dt = new SqlBuilder().SELECT.TOP(cmd.top).COLUMNS().FROM(tname).SqlCmd.FillDataTable(); var file = xml.Write(tname, dt); stdio.WriteLine("completed {0} => {1}", tname.ShortName, file); } return; } ); if (cmd.top == 0) stdio.WriteLine("completed"); else stdio.WriteLine("completed to export TOP {0} row(s) for each table", cmd.top); } else { stdio.ErrorFormat("warning: table or database is not seleted"); } }
static void Main(string[] args) { //注册EncodeProvider Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); //foreach (EncodingInfo item in System.Text.Encoding.GetEncodings()) //{ // Console.WriteLine($" {item.CodePage} {item.DisplayName} {item.Name} "); //} //string keyid = $@"GlobalKey\.KEY_100(?=[,\s\t\);\.\+\-\*\/]+?)"; // //string keyid = $@"GlobalKey\.KEY_100"; // string str = @"GlobalConfig.getValue(GlobalKey.KEY_100.tostring()) //GlobalConfig.getValue(GlobalKey.KEY_100_Hello) //"; // var content = Regex.Replace(str, keyid, "GlobalKey.KEY_100_LALA"); // Console.WriteLine(content); // Console.Read(); // return; //ChineseChar cc = new ChineseChar('蜻'); //foreach (var item in cc.Pinyins) //{ // Console.WriteLine(item); //} //string str = "KEY_99 奥斯卡比赛单次大卖奖励道具"; //Console.WriteLine($"str = {str}"); //str = str.Utf8ToGB2312(); //Console.WriteLine($"str = {str}"); //string quanping = PinYinConverter.Get(str); //string zimu = PinYinConverter.GetFirst(str); //Console.WriteLine($"quanping = {quanping}"); //Console.WriteLine($"zimu = {zimu}"); //Console.WriteLine($""); //PingYinModel pym = PinYinConverterHelp.GetTotalPingYin(str); //Console.WriteLine($"TotalPingYin = {String.Join(' ', pym.TotalPingYin.ToArray())}"); //Console.WriteLine($"FirstPingYin = {String.Join(' ', pym.FirstPingYin.ToArray())}"); //Console.WriteLine($"FullPing = {PinYinConverterHelp.GetFullPing(str, string.Empty)}"); //Console.Read(); //return; Setting.Init(args); foreach (OptionItem item in Setting.list.list) { TableReader tableReader = new TableReader(); tableReader.option = item; tableReader.path = item.xlsx; tableReader.Load(); tableReader.GenerateEmptyKey(); tableReader.SaveExcel(); tableReader.SaveCode(); tableReader.ReplaceOldCode(); } Console.WriteLine("完成"); if (!Setting.Options.autoEnd) { Console.Read(); } }
private void ImportResourceData() { string file_name = cmd.InputPath(); ResourceFormat format = cmd.GetEnum("format", ResourceFormat.resx); string schema_name = cmd.GetValue("schema-name") ?? SchemaName.dbo; string table_name = cmd.GetValue("table-name"); string name_column = cmd.GetValue("name-column") ?? "name"; string value_column = cmd.GetValue("value-column") ?? name_column; string order_column = cmd.GetValue("order-column"); bool trim_name = cmd.Has("trim-name"); bool trim_value = cmd.Has("trim-value"); bool deleteRowNotInResource = cmd.Has("delete-rows-not-in-resource-file"); if (file_name == null) { cerr.WriteLine($"file name is not defined, use option /in:file_name"); return; } if (!File.Exists(file_name)) { cerr.WriteLine($"file doesn't exist: \"{file_name}\""); return; } if (tname == null) { if (table_name == null) { cerr.WriteLine($"/table-name is not defined"); return; } if (dname == null) { cerr.WriteLine($"required to select a database"); return; } tname = new TableName(dname, schema_name, table_name); if (!tname.Exists()) { cerr.WriteLine($"table-name doesn't exist: {tname}"); return; } } DataTable dt = new TableReader(tname) { CaseSensitive = true, }.Table; if (!ValidateColumn <string>(dt, name_column, "name-column", required: true)) { return; } if (!ValidateColumn <string>(dt, value_column, "value-column", required: true)) { return; } if (!ValidateColumn <int>(dt, order_column, "order-column", required: false)) { return; } cout.WriteLine($"{dt.Rows.Count} of entries on \"{file_name}\""); ResourceTableWriter writer = new ResourceTableWriter(file_name, tname, name_column, value_column, order_column); List <ResourceEntry> entries = writer.Differ(format, dt, trim_name, trim_value); foreach (var entry in entries) { switch (entry.Action) { case DataRowAction.Add: cout.WriteLine($"new entry: \"{entry.Name}\", \"{entry.NewValue}\""); break; case DataRowAction.Change: cout.WriteLine($"update entry: \"{entry.Name}\", \"{entry.OldValue}\" -> \"{entry.NewValue}\""); break; case DataRowAction.Delete: cout.WriteLine($"delete entry: \"{entry.Name}\""); break; } } if (entries.Count > 0) { cout.WriteLine($"{entries.Count} of entries were changed"); } else { cout.WriteLine($"no entry is changed"); } if (entries.Count == 0) { return; } bool commit = cmd.Has("submit-changes"); if (!commit) { return; } cout.WriteLine($"starting to save changes into table \"{tname}\""); try { writer.SubmitChanges(entries, deleteRowNotInResource); cout.WriteLine($"completed to save on table \"{tname}\" from \"{file_name}\""); } catch (Exception ex) { cerr.WriteLine($"failed to save in \"{tname}\" , {ex.AllMessages()}"); } }