Exemplo n.º 1
0
    void output(bool error, ParamCheck param)
    {
        string str = "";

        if (error)
        {
            str = "检测 不 通过";

            LogMgr.log.InfoFormat("检测完毕:游戏时间[{0}], 玩家[{1}]在游戏[{2}],道具[{3}],结果[{4}], 不通过时间点[{5}]",
                                  param.m_startTime.ToString(),
                                  param.m_playerId,
                                  StrName.s_gameName[param.m_gameId],
                                  m_items[param.m_itemId],
                                  str,
                                  m_errorTime.ToString());
        }
        else
        {
            str = "检测通过";

            LogMgr.log.InfoFormat("检测完毕:游戏时间[{0}],玩家[{1}]在游戏[{2}],道具[{3}],结果[{4}]",
                                  param.m_startTime.ToString(),
                                  param.m_playerId,
                                  StrName.s_gameName[param.m_gameId],
                                  m_items[param.m_itemId],
                                  str);
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// 进行映射处理。
        /// </summary>
        /// <param name="builder">指定当前上下文构建模型的生成器。</param>
        /// <param name="modelType">将要进行映射的实体模型类型。</param>
        /// <exception cref="ArgumentNullException">当 <paramref name="builder"/> 或 <paramref name="modelType"/> 为空引用(<c>null</c>)时引发。</exception>
        public void Mapping(ModelBuilder builder, Type modelType)
        {
            #region Parameter Check

            ParamCheck.NotNull(builder, nameof(builder));
            ParamCheck.NotNull(modelType, nameof(modelType));

            #endregion

            // 检查可用性。
            if (!this.CanMapping(modelType))
            {
                return;
            }

            var typeBuilder = builder.Entity(modelType);

            typeBuilder.Property(nameof(ICnvOfEntityModel.Code))
            .IsRequired()
            .HasMaxLength(32)
            .IsUnicode(false);

            typeBuilder.Property(nameof(ICnvOfEntityModel.Name))
            .IsRequired()
            .HasMaxLength(64);

            typeBuilder.Property(nameof(ICnvOfEntityModel.Description)).HasMaxLength(255);
            typeBuilder.Property(nameof(ICnvOfEntityModel.Value)).HasMaxLength(255);
        }
Exemplo n.º 3
0
        /// <summary>
        /// <para>从“One-to-Many”关系的“One”实体模型中查找表示“Many”的实体模型的类型。</para>
        /// <para>代表“One”的实体模型类型必须实现 <see cref="IChildEntityModel"/> 接口。</para>
        /// </summary>
        /// <param name="oneType">代表“One”的实体模型类型。</param>
        /// <returns>返回代表“Many”实体模型的类型(已找到)或空引用(<c>null</c>,未找到)</returns>
        /// <exception cref="ArgumentNullException">当 <paramref name="oneType"/> 为空引用(<c>null</c>)时引发。</exception>
        /// <exception cref="InvalidOperationException">当 <paramref name="oneType"/> 未实现 <see cref="IChildEntityModel"/> 接口时引发。</exception>
        /// <exception cref="InvalidOperationException">当 <paramref name="oneType"/> 代表的类型未实现 <see cref="IChildEntityModel"/> 接口时引发。</exception>
        public static Type FindManyTypeFromOne(this Type oneType)
        {
            #region Paramter Check

            ParamCheck.NotNull(oneType, nameof(oneType));

            #endregion

            // 如果 oneType 未实现 IChildEntityModel 接口,则
            if (!oneType.IsImplFrom <IChildEntityModel>())
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  Properties.Resource.TypeImplInterfaceRequire,
                                                                  typeof(IChildEntityModel).FullName));
            }

            // 获取给定类型已实现的满足条件的接口类型(泛型&是 IChildEntityModel 的继承)
            var oneTypeInfo = oneType.GetTypeInfo();
            var childIfType = oneTypeInfo.GetInterfaces()
                              .FirstOrDefault(ifType =>
                                              ifType.GetTypeInfo().IsGenericType&&
                                              ifType.IsDerivedFrom <IChildEntityModel>());

            return(childIfType?.GenericTypeArguments[0]);
        }
Exemplo n.º 4
0
 public RevitInstanceSet(int category)
 {
     ParamSet = new List<Couplet>();
     This.Category = category;
     ParamCheck pc = new ParamCheck(GenerateParamSet);
     ParamQualifier pq = new ParamQualifier(IsInSet);
     ParameterCalls.ParamLoop(pc, pq);
 }
        /// <summary>
        /// 使用指定的模型生成操作来初始化 <see cref="DbContextByMappingStrategy"/> 的新实例。
        /// </summary>
        /// <param name="action">用于配置模型的生成操作。</param>
        public DbContextByMappingStrategy(Action <ModelBuilder> action)
        {
            #region Parameter's Check

            ParamCheck.NotNull(action, nameof(action));

            #endregion

            this._action = action;
        }
 public void NotEmptyOrNullByStringTest(string value, Type exType, string paramName)
 {
     if (exType != null)
     {
         ArgumentException ex =
             (ArgumentException)Assert.Throws(exType, () => ParamCheck.NotEmptyOrNull(value, paramName));
         Assert.Equal(String.IsNullOrEmpty(paramName) ? "name" : paramName, ex.ParamName);
     }
     else
     {
         ParamCheck.NotEmptyOrNull(value, paramName);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// create this factory. all parameters are mandatory.
        /// </summary>
        /// <param name="evernoteUri">evernote base url, like http://sandbox.evernote.com/</param>
        /// <param name="consumerKey">your personal consumer key that you got from Evernote</param>
        /// <param name="consumerSecret">your secret key that you got from Evernote</param>
        public StoreFactory(Uri evernoteUri, string consumerKey, string consumerSecret)
        {
            ParamCheck.NotNull("evernoteUri", evernoteUri);
            ParamCheck.NullNorEmpty("consumerKey", consumerKey);
            ParamCheck.NullNorEmpty("consumerSecret", consumerSecret);

            this.evernoteUri    = evernoteUri;
            this.consumerKey    = consumerKey;
            this.consumerSecret = consumerSecret;
            this.servicebus     = new ServiceBus();

            //we are interested in auth event
            this.servicebus.AddSubscriber <AuthenticationEvent>(authenticationEventHandler);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Authenticate an evernote user agains the evernote authentication service.
        /// </summary>
        public AuthenticationResult Authenticate(string userName, string password)
        {
            ParamCheck.NullNorEmpty("userName", userName);

            lock (this)
                using (var client = GetHttpClient())
                {
                    var authResult = GetUserStoreClient(client).authenticate(userName, password, this.consumerKey, this.consumerSecret);

                    saveAndPublishAuthResult(authResult);

                    return(authResult);
                }
        }
        public void NotEmptyTest(string value, Type exType, string paramName)
        {
            Guid measurand = Guid.Parse(value);

            if (exType != null)
            {
                ArgumentException ex =
                    (ArgumentException)Assert.Throws(exType, () => ParamCheck.NotEmpty(measurand, paramName));

                Assert.Equal(String.IsNullOrEmpty(paramName) ? "name" : paramName, ex.ParamName);
            }
            else
            {
                ParamCheck.NotEmpty(measurand, paramName);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 进行映射处理。
        /// </summary>
        /// <param name="builder">指定当前上下文构建模型的生成器。</param>
        /// <param name="modelType">将要进行映射的实体模型类型。</param>
        /// <exception cref="ArgumentNullException">当 <paramref name="builder"/> 或 <paramref name="modelType"/> 为空引用(<c>null</c>)时引发。</exception>
        public void Mapping(ModelBuilder builder, Type modelType)
        {
            #region Parameter Check

            ParamCheck.NotNull(builder, nameof(builder));
            ParamCheck.NotNull(modelType, nameof(modelType));

            #endregion

            // 检查可用性。
            if (!this.CanMapping(modelType))
            {
                return;
            }

            var typeBuilder = builder.Entity(modelType);
            typeBuilder.Property(nameof(IStateOfEntityModel.State))
            .IsRequired();
        }
Exemplo n.º 11
0
        /// <summary>
        /// 进行映射处理。
        /// </summary>
        /// <param name="builder">指定当前上下文构建模型的生成器。</param>
        /// <param name="modelType">将要进行映射的实体模型类型。</param>
        /// <exception cref="ArgumentNullException">当 <paramref name="builder"/> 或 <paramref name="modelType"/> 为空引用(<c>null</c>)时引发。</exception>
        public virtual void Mapping(ModelBuilder builder, Type modelType)
        {
            #region Parameter Check

            ParamCheck.NotNull(builder, nameof(builder));
            ParamCheck.NotNull(modelType, nameof(modelType));

            #endregion

            // 检查可用性。
            if (!this.CanMapping(modelType))
            {
                return;
            }

            builder.Entity(modelType)
            .Property(nameof(IParentEntityModelOfInt32 <EntityModelOfInt32> .ParentId))
            .IsRequired();
        }
Exemplo n.º 12
0
        /// <summary>
        /// 进行映射处理。
        /// </summary>
        /// <param name="builder">指定当前上下文构建模型的生成器。</param>
        /// <param name="modelType">将要进行映射的实体模型类型。</param>
        /// <exception cref="ArgumentNullException">当 <paramref name="builder"/> 或 <paramref name="modelType"/> 为空引用(<c>null</c>)时引发。</exception>
        public void Mapping(ModelBuilder builder, Type modelType)
        {
            #region Parameter Check

            ParamCheck.NotNull(builder, nameof(builder));
            ParamCheck.NotNull(modelType, nameof(modelType));

            #endregion

            // 检查可用性。
            if (!this.CanMapping(modelType))
            {
                return;
            }

            var typeBuilder = builder.Entity(modelType);
            typeBuilder.Property(nameof(INoteOfEntityModel.Note)).HasMaxLength(255);
            typeBuilder.Property(nameof(INoteOfEntityModel.SecondNote)).HasMaxLength(255);
            typeBuilder.Property(nameof(INoteOfEntityModel.ThirdNote)).HasMaxLength(255);
        }
        /// <summary>
        /// 进行映射处理。
        /// </summary>
        /// <param name="builder">指定当前上下文构建模型的生成器。</param>
        /// <param name="modelType">将要进行映射的实体模型类型。</param>
        /// <exception cref="ArgumentNullException">当 <paramref name="builder"/> 或 <paramref name="modelType"/> 为空引用(<c>null</c>)时引发。</exception>
        public virtual void Mapping(ModelBuilder builder, Type modelType)
        {
            #region Parameter Check

            ParamCheck.NotNull(builder, nameof(builder));
            ParamCheck.NotNull(modelType, nameof(modelType));

            #endregion

            // 检查可用性。
            if (!this.CanMapping(modelType))
            {
                return;
            }

            #region  射的目的表名称

            string modelTypeName = modelType.Name;
            string tableName     = modelTypeName.Replace("EntityModel", String.Empty)
                                   .Replace("Model", String.Empty)
                                   .Replace("Entity", String.Empty);
            // 如果表名称为空,则使用类型名称替代。
            if (String.IsNullOrEmpty(tableName))
            {
                tableName = modelTypeName;
            }

            #endregion

            // 主键 ID 的名称。
            string idName = this.GetIdName(modelType);

            var typeBuilder = builder.Entity(modelType);
            typeBuilder.ToTable(tableName)
            .HasKey(idName)
            .HasName($"PK_{tableName}_{idName}");
        }
Exemplo n.º 14
0
        // 开始检测收支平衡
        private void btnCheck_Click(object sender, EventArgs e)
        {
            StatService stat = ServiceMgr.getInstance().getSys <StatService>(ServiceType.serviceTypeStat);

            if (stat.isBusy())
            {
                MessageBox.Show("忙碌中,请稍候");
                return;
            }

            int playerId = 0;

            if (!int.TryParse(txtPlayerId.Text, out playerId))
            {
                MessageBox.Show("玩家ID非法");
                return;
            }

            DateTime mint = DateTime.Now, maxt = DateTime.Now;
            bool     res = Tool.splitTimeStr(txtGameTime.Text, ref mint, ref maxt);

            if (!res || mint.AddDays(1) != maxt)
            {
                MessageBox.Show("游戏时间非法");
                return;
            }

            ParamCheck param = new ParamCheck();

            param.m_gameId    = StrName.s_onlineGameIdList[m_gameList.SelectedIndex];
            param.m_playerId  = playerId;
            param.m_startTime = mint;
            param.m_endTime   = maxt;
            param.m_itemId    = s_itemId[m_moneyType.SelectedIndex];
            param.m_from      = this;
            stat.startCheck(param);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 进行映射处理。
        /// </summary>
        /// <param name="builder">指定当前上下文构建模型的生成器。</param>
        /// <param name="modelType">将要进行映射的实体模型类型。</param>
        /// <exception cref="ArgumentNullException">当 <paramref name="builder"/> 或 <paramref name="modelType"/> 为空引用(<c>null</c>)时引发。</exception>
        public virtual void Mapping(ModelBuilder builder, Type modelType)
        {
            #region Parameter Check

            ParamCheck.NotNull(builder, nameof(builder));
            ParamCheck.NotNull(modelType, nameof(modelType));

            #endregion

            // 检查可用性。
            if (!this.CanMapping(modelType))
            {
                return;
            }

            // 映射实体类型。
            var typeBuilder = builder.Entity(modelType);

            // 映射实体属性。
            typeBuilder.Property(nameof(IChildEntityModelOfGuid <EntityModelOfGuid> .CountOfChild))
            .IsRequired();

            // 获取子实体模型的类型。
            var cEntityModelType = modelType.FindManyTypeFromOne();

            // 获取子实体类型(EF 中的 EntityType)。
            var cEntityType = builder.Model.FindEntityType(cEntityModelType);
            // 获取子实体模型对应原表名称。
            var cTableName = cEntityType.Relational().TableName;

            // 映射“One-to-Many”关系。
            typeBuilder.HasMany(cEntityModelType,
                                nameof(IChildEntityModelOfGuid <EntityModelOfGuid> .Children))
            .WithOne(nameof(IParentEntityModelOfGuid <EntityModelOfGuid> .Parent))
            .HasForeignKey(nameof(IParentEntityModelOfGuid <EntityModelOfGuid> .ParentId))
            .HasConstraintName($"FK_{cTableName}_{nameof(IParentEntityModelOfGuid<EntityModelOfGuid>.ParentId)}");
        }
 public void startCheck(ParamCheck param)
 {
     m_param = param;
     m_state = State.busy;
 }
Exemplo n.º 17
0
    public void check(ParamCheck param)
    {
        m_startValue = m_endValue = INIT_VALUE;

        IMongoQuery imq1 = Query.LT("genTime", BsonValue.Create(param.m_endTime));
        IMongoQuery imq2 = Query.GTE("genTime", BsonValue.Create(param.m_startTime));
        IMongoQuery imq3 = Query.EQ("playerId", param.m_playerId);
        IMongoQuery imq4 = Query.EQ("itemId", param.m_itemId);
        IMongoQuery imq5 = Query.EQ("gameId", param.m_gameId);
        IMongoQuery imq  = Query.And(imq1, imq2, imq3, imq4, imq5);

        int count = (int)MongodbLog.Instance.ExecuteGetCount(TableName.PUMP_PLAYER_MONEY, imq);

        param.m_from.begin(count);

        int skip = 0;
        List <Dictionary <string, object> > dataList = null;
        bool run   = true;
        bool error = false;

        while (run)
        {
            dataList = QueryTool.nextData(MongodbLog.Instance,
                                          TableName.PUMP_PLAYER_MONEY,
                                          imq,
                                          ref skip,
                                          1000,
                                          FIELDS, "genTime");
            if (dataList == null)
            {
                break;
            }

            for (int i = 0; i < dataList.Count; i++)
            {
                Dictionary <string, object> data = dataList[i];
                if (param.m_gameId == 1 && Convert.ToInt32(data["reason"]) != 11)
                {
                    continue;
                }

                if (m_startValue == INIT_VALUE && m_endValue == INIT_VALUE)
                {
                    m_startValue = Convert.ToInt32(data["oldValue"]);
                    m_endValue   = Convert.ToInt32(data["newValue"]);
                    m_errorTime  = Convert.ToDateTime(data["genTime"]).ToLocalTime();
                }
                else
                {
                    int start = Convert.ToInt32(data["oldValue"]);
                    int end   = Convert.ToInt32(data["newValue"]);

                    if (m_endValue != start)
                    {
                        error       = true;
                        run         = false;
                        m_errorTime = Convert.ToDateTime(data["genTime"]).ToLocalTime();
                        break;
                    }
                    else
                    {
                        m_startValue = start;
                        m_endValue   = end;
                    }
                }

                param.m_from.finishOne();
            }
        }

        output(error, param);

        param.m_from.done();
    }