You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
10 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/////////////////////////////////////////////////////////////////
//
// (C) Copyright 2013, Kenneth, Inc.
// All rights reserved. Confidential. Except as pursuant
// to a written agreement with Kenneth, this software may
// not be used or distributed. This software may be covered
// by one or more patents.
//
// 本软件为 ** 公司开发版权所有违者必究23810511@qq.com
//
/////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System.IO;
using System.Reflection;
using System.Data;
using System.Data.SqlClient;
using System.Transactions;
using QuiltingCommon;
using MySql.Data.MySqlClient;
namespace QuiltingBusiness
{
public partial class Printsetting
{
private static void ConvertSingleData(PrintsettingEntityExtension data)
{
var user = SysUserPool.GetById(data.CreateBy);
if (user != null)
{
data.CreateByDisplayer = user.UserName;
}
user = SysUserPool.GetById(data.ModifyBy);
if (user != null)
{
data.ModifyByDisplayer = user.UserName;
}
var Pageobj = PrintpagePool.GetById(data.Page);
if (Pageobj != null)
{
data.PageDisplayer = Pageobj.PageName;
}
}
public static string LoadResultByPage(string currentUserId, string currentClientId, string currentSendParameter)
{
var rows = PrintsettingPool.BufferPool.Where(q=>q.Page == currentSendParameter);
foreach (var row in rows)
{
ConvertSingleData(row);
}
OutEntity oe = new OutEntity() { ErrorCode = ErrorCode.Success, ReturnObj = JsonConvert.SerializeObject(rows) };
return JsonConvert.SerializeObject(oe);
}
public static string SaveResults(string currentUserId, string currentClientId, string currentSendParameter)
{
lock (lockobj)
{
using (var tranScope = new TransactionScope())
{
string connectionString = AppHelper.GetLinkString();
using (MySqlConnection connection = new MySqlConnection(connectionString))
{
List<PrintsettingEntity> sends = JsonConvert.DeserializeObject<List<PrintsettingEntity>>(currentSendParameter);
if (sends.Count > 0)
{
var pageid = sends[0].Page;
MysqlHelper.ExecuteNonQuery(connection, string.Format("delete from PrintSetting where page = '{0}'", pageid));
PrintsettingPool.BufferPool.RemoveAll(q => q.Page == pageid);
}
foreach (var send in sends)
{
MySqlParameter paramRecId = new MySqlParameter("@RecId", MySqlDbType.VarChar) { Value = send.RecId };
MySqlParameter paramSettingCode = new MySqlParameter("@SettingCode", MySqlDbType.VarChar) { Value = send.SettingCode };
MySqlParameter paramSettingName = new MySqlParameter("@SettingName", MySqlDbType.VarChar) { Value = send.SettingName };
MySqlParameter paramPage = new MySqlParameter("@Page", MySqlDbType.VarChar) { Value = send.Page };
var Pageobj = PrintpagePool.GetById(send.Page);
MySqlParameter paramPageDisplayer = new MySqlParameter("@PageDisplayer", MySqlDbType.VarChar);
if (Pageobj != null)
{
paramPageDisplayer = new MySqlParameter("@PageDisplayer", MySqlDbType.VarChar) { Value = Pageobj.PageName };
}
MySqlParameter paramControlIndex = new MySqlParameter("@ControlIndex", MySqlDbType.VarChar) { Value = send.ControlIndex };
MySqlParameter paramControlType = new MySqlParameter("@ControlType", MySqlDbType.VarChar) { Value = send.ControlType };
MySqlParameter paramControlField = new MySqlParameter("@ControlField", MySqlDbType.VarChar) { Value = send.ControlField };
MySqlParameter paramControlFormat = new MySqlParameter("@ControlFormat", MySqlDbType.VarChar) { Value = send.ControlFormat };
MySqlParameter paramControlFont = new MySqlParameter("@ControlFont", MySqlDbType.VarChar) { Value = send.ControlFont };
MySqlParameter paramControlFontSize = new MySqlParameter("@ControlFontSize", MySqlDbType.VarChar) { Value = send.ControlFontSize };
MySqlParameter paramControlFontWeight = new MySqlParameter("@ControlFontWeight", MySqlDbType.VarChar) { Value = send.ControlFontWeight };
MySqlParameter paramControlPen = new MySqlParameter("@ControlPen", MySqlDbType.VarChar) { Value = send.ControlPen };
MySqlParameter paramControlX = new MySqlParameter("@ControlX", MySqlDbType.VarChar) { Value = send.ControlX };
MySqlParameter paramControlY = new MySqlParameter("@ControlY", MySqlDbType.VarChar) { Value = send.ControlY };
MySqlParameter paramControlW = new MySqlParameter("@ControlW", MySqlDbType.VarChar) { Value = send.ControlW };
MySqlParameter paramControlH = new MySqlParameter("@ControlH", MySqlDbType.VarChar) { Value = send.ControlH };
MySqlParameter paramCreateBy = new MySqlParameter("@CreateBy", MySqlDbType.VarChar) { Value = currentUserId };
MySqlParameter paramCreateTime = new MySqlParameter("@CreateTime", MySqlDbType.DateTime) { Value = send.CreateTime == null ? System.DateTime.Now : send.CreateTime };
MySqlParameter paramModifyBy = new MySqlParameter("@ModifyBy", MySqlDbType.VarChar) { Value = currentUserId };
MySqlParameter paramModifyTime = new MySqlParameter("@ModifyTime", MySqlDbType.DateTime) { Value = send.ModifyTime == null ? System.DateTime.Now : send.ModifyTime };
MySqlParameter paramIsActive = new MySqlParameter("@IsActive", MySqlDbType.Int16) { Value = 1 };
DataTable dt = MysqlHelper.ExecuteDataTable(connection, "select RecId from PrintSetting where RecId = @RecId and IsActive > 0 limit 1", paramRecId);
var opertype = "";
if (dt.Rows.Count == 0)
{
opertype = ((int)AppEnum.OperType.New).ToString();
if (string.IsNullOrEmpty(send.RecId))
{
paramRecId.Value = Guid.NewGuid().ToString();
}
paramIsActive.Value = 1;
MysqlHelper.ExecuteNonQuery(connection, "insert into PrintSetting (RecId,SettingCode,SettingName,Page,PageDisplayer,ControlIndex,ControlType,ControlField,ControlFormat,ControlFont,ControlFontSize,ControlFontWeight,ControlPen,ControlX,ControlY,ControlW,ControlH,CreateBy,CreateTime,ModifyBy,ModifyTime,IsActive) values (@RecId,@SettingCode,@SettingName,@Page,@PageDisplayer,@ControlIndex,@ControlType,@ControlField,@ControlFormat,@ControlFont,@ControlFontSize,@ControlFontWeight,@ControlPen,@ControlX,@ControlY,@ControlW,@ControlH,@CreateBy,@CreateTime,@ModifyBy,@ModifyTime,@IsActive)",
new MySqlParameter[] { paramRecId, paramSettingCode, paramSettingName, paramPage, paramPageDisplayer, paramControlIndex, paramControlType, paramControlField, paramControlFormat, paramControlFont, paramControlFontSize, paramControlFontWeight, paramControlPen, paramControlX, paramControlY, paramControlW, paramControlH, paramCreateBy, paramCreateTime, paramModifyBy, paramModifyTime, paramIsActive });
}
else
{
opertype = ((int)AppEnum.OperType.Modify).ToString();
MysqlHelper.ExecuteNonQuery(connection, "update PrintSetting set SettingCode = @SettingCode, SettingName = @SettingName, Page = @Page, PageDisplayer = @PageDisplayer, ControlIndex = @ControlIndex, ControlType = @ControlType, ControlField = @ControlField, ControlFormat = @ControlFormat, ControlFont = @ControlFont, ControlFontSize = @ControlFontSize, ControlFontWeight = @ControlFontWeight, ControlPen = @ControlPen, ControlX = @ControlX, ControlY = @ControlY, ControlW = @ControlW, ControlH = @ControlH, ModifyBy = @ModifyBy, ModifyTime = @ModifyTime,IsActive = @IsActive where RecId = @RecId",
new MySqlParameter[] { paramSettingCode, paramSettingName, paramPage, paramPageDisplayer, paramControlIndex, paramControlType, paramControlField, paramControlFormat, paramControlFont, paramControlFontSize, paramControlFontWeight, paramControlPen, paramControlX, paramControlY, paramControlW, paramControlH, paramModifyBy, paramModifyTime, paramIsActive, paramRecId });
}
//save log
InsertToLog(connection, paramRecId.Value.ToString(), currentUserId, opertype);
//更新池
PrintsettingPool.Update(LoadResult(connection, paramRecId.Value.ToString()));
}
tranScope.Complete();
OutEntity oe = new OutEntity() { ErrorCode = ErrorCode.Success };
return JsonConvert.SerializeObject(oe);
}
}
}
}
}
}