123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- using System;
- using System.Collections.Generic;
- using System.Data.Common;
- using System.Linq;
- using System.Text;
- using Microsoft.Practices.EnterpriseLibrary.Data;
- //using MediII.Adapter.Model.UE;
- using IL.Common;
- using System.Data;
- namespace MediII.Adapter.BizComponent.MFN
- {
- /// <summary>
- /// MFN消息处理的基类
- /// zengfan 2012-09-04
- /// </summary>
- public abstract class MFNBase
- {
- /// <summary>
- /// 新增
- /// </summary>
- protected const string MAD = "MAD";
- /// <summary>
- /// 更新
- /// </summary>
- protected const string MUP = "MUP";
- /// <summary>
- /// 删除
- /// </summary>
- protected const string MDL = "MDL";
- /// <summary>
- /// 恢复
- /// </summary>
- protected const string MAC = "MAC";
- /// <summary>
- /// 消息处理,入库
- /// </summary>
- /// <param name="message">转化过的强类型消息</param>
- /// <returns></returns>
- public abstract int Process(string message);
- #region 根据不同类型初始化对应子类
- /// <summary>
- /// 根据不同类型初始化对应子类
- /// </summary>
- /// <param name="type">消息类型</param>
- /// <returns></returns>
- public static MFNBase GetProcessor(string type, Database ctx)
- {
- switch (type)
- {
- /*
- MFN_Z1A MFN_Z1A
- MFN_Z1B MFN_Z1B
- MFN_Z1C MFN_Z1C
- MFN_Z1D MFN_Z1D
- MFN_Z1E MFN_Z1E
- MFN_Z1F MFN_Z1F
- MFN_Z1G MFN_Z1G
- MFN_Z1H MFN_Z1H
- MFN_Z1I MFN_Z1I
- MFN_Z3F MFN_Z3F
- MFN_Z3I
- MFN_Z3J
- MFN_Z3K
- MFN_Z3L
- MFN_Z3M MFN_Z3M
- MFN_Z3N MFN_Z3N
- MFN_Z4B MFN_Z4B
- MFN_Z5F
- MFN_Z6C
- MFN_Z6D
- MFN_Z6E
- MFN_Z6G
- MFN_Z6H
- MFN_Z7B MFN_Z7B
- MFN_Z7C MFN_Z7C
- MFN_Z8B MFN_Z8B
- MFN_Z8C MFN_Z8C
- MFN_Z8D MFN_Z8D
- */
- case "MFN_Z1A":
- //return new MFN_Z1H_V_Title(ctx);
- //return new MFN_Z1G_dbo_PublicCode(ctx);
- //return new MFN_Z8C_PublicCode(ctx);
- case "MFN_Z1B":
- case "MFN_Z1C":
- case "MFN_Z1D":
- case "MFN_Z1E":
- case "MFN_Z1F":
- //case "MFN_Z1G":
- // return new MFN_Z1G_dbo_PublicCode(ctx);
- //case "MFN_Z1H":
- // return new MFN_Z1H_V_Title(ctx);
- case "MFN_Z1I":
- case "MFN_Z3F":
- case "MFN_Z3M":
- // case "MFN_Z3N":
- case "MFN_Z4B":
- case "MFN_Z7B":
- case "MFN_Z7C":
- case "MFN_Z8B":
- //case "MFN_Z8C":
- // return new MFN_Z8C_PublicCode(ctx);
- //case "MFN_Z8D":
- // //return new MFN_Z1A_GY_DAIMA(ctx);
- //case "MFN_Z2A":
- // //return new MFN_Z2A_GY_YUANQU(ctx);
- case "MFN_Z2B":
- return new MFN_Z2B_GY_KESHI(ctx);
- //case "MFN_Z2C":
- // return new MFN_Z2C_Depart(ctx); // return new MFN_Z2C_GY_BINGQU(ctx);
- //case "MFN_Z2D":
- // return new MFN_Z2D_GY_KESHIBQ(ctx);
- //case "MFN_Z2E":
- // return new MFN_Z2E_GY_YILIAOZU1(ctx);
- //case "MFN_Z2F":
- // return new MFN_Z2F_GY_YILIAOZU2(ctx);
- //case "MFN_Z2G":
- // return new MFN_Z2G_bed(ctx); // return new MFN_Z2G_GY_CHANGWEIXX(ctx);
- //case "MFN_Z2H":
- // return new MFN_Z2H_GY_ZHIGONGKSBG(ctx);
- //case "MFN_Z2I":
- // return new MFN_Z2I_EmpLicense(ctx);
- //case "MFN_Z2K":
- // return new MFN_Z2K_GY_CHANGWEIFU(ctx);
- //case "MFN_Z2L":
- // return new MFN_Z2L_OpdRoomSet(ctx); //MFN_Z2L_WEIZHIXX(ctx);
- //case "MFN_Z3A":
- // return new MFN_Z3A_GY_YAOPINXX(ctx);
- //case "MFN_Z3B":
- // return new MFN_Z3B_GY_YAOPINCD(ctx);
- //case "MFN_Z3C":
- // return new MFN_Z3C_DrugSet(ctx); // return new MFN_Z3C_GY_YAOPINJG(ctx);
- //case "MFN_Z3D":
- // return new MFN_Z3D_GY_YAOPINZBM(ctx);
- //case "MFN_Z3E":
- // return new MFN_Z3E_GY_GEIYAOFS(ctx);
- //case "MFN_Z3G":
- // return new MFN_Z3G_GY_PINCI(ctx);
- //case "MFN_Z3H":
- // return new MFN_Z3H_GY_YAOPINFL(ctx);
- //case "MFN_Z3I":
- // return new MFN_Z3I_GY_JIXING(ctx);
- //case "MFN_Z3J":
- // return new MFN_Z3J_GY_ZHANGBULB(ctx);
- //case "MFN_Z3K":
- // return new MFN_Z3K_YAOPINDLFL(ctx);
- //case "MFN_Z3L":
- // return new MFN_Z3L_GY_YAOPINJZFL(ctx);
- //case "MFN_Z3N":
- // return new MFN_Z3N_V_SkinAdvice(ctx);
- //case "MFN_Z3P":
- // return new MFN_Z3P_GY_YAOPINDW(ctx);
- //case "MFN_Z3Q":
- // return new MFN_Z3Q_GY_YAOPINMCGG(ctx);
- //case "MFN_Z3R":
- // return new MFN_Z3R_DrugStock(ctx);//MFN_Z3R_GY_YAOPINKC(ctx);
- //case "MFN_Z4A":
- // return new MFN_Z4A_GY_JIBING(ctx);
- //return new MFN_Z4A_Diag(ctx);
- //case "MFN_Z5A":
- // return new MFN_Z5A_GY_FEIYONGLB(ctx);
- //case "MFN_Z5B":
- // return new MFN_Z5B_GY_FEIYONGXZ(ctx);
- //case "MFN_Z5C":
- // return new MFN_Z5C_YB_BAOXIANLB(ctx);
- //case "MFN_Z5D":
- // return new MFN_Z5D_MedCodeSet(ctx); //MFN_Z5D_GY_SHOUFEIXM(ctx);
- //case "MFN_Z5E":
- // return new MFN_Z5E_GY_HESUANXM(ctx);
- //case "MFN_Z5F":
- // return new MFN_Z5F_GY_XIANGMULX(ctx);
- //case "MFN_Z5I":
- // return new MFN_Z5I_MedCodeFee(ctx);
- //case "MFN_Z5G":
- // return new MFN_Z5G_GY_GEIYAOFSJFXM(ctx);
- //case "MFN_Z5H":
- // return new MFN_Z5H_MedCodeFee(ctx);
- //case "MFN_Z5I":
- // return new MFN_Z5I_GY_JIANYANXMSF(ctx);
- //case "MFN_Z5J":
- // return new MFN_Z5J_GY_JIJIADW(ctx);
- //case "MFN_Z5K":
- // return new MFN_Z5K_YB_YIBAOYPDZ(ctx);
- //case "MFN_Z5L":
- // return new MFN_Z5L_YB_JBDMDZ(ctx);
- //case "MFN_Z5M":
- // return new MFN_Z5M_YB_ZLDMDZ(ctx);
- //case "MFN_Z5N":
- // return new MFN_Z5N_GY_SHOUFEITCMX(ctx);
- //case "MFN_Z6A":
- // return new MFN_Z6A_ModeCodeSet(ctx);
- //case "MFN_Z6B":
- // return new MFN_Z6B_GY_JIANYANTCMX(ctx);
- //case "MFN_Z6C":
- // return new MFN_Z6C_GY_CAIJIBW(ctx);
- //case "MFN_Z6D":
- // return new MFN_Z6D_GY_JIANYANRQ(ctx);
- //case "MFN_Z6E":
- // return new MFN_Z6E_MedViewTypeRef(ctx);
- //case "MFN_Z6F":
- // return new MFN_Z6F_GY_YANGBENLX(ctx);
- //case "MFN_Z6G":
- // return new MFN_Z6G_MedCodeSet(ctx);
- //case "MFN_Z6H":
- // return new MFN_Z6H_GY_JIANCHALX(ctx);
- //case "MFN_Z6I":
- // return new MFN_Z6I_MedViewTypeRef(ctx);
- //case "MFN_Z6J":
- // return new MFN_Z6J_MedCodeSetAndMedViewType(ctx);
- //case "MFN_Z6K":
- // return new MFN_Z6K_MedCodeFee(ctx);
- //case "MFN_Z6L":
- // return new MFN_Z6L_GY_JIANYANKDSYXMDY(ctx);
- //case "MFN_Z6M":
- // return new MFN_Z6M_GY_JIANYANSYXM(ctx);
- //case "MFN_Z6N":
- // return new MFN_Z6N_GY_JIANCHAXMYPSF(ctx);
- //case "MFN_Z6O":
- // return new MFN_Z6O_TubeFee(ctx);
- //case "MFN_Z8A":
- // return new MFN_Z8A_MedCodeSet(ctx);
- //case "MFN_Z2M":
- // return new MFN_Z2M_EmpRight(ctx);
- //case "MFN_Z7A":
- // return new MFN_Z7A_ModeCodeSet(ctx);
- //case "MFN_Z7D":
- // return new MFN_Z7D_YZ_PAICHIYZ1(ctx);
- //case "MFN_Z7E":
- // return new MFN_Z7E_YZ_PAICHIYZ2(ctx);
- //case "MFN_Z7F":
- // return new MFN_Z7F_YZ_CHUANGWEIPXS(ctx);
- ////Z7G(医嘱项目收费)定义多余
- ////case "MFN_Z7G":
- //// return new MFN_Z7G_YIZHUXMSF(ctx);
- //case "MFN_Z8A":
- // return new MFN_Z8A_SM_SHOUSHUMC(ctx);
- default:
- throw new NotImplementedException();
- }
-
- }
- #endregion
- //public static HealthCareContainer conn = new HealthCareContainer();
- //public static IEnumerable<MedCodeSet> MCSList = conn.MedCodeSet.ToList();
- #region 取序列
- /// <summary>
- /// 取序列
- /// </summary>
- /// <param name="ctx"></param>
- /// <param name="seqName"></param>
- /// <returns></returns>
- public static string GetSeq(Database ctx, string seqName)
- {
- //string sql = string.Format("select {0}.Nextval from dual", seqName);//caowen
- string sql = "SELECT NEXT VALUE FOR " + seqName;
- DbCommand command = ctx.GetSqlStringCommand(sql);
- object obj = ctx.ExecuteScalar(command);
- if (obj != null)
- return obj.ToString();
- else
- return "0";
- }
- #endregion
- #region 获取表对应的顺序号
- /// <summary>
- /// 获取表对应的顺序号
- /// </summary>
- /// <param name="ctx"></param>
- /// <param name="tableName"></param>
- /// <returns></returns>
- public static object GetSortNum(Database ctx, string tableName)
- {
- // "SELECT CONVERT(INT,MAX(UsageNo)) +1 FROM HealthCare.dbo.MedUsageSet WHERE UsageNo BETWEEN '1000' AND '7999'";
- string sql = string.Format(@" SELECT CONVERT(INT,MAX(SeqNo)) +1 FROM {0} ", tableName);
- // string sql = string.Format(@" SELECT COUNT(1)+1 FROM {0} ", tableName);
- DbCommand command = ctx.GetSqlStringCommand(sql);
- return ctx.ExecuteScalar(command);
- }
- #endregion
- #region 获取输入码
- /// <summary>
- /// 获取输入码
- /// </summary>
- /// <param name="words">名称单词</param>
- /// <param name="inputType">获取的输入码类型:0 拼音,1 五笔</param>
- /// <returns></returns>
- public static string GetInputCode(int inputType, string words)
- {
- words = inputType == 0 ? MediII.Common.InputCodeHelper.GetCode1(words) + "" : MediII.Common.InputCodeHelper.GetCode2(words) + "";
- return words = words.Length > 10 ? words.Substring(0, 9) : words;
- }
- #endregion
- #region 更新数据和字段(单个字段)
- /// <summary>
- /// 更新字段数据(单个字段)
- /// </summary>
- /// <param name="tableName">表名称</param>
- /// <param name="columnName">列名</param>
- /// <param name="columnValue">字段更新值</param>
- /// <param name="conditions">条件</param>
- /// <param name="ctx">数据库链接</param>
- public static void UpdateCommonColumn(string tableName, string columnName, object columnValue, string conditions, Database ctx)
- {
- string updateSql = string.Format(@" UPDATE " + tableName + " SET " + columnName + " = " + columnValue + " WHERE " + conditions);
- DbCommand command = ctx.GetSqlStringCommand(updateSql);
- ctx.ExecuteNonQuery(command);
- }
- #endregion
- }
- }
|