SVN r484
SVN-Revision: r484
This commit is contained in:
+716
-401
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Control;
|
||||
using Lskj.Core;
|
||||
using Lskj.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -30,14 +31,102 @@ namespace Lskj.PubApiSetModule
|
||||
/// <param name="e"></param>
|
||||
private void OnFrmMainLoad(object sender, EventArgs e)
|
||||
{
|
||||
InitlizeSpiltLocation();
|
||||
InitEventApiTable();
|
||||
InitEventApiPmsTable();
|
||||
InitEvents();
|
||||
InitColumnsData();
|
||||
InitDataSource();
|
||||
InitApiTabDataSource();
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化数据源
|
||||
/// 初始化事件
|
||||
/// </summary>
|
||||
private void InitDataSource()
|
||||
private void InitEvents()
|
||||
{
|
||||
splitControlSend.SplitterPositionChanged += OnSplitContainerPositionChanged; ;
|
||||
sendMainView.FocusedRowObjectChanged += OnSendMainViewFocusedRowObjectChanged;
|
||||
btnApiAdd.Click += OnBtnAddClick;
|
||||
btnApiDelete.Click += OnBtnDeleteClick;
|
||||
btnApiSave.Click += OnBtnSaveClick;
|
||||
btnPmsAdd.Click += OnBtnAddClick;
|
||||
btnPmsDelete.Click += OnBtnDeleteClick;
|
||||
btnPmsSave.Click += OnBtnSaveClick;
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加按钮点击
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBtnAddClick(object sender, EventArgs e)
|
||||
{
|
||||
if (sender == btnApiAdd)
|
||||
{
|
||||
sendMainView.AddNewRow();
|
||||
}
|
||||
else if (sender == btnPmsAdd)
|
||||
{
|
||||
sendDetailView.AddNewRow();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除按钮点击
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBtnDeleteClick(object sender, EventArgs e)
|
||||
{
|
||||
if (sender == btnApiDelete)
|
||||
{
|
||||
sendMainView.DeleteRow(sendMainView.FocusedRowHandle);
|
||||
}
|
||||
else if (sender == btnPmsDelete)
|
||||
{
|
||||
sendDetailView.DeleteRow(sendDetailView.FocusedRowHandle);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存按钮点击
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnBtnSaveClick(object sender, EventArgs e)
|
||||
{
|
||||
if (sender == btnApiSave)
|
||||
{
|
||||
sendMainView.UpdateCurrentRow();
|
||||
if (sendMainView.DataSource != null && sendMainView.DataSource is DataTable sourceTable)
|
||||
{
|
||||
SendMainAdapterObj.Update(sourceTable);
|
||||
}
|
||||
}
|
||||
else if (sender == btnPmsSave)
|
||||
{
|
||||
sendDetailView.UpdateCurrentRow();
|
||||
if (sendDetailView.DataSource != null && sendDetailView.DataSource is DataTable sourceTable)
|
||||
{
|
||||
SendDetailAdapterObj.Update(sourceTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中行改变时
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnSendMainViewFocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
|
||||
{
|
||||
if (e.Row is DataRowView dataRowView)
|
||||
{
|
||||
DataRow focusedRow = dataRowView.Row;
|
||||
string apiId = focusedRow["id"] + "";
|
||||
InitApiPmsTabDataSource(apiId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化接口主表数据源
|
||||
/// </summary>
|
||||
private void InitApiTabDataSource()
|
||||
{
|
||||
//SendMain
|
||||
SendMainAdapterObj = BaseImpl.GetAdapterResult("select * from p_systemeventapitab");
|
||||
@@ -51,10 +140,23 @@ namespace Lskj.PubApiSetModule
|
||||
sendGcDetail.DataSource = sendDetailTable;
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化表格数据源
|
||||
/// 初始化接口明细表数据源
|
||||
/// </summary>
|
||||
private void InitApiPmsTabDataSource(string apiId)
|
||||
{
|
||||
//SendDetail
|
||||
SendDetailAdapterObj = BaseImpl.GetAdapterResult($"select * from p_systemeventapipmstab where apiid = '{apiId}'");
|
||||
DataTable sendDetailTable = new DataTable();
|
||||
SendMainAdapterObj.Fill(sendDetailTable);
|
||||
sendGcDetail.DataSource = sendDetailTable;
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化表格列
|
||||
/// </summary>
|
||||
private void InitColumnsData()
|
||||
{
|
||||
#region 主表
|
||||
idColumn.OptionsColumn.AllowEdit = false;
|
||||
//reqDataType
|
||||
reqDataTypeComboBox.Items.Add(new ComBoxModel() { Value = 1, Text = "Json" });
|
||||
reqDataTypeComboBox.Items.Add(new ComBoxModel() { Value = 0, Text = "Text" });
|
||||
@@ -86,12 +188,34 @@ namespace Lskj.PubApiSetModule
|
||||
eTypeCodeComboBox.Items.Add(new ComBoxModel() { Value = "21", Text = "提交审核" });
|
||||
eTypeCodeComboBox.Items.Add(new ComBoxModel() { Value = "31", Text = "审核" });
|
||||
eTypeCodeComboBox.Items.Add(new ComBoxModel() { Value = "32", Text = "反审" });
|
||||
//pmsType
|
||||
pmsTypeComboBox.Items.Add(new ComBoxModel() { Value = "1", Text = "老版" });
|
||||
pmsTypeComboBox.Items.Add(new ComBoxModel() { Value = "2", Text = "新版" });
|
||||
//allowShowMsg
|
||||
allowShowMsgComboBox.Items.Add(new ComBoxModel() { Value = "0", Text = "不提示" });
|
||||
allowShowMsgComboBox.Items.Add(new ComBoxModel() { Value = "1", Text = "提示" });
|
||||
//disableTag
|
||||
disableTagComboBox.Items.Add(new ComBoxModel() { Value = "0", Text = "启用" });
|
||||
disableTagComboBox.Items.Add(new ComBoxModel() { Value = "1", Text = "禁用" });
|
||||
#endregion
|
||||
#region 明细表
|
||||
pmsIdColumn.OptionsColumn.AllowEdit = false;
|
||||
//pmType
|
||||
pmTypeComboBox.Items.Add(new ComBoxModel() { Value = "0", Text = "发送参数" });
|
||||
pmTypeComboBox.Items.Add(new ComBoxModel() { Value = "2", Text = "Header参数" });
|
||||
pmTypeComboBox.Items.Add(new ComBoxModel() { Value = "1", Text = "接收参数" });
|
||||
//valueType
|
||||
valueTypeComboBox.Items.Add(new ComBoxModel() { Value = "0", Text = "json值" });
|
||||
valueTypeComboBox.Items.Add(new ComBoxModel() { Value = "1", Text = "json对象" });
|
||||
valueTypeComboBox.Items.Add(new ComBoxModel() { Value = "2", Text = "json数组" });
|
||||
//valueDataType
|
||||
valueDataTypeComboBox.Items.Add(new ComBoxModel() { Value = "0", Text = "文本" });
|
||||
valueDataTypeComboBox.Items.Add(new ComBoxModel() { Value = "1", Text = "整数" });
|
||||
valueDataTypeComboBox.Items.Add(new ComBoxModel() { Value = "2", Text = "小数" });
|
||||
//allowNull
|
||||
allowNullComboBox.Items.Add(new ComBoxModel() { Value = "1", Text = "必填" });
|
||||
allowNullComboBox.Items.Add(new ComBoxModel() { Value = "0", Text = "非必填" });
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建数据表
|
||||
@@ -131,4 +255,80 @@ namespace Lskj.PubApiSetModule
|
||||
DataRow[] dataRows = columnsTab.Select().Where(n => (n["name"] + "").Equals(colunmField.Key)).ToArray();
|
||||
if (dataRows.Length == 0)
|
||||
{
|
||||
string addColSql =
|
||||
string addColSql = string.Format("alter table p_systemEventApiTab add {0} {1}", colunmField.Key, colunmField.Value);
|
||||
SqlHelper.ExecuteNonQuery(addColSql);//添加列
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string createTabSql = "create table p_systemEventApiTab(id int IDENTITY(1,1) NOT NULL,{0})";
|
||||
string createCol = string.Empty;
|
||||
foreach (KeyValuePair<string, string> colunmField in colDic)
|
||||
{
|
||||
createCol += string.Format("{0} {1},", colunmField.Key, colunmField.Value);
|
||||
}
|
||||
createTabSql = string.Format(createTabSql, createCol.TrimEnd(','));
|
||||
SqlHelper.ExecuteNonQuery(createTabSql);//创建表
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 构建数据表
|
||||
/// </summary>
|
||||
private bool InitEventApiPmsTable()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string> colDic = new Dictionary<string, string>();
|
||||
colDic.Add("apiId", "int");
|
||||
colDic.Add("title", "varchar(200)");
|
||||
colDic.Add("pmType", "int");
|
||||
colDic.Add("valueType", "int");
|
||||
colDic.Add("pmsDataSource", "varchar(8000)");
|
||||
colDic.Add("name", "varchar(100)");
|
||||
colDic.Add("value", "varchar(8000)");
|
||||
colDic.Add("valueDataType", "int");
|
||||
colDic.Add("unionPmsId", "int");
|
||||
colDic.Add("allowNull", "int");
|
||||
string isExitApiTab = "select top 1 * from sysObjects where Id=OBJECT_ID(N'P_systemEventApiPmsTab') and xtype='U'";
|
||||
DataTable apiTab = SqlHelper.ExecuteDataTable(isExitApiTab);
|
||||
if (apiTab.Rows.Count > 0)//存在日志表
|
||||
{
|
||||
DataTable columnsTab = SqlHelper.ExecuteDataTable(string.Format("select name from syscolumns where id=object_id('P_systemEventApiPmsTab')"));
|
||||
foreach (KeyValuePair<string, string> colunmField in colDic)
|
||||
{
|
||||
DataRow[] dataRows = columnsTab.Select().Where(n => (n["name"] + "").Equals(colunmField.Key)).ToArray();
|
||||
if (dataRows.Length == 0)
|
||||
{
|
||||
string addColSql = string.Format("alter table P_systemEventApiPmsTab add {0} {1}", colunmField.Key, colunmField.Value);
|
||||
SqlHelper.ExecuteNonQuery(addColSql);//添加列
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string createTabSql = "create table P_systemEventApiPmsTab(id int IDENTITY(1,1) NOT NULL,{0})";
|
||||
string createCol = string.Empty;
|
||||
foreach (KeyValuePair<string, string> colunmField in colDic)
|
||||
{
|
||||
createCol += string.Format("{0} {1},", colunmField.Key, colunmField.Value);
|
||||
}
|
||||
createTabSql = string.Format(createTabSql, createCol.TrimEnd(','));
|
||||
SqlHelper.ExecuteNonQuery(createTabSql);//创建表
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置分割条位置
|
||||
|
||||
@@ -67,7 +67,6 @@
|
||||
<EmbeddedResource Include="FrmMain.resx">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\licenses.licx" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
Reference in New Issue
Block a user