12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Winsoft.GOV.Framework.Model;
- using Dapper;
- using MySql.Data.MySqlClient;
- using System.Security.Cryptography;
- namespace Winsoft.GOV.Framework.Provider
- {
- public class PowerMatterTypeProvider : BaseProvider<PowerMattersBase>
- {
- private static string cols = " `QL_NAME`, "
- + "`QL_INNER_CODE`, "
- + "`QL_DEP`, "
- + "`OUGUID`, "
- + "`ApplyCode` ";
- public void CreateTable()
- {
- string sql = "create table if not exists powermattertype("
- + "QL_NAME varchar(200),"
- + "QL_INNER_CODE varchar(50),"
- + "QL_DEP varchar(50),"
- + "OUGUID varchar(50),"
- + "ApplyCode int"
- + "); "
- + "call add_index('powermattertype', 'index1', 'index1(QL_INNER_CODE, OUGUID)'); "
- + "call add_index('powermattertype', 'index2', 'index2(OUGUID)'); "
- + "call add_index('powermattertype', 'index3', 'index3(OUGUID, ApplyCode)'); "
- + "call add_index('powermattertype', 'index4', 'index4(ApplyCode)'); ";///ApplyCode///
- using (var con = GetDbConnection())
- {
- con.Execute(sql);
- }
- }
- public PowerMatterTypeProvider(County county) : base(county)
- {
- }
- public PowerMattersBase FindById(string ql_inner_code)
- {
- string sql = "select * from powermattertype where QL_INNER_CODE=@ql_inner_code; ";
- using (var con = GetDbConnection())
- {
- return con.QueryFirstOrDefault<PowerMattersBase>(sql, new { ql_inner_code = ql_inner_code });
- }
- }
- public void Insert(IEnumerable<PowerMattersBase> list, ref IList<PowerMattersBase> failslist)
- {
- if (failslist == null)
- failslist = new List<PowerMattersBase>();
- string sql = "delete from powermattertype where QL_INNER_CODE=@QL_INNER_CODE and OUGUID=@OUGUID; "
- + "insert powermattertype(" + cols + ")" + "values(@QL_NAME, @QL_INNER_CODE, @QL_DEP, @OUGUID, @ApplyCode);";
- using (var con = GetDbConnection())
- {
- foreach (PowerMattersBase p in list)
- {
- PowerMattersBase p2 =ProvidersFactory.GetOnceRunPowerMattersProvider(_county).FindByQLNameAndOUORGCODE(p.QL_NAME, p.OUGUID);
- if (p2 != null)
- {
- p.QL_INNER_CODE = p2.QL_INNER_CODE;
- }
- else
- {
- byte[] result = Encoding.Default.GetBytes(p.QL_NAME.Trim()); //tbPass为输入密码的文本框
- MD5 md5 = new MD5CryptoServiceProvider();
- byte[] output = md5.ComputeHash(result);
- p.QL_INNER_CODE = BitConverter.ToString(output);
- ProvidersFactory.GetOnceRunPowerMattersProvider(_county).Insert(p);
- }
- con.Execute(sql, p);
- }
- }
- }
- }
- }
|