Commit 647e7514 authored by keyongyu's avatar keyongyu

导出sql

parent 3a87d27b
......@@ -160,16 +160,16 @@ static string Retext(string text)
return text;
}
public static Card[] Read(string DB, bool reNewLine, params long[] ids)
{
List<string> idlist = new List<string>();
foreach (long id in ids)
{
idlist.Add(id.ToString());
}
return Read(DB, reNewLine, idlist.ToArray());
}
/// <summary>
public static Card[] Read(string DB, bool reNewLine, params long[] ids)
{
List<string> idlist = new List<string>();
foreach (long id in ids)
{
idlist.Add(id.ToString());
}
return Read(DB, reNewLine, idlist.ToArray());
}
/// <summary>
/// 根据密码集合,读取数据
/// </summary>
/// <param name="DB">数据库</param>
......@@ -325,8 +325,8 @@ public static string GetSelectSQL(Card c)
{
StringBuilder sb=new StringBuilder();
sb.Append("SELECT datas.*,texts.* FROM datas,texts WHERE datas.id=texts.id ");
if (c == null)
return sb.ToString();
if (c == null)
return sb.ToString();
if(!string.IsNullOrEmpty(c.name)){
if(c.name.IndexOf("%%")>=0)
c.name=c.name.Replace("%%","%");
......@@ -377,12 +377,10 @@ public static string GetSelectSQL(Card c)
/// 转换为插入语句
/// </summary>
/// <param name="c">卡片数据</param>
/// <param name="ignore"></param>
/// <returns>SQL语句</returns>
public static string GetInsertSQL(Card c, bool ignore)
{
if (c == null)
return "";
StringBuilder st = new StringBuilder();
if(ignore)
st.Append("INSERT or ignore into datas values(");
......@@ -391,18 +389,18 @@ public static string GetInsertSQL(Card c, bool ignore)
st.Append(c.id.ToString()); st.Append(",");
st.Append(c.ot.ToString()); st.Append(",");
st.Append(c.alias.ToString()); st.Append(",");
st.Append(c.setcode.ToString()); st.Append(",");
st.Append(c.type.ToString()); st.Append(",");
st.Append("0x"+c.setcode.ToString("x")); st.Append(",");
st.Append("0x"+c.type.ToString("x")); st.Append(",");
st.Append(c.atk.ToString()); ; st.Append(",");
st.Append(c.def.ToString()); st.Append(",");
st.Append(c.level.ToString()); st.Append(",");
st.Append(c.race.ToString()); st.Append(",");
st.Append(c.attribute.ToString()); st.Append(",");
st.Append(c.category.ToString()); st.Append(")");
st.Append("0x"+c.level.ToString("x")); st.Append(",");
st.Append("0x"+c.race.ToString("x")); st.Append(",");
st.Append("0x"+c.attribute.ToString("x")); st.Append(",");
st.Append("0x"+c.category.ToString("x")); st.Append(")");
if(ignore)
st.Append(";INSERT or ignore into texts values(");
st.Append(";\nINSERT or ignore into texts values(");
else
st.Append(";INSERT or replace into texts values(");
st.Append(";\nINSERT or replace into texts values(");
st.Append(c.id.ToString()); st.Append(",'");
st.Append(c.name.Replace("'", "''")); st.Append("','");
st.Append(c.desc.Replace("'", "''"));
......@@ -426,9 +424,6 @@ public static string GetInsertSQL(Card c, bool ignore)
public static string GetUpdateSQL(Card c)
{
StringBuilder st = new StringBuilder();
if (c == null)
return "";
st.Append("update datas set ot="); st.Append(c.ot.ToString());
st.Append(",alias="); st.Append(c.alias.ToString());
st.Append(",setcode="); st.Append(c.setcode.ToString());
......@@ -472,5 +467,18 @@ public static string GetDeleteSQL(Card c)
}
#endregion
#endregion
public static void exportSql(String file,params Card[] cards){
using (FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write))
{
StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
foreach (Card c in cards)
{
sw.WriteLine(GetInsertSQL(c, false));
}
sw.Close();
}
}
}
}
......@@ -731,13 +731,14 @@ public Card[] ReadCards(string set, bool repalceOld)
/// 图片缓存
/// </summary>
/// <param name="img"></param>
/// <param name="card"></param>
/// <returns></returns>
public string getImageCache(string img,Card card){
if(!cfg.reimage){
//不需要调整
return img;
}
bool isPendulum =card!=null && card.IsType(CardType.TYPE_PENDULUM);
bool isPendulum = card.IsType(CardType.TYPE_PENDULUM);
if(isPendulum){
if(cfg.pwidth<=0 && cfg.pheight<=0)
return img;
......@@ -779,7 +780,7 @@ public Card[] ReadCards(string set, bool repalceOld)
string mse_path=args[0];
string setfile=args[1];
string path=args[2];
if(mse_path==null||mse_path.Length==0||setfile==null||setfile.Length==0){
if(string.IsNullOrEmpty(mse_path)||string.IsNullOrEmpty(setfile)){
System.Windows.Forms.MessageBox.Show(Language.LanguageHelper.GetMsg(LMSG.exportMseImagesErr));
return;
}else{
......@@ -814,7 +815,7 @@ public Card[] ReadCards(string set, bool repalceOld)
}catch{}
}
public static void exportSet(string mse_path,string setfile,string path,EventHandler handler){
if(mse_path==null||mse_path.Length==0||setfile==null||setfile.Length==0){
if(string.IsNullOrEmpty(mse_path)||setfile==null||setfile.Length==0){
return;
}
ParameterizedThreadStart ParStart = new ParameterizedThreadStart(exportSetThread);
......@@ -827,7 +828,7 @@ public Card[] ReadCards(string set, bool repalceOld)
#region test
public void testPendulum(string desc){
if(desc==null||desc.Length==0){
if(string.IsNullOrEmpty(desc)){
MessageBox.Show("desc is null", "info");
}else{
string ptext=GetDesc(desc, cfg.regx_pendulum);
......
......@@ -64,6 +64,8 @@ private void InitializeComponent()
this.menuitem_readimages = new System.Windows.Forms.ToolStripMenuItem();
this.tsep6 = new System.Windows.Forms.ToolStripSeparator();
this.menuitem_compdb = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_export_select_sql = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_export_all_sql = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_findluafunc = new System.Windows.Forms.ToolStripMenuItem();
this.menuitem_exportdata = new System.Windows.Forms.ToolStripMenuItem();
this.tsep5 = new System.Windows.Forms.ToolStripSeparator();
......@@ -122,10 +124,10 @@ private void InitializeComponent()
this.tb_setcode3 = new System.Windows.Forms.TextBox();
this.tb_setcode4 = new System.Windows.Forms.TextBox();
this.lb_cardcode = new System.Windows.Forms.Label();
this.pl_category = new DFlowLayoutPanel();
this.pl_cardtype = new DFlowLayoutPanel();
this.lb_scripttext = new DListBox();
this.lv_cardlist = new DListView();
this.pl_category = new DataEditorX.DFlowLayoutPanel();
this.pl_cardtype = new DataEditorX.DFlowLayoutPanel();
this.lb_scripttext = new DataEditorX.DListBox();
this.lv_cardlist = new DataEditorX.DListView();
this.ch_cardcode = new System.Windows.Forms.ColumnHeader();
this.ch_cardname = new System.Windows.Forms.ColumnHeader();
this.mainMenu.SuspendLayout();
......@@ -134,10 +136,10 @@ private void InitializeComponent()
// mainMenu
//
this.mainMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuitem_file,
this.menu_image,
this.menu_data,
this.menuitem_help});
this.menuitem_file,
this.menu_image,
this.menu_data,
this.menuitem_help});
this.mainMenu.Location = new System.Drawing.Point(0, 0);
this.mainMenu.Name = "mainMenu";
this.mainMenu.Size = new System.Drawing.Size(859, 25);
......@@ -147,15 +149,15 @@ private void InitializeComponent()
// menuitem_file
//
this.menuitem_file.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuitem_open,
this.menuitem_new,
this.toolStripSeparator3,
this.menuitem_copyselectto,
this.menuitem_copyto,
this.tsep4,
this.menuitem_openLastDataBase,
this.toolStripSeparator2,
this.menuitem_quit});
this.menuitem_open,
this.menuitem_new,
this.toolStripSeparator3,
this.menuitem_copyselectto,
this.menuitem_copyto,
this.tsep4,
this.menuitem_openLastDataBase,
this.toolStripSeparator2,
this.menuitem_quit});
this.menuitem_file.Name = "menuitem_file";
this.menuitem_file.Size = new System.Drawing.Size(53, 21);
this.menuitem_file.Text = "File(&F)";
......@@ -216,15 +218,15 @@ private void InitializeComponent()
// menu_image
//
this.menu_image.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuitem_mseconfig,
this.tsep3,
this.menuitem_readmse,
this.menuitem_saveasmse_select,
this.menuitem_saveasmse,
this.menuitem_exportMSEimage,
this.menuitem_testpendulumtext,
this.tsep7,
this.menuitem_importmseimg});
this.menuitem_mseconfig,
this.tsep3,
this.menuitem_readmse,
this.menuitem_saveasmse_select,
this.menuitem_saveasmse,
this.menuitem_exportMSEimage,
this.menuitem_testpendulumtext,
this.tsep7,
this.menuitem_importmseimg});
this.menu_image.Name = "menu_image";
this.menu_image.Size = new System.Drawing.Size(69, 21);
this.menu_image.Text = "Image(&I)";
......@@ -290,20 +292,22 @@ private void InitializeComponent()
// menu_data
//
this.menu_data.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuitem_operacardsfile,
this.menuitem_openfileinthis,
this.tsep2,
this.menuitem_readydk,
this.menuitem_readimages,
this.tsep6,
this.menuitem_compdb,
this.menuitem_findluafunc,
this.menuitem_exportdata,
this.tsep5,
this.menuitem_cutimages,
this.menuitem_convertimage,
this.tsep1,
this.menuitem_cancelTask});
this.menuitem_operacardsfile,
this.menuitem_openfileinthis,
this.tsep2,
this.menuitem_readydk,
this.menuitem_readimages,
this.tsep6,
this.menuitem_compdb,
this.menuitem_export_select_sql,
this.menuitem_export_all_sql,
this.menuitem_findluafunc,
this.menuitem_exportdata,
this.tsep5,
this.menuitem_cutimages,
this.menuitem_convertimage,
this.tsep1,
this.menuitem_cancelTask});
this.menu_data.Name = "menu_data";
this.menu_data.Size = new System.Drawing.Size(62, 21);
this.menu_data.Text = "Data(&T)";
......@@ -353,6 +357,20 @@ private void InitializeComponent()
this.menuitem_compdb.Text = "Compression DataBase";
this.menuitem_compdb.Click += new System.EventHandler(this.menuitem_compdb_Click);
//
// menuitem_export_select_sql
//
this.menuitem_export_select_sql.Name = "menuitem_export_select_sql";
this.menuitem_export_select_sql.Size = new System.Drawing.Size(212, 22);
this.menuitem_export_select_sql.Text = "Export select to Sql";
this.menuitem_export_select_sql.Click += new System.EventHandler(this.Menuitem_export_select_sqlClick);
//
// menuitem_export_all_sql
//
this.menuitem_export_all_sql.Name = "menuitem_export_all_sql";
this.menuitem_export_all_sql.Size = new System.Drawing.Size(212, 22);
this.menuitem_export_all_sql.Text = "Export all to Sql";
this.menuitem_export_all_sql.Click += new System.EventHandler(this.Menuitem_export_all_sqlClick);
//
// menuitem_findluafunc
//
this.menuitem_findluafunc.Name = "menuitem_findluafunc";
......@@ -401,11 +419,11 @@ private void InitializeComponent()
// menuitem_help
//
this.menuitem_help.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.menuitem_about,
this.menuitem_language,
this.menuitem_checkupdate,
this.menuitem_autocheckupdate,
this.menuitem_github});
this.menuitem_about,
this.menuitem_language,
this.menuitem_checkupdate,
this.menuitem_autocheckupdate,
this.menuitem_github});
this.menuitem_help.Name = "menuitem_help";
this.menuitem_help.Size = new System.Drawing.Size(64, 21);
this.menuitem_help.Text = "Help(&H)";
......@@ -670,7 +688,7 @@ private void InitializeComponent()
// btn_PageUp
//
this.btn_PageUp.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.btn_PageUp.Location = new System.Drawing.Point(-1, 543);
this.btn_PageUp.Location = new System.Drawing.Point(0, 543);
this.btn_PageUp.Name = "btn_PageUp";
this.btn_PageUp.Size = new System.Drawing.Size(64, 27);
this.btn_PageUp.TabIndex = 5;
......@@ -1019,13 +1037,13 @@ private void InitializeComponent()
this.lv_cardlist.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.lv_cardlist.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lv_cardlist.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.ch_cardcode,
this.ch_cardname});
this.ch_cardcode,
this.ch_cardname});
this.lv_cardlist.FullRowSelect = true;
this.lv_cardlist.GridLines = true;
this.lv_cardlist.HideSelection = false;
this.lv_cardlist.LabelWrap = false;
this.lv_cardlist.Location = new System.Drawing.Point(-1, 27);
this.lv_cardlist.Location = new System.Drawing.Point(0, 27);
this.lv_cardlist.Name = "lv_cardlist";
this.lv_cardlist.Scrollable = false;
this.lv_cardlist.ShowItemToolTips = true;
......@@ -1113,6 +1131,7 @@ private void InitializeComponent()
this.mainMenu.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.ToolStripMenuItem menuitem_testpendulumtext;
private System.Windows.Forms.ToolStripMenuItem menuitem_exportMSEimage;
......@@ -1207,5 +1226,7 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem menuitem_openfileinthis;
private System.Windows.Forms.ToolStripMenuItem menuitem_autocheckupdate;
private System.Windows.Forms.ToolStripMenuItem menuitem_language;
private System.Windows.Forms.ToolStripMenuItem menuitem_export_select_sql;
private System.Windows.Forms.ToolStripMenuItem menuitem_export_all_sql;
}
}
......@@ -1670,6 +1670,24 @@ void Menuitem_testPendulumTextClick(object sender, EventArgs e)
tasker.testPendulumText(c.desc);
}
}
void Menuitem_export_select_sqlClick(object sender, EventArgs e)
{
using(SaveFileDialog dlg = new SaveFileDialog()){
if(dlg.ShowDialog() == DialogResult.OK){
DataBase.exportSql(dlg.FileName, GetCardList(true));
MyMsg.Show("OK");
}
}
}
void Menuitem_export_all_sqlClick(object sender, EventArgs e)
{
using(SaveFileDialog dlg = new SaveFileDialog()){
if(dlg.ShowDialog() == DialogResult.OK){
DataBase.exportSql(dlg.FileName, GetCardList(false));
MyMsg.Show("OK");
}
}
}
}
}
......@@ -28,4 +28,4 @@
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("2.4.0.6")]
[assembly: AssemblyVersion("2.4.0.7")]
★更新历史
2.4.0.7
导出卡片为sql功能
2.4.0.5
更新数据
多卡图打开同名卡脚本
......
......@@ -58,6 +58,8 @@ DataEditForm.mainMenu.menuitem_convertimage 批量导入卡图
DataEditForm.mainMenu.menuitem_exportMSEimage 从MSE存档导出图片(再次点击停止)
DataEditForm.mainMenu.menuitem_cancelTask 取消任务
DataEditForm.mainMenu.menuitem_testpendulumtext 测试灵摆效果文本
DataEditForm.mainMenu.menuitem_export_all_sql 所有卡片导出为sql
DataEditForm.mainMenu.menuitem_export_select_sql 选择卡片导出为sql
DataEditForm.mainMenu.menuitem_help 帮助(&H)
DataEditForm.mainMenu.menuitem_about 关于
DataEditForm.mainMenu.menuitem_language 语言
......
......@@ -54,7 +54,9 @@ DataEditForm.mainMenu.menuitem_saveasmse_select Save Selected As MSE-set
DataEditForm.mainMenu.menuitem_saveasmse Save All As MSE-set
DataEditForm.mainMenu.menuitem_cutimages Cut Images
DataEditForm.mainMenu.menuitem_convertimage Convert Images
DataEditForm.mainMenu.menuitem_importmseimg Set MSE'Image
DataEditForm.mainMenu.menuitem_importmseimg Set MSE'Image
DataEditForm.mainMenu.menuitem_export_all_sql Export all to sql
DataEditForm.mainMenu.menuitem_export_select_sql Export select to sql
DataEditForm.mainMenu.menuitem_cancelTask Cancel Task
DataEditForm.mainMenu.menuitem_exportMSEimage export mse-set to images(Click stop)
DataEditForm.mainMenu.menuitem_help Help(&H)
......
[DataEditorX]2.4.0.6[DataEditorX]
[DataEditorX]2.4.0.7[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
No preview for this file type
★更新历史
2.4.0.7
导出卡片为sql功能
2.4.0.5
更新数据
多卡图打开同名卡脚本
......
......@@ -58,6 +58,8 @@ DataEditForm.mainMenu.menuitem_convertimage 批量导入卡图
DataEditForm.mainMenu.menuitem_exportMSEimage 从MSE存档导出图片(再次点击停止)
DataEditForm.mainMenu.menuitem_cancelTask 取消任务
DataEditForm.mainMenu.menuitem_testpendulumtext 测试灵摆效果文本
DataEditForm.mainMenu.menuitem_export_all_sql 所有卡片导出为sql
DataEditForm.mainMenu.menuitem_export_select_sql 选择卡片导出为sql
DataEditForm.mainMenu.menuitem_help 帮助(&H)
DataEditForm.mainMenu.menuitem_about 关于
DataEditForm.mainMenu.menuitem_language 语言
......
......@@ -54,7 +54,9 @@ DataEditForm.mainMenu.menuitem_saveasmse_select Save Selected As MSE-set
DataEditForm.mainMenu.menuitem_saveasmse Save All As MSE-set
DataEditForm.mainMenu.menuitem_cutimages Cut Images
DataEditForm.mainMenu.menuitem_convertimage Convert Images
DataEditForm.mainMenu.menuitem_importmseimg Set MSE'Image
DataEditForm.mainMenu.menuitem_importmseimg Set MSE'Image
DataEditForm.mainMenu.menuitem_export_all_sql Export all to sql
DataEditForm.mainMenu.menuitem_export_select_sql Export select to sql
DataEditForm.mainMenu.menuitem_cancelTask Cancel Task
DataEditForm.mainMenu.menuitem_exportMSEimage export mse-set to images(Click stop)
DataEditForm.mainMenu.menuitem_help Help(&H)
......
[DataEditorX]2.4.0.6[DataEditorX]
[DataEditorX]2.4.0.7[DataEditorX]
[URL]https://github.com/247321453/DataEditorX/raw/master/win32/win32.zip[URL]
★运行环境(Environment)
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment