Commit 5fc81e5a by mahaisong

fix:新增功能

parent a0dc920b
namespace StockListingRelatedCode
{
partial class Form2
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listBox1 = new System.Windows.Forms.ListBox();
this.button_OK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// listBox1
//
this.listBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 16;
this.listBox1.Location = new System.Drawing.Point(38, 55);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(398, 228);
this.listBox1.TabIndex = 4;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// button_OK
//
this.button_OK.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button_OK.Location = new System.Drawing.Point(38, 12);
this.button_OK.Name = "button_OK";
this.button_OK.Size = new System.Drawing.Size(116, 31);
this.button_OK.TabIndex = 3;
this.button_OK.Text = "开始执行";
this.button_OK.UseVisualStyleBackColor = true;
this.button_OK.Click += new System.EventHandler(this.button_OK_Click);
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(485, 324);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button_OK);
this.Name = "Form2";
this.Text = "将所有港股重置为初始(删除排除的规则)";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button_OK;
}
}
\ No newline at end of file
using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StockListingRelatedCode
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.listBox1.Text = "";
this.listBox1.HorizontalScrollbar = true;
}
private void button_OK_Click(object sender, EventArgs e)
{
this.listBox1.Items.Clear();
this.button_OK.Enabled = false;
this.button_OK.Visible = false;
this.listBox1.Items.Add("正在执行中……");
string filename = DateTime.Now.ToString("HH_mm_ss_fff");
//输出原始全表数据备份
string OldTablePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename + "删除排除的规则-原始全表数据备份" + ".txt");
//输出执行update规则的语句
string UpdateSQLPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, filename + "删除排除的规则-执行update规则的SQL语句" + ".txt");
//暂存找到非港股的规则,后面作为SQL语句执行。
ConcurrentDictionary<string, string> updateDic = new ConcurrentDictionary<string, string>();
//声明mysql调用
//查询Organization 表中所有港股
//查询Organization 表中所有非港股
//for循环港股、查找非港股的包含港股编号的股票、输出
StringBuilder stb = new StringBuilder();
try
{
MySqlConnection con = new MySqlConnection("Server=pubtopic.org;uid=palas;pwd=lapas;Database=Palas_V5;charset=utf8;connection timeout=300;SslMode = none");
//查询数据---必须确保Organization类字段、顺序与数据库字段 一致
IEnumerable<Organization> list = con.Query<Organization>("select * from Organization");
con.Close();
IEnumerable<Organization> list12 = list.Where(x => { return x.StockListing == 12; });
stb.AppendLine("操作的数据: 总行数" + list.Count() + "; 港股12的行数" + list12.Count() + ";");
foreach (Organization item12 in list12)
{
if (!String.IsNullOrWhiteSpace(item12.QueryRule))
{
string oldcontent = Util.DecodeRule(item12.QueryRule)[0];
if (oldcontent.Length > 1)
{
oldcontent = oldcontent.Remove(0, 1);
updateDic.TryAdd(item12.OrganizationID, oldcontent.Replace("'", "")); //将数据中的单引号去除。 没办法,要执行update语句,就不能用单引号。
}
}
}
//更新数据库。
//1.将原有数据全表全量全部输出为txt文件。防止修改后找不到备份。
//OldTablePath
if (!File.Exists(OldTablePath))
{
FileStream fs = new FileStream(OldTablePath, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
//标题行
Organization model = new Organization();
System.Reflection.PropertyInfo[] pArray = model.GetType().GetProperties(); //注意此方法是无序的。
string Oldtitle = "";
foreach (System.Reflection.PropertyInfo p in pArray)
{
Oldtitle += p.Name + ",";
}
Oldtitle = Oldtitle.Remove(Oldtitle.Length - 1, 1);
sw.WriteLine(Oldtitle);
//清空缓冲区
sw.Flush();
foreach (Organization old in list)
{
string row = "";
//每行的每列数据
foreach (System.Reflection.PropertyInfo p in pArray)
{
row += ((null == p.GetValue(old) ? "NULL" : p.GetValue(old)) + ",").Replace("\r\n", "").Replace("\r", "").Replace("\n", "").Replace("\t", "");
}
row = row.Remove(row.Length - 1, 1);
sw.WriteLine(row);
//清空缓冲区
sw.Flush();
}
//关闭流
sw.Close();
fs.Close();
this.Invoke(new MethodInvoker(() =>
{
this.listBox1.Items.Add("2:原始全表数据备份--生成完毕:" + OldTablePath);
}));
}
else
{
MessageBox.Show("文件已经存在重名" + OldTablePath + "。建议重新生成!");
return;
}
//2.将需要更新的数据,从执行的队列里面循环,进行update操作。
//组装update语句--100条执行1次。
//UpdateSQLPath
string formatsql = @"update Organization set QueryRule='@a' where OrganizationID='@b';";
if (!File.Exists(UpdateSQLPath))
{
FileStream fs = new FileStream(UpdateSQLPath, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
for (int jindex = 0; jindex < updateDic.Count(); jindex++)
{
string OrganizationID = updateDic.ElementAt(jindex).Key.ToString();
string QueryRule = updateDic.ElementAt(jindex).Value.ToString();
//开始写入
sw.WriteLine(formatsql.Replace("@a", QueryRule).Replace("@b", OrganizationID));
//清空缓冲区
sw.Flush();
}
//关闭流
sw.Close();
fs.Close();
this.Invoke(new MethodInvoker(() =>
{
this.listBox1.Items.Add("3:执行update规则的SQL语句--生成完毕:" + UpdateSQLPath);
}));
}
else
{
MessageBox.Show("文件已经存在重名" + UpdateSQLPath + "。建议重新生成!");
return;
}
StringBuilder updatesqlstb = new StringBuilder();
con.Open();
int i = 0;
while (i < updateDic.Count())
{
string OrganizationID = updateDic.ElementAt(i).Key.ToString();
string QueryRule = updateDic.ElementAt(i).Value.ToString();
updatesqlstb.Append(formatsql.Replace("@a", QueryRule).Replace("@b", OrganizationID));
if (i % 10 == 0)
{
//提交执行
try
{
IDbTransaction transaction = con.BeginTransaction();
try
{
con.Execute(updatesqlstb.ToString(), null, transaction);
transaction.Commit();
}
catch (Exception exception)
{
transaction.Rollback();
MessageBox.Show("数据库错误--事务回滚!" + exception.ToString());
}
//
}
catch (Exception ext)
{
MessageBox.Show("数据库错误!" + ext.ToString());
}
updatesqlstb.Clear();
}
i++;
}
if (updatesqlstb.Length > 0)
{
try
{
IDbTransaction transaction = con.BeginTransaction();
try
{
con.Execute(updatesqlstb.ToString(), null, transaction);
transaction.Commit();
}
catch (Exception exception)
{
transaction.Rollback();
MessageBox.Show("数据库错误--事务回滚!" + exception.ToString());
}
//
}
catch (Exception ext)
{
MessageBox.Show("数据库错误!" + ext.ToString());
}
updatesqlstb.Clear();
}
con.Close();
con.Dispose();
this.Invoke(new MethodInvoker(() =>
{
this.listBox1.Items.Add("3:更新数据库完毕:" + UpdateSQLPath);
}));
}
catch (Exception ex)
{
MessageBox.Show("异常错误!" + ex.ToString());
}
finally
{
this.Invoke(new MethodInvoker(() =>
{
this.listBox1.Items.Add("执行完成");
this.button_OK.Enabled = true;
this.button_OK.Visible = true;
}));
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ListControl ls = (ListControl)sender;
MessageBox.Show(ls.Text);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using MySql.Data.MySqlClient;
using Dapper;
namespace StockListingRelatedCode
{
public partial class MainForm : Form
{
private NotifyIcon notifyIcon = null;
MySqlConnection con = null;
public MainForm()
{
try
{
InitializeComponent();
con = new MySqlConnection("Server=pubtopic.org;uid=palas;pwd=lapas;Database=Palas_V5;charset=utf8;connection timeout=3000;SslMode = none");
this.button_OK.Enabled = false;
this.button_OK.Visible = false;
this.button_Reset.Enabled = false;
this.button_Reset.Visible = false;
this.listBox1.Text = "";
this.listBox1.HorizontalScrollbar = true;
//隐藏托盘
notifyIcon = new NotifyIcon();
//气泡显示的内容
notifyIcon.Text = "港股关联规则程序后台运行";
string MyFileName = Application.StartupPath + "\\iconet.ico";
notifyIcon.Icon = new Icon(MyFileName);
//true表示在托盘区可见,false表示在托盘区不可见
notifyIcon.Visible = true;
//气泡显示的时间(单位是毫秒)
notifyIcon.BalloonTipText = "港股关联规则程序停止...";
notifyIcon.ShowBalloonTip(2000);
notifyIcon.MouseClick += new MouseEventHandler(notifyIcon_MouseClick);
//退出菜单项
MenuItem exit = new MenuItem("退出");
exit.Click += new EventHandler(exit_Click);
//显示菜单项
MenuItem showme = new MenuItem("显示窗体");
showme.Click += new EventHandler(showme_Click);
MenuItem[] childen = new MenuItem[] { showme, exit };
notifyIcon.ContextMenu = new ContextMenu(childen);
}
catch { }
}
void showme_Click(object sender, EventArgs e)
{
try
{
this.Visible = true;
this.TopMost = true;
this.Activate();
}
catch { }
}
void exit_Click(object sender, EventArgs e)
{
try
{
writeLogTxt("强制退出");
}
catch { }
System.Environment.Exit(0);
}
void notifyIcon_MouseClick(object sender, MouseEventArgs e)
{
try
{
//鼠标左键单击 托盘区图标/窗体 切换
if (e.Button == MouseButtons.Left)
{
if (this.Visible == true)
{
this.Visible = false;
}
else
{
this.Visible = true;
this.TopMost = true;
this.Activate();
}
}
}
catch { }
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
Form1 shlog = new Form1();
shlog.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
toolStripButton2.Enabled = false;
shlog.Show();
}
void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
toolStripButton2.Enabled = true;
}
private void MainForm_SizeChanged(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.Visible = false;
this.notifyIcon.Visible = true;//展示出notifyicon控件
}
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
//将窗体隐藏,实现一个“伪关闭”
this.Visible = false;
this.notifyIcon.Visible = true;//展示出notifyicon控件
}
#region 日志
//倒写日志 最新日志放最前面
protected void writeLogTxt(string oper)
{
try
{
string strFilePath = GetLogFilePath();
string strOldText = File.ReadAllText(strFilePath, System.Text.Encoding.Default);
File.WriteAllText(strFilePath, DateTime.Now.ToString() + "\t __ " + oper + " \r\n ", System.Text.Encoding.Default);
File.AppendAllText(strFilePath, strOldText, System.Text.Encoding.Default);
}
catch { }
}
//取得当前所应操作的日志文件的路径
private string GetLogFilePath()
{
string strFilePath = "";
try
{
string strYearMonth = DateTime.Now.ToString("yyyyMMdd");
string strLogDirPath = AppDomain.CurrentDomain.BaseDirectory + @"log\";
if (!Directory.Exists(strLogDirPath))//若文件夹不存在则新建文件夹
{
Directory.CreateDirectory(strLogDirPath); //新建文件夹
}
//判断当前月份是否已有日志文件
string[] strFilesArray = Directory.GetFiles(strLogDirPath, "log_" + strYearMonth + "_*.txt");
if (strFilesArray.Length == 0)
{
strFilePath = strLogDirPath + "log_" + strYearMonth + "_1.txt";
//之前没有本年月的日志文件 需要新建
using (File.Create(strFilePath))
{
}
}
else
{
int intOrderID = 1;
for (int i = 0; i < strFilesArray.Length; i++)
{
string strA = strFilesArray[i].Trim();
strA = strA.Substring(strA.LastIndexOf("_") + 1);
strA = strA.Replace(".txt", "");
int intA = Convert.ToInt32(strA);
if (intA > intOrderID)
intOrderID = intA;
}
strFilePath = strLogDirPath + "log_" + strYearMonth + "_" + intOrderID.ToString() + ".txt";
//之前有 需要判断最后一个是否超容
FileInfo fileInfo = new FileInfo(strFilePath);
if (fileInfo.Length >= 1024)
{
//超容了 新建之
int intCount = intOrderID + 1;
strFilePath = strLogDirPath + "log_" + strYearMonth + "_" + intCount.ToString() + ".txt";
using (File.Create(strFilePath))
{
}
}
}
}
catch { }
return strFilePath;
}
#endregion
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
writeLogTxt("异常引起关闭---原因:" + e.CloseReason.ToString());
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
Form2 shlog = new Form2();
shlog.FormClosing += new FormClosingEventHandler(Form2_FormClosing);
toolStripButton2.Enabled = false;
shlog.Show();
}
void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
toolStripButton2.Enabled = true;
}
private void label3_Click(object sender, EventArgs e)
{
}
private void button_Query_Click(object sender, EventArgs e)
{
//查询textBox_HK的港股
//查询原本的规则
//本次计算的新的排除规则
if (!String.IsNullOrEmpty(this.textBox_HK.Text))
{
this.button_Query.Enabled = false;
this.button_Reset.Enabled = true;
this.button_Reset.Visible = true;
this.listBox1.Items.Add("正在执行中……");
string hk = this.textBox_HK.Text;
//抽取里面的数字编号
//正则表达式提取数字
string number12 = Regex.Replace(hk, @"[^0-9]+", "");
this.Invoke(new MethodInvoker(() =>
{
this.listBox1.Items.Add("1.查询的港股12的编号 - 数字部分为:" + number12);
}));
//sql查询
try
{
if (con.State == ConnectionState.Broken || con.State == ConnectionState.Closed)
{
con.Open();
}
//查询数据---必须确保Organization类字段、顺序与数据库字段 一致
IEnumerable<Organization> list = con.Query<Organization>("select * from Organization");
con.Close();
IEnumerable<Organization> list12 = list.Where(x => { return x.Code == hk; });
if (null == list12 || list12.Count() == 0)
{
this.listBox1.Items.Add("数据库中:港股编号为:" + hk + "的,没有找到");
throw new Exception("数据库中:港股编号为:" + hk + "的,没有找到!");
}
else
{
if (null == list12 || list12.Count() == 0 || list12.Count() > 1)
{
this.listBox1.Items.Add("数据库中:港股编号为:" + hk + "的,有" + list12.Count() + "个");
foreach (Organization model in list12)
{
this.listBox1.Items.Add("OrganizationID为:" + model.OrganizationID);
}
throw new Exception("数量只允许有1个!");
}
else
{
this.textBox_ID.Text = list12.ElementAt(0).OrganizationID;
//符合1条数据。
//textBox_OldRule
//textBox_Except
//textBox_NewRule
this.Invoke(new MethodInvoker(() =>
{
this.textBox_OldRule.Text = list12.ElementAt(0).QueryRule;
this.listBox1.Items.Add("原规则为:" + list12.ElementAt(0).QueryRule);
}));
//计算本次排除的规则、 里面所有的排除的规则。
string tempstr = "";
//查找非港股的包含港股编号的股票\顺序一样的。 (不要求编号一样,编号作为文本字符被包含即可)
IEnumerable<Organization> listNot12Number = list.Where(x => { return x.StockListing != 12 && x.StockListing != 0 && x.Code.Contains(number12); });
if (null != listNot12Number && listNot12Number.Count() > 0)
{
foreach (Organization Not12 in listNot12Number)
{
string numberNot12 = Regex.Replace(Not12.Code, @"[^0-9]+", "");
tempstr += "\"" + numberNot12 + "\" ";
}
if (!String.IsNullOrWhiteSpace(tempstr))
{
//移除最后1个空格
tempstr = "(" + tempstr.Remove(tempstr.Length - 1, 1) + ")";
this.Invoke(new MethodInvoker(() =>
{
this.textBox_Except.Text = tempstr;
this.listBox1.Items.Add("本次计算的排除规则:" + tempstr);
}));
}
else
{
this.listBox1.Items.Add(" 其他股票没有相同的编号!");
//无关不做改动
return;
}
}
else
{
this.listBox1.Items.Add(" 其他股票没有相同的编号!");
//无关不做改动
return;
}
//新规则: 将原规则中 ")-(" 进行拆除,将新的拼接。
string newrule;
if (!string.IsNullOrWhiteSpace(list12.ElementAt(0).QueryRule))
{
string[] spilt = Util.DecodeRule(list12.ElementAt(0).QueryRule);
if (spilt.Length > 1)
{
//spilt[0]
//开头已经带括号
newrule = spilt[0] + ")-" + tempstr;
}
else
{
//开头将要包括号。
newrule = "(" + spilt[0] + ")-" + tempstr;
}
}
else
{
//原规则为空
newrule = "-" + tempstr;
}
this.textBox_NewRule.Text = newrule;
this.listBox1.Items.Add("新的规则:" + newrule);
if (!String.IsNullOrWhiteSpace(this.textBox_ID.Text) &&!String.IsNullOrWhiteSpace(this.textBox_NewRule.Text))
{
button_OK.Enabled = true;
button_OK.Visible = true;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("异常错误!" + ex.ToString());
con.Close();
}
finally
{
this.listBox1.Items.Add("1.查询完成");
if (!String.IsNullOrWhiteSpace(this.textBox_NewRule.Text))
{
this.listBox1.Items.Add("2.请点击将规则变更为新规则(数据库)");
}
}
}
else
{
MessageBox.Show("港股编号未填写!");
return;
}
}
private void button_Reset_Click(object sender, EventArgs e)
{
this.listBox1.Text = "";
this.listBox1.Items.Clear();
this.textBox_Except.Text = "";
this.textBox_HK.Text = "";
this.textBox_NewRule.Text = "";
this.textBox_OldRule.Text = "";
this.textBox_ID.Text = "";
this.button_Query.Enabled = true;
this.button_OK.Enabled = false;
this.button_OK.Visible = false;
this.button_Reset.Enabled = false;
this.button_Reset.Visible = false;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
ListControl ls = (ListControl)sender;
MessageBox.Show(ls.Text);
}
private void button_OK_Click(object sender, EventArgs e)
{
//判断textBox_ID\textBox_NewRule 不为空。
//变更数据库。
if (!String.IsNullOrWhiteSpace(this.textBox_ID.Text) && !String.IsNullOrWhiteSpace(this.textBox_NewRule.Text))
{
string formatsql = @"update Organization set QueryRule='@a' where OrganizationID='@b';";
StringBuilder updatesqlstb = new StringBuilder();
updatesqlstb.Append(formatsql.Replace("@a", this.textBox_NewRule.Text).Replace("@b", this.textBox_ID.Text));
try
{
if (con.State == ConnectionState.Broken || con.State == ConnectionState.Closed)
{
con.Open();
}
IDbTransaction transaction = con.BeginTransaction();
try
{
con.Execute(updatesqlstb.ToString(), null, transaction);
transaction.Commit();
}
catch (Exception exception)
{
transaction.Rollback();
MessageBox.Show("数据库错误--事务回滚!" + exception.ToString());
}
con.Close();
}
catch (Exception ext)
{
con.Close();
MessageBox.Show("数据库错误!" + ext.ToString());
}
this.listBox1.Items.Add("2.修改数据库SQL语句为:" + updatesqlstb.ToString());
this.listBox1.Items.Add("2.修改数据库完成");
this.button_OK.Enabled = false;
this.button_OK.Visible = false;
this.button_Reset.Enabled = true;
this.button_Reset.Visible = true;
}
else
{
this.listBox1.Items.Add("修改数据库--新规则不能为空!");
MessageBox.Show("修改数据库--新规则不能为空!");
}
}
}
}
namespace StockListingRelatedCode
{
partial class MainForm
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.toolStrip1 = new System.Windows.Forms.ToolStrip();
this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.button_Reset = new System.Windows.Forms.Button();
this.button_OK = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox_Except = new System.Windows.Forms.TextBox();
this.textBox_OldRule = new System.Windows.Forms.TextBox();
this.textBox_NewRule = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.textBox_HK = new System.Windows.Forms.TextBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.button_Query = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.textBox_ID = new System.Windows.Forms.TextBox();
this.toolStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.SuspendLayout();
//
// toolStrip1
//
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripButton1,
this.toolStripButton2});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(905, 25);
this.toolStrip1.TabIndex = 0;
this.toolStrip1.Text = "toolStrip1";
//
// toolStripButton1
//
this.toolStripButton1.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton1.Image")));
this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton1.Name = "toolStripButton1";
this.toolStripButton1.Size = new System.Drawing.Size(348, 22);
this.toolStripButton1.Text = "禁用--全量生成:非港股相同编号排除规则--全量更新数据库";
this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
//
// toolStripButton2
//
this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
this.toolStripButton2.Name = "toolStripButton2";
this.toolStripButton2.Size = new System.Drawing.Size(278, 22);
this.toolStripButton2.Text = "禁用--将所有港股重置为初始(删除排除规则)";
this.toolStripButton2.ToolTipText = "今日实时日志信息";
this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.toolStrip1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.label5);
this.splitContainer1.Panel2.Controls.Add(this.textBox_ID);
this.splitContainer1.Panel2.Controls.Add(this.button_Reset);
this.splitContainer1.Panel2.Controls.Add(this.button_OK);
this.splitContainer1.Panel2.Controls.Add(this.label4);
this.splitContainer1.Panel2.Controls.Add(this.label3);
this.splitContainer1.Panel2.Controls.Add(this.label2);
this.splitContainer1.Panel2.Controls.Add(this.textBox_Except);
this.splitContainer1.Panel2.Controls.Add(this.textBox_OldRule);
this.splitContainer1.Panel2.Controls.Add(this.textBox_NewRule);
this.splitContainer1.Panel2.Controls.Add(this.label1);
this.splitContainer1.Panel2.Controls.Add(this.textBox_HK);
this.splitContainer1.Panel2.Controls.Add(this.listBox1);
this.splitContainer1.Panel2.Controls.Add(this.button_Query);
this.splitContainer1.Size = new System.Drawing.Size(905, 419);
this.splitContainer1.SplitterDistance = 29;
this.splitContainer1.TabIndex = 0;
//
// button_Reset
//
this.button_Reset.Location = new System.Drawing.Point(494, 25);
this.button_Reset.Name = "button_Reset";
this.button_Reset.Size = new System.Drawing.Size(99, 27);
this.button_Reset.TabIndex = 14;
this.button_Reset.Text = "重置";
this.button_Reset.UseVisualStyleBackColor = true;
this.button_Reset.Click += new System.EventHandler(this.button_Reset_Click);
//
// button_OK
//
this.button_OK.Location = new System.Drawing.Point(132, 176);
this.button_OK.Name = "button_OK";
this.button_OK.Size = new System.Drawing.Size(195, 26);
this.button_OK.TabIndex = 13;
this.button_OK.Text = "将规则变更为新规则(数据库)";
this.button_OK.UseVisualStyleBackColor = true;
this.button_OK.Click += new System.EventHandler(this.button_OK_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 144);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(79, 13);
this.label4.TabIndex = 12;
this.label4.Text = "生成新的规则";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(5, 119);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(115, 13);
this.label3.TabIndex = 11;
this.label3.Text = "本次计算的排除规则";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(46, 89);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(43, 13);
this.label2.TabIndex = 10;
this.label2.Text = "原规则";
//
// textBox_Except
//
this.textBox_Except.Location = new System.Drawing.Point(132, 116);
this.textBox_Except.Name = "textBox_Except";
this.textBox_Except.Size = new System.Drawing.Size(572, 20);
this.textBox_Except.TabIndex = 9;
//
// textBox_OldRule
//
this.textBox_OldRule.Location = new System.Drawing.Point(132, 86);
this.textBox_OldRule.Name = "textBox_OldRule";
this.textBox_OldRule.Size = new System.Drawing.Size(761, 20);
this.textBox_OldRule.TabIndex = 8;
//
// textBox_NewRule
//
this.textBox_NewRule.Location = new System.Drawing.Point(132, 144);
this.textBox_NewRule.Name = "textBox_NewRule";
this.textBox_NewRule.Size = new System.Drawing.Size(761, 20);
this.textBox_NewRule.TabIndex = 7;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(34, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 13);
this.label1.TabIndex = 6;
this.label1.Text = "港股编号";
//
// textBox_HK
//
this.textBox_HK.Location = new System.Drawing.Point(132, 30);
this.textBox_HK.Name = "textBox_HK";
this.textBox_HK.Size = new System.Drawing.Size(209, 20);
this.textBox_HK.TabIndex = 5;
//
// listBox1
//
this.listBox1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 16;
this.listBox1.Location = new System.Drawing.Point(3, 218);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(880, 164);
this.listBox1.TabIndex = 4;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// button_Query
//
this.button_Query.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button_Query.Location = new System.Drawing.Point(366, 25);
this.button_Query.Name = "button_Query";
this.button_Query.Size = new System.Drawing.Size(107, 27);
this.button_Query.TabIndex = 3;
this.button_Query.Text = "查询";
this.button_Query.UseVisualStyleBackColor = true;
this.button_Query.Click += new System.EventHandler(this.button_Query_Click);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(11, 61);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(78, 13);
this.label5.TabIndex = 16;
this.label5.Text = "结果:港股ID";
//
// textBox_ID
//
this.textBox_ID.Location = new System.Drawing.Point(132, 58);
this.textBox_ID.Name = "textBox_ID";
this.textBox_ID.Size = new System.Drawing.Size(209, 20);
this.textBox_ID.TabIndex = 15;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(905, 419);
this.Controls.Add(this.splitContainer1);
this.Name = "MainForm";
this.Text = "港股关联规则程序";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_FormClosed);
this.SizeChanged += new System.EventHandler(this.MainForm_SizeChanged);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.ToolStrip toolStrip1;
private System.Windows.Forms.ToolStripButton toolStripButton1;
private System.Windows.Forms.ToolStripButton toolStripButton2;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button_Query;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox_HK;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox_Except;
private System.Windows.Forms.TextBox textBox_OldRule;
private System.Windows.Forms.TextBox textBox_NewRule;
private System.Windows.Forms.Button button_OK;
private System.Windows.Forms.Button button_Reset;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox textBox_ID;
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="toolStripButton1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<data name="toolStripButton2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG
YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9
0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw
bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc
VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9
c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32
Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo
mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+
kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
</root>
\ No newline at end of file
using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace StockListingRelatedCode
{
class Other
{
//将内容进行检查、开头不是双引号的加上,更新
private void button_Query_Click(object sender, EventArgs e)
{
//将内容进行检查、开头不是双引号的加上,更新
MySqlConnection con = new MySqlConnection("Server=pubtopic.org;uid=palas;pwd=lapas;Database=Palas_V5;charset=utf8;connection timeout=300;SslMode = none");
con.Open();
//查询数据---必须确保Organization类字段、顺序与数据库字段 一致
IEnumerable<Organization> list = con.Query<Organization>("select * from Organization");
IEnumerable<Organization> list12 = list.Where(x => { return x.StockListing == 12; });
foreach (Organization item12 in list12)
{
if (!String.IsNullOrWhiteSpace(item12.QueryRule))
{
if (item12.QueryRule.First() != '\"')
{
item12.QueryRule = "\"" + item12.QueryRule;
string OrganizationID = item12.OrganizationID;
string QueryRule = item12.QueryRule;
StringBuilder updatesqlstb = new StringBuilder();
string formatsql = @"update Organization set QueryRule='@a' where OrganizationID='@b';";
updatesqlstb.Append(formatsql.Replace("@a", QueryRule).Replace("@b", OrganizationID));
try
{
IDbTransaction transaction = con.BeginTransaction();
try
{
con.Execute(updatesqlstb.ToString(), null, transaction);
transaction.Commit();
}
catch (Exception exception)
{
transaction.Rollback();
MessageBox.Show("数据库错误--事务回滚!" + exception.ToString());
}
//
}
catch (Exception ext)
{
MessageBox.Show("数据库错误!" + ext.ToString());
}
}
}
}
con.Close();
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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