///////////////////////////////////////////////////////////////// // // (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 Testhealthcompare { private static void ConvertSingleData(TesthealthcompareEntityExtension 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; } } public static string DeleteTestHealthCompare(string currentUserId, string currentClientId, string currentSendParameter) { string connectionString = AppHelper.GetLinkString(); using (MySqlConnection connection = new MySqlConnection(connectionString)) { TesthealthcompareEntityExtension pt = JsonConvert.DeserializeObject(currentSendParameter); if (pt != null) { MysqlHelper.ExecuteNonQuery(connection, string.Format("delete from TestHealthCompare where RecId='{0}' or TypeName = '{1}'", pt.RecId, pt.TypeName)); } //更新池 TesthealthcomparePool.InitializeResults(); OutEntity oe = new OutEntity() { ErrorCode = ErrorCode.Success, ReturnObj = JsonConvert.SerializeObject(true) }; return JsonConvert.SerializeObject(oe); } } public static string SaveTypeResult(string currentUserId, string typegroup, string typeid, string typename) { lock (lockobj) { using (var tranScope = new TransactionScope()) { string connectionString = AppHelper.GetLinkString(); using (MySqlConnection connection = new MySqlConnection(connectionString)) { MySqlParameter paramRecId = new MySqlParameter("@RecId", MySqlDbType.VarChar) { Value = typeid }; MySqlParameter paramTypeCode = new MySqlParameter("@TypeCode", MySqlDbType.VarChar) { Value = typename }; MySqlParameter paramTypeName = new MySqlParameter("@TypeName", MySqlDbType.VarChar) { Value = typename }; MySqlParameter paramTypeGroup = new MySqlParameter("@TypeGroup", MySqlDbType.VarChar) { Value = typegroup }; MySqlParameter paramCreateBy = new MySqlParameter("@CreateBy", MySqlDbType.VarChar) { Value = currentUserId }; MySqlParameter paramCreateTime = new MySqlParameter("@CreateTime", MySqlDbType.DateTime) { Value = System.DateTime.Now }; MySqlParameter paramModifyBy = new MySqlParameter("@ModifyBy", MySqlDbType.VarChar) { Value = currentUserId }; MySqlParameter paramModifyTime = new MySqlParameter("@ModifyTime", MySqlDbType.DateTime) { Value = System.DateTime.Now }; MySqlParameter paramIsActive = new MySqlParameter("@IsActive", MySqlDbType.Int16) { Value = 1 }; DataTable dt = MysqlHelper.ExecuteDataTable(connection, "select RecId from TestHealthCompare where TypeGroup = @TypeGroup and TypeName = @TypeName and IsActive > 0 limit 1", paramTypeGroup, paramTypeName); var opertype = ""; if (dt.Rows.Count == 0) { opertype = ((int)AppEnum.OperType.New).ToString(); paramIsActive.Value = 1; MysqlHelper.ExecuteNonQuery(connection, "insert into TestHealthCompare (RecId,TypeCode,TypeName,TypeGroup,CreateBy,CreateTime,ModifyBy,ModifyTime,IsActive) values (@RecId,@TypeCode,@TypeName,@TypeGroup,@CreateBy,@CreateTime,@ModifyBy,@ModifyTime,@IsActive)", new MySqlParameter[] { paramRecId, paramTypeCode, paramTypeName, paramTypeGroup, paramCreateBy, paramCreateTime, paramModifyBy, paramModifyTime, paramIsActive }); } else { opertype = ((int)AppEnum.OperType.Modify).ToString(); typeid = dt.Rows[0][0].ToString(); MysqlHelper.ExecuteNonQuery(connection, "update TestHealthCompare set TypeCode = @TypeCode, TypeName = @TypeName, TypeGroup = @TypeGroup, ModifyBy = @ModifyBy, ModifyTime = @ModifyTime,IsActive = @IsActive where RecId = @RecId", new MySqlParameter[] { paramTypeCode, paramTypeName, paramTypeGroup, paramModifyBy, paramModifyTime, paramIsActive, paramRecId }); } //save log InsertToLog(connection, paramRecId.Value.ToString(), currentUserId, opertype); //更新池 TesthealthcomparePool.Update(LoadResult(connection, paramRecId.Value.ToString())); tranScope.Complete(); return typeid; } } } } } }