Esempio n. 1
0
        public static void InitializeSqlMapper()
        {
            if (_sqlmapper == null)
            {
                lock (typeof(IBatisNet.DataMapper.SqlMapper))
                {
                    //if (_sqlmapper == null) // double-check
                    //{
                    IBatisNet.Common.Utilities.ConfigureHandler         handler = new IBatisNet.Common.Utilities.ConfigureHandler(Configure);
                    IBatisNet.DataMapper.Configuration.DomSqlMapBuilder builder = new IBatisNet.DataMapper.Configuration.DomSqlMapBuilder();
#if DEBUG
                    try
                    {
                        _sqlmapper = builder.ConfigureAndWatch("Book.SQLServer.SQLMap.config", handler);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
#else
                    _sqlmapper = builder.ConfigureAndWatch("Book.SQLServer.SQLMap.config", handler);
#endif

                    //   }
                }
            }
        }
Esempio n. 2
0
        public string GetPosNo(string customerID, string unitID, string posSN, bool IsTran)
        {
            this.Log(LogLevel.DEBUG, "", "", "GetPosNo", "cid", customerID);
            this.Log(LogLevel.DEBUG, "", "", "GetPosNo", "uid", unitID);
            this.Log(LogLevel.DEBUG, "", "", "GetPosNo", "pid", posSN);

            if (string.IsNullOrEmpty(customerID))
            {
                throw new ArgumentNullException("customerID");
            }
            if (string.IsNullOrEmpty(unitID))
            {
                throw new ArgumentNullException("unitID");
            }
            if (string.IsNullOrEmpty(posSN))
            {
                throw new ArgumentNullException("posSN");
            }

            string  pos_no     = "";
            bool    is_new_pos = false;
            PosInfo pos        = null;
            //从POS的序列号中取第一位作为POS的类型
            string         pos_type       = posSN.Substring(0, 1);
            LoggingManager loggingManager = new cLoggingManager().GetLoggingManager(customerID);

            this.Log(LogLevel.DEBUG, "", "", "GetPosNo", "cs", loggingManager.Connection_String);
            IBatisNet.DataMapper.ISqlMapper sqlMpper = cSqlMapper.Instance(loggingManager);
            try
            {
                if (IsTran)
                {
                    sqlMpper.BeginTransaction();
                }

                //根据终端序列号,在终端表中查找有没有被登记过
                pos = sqlMpper.QueryForObject <PosInfo>("Pos.Pos.SelectPosBySN", posSN);
                //如果没有被登记过,则插入终端信息
                if (pos == null)
                {
                    is_new_pos = true;
                    pos        = new PosInfo();
                    pos.ID     = this.NewGuid();
                    pos.Type   = pos_type;
                    pos.SN     = posSN;
                    sqlMpper.Insert("Pos.Pos.InsertPosFromCT", pos);
                    //重新查询出
                    //pos = sqlMpper.QueryForObject<PosInfo>("Pos.Pos.SelectPosBySN", posSN);
                }
                PosUnitInfo pos_unit = new PosUnitInfo(pos);
                pos_unit.ID      = this.NewGuid();
                pos_unit.Unit.Id = unitID;
                pos_unit.Pos     = pos;
                //如果不存在终端与门店的关系,则插入,并产生编号
                sqlMpper.Insert("Pos.PosUnit.Insert", pos_unit);
                //取终端编号
                pos_no = sqlMpper.QueryForObject <string>("Pos.PosUnit.GetPosNoByUnitIDAndPosID", pos_unit);

                if (IsTran)
                {
                    sqlMpper.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                if (IsTran)
                {
                    sqlMpper.RollBackTransaction();
                }
                throw ex;
            }

            //如果是新的终端,则传入管理平台
            //if (is_new_pos)
            //{
            //    //提交至管理平台
            //    this.Log(LogLevel.DEBUG, "bs", "service", "GetPosNo", "is_new_pos", "true");
            //    this.synPosToAP(customerID, 1, pos);
            //}
            return(pos_no);
        }
Esempio n. 3
0
 public static void Clearsqlmapper()
 {
     _sqlmapper = null;
 }
Esempio n. 4
0
 public static void Configure(object obj)
 {
     _sqlmapper = (IBatisNet.DataMapper.SqlMapper)obj;
 }
 public Transaction(IBatisNet.DataMapper.ISqlMapper sqlMapper)
 {
     _sqlMapper     = sqlMapper;
     _sqlMapSession = _sqlMapper.BeginTransaction();
 }