### 2023-02-21更新

------
#### SuperDesign    V3.0.2302.2101
- *.[新增]全新文本编辑器,支持高亮、FTP查看和编辑、目录浏览,历史版本等众多功能。
This commit is contained in:
鑫Intel committed 2023-02-21 09:46:13 +08:00
1 parent c7b33920bd
commit 03bcb8c5fd
406 files changed
+312053 -48889

No files matched your search

+390
View File
@@ -0,0 +1,390 @@
namespace 开发辅助工具.Tools
{
partial class APIEditor
{
/// <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.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(APIEditor));
this.label1 = new System.Windows.Forms.Label();
this.TxtUrl = new ryControls.TextBoxEx2();
this.label2 = new System.Windows.Forms.Label();
this.TxtName = new ryControls.TextBoxEx2();
this.label3 = new System.Windows.Forms.Label();
this.LvPostData = new BrightIdeasSoftware.ObjectListView();
this.OlvParamName = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.OlvTitle = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.OlvParamValue = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.OlvDesc = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.设置时间戳ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.添加参数ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.删除参数ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BtnCancel = new ryControls.ButtonEx();
this.BtnOK = new ryControls.ButtonEx();
this.BtnAddPost = new ryControls.ButtonEx();
this.BtnDelPost = new ryControls.ButtonEx();
this.TxtAPIName = new ryControls.TextBoxEx2();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.TxtDesc = new ryControls.TextBoxEx2();
((System.ComponentModel.ISupportInitialize)(this.LvPostData)).BeginInit();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(23, 12);
this.label1.TabIndex = 0;
this.label1.Text = "Url";
//
// TxtUrl
//
this.TxtUrl.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TxtUrl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192)))));
this.TxtUrl.EmptyText = "";
this.TxtUrl.Location = new System.Drawing.Point(41, 40);
this.TxtUrl.MaxLength = 999999999;
this.TxtUrl.Multiline = false;
this.TxtUrl.Name = "TxtUrl";
this.TxtUrl.OnlyNumeric = false;
this.TxtUrl.PasswordChar = '\0';
this.TxtUrl.ReadOnly = true;
this.TxtUrl.SelectedText = "";
this.TxtUrl.SelectionLength = 0;
this.TxtUrl.SelectionStart = 0;
this.TxtUrl.Size = new System.Drawing.Size(652, 27);
this.TxtUrl.TabIndex = 1;
this.TxtUrl.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
this.TxtUrl.ToolTip = "";
this.TxtUrl.WordWrap = true;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 14);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 12);
this.label2.TabIndex = 2;
this.label2.Text = "名称";
//
// TxtName
//
this.TxtName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TxtName.BackColor = System.Drawing.Color.White;
this.TxtName.EmptyText = "请输入名称";
this.TxtName.Location = new System.Drawing.Point(41, 7);
this.TxtName.MaxLength = 999999999;
this.TxtName.Multiline = false;
this.TxtName.Name = "TxtName";
this.TxtName.OnlyNumeric = false;
this.TxtName.PasswordChar = '\0';
this.TxtName.ReadOnly = false;
this.TxtName.SelectedText = "";
this.TxtName.SelectionLength = 0;
this.TxtName.SelectionStart = 0;
this.TxtName.Size = new System.Drawing.Size(352, 27);
this.TxtName.TabIndex = 0;
this.TxtName.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
this.TxtName.ToolTip = "";
this.TxtName.WordWrap = true;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(9, 92);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(29, 12);
this.label3.TabIndex = 4;
this.label3.Text = "参数";
//
// LvPostData
//
this.LvPostData.AllColumns.Add(this.OlvParamName);
this.LvPostData.AllColumns.Add(this.OlvTitle);
this.LvPostData.AllColumns.Add(this.OlvParamValue);
this.LvPostData.AllColumns.Add(this.OlvDesc);
this.LvPostData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.LvPostData.CellEditActivation = BrightIdeasSoftware.ObjectListView.CellEditActivateMode.DoubleClick;
this.LvPostData.CellEditUseWholeCell = false;
this.LvPostData.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.OlvParamName,
this.OlvTitle,
this.OlvParamValue,
this.OlvDesc});
this.LvPostData.ContextMenuStrip = this.contextMenuStrip1;
this.LvPostData.Cursor = System.Windows.Forms.Cursors.Default;
this.LvPostData.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.LvPostData.FullRowSelect = true;
this.LvPostData.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.LvPostData.HideSelection = false;
this.LvPostData.Location = new System.Drawing.Point(41, 92);
this.LvPostData.MultiSelect = false;
this.LvPostData.Name = "LvPostData";
this.LvPostData.RowHeight = 25;
this.LvPostData.Size = new System.Drawing.Size(653, 292);
this.LvPostData.TabIndex = 5;
this.LvPostData.UseCellFormatEvents = true;
this.LvPostData.UseCompatibleStateImageBehavior = false;
this.LvPostData.View = System.Windows.Forms.View.Details;
this.LvPostData.CellEditFinishing += new BrightIdeasSoftware.CellEditEventHandler(this.LvPostData_CellEditFinishing);
//
// OlvParamName
//
this.OlvParamName.Text = "参数名";
this.OlvParamName.Width = 120;
//
// OlvTitle
//
this.OlvTitle.IsEditable = true;
this.OlvTitle.Text = "标题";
this.OlvTitle.Width = 100;
//
// OlvParamValue
//
this.OlvParamValue.IsEditable = true;
this.OlvParamValue.Text = "参数值";
this.OlvParamValue.Width = 210;
//
// OlvDesc
//
this.OlvDesc.IsEditable = true;
this.OlvDesc.Text = "备注";
this.OlvDesc.Width = 200;
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.设置时间戳ToolStripMenuItem,
this.toolStripMenuItem1,
this.添加参数ToolStripMenuItem,
this.删除参数ToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(137, 76);
//
// 设置时间戳ToolStripMenuItem
//
this.设置时间戳ToolStripMenuItem.Name = "设置时间戳ToolStripMenuItem";
this.设置时间戳ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.设置时间戳ToolStripMenuItem.Text = "设置时间戳";
this.设置时间戳ToolStripMenuItem.Click += new System.EventHandler(this.设置时间戳ToolStripMenuItem_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(133, 6);
//
// 添加参数ToolStripMenuItem
//
this.添加参数ToolStripMenuItem.Name = "添加参数ToolStripMenuItem";
this.添加参数ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.添加参数ToolStripMenuItem.Text = "添加参数";
this.添加参数ToolStripMenuItem.Click += new System.EventHandler(this.添加参数ToolStripMenuItem_Click);
//
// 删除参数ToolStripMenuItem
//
this.删除参数ToolStripMenuItem.Name = "删除参数ToolStripMenuItem";
this.删除参数ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.删除参数ToolStripMenuItem.Text = "删除参数";
this.删除参数ToolStripMenuItem.Click += new System.EventHandler(this.删除参数ToolStripMenuItem_Click);
//
// BtnCancel
//
this.BtnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnCancel.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
this.BtnCancel.Location = new System.Drawing.Point(618, 509);
this.BtnCancel.Name = "BtnCancel";
this.BtnCancel.Size = new System.Drawing.Size(75, 30);
this.BtnCancel.TabIndex = 7;
this.BtnCancel.Text = "取消";
this.BtnCancel.UseVisualStyleBackColor = true;
this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// BtnOK
//
this.BtnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnOK.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
this.BtnOK.Location = new System.Drawing.Point(537, 509);
this.BtnOK.Name = "BtnOK";
this.BtnOK.Size = new System.Drawing.Size(75, 30);
this.BtnOK.TabIndex = 6;
this.BtnOK.Text = "确定";
this.BtnOK.UseVisualStyleBackColor = true;
this.BtnOK.Click += new System.EventHandler(this.BtnOK_Click);
//
// BtnAddPost
//
this.BtnAddPost.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
this.BtnAddPost.Location = new System.Drawing.Point(41, 68);
this.BtnAddPost.Name = "BtnAddPost";
this.BtnAddPost.Size = new System.Drawing.Size(30, 23);
this.BtnAddPost.TabIndex = 8;
this.BtnAddPost.Text = "+";
this.BtnAddPost.UseVisualStyleBackColor = true;
this.BtnAddPost.Click += new System.EventHandler(this.BtnAddPost_Click);
//
// BtnDelPost
//
this.BtnDelPost.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
this.BtnDelPost.Location = new System.Drawing.Point(77, 68);
this.BtnDelPost.Name = "BtnDelPost";
this.BtnDelPost.Size = new System.Drawing.Size(30, 23);
this.BtnDelPost.TabIndex = 9;
this.BtnDelPost.Text = "-";
this.BtnDelPost.UseVisualStyleBackColor = true;
this.BtnDelPost.Click += new System.EventHandler(this.BtnDel_Click);
//
// TxtAPIName
//
this.TxtAPIName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.TxtAPIName.BackColor = System.Drawing.Color.White;
this.TxtAPIName.EmptyText = "请输入API名称";
this.TxtAPIName.Location = new System.Drawing.Point(448, 7);
this.TxtAPIName.MaxLength = 999999999;
this.TxtAPIName.Multiline = false;
this.TxtAPIName.Name = "TxtAPIName";
this.TxtAPIName.OnlyNumeric = false;
this.TxtAPIName.PasswordChar = '\0';
this.TxtAPIName.ReadOnly = false;
this.TxtAPIName.SelectedText = "";
this.TxtAPIName.SelectionLength = 0;
this.TxtAPIName.SelectionStart = 0;
this.TxtAPIName.Size = new System.Drawing.Size(245, 27);
this.TxtAPIName.TabIndex = 11;
this.TxtAPIName.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
this.TxtAPIName.ToolTip = "";
this.TxtAPIName.WordWrap = true;
//
// label4
//
this.label4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(395, 14);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(47, 12);
this.label4.TabIndex = 10;
this.label4.Text = "API名称";
//
// label5
//
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(9, 391);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(29, 12);
this.label5.TabIndex = 12;
this.label5.Text = "备注";
//
// TxtDesc
//
this.TxtDesc.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.TxtDesc.BackColor = System.Drawing.Color.White;
this.TxtDesc.EmptyText = "";
this.TxtDesc.Location = new System.Drawing.Point(41, 391);
this.TxtDesc.MaxLength = 999999999;
this.TxtDesc.Multiline = true;
this.TxtDesc.Name = "TxtDesc";
this.TxtDesc.OnlyNumeric = false;
this.TxtDesc.PasswordChar = '\0';
this.TxtDesc.ReadOnly = false;
this.TxtDesc.SelectedText = "";
this.TxtDesc.SelectionLength = 0;
this.TxtDesc.SelectionStart = 0;
this.TxtDesc.Size = new System.Drawing.Size(652, 112);
this.TxtDesc.TabIndex = 13;
this.TxtDesc.TextAlign = System.Windows.Forms.HorizontalAlignment.Left;
this.TxtDesc.ToolTip = "";
this.TxtDesc.WordWrap = true;
//
// APIEditor
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(709, 549);
this.Controls.Add(this.TxtDesc);
this.Controls.Add(this.label5);
this.Controls.Add(this.TxtAPIName);
this.Controls.Add(this.label4);
this.Controls.Add(this.BtnDelPost);
this.Controls.Add(this.BtnAddPost);
this.Controls.Add(this.BtnCancel);
this.Controls.Add(this.BtnOK);
this.Controls.Add(this.LvPostData);
this.Controls.Add(this.label3);
this.Controls.Add(this.TxtName);
this.Controls.Add(this.label2);
this.Controls.Add(this.TxtUrl);
this.Controls.Add(this.label1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "APIEditor";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "API编辑器";
this.Load += new System.EventHandler(this.APIEditor_Load);
this.Shown += new System.EventHandler(this.APIEditor_Shown);
((System.ComponentModel.ISupportInitialize)(this.LvPostData)).EndInit();
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private ryControls.TextBoxEx2 TxtUrl;
private System.Windows.Forms.Label label2;
private ryControls.TextBoxEx2 TxtName;
private System.Windows.Forms.Label label3;
private BrightIdeasSoftware.ObjectListView LvPostData;
private BrightIdeasSoftware.OLVColumn OlvParamName;
private BrightIdeasSoftware.OLVColumn OlvTitle;
private BrightIdeasSoftware.OLVColumn OlvParamValue;
private BrightIdeasSoftware.OLVColumn OlvDesc;
private ryControls.ButtonEx BtnCancel;
private ryControls.ButtonEx BtnOK;
private ryControls.ButtonEx BtnAddPost;
private ryControls.ButtonEx BtnDelPost;
private ryControls.TextBoxEx2 TxtAPIName;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem 添加参数ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem 删除参数ToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem 设置时间戳ToolStripMenuItem;
private System.Windows.Forms.Label label5;
private ryControls.TextBoxEx2 TxtDesc;
}
}
@@ -0,0 +1,450 @@
using Newtonsoft.Json.Linq;
using ryCommon;
using ryCommonDb;
using 开发辅助工具.Controls;
using 开发辅助工具.Tools.API;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using 开发辅助工具.Manager;
using 开发辅助工具.Tools;
namespace 开发辅助工具.Tools
{
public partial class APIEditor : Form
{
public APIEditor()
{
InitializeComponent();
OlvTitle.AspectGetter = delegate (object x) { return ((PostInfo)x).Title; };
OlvParamName.AspectGetter = delegate (object x) { return ((PostInfo)x).ParamName; };
OlvParamValue.AspectGetter = delegate (object x) { return ((PostInfo)x).ParamValue; };
OlvParamValue.AspectToStringConverter = delegate (object rowdata,object x) {
var row = (PostInfo)rowdata;
if (row.ParamValue.IsInt())
{
long time = row.ParamValue.ToInt64();
if (time <= 100000) { return row.ParamValue; }
var dt = time.ToDateTime();
if (dt == DateTime.MinValue || dt<=new DateTime(2000,1,1) || dt >= new DateTime(2100, 1, 1)) { return row.ParamValue; }
if (dt == dt.Date) {return dt.ToString("yyyy-MM-dd"); }
return dt.ToString("yyyy-MM-dd HH:mm:ss");
}
return row.ParamValue;
};
OlvDesc.AspectGetter = delegate (object x) { return ((PostInfo)x).Desc; };
LvPostData.FormatCell += LvPostData_FormatCell;
}
Font bold_font = new Font("Consolas",9,FontStyle.Bold);
private void LvPostData_FormatCell(object sender, BrightIdeasSoftware.FormatCellEventArgs e)
{
if(e.Column ==OlvParamName)
{
e.SubItem.Font = bold_font;
e.SubItem.BackColor = Color.FromArgb(255, 255, 192);
}
else if (e.Column == OlvTitle || e.Column==OlvDesc)
{
e.SubItem.ForeColor = Color.Gray;
}
}
public void LoadData(Uri uri,string postdata,bool isGetMode=false)
{
var host = uri.Host.ToLower();
if (host.IndexOfEx("www.87g") == 0 || host.IndexOfEx("www.3h3") == 0
|| host.IndexOfEx("www.downxia") == 0 || host.IndexOfEx("www.downbank") == 0)
{
if (isGetMode)
{
TxtUrl.Text = "<site>" + uri.AbsolutePath;
}
else
{
TxtUrl.Text = "<site>" + uri.PathAndQuery;
}
var urlparam = RyWeb.WebDecode.UrlToData(uri.OriginalString);
TxtAPIName.Text = urlparam.Get("a");
if (TxtAPIName.Text.Length==0)
{
TxtAPIName.Text = urlparam.Get("api");
}
}
else
{
if (isGetMode)
{
TxtUrl.Text = uri.Scheme+"://" +uri.Host+(uri.Port==80?"":(":"+uri.Port))+ uri.AbsolutePath;
}
else
{
TxtUrl.Text = uri.OriginalString;
}
}
LvPostData.ClearObjects();
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
{
RyQuickSQL mySQL = new RyQuickSQL("api");
mySQL.AddField("Name", TxtName.Text);
mySQL.AddField("Url", TxtUrl.Text);
DataSet ds = db.ReadData("select * from api where Url=@Url", mySQL);
var json_post = "";
if (ds.HaveData())
{
var row = ds.GetFirstRowData();
TxtName.Text = row["Name"].ToString();
TxtAPIName.Text = row["APIName"].ToString();
TxtDesc.Text = row["desc"].ToString();
json_post = row["Postdata"].ToString();
}
JObject jo;
if (json_post.Length == 0) { jo = new JObject(); }
else { jo = JObject.Parse(json_post); }
Dictionary<string, PostInfo> dict_post = new Dictionary<string, PostInfo>();
if (jo.ContainsKey("list"))
{
JArray jarr = JArray.Parse(jo["list"].ToString());
for (int i = 0; i < jarr.Count; i++)
{
var item = jarr[i];
var param_name = item["paramname"].ToString();
if (!dict_post.ContainsKey(param_name))
{
dict_post.Add(param_name, new PostInfo()
{
Title = item["title"].ToString(),
ParamName = param_name,
Desc = item["desc"].ToString(),
});
}
}
}
var post = RyWeb.WebDecode.UrlToData(isGetMode?uri.OriginalString:("f?" + postdata));
List<KeyValuePair<string, string>> post_list;
if (post.Item2 == null)
{
post_list = new List<KeyValuePair<string, string>>();
}
else
{
post_list = post.Item2.ToList();
}
List<PostInfo> list = new List<PostInfo>();
if (post_list.Count > 0)
{
for (int i = 0; i < post_list.Count; i++)
{
var item = post_list[i];
var title = "";
var desc = "";
if (dict_post.ContainsKey(item.Key))
{
var value = dict_post[item.Key];
title = value.Title;
desc= value.Desc;
}
else
{
switch(item.Key.ToLower())
{
case "starttime":
title = "开始时间";
break;
case "endtime":
title = "结束时间";
break;
case "page":
title = "页码";
break;
case "pagesize":
title = "每页数量";
break;
case "title":
title = "标题";
break;
case "name":
title = "名称";
break;
case "id":
title = "id编号";
break;
case "modelid":
title = "资源类型";
break;
case "packagename":
case "pkgname":
title = "包名";
break;
case "filename":
title = "文件名";
break;
case "url":
title = "网址";
break;
case "username":
title = "用户名";
break;
case "realname":
title = "真实姓名";
break;
case "cooperid":
title = "合作包id";
break;
}
}
list.Add(new PostInfo() { ParamName = item.Key, ParamValue = item.Value,Title=title,Desc=desc });
}
}
LvPostData.AddObjects(list);
}
db.Free();
}
private void BtnCancel_Click(object sender, EventArgs e)
{
DialogResult= DialogResult.Cancel;
}
public string SelectedPostDatas { get; set; } = "";
private void BtnOK_Click(object sender, EventArgs e)
{
if(LvPostData.GetItemCount()==0)
{
MessageBox.Show("POST内容为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
{
RyQuickSQL mySQL = new RyQuickSQL("api");
mySQL.AddField("Name", TxtName.Text);
mySQL.AddField("Url", TxtUrl.Text);
mySQL.AddField("desc", TxtDesc.Text);
DataSet ds = db.ReadData("select * from api where Url=@Url", mySQL);
var json_post = "";
if(ds.HaveData())
{
json_post = ds.GetFirstRowData()["Postdata"].ToString();
}
mySQL.AddField("APIName",TxtAPIName.Text);
JObject jo;
if (json_post.Length == 0) { jo = new JObject(); }
else { jo = JObject.Parse(json_post); }
Dictionary<string,PostInfo> dict_post = new Dictionary<string, PostInfo>();
if(jo.ContainsKey("list"))
{
JArray jarr = JArray.Parse(jo["list"].ToString());
for (int i = 0; i < jarr.Count; i++)
{
var item = jarr[i];
var param_name = item["paramname"].ToString("");
if (!dict_post.ContainsKey(param_name))
{
dict_post.Add(param_name, new PostInfo()
{
Title = item["title"].ToString(""),
ParamName = param_name,
Desc = item["desc"].ToString(""),
ParamValue = item["paramvalue"].ToString(""),
IsAdd = false
}) ;
}
}
}
var list = LvPostData.ObjectsList;
var post = "";
for (int i = 0; i < list.Count; i++)
{
var item = (PostInfo)list[i];
if (post.Length > 0) { post += "&"; }
if (item.ParamValue.IsEngOrNum())
{
post += item.ParamName + "=" + item.ParamValue;
}
else
{
post += item.ParamName + "=" +RyWeb.WebDecode.UrlEncode(item.ParamValue);
}
if(dict_post.ContainsKey(item.ParamName))
{
item.ParamValue = dict_post[item.ParamName].ParamValue;
dict_post[item.ParamName] = item;
}
else
{
dict_post.Add(item.ParamName,item);
}
}
SelectedPostDatas = post;
JObject jo_new=new JObject();
JArray jarr_new=new JArray();
foreach (var item in dict_post)
{
JObject jo_item = new JObject
{
{ "paramname", item.Value.ParamName },
{ "title", item.Value.Title },
{ "paramvalue", item.Value.ParamValue },
{ "desc", item.Value.Desc }
};
jarr_new.Add(jo_item);
}
jo_new.Add("list",jarr_new);
mySQL.AddField("Postdata", jo_new.ToString());
if (db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where Url=@Url", mySQL) == 0)
{
mySQL.AddField("ClickCount", 0);//点击次数
mySQL.AddField("editTime", DateTime.Now);
mySQL.AddField("addTime", DateTime.Now);
db.Insert(mySQL);
}
}
db.Free();
DialogResult = DialogResult.OK;
}
private void LvPostData_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
{
if (e.Cancel) { return; }
var row = (PostInfo)e.RowObject;
if (e.Column==OlvTitle)
{
row.Title = e.NewValue.ToString();
}
else if (e.Column == OlvParamValue)
{
row.ParamValue = e.NewValue.ToString();
}
else if (e.Column == OlvDesc)
{
row.Desc = e.NewValue.ToString();
}
}
private void BtnDel_Click(object sender, EventArgs e)
{
if (LvPostData.SelectedObject == null) { return; }
switch (MessageBox.Show("是否要删除选定项", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
{
case DialogResult.Yes:
LvPostData.RemoveObjects(LvPostData.SelectedObjects);
break;
}
}
private void APIEditor_Shown(object sender, EventArgs e)
{
TxtName.SelectionLength = 0;
}
private void BtnAddPost_Click(object sender, EventArgs e)
{
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
{
RyQuickSQL mySQL = new RyQuickSQL("api");
mySQL.AddField("Url", TxtUrl.Text);
DataSet ds = db.ReadData("select * from api where Url=@Url", mySQL);
var json_post = "";
if (ds.HaveData())
{
var row = ds.GetFirstRowData();
json_post = row["Postdata"].ToString();
}
JObject jo;
if (json_post.Length == 0) { jo = new JObject(); }
else { jo = JObject.Parse(json_post); }
Dictionary<string, PostInfo> dict_post = new Dictionary<string, PostInfo>();
List<PostInfo> list = new List<PostInfo>();
var list_lv = LvPostData.ObjectsList;
for (int i = 0; i < list_lv.Count; i++)
{
var item = (PostInfo)list_lv[i];
dict_post[item.ParamName] = item;
}
if (jo.ContainsKey("list"))
{
JArray jarr = JArray.Parse(jo["list"].ToString());
for (int i = 0; i < jarr.Count; i++)
{
var item = jarr[i];
var param_name = item["paramname"].ToString();
if (!dict_post.ContainsKey(param_name))
{
list.Add(new PostInfo()
{
ParamName = param_name,
Title = item["title"].ToString(),
Desc = item["desc"].ToString(),
ParamValue = item["paramvalue"].ToString()
});
}
}
}
FrmAddPostParam frm = new FrmAddPostParam();
frm.Url = TxtUrl.Text;
frm.LvPostData.AddObjects(list);
if (frm.ShowDialog() == DialogResult.OK)
{
var item = frm.SelectedItem;
item.IsAdd = false;
LvPostData.AddObject(item);
}
frm.Dispose();
}
db.Free();
}
private void APIEditor_Load(object sender, EventArgs e)
{
}
private void 添加参数ToolStripMenuItem_Click(object sender, EventArgs e)
{
BtnAddPost.PerformClick();
}
private void 删除参数ToolStripMenuItem_Click(object sender, EventArgs e)
{
BtnDelPost.PerformClick();
}
private void 设置时间戳ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (LvPostData.SelectedObject == null) { return; }
var item = (PostInfo)LvPostData.SelectedObject;
FrmInsertUnixTime frm = new FrmInsertUnixTime();
frm.Icon = Icon;
var text = item.ParamValue;
if (text.Length > 4 && text.IsInt())
{
frm.dateTimePickerEX1.Value = RyDate.UnixTimeToDateTime(text);
}
if (frm.ShowDialog() == DialogResult.OK)
{
item.ParamValue= RyDate.DateTimeToUnixTime(frm.dateTimePickerEX1.Value).ToString();
LvPostData.RefreshObject(item);
}
frm.Dispose();
}
}
public class PostInfo
{
public string Title { get; set; } = "";
public string ParamName { get; set; } = "";
public string ParamValue { get; set; } = "";
public string Desc { get; set; } = "";
/// <summary>
/// 是否是json新增的内容
/// </summary>
public bool IsAdd { get; set; } = true;
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,149 @@
namespace 开发辅助工具.Tools.API
{
partial class FrmAddPostParam
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmAddPostParam));
this.LvPostData = new BrightIdeasSoftware.ObjectListView();
this.OlvParamName = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.OlvTitle = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.OlvParamValue = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.OlvDesc = ((BrightIdeasSoftware.OLVColumn)(new BrightIdeasSoftware.OLVColumn()));
this.BtnCancel = new ryControls.ButtonEx();
this.BtnOK = new ryControls.ButtonEx();
((System.ComponentModel.ISupportInitialize)(this.LvPostData)).BeginInit();
this.SuspendLayout();
//
// LvPostData
//
this.LvPostData.AllColumns.Add(this.OlvParamName);
this.LvPostData.AllColumns.Add(this.OlvTitle);
this.LvPostData.AllColumns.Add(this.OlvParamValue);
this.LvPostData.AllColumns.Add(this.OlvDesc);
this.LvPostData.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.LvPostData.CellEditActivation = BrightIdeasSoftware.ObjectListView.CellEditActivateMode.DoubleClick;
this.LvPostData.CellEditUseWholeCell = false;
this.LvPostData.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.OlvParamName,
this.OlvTitle,
this.OlvParamValue,
this.OlvDesc});
this.LvPostData.Cursor = System.Windows.Forms.Cursors.Default;
this.LvPostData.Font = new System.Drawing.Font("Consolas", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.LvPostData.FullRowSelect = true;
this.LvPostData.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.LvPostData.HideSelection = false;
this.LvPostData.Location = new System.Drawing.Point(12, 12);
this.LvPostData.MultiSelect = false;
this.LvPostData.Name = "LvPostData";
this.LvPostData.RowHeight = 25;
this.LvPostData.Size = new System.Drawing.Size(653, 443);
this.LvPostData.TabIndex = 6;
this.LvPostData.UseCellFormatEvents = true;
this.LvPostData.UseCompatibleStateImageBehavior = false;
this.LvPostData.View = System.Windows.Forms.View.Details;
this.LvPostData.CellEditFinishing += new BrightIdeasSoftware.CellEditEventHandler(this.LvPostData_CellEditFinishing);
this.LvPostData.CellClick += new System.EventHandler<BrightIdeasSoftware.CellClickEventArgs>(this.LvPostData_CellClick);
this.LvPostData.DoubleClick += new System.EventHandler(this.LvPostData_DoubleClick);
//
// OlvParamName
//
this.OlvParamName.Text = "参数名";
this.OlvParamName.Width = 100;
//
// OlvTitle
//
this.OlvTitle.IsEditable = true;
this.OlvTitle.Text = "标题";
this.OlvTitle.Width = 100;
//
// OlvParamValue
//
this.OlvParamValue.IsEditable = true;
this.OlvParamValue.Text = "参数默认值";
this.OlvParamValue.Width = 110;
//
// OlvDesc
//
this.OlvDesc.IsEditable = true;
this.OlvDesc.Text = "备注";
this.OlvDesc.Width = 200;
//
// BtnCancel
//
this.BtnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnCancel.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
this.BtnCancel.Location = new System.Drawing.Point(589, 461);
this.BtnCancel.Name = "BtnCancel";
this.BtnCancel.Size = new System.Drawing.Size(75, 30);
this.BtnCancel.TabIndex = 9;
this.BtnCancel.Text = "取消";
this.BtnCancel.UseVisualStyleBackColor = true;
this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// BtnOK
//
this.BtnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.BtnOK.BaseColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(76)))), ((int)(((byte)(95)))));
this.BtnOK.Location = new System.Drawing.Point(508, 461);
this.BtnOK.Name = "BtnOK";
this.BtnOK.Size = new System.Drawing.Size(75, 30);
this.BtnOK.TabIndex = 8;
this.BtnOK.Text = "确定";
this.BtnOK.UseVisualStyleBackColor = true;
this.BtnOK.Click += new System.EventHandler(this.BtnOK_Click);
//
// FrmAddPostParam
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(677, 501);
this.Controls.Add(this.BtnCancel);
this.Controls.Add(this.BtnOK);
this.Controls.Add(this.LvPostData);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "FrmAddPostParam";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "添加参数";
((System.ComponentModel.ISupportInitialize)(this.LvPostData)).EndInit();
this.ResumeLayout(false);
}
#endregion
private BrightIdeasSoftware.OLVColumn OlvParamName;
private BrightIdeasSoftware.OLVColumn OlvTitle;
private BrightIdeasSoftware.OLVColumn OlvDesc;
private ryControls.ButtonEx BtnCancel;
private ryControls.ButtonEx BtnOK;
public BrightIdeasSoftware.ObjectListView LvPostData;
private BrightIdeasSoftware.OLVColumn OlvParamValue;
}
}
@@ -0,0 +1,135 @@
using Newtonsoft.Json.Linq;
using ryCommon;
using ryCommonDb;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using 开发辅助工具.Manager;
namespace 开发辅助工具.Tools.API
{
public partial class FrmAddPostParam : Form
{
public FrmAddPostParam()
{
InitializeComponent();
OlvTitle.AspectGetter = delegate (object x) { return ((PostInfo)x).Title; };
OlvParamName.AspectGetter = delegate (object x) { return ((PostInfo)x).ParamName; };
OlvParamValue.AspectGetter = delegate (object x) { return ((PostInfo)x).ParamValue; };
OlvDesc.AspectGetter = delegate (object x) { return ((PostInfo)x).Desc; };
}
public string Url { get; set; } = "";
private void BtnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
public PostInfo SelectedItem { get; set; } = null;
private void BtnOK_Click(object sender, EventArgs e)
{
if (LvPostData.SelectedObject == null) { return; }
SelectedItem = (PostInfo)LvPostData.SelectedObject;
DialogResult= DialogResult.OK;
}
private void LvPostData_DoubleClick(object sender, EventArgs e)
{
}
private void LvPostData_CellEditFinishing(object sender, BrightIdeasSoftware.CellEditEventArgs e)
{
var row = (PostInfo)e.RowObject;
if (e.Cancel) { return; }
if (e.Column == OlvTitle)
{
row.Title = e.NewValue.ToString();
}
else if (e.Column == OlvParamValue)
{
row.ParamValue = e.NewValue.ToString();
}
else if (e.Column == OlvDesc)
{
row.Desc = e.NewValue.ToString();
}
IDbInterface db = Itrycn_Db.CreateDataProvider(Itrycn_Db.dataType);
if (db.ConnDb(Itrycn_Db.User_SQLConn) == 1)
{
RyQuickSQL mySQL = new RyQuickSQL("api");
mySQL.AddField("Url",Url);
DataSet ds = db.ReadData("select * from api where Url=@Url", mySQL);
var json_post = "";
if (ds.HaveData())
{
json_post = ds.GetFirstRowData()["Postdata"].ToString();
}
JObject jo;
if (json_post.Length == 0) { jo = new JObject(); }
else { jo = JObject.Parse(json_post); }
Dictionary<string, PostInfo> dict_post = new Dictionary<string, PostInfo>();
if (jo.ContainsKey("list"))
{
JArray jarr = JArray.Parse(jo["list"].ToString());
for (int i = 0; i < jarr.Count; i++)
{
var item = jarr[i];
var param_name = item["paramname"].ToString("");
if (!dict_post.ContainsKey(param_name))
{
dict_post.Add(param_name, new PostInfo()
{
Title = item["title"].ToString(""),
ParamName = param_name,
Desc = item["desc"].ToString(""),
ParamValue = item["paramvalue"].ToString(""),
IsAdd = false
});
}
}
}
if (dict_post.ContainsKey(row.ParamName))
{
dict_post[row.ParamName] = row;
}
else
{
dict_post.Add(row.ParamName, row);
}
JObject jo_new = new JObject();
JArray jarr_new = new JArray();
foreach (var item in dict_post)
{
JObject jo_item = new JObject
{
{ "paramname", item.Value.ParamName },
{ "title", item.Value.Title },
{ "paramvalue", item.Value.ParamValue },
{ "desc", item.Value.Desc }
};
jarr_new.Add(jo_item);
}
jo_new.Add("list", jarr_new);
mySQL.AddField("Postdata", jo_new.ToString());
if (db.ExecuteNonQuery(mySQL.GetUpdateSQL() + " where Url=@Url", mySQL) == 0)
{
}
}
db.Free();
}
private void LvPostData_CellClick(object sender, BrightIdeasSoftware.CellClickEventArgs e)
{
if(e.ClickCount==2 && e.Column==OlvParamName)
{
BtnOK.PerformClick();
}
}
}
}
File diff suppressed because it is too large. Load diff