Пример #1
0
        /// <summary>
        /// SqlServer助手构造函数
        /// <para>详情参考:https://docs.microsoft.com/zh-cn/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring</para>
        /// </summary>
        /// <param name="connectionString">连接配置</param>
        public SqlServerDbHelper(string connectionString)
        {
            builder = new SqlConnectionStringBuilder(connectionString);

            timeFlow = BaseTimeFlow.CreateTimeFlow(this, 0);
            timeFlow.StartTimeFlowES();
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="timeout">(超时)断线时间,单位:s</param>
        public MonitorSocketStatusTask(int timeout)
        {
            SetTimeout(timeout);

            timeFlow = BaseTimeFlow.CreateTimeFlow(this, 0);
            timeFlow.StartTimeFlowES();
        }
Пример #3
0
        /// <summary>
        /// 验证服务器数据
        /// </summary>
        internal void VerifyServerData(byte[] data)
        {
            var str = Encoding.UTF8.GetString(data);

            if (str.ElementAt(0) == '0')
            {
                IsValid = true;
                IsAlive = true;
                timeFlow.StartTimeFlowES();
                SendTcp(ConnectedClientBytes);
            }
            else if (str.ElementAt(0) == '1')
            {
                IsValid = true;
                IsAlive = true;
                var publicKey = str.Substring(2);
                config.UseSSL  = true;
                config.SSLMode = int.Parse(str.ElementAt(1).ToString());
                ssl            = new SSL(SSL.SSLMode.Both, publicKey);
                tcpClient.Send(SessionId, ssl.RSAEncrypt(ssl.GetAESKey().AsBytes()));
            }
            else
            {
                Close();
            }
        }
Пример #4
0
        /// <summary>
        /// SqlServer助手构造函数
        /// <para>存在参数不需要再次在额外配置中设置</para>
        /// <para>详情参考:https://docs.microsoft.com/zh-cn/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring</para>
        /// </summary>
        /// <param name="address">数据库地址,如果非默认端口需要带端口号,注意地址与端口号是以逗号分隔的</param>
        /// <param name="username">数据库账号</param>
        /// <param name="password">数据库密码</param>
        /// <param name="databaseName">数据库名称,默认为空</param>
        /// <param name="minPoolSize">数据库池连接最小值,默认为0</param>
        /// <param name="maxPoolSize">数据库池连接最大值,默认为100</param>
        /// <param name="extraConfig">数据库额外配置</param>
        public SqlServerDbHelper(string address, string username, string password, string databaseName = null, int minPoolSize = 0, int maxPoolSize = 100, string extraConfig = null)
        {
            if (!string.IsNullOrEmpty(extraConfig))
            {
                builder = new SqlConnectionStringBuilder(extraConfig);
            }
            else
            {
                builder = new SqlConnectionStringBuilder();
            }
            builder.DataSource = address;
            builder.UserID     = username;
            builder.Password   = password;
            if (databaseName != null)
            {
                builder.InitialCatalog = databaseName;
            }
            builder.Pooling = true;
            if (minPoolSize > maxPoolSize)
            {
                minPoolSize = maxPoolSize;
            }
            builder.MinPoolSize        = minPoolSize;
            builder.MaxPoolSize        = maxPoolSize;
            builder.IntegratedSecurity = false;

            timeFlow = BaseTimeFlow.CreateTimeFlow(this, 0);
            timeFlow.StartTimeFlowES();
        }
Пример #5
0
        /// <summary>
        /// SqlServer助手构造函数
        /// <para>详情参考:https://docs.microsoft.com/zh-cn/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring</para>
        /// </summary>
        public SqlServerDbHelper(SqlConnectionStringBuilder sqlConnectionStringBuilder)
        {
            builder = sqlConnectionStringBuilder;

            timeFlow = BaseTimeFlow.CreateTimeFlow(this, 0);
            timeFlow.StartTimeFlowES();
        }
Пример #6
0
        /// <summary>
        /// 创建一个非关系型数据存储类
        /// </summary>
        /// <param name="dBHelper">对应的数据对象</param>
        /// <param name="keyName">数据所对应数据库中的key名</param>
        /// <param name="valueName">数据所对应数据库中的value名</param>
        /// <param name="tableName">数据所对应数据库的表名</param>
        /// <param name="syncPeriod">同步周期 用于控制写入到持久化数据库的时间 单位 毫秒 默认 1000ms</param>
        /// <param name="condition">数据查询的其他条件 如不需要则默认值即可,注意此处不需要再次写入key名所对应的条件了</param>
        public NoSqlStorage(SqlServerDbHelper dBHelper, string keyName, string valueName, string tableName, int syncPeriod = 1000, string condition = "")
        {
            this.dBHelper   = dBHelper;
            this.keyName    = keyName;
            this.valueName  = valueName;
            this.tableName  = tableName;
            this.syncPeriod = syncPeriod;
            this.condition  = !string.IsNullOrEmpty(condition) ? (condition + " AND ") : "";

            timeFlow = BaseTimeFlow.CreateTimeFlow(this, 0);
            timeFlow.StartTimeFlowES();
        }
Пример #7
0
        /// <summary>
        /// 构造函数
        /// </summary>
        private LogManager()
        {
            proccessName = Process.GetCurrentProcess().ProcessName.ToLower();
            logId        = new Random().Next(100, 999).ToString();
            logInfos     = new ConcurrentQueue <LogInfo>();
            // 创建目录
            if (!Directory.Exists(Log.LOG_PATH))
            {
                Directory.CreateDirectory(Log.LOG_PATH);
            }

            timeFlow = BaseTimeFlow.CreateTimeFlow(this, 1);
            timeFlow.StartTimeFlowES();
        }
Пример #8
0
        /// <summary>
        /// 创建一个时间执行器
        /// </summary>
        /// <param name="delayTime">第一次开始延迟时间,单位ms</param>
        /// <param name="periodTime">每次周期时间【第二次之后开始执行的延迟时间】,单位ms</param>
        /// <param name="isRepeat">是否重复状态,不重复状态下周期时间无效, 默认不重复</param>
        /// <param name="repeatNum">重复次数,值为 -1时 无限循环,默认 -1</param>
        /// <param name="handle">需要被执行的函数</param>
        /// <param name="tfIndex">时间流索引</param>
        private TimeCaller(int delayTime, int periodTime, bool isRepeat, long repeatNum, MethodHandle handle, int tfIndex = -1)
        {
            this.delayTime  = delayTime;
            this.periodTime = periodTime;
            this.isRepeat   = isRepeat;
            this.repeatNum  = repeatNum;
            this.handle     = handle;

            if (tfIndex == -1)
            {
                timeFlow = BaseTimeFlow.CreateTimeFlow(this);
            }
            else
            {
                timeFlow = BaseTimeFlow.CreateTimeFlow(this, tfIndex);
            }
            timeFlow.StartTimeFlowES();
        }
Пример #9
0
        /// <summary>
        /// 命名空间构造函数
        /// </summary>
        internal DataEntityRows(SqlServerDbHelper dBHelper, DataRowCollection collection, string primaryKey, string tableName, string fieldNames)
        {
            this.dBHelper   = dBHelper;
            this.TableName  = tableName;
            this.PrimaryKey = primaryKey;
            this.FieldNames = fieldNames;
            foreach (DataRow dataRow in collection)
            {
                DataEntityRow dataObject = new DataEntityRow(this);
                foreach (object column in dataRow.Table.Columns)
                {
                    dataObject.data.TryAdd(column.ToString(), dataRow[column.ToString()]);
                }
                rows.TryAdd(dataRow[primaryKey], dataObject);
            }

            timeFlow = BaseTimeFlow.CreateTimeFlow(this, 0);
            timeFlow.StartTimeFlowES();
        }
Пример #10
0
        internal KcpHelper(uint conv, int mtu, int winSize, KcpMode kcpMode, IKcp listener)
        {
            kcp = new Kcp(conv, this);
            if (kcpMode == KcpMode.Normal)
            {
                kcp.NoDelay(0, 40, 0, 0);
            }
            else if (kcpMode == KcpMode.Fast)
            {
                kcp.NoDelay(1, 10, 2, 1);
            }
            kcp.WndSize(winSize, winSize);
            kcp.SetMtu(mtu);

            kcpListener = listener;

            timeFlow = BaseTimeFlow.CreateTimeFlow(this);
            timeFlow.StartTimeFlowES();
        }
Пример #11
0
 /// <summary>
 /// 创建一个热更管理器
 /// </summary>
 private HotfixMgr()
 {
     agentTypeMap = new ConcurrentDictionary <Type, Type>();
     tf           = BaseTimeFlow.CreateTimeFlow(this, 0);
     tf.StartTimeFlowES();
 }