Esempio n. 1
0
 public void UCJingcai_Redis()
 {
     try
     {
         XmlDocument   xmlDoc     = new XmlDocument();
         XmlSerializer serializer = new XmlSerializer(typeof(XmlDocument));
         xmlDoc = LoadXmlDocument("http://lottery.jdddata.com/uc/jingcai");
         var commonConfig = ConfigFileHelper.Get <List <JingCai> >("JingCai");
         if (xmlDoc == null || xmlDoc.DocumentElement.ChildNodes.Count == 0)
         {
             return;
         }
         var nodes = xmlDoc.DocumentElement.ChildNodes;
         foreach (XmlElement element in nodes)
         {
             var Common = commonConfig.Where(x => x.key == element.FirstChild.InnerText).FirstOrDefault();
             if (Common == null)
             {
                 continue;
             }
             foreach (XmlElement Sub_element in element.LastChild)
             {
                 if (Sub_element.Name == "source")
                 {
                     Sub_element.InnerText = Source;
                 }
                 if (Sub_element.Name == "url")
                 {
                     Sub_element.InnerText = Common.url;
                 }
                 else if (Sub_element.Name == "links")
                 {
                     foreach (XmlElement Sub_item in Sub_element.ChildNodes)
                     {
                         if (Sub_item.FirstChild.InnerText == "更多赛果")
                         {
                             Sub_item.LastChild.InnerText = Common.links.Where(x => x.key == Sub_item.FirstChild.InnerText).FirstOrDefault().title_url;
                         }
                         else
                         {
                             Sub_item.LastChild.InnerText = Common.links.Where(x => x.key == Sub_item.FirstChild.InnerText).FirstOrDefault().title_url;
                         }
                     }
                 }
             }
         }
         MemoryStream ms = new MemoryStream();
         serializer.Serialize(ms, xmlDoc);
         RedisManager.DB_Other.Set("UC_jingcai", ms.ToArray());
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 2
0
        /*
         * 时时彩:重庆时时彩, 新疆时时彩,天津时时彩  (台湾时时彩,澳门时时彩)
         * 11x5:   广东11x5,江西11x5,山东11x5,上海11x5    (台湾11x5,澳门11x5)
         * kl8:    北京快乐8  (新韩国快乐8)                             (澳门快乐8,韩国快乐8)
         * PK10:  北京PK10                                (澳门pk10,台湾Pk10)
         * k3:江苏快三            (澳门快三,台湾快三)
         * 幸运农场 澳门幸运农场  台湾幸运农场
         */
        public static async Task Main(string[] args)
        {
            //var config = new ConfigurationBuilder()
            //.SetBasePath(Directory.GetCurrentDirectory())   //指定配置文件所在的目录
            //.AddJsonFile("config.json", optional: true, reloadOnChange: true)
            //.Build();  //指定加载的配
            //var services = new ServiceCollection();

            ConfigFileHelper.Set("config.json");
            var connstr  = ConfigFileHelper.Get("Lottery:Data:Database:Connection");
            var services = new ServiceCollection();

            //services.AddDataDapper(options =>
            //{
            //    options.ConnString = ConfigFileHelper.Get("Lottery:Data:Database:Connection");
            //    options.DbType = Smart.Data.Dapper.DBProvider.MySQL;
            //});
            ////log4net
            repository = LogManager.CreateRepository("LotteryRepository");
            ////指定配置文件
            XmlConfigurator.Configure(repository, new FileInfo("log4net.config"));
            services.AddSqlSugarClient <DbFactory>((sp, op) =>
            {
                op.ConnectionString      = ConfigFileHelper.Get("Lottery:Data:Database:Connection");
                op.DbType                = DbType.MySql;
                op.IsAutoCloseConnection = true;
                op.InitKeyType           = InitKeyType.Attribute;
                op.IsShardSameThread     = true;
            });
            services.AddServices();



            //services.AddCSRedis(options =>
            //{
            //    options.Add(new Smart.Core.NoSql.Redis.RedisConfig() { C_IP = "10.0.3.6", C_Post = 6379, C_Password = "******",C_Defaultdatabase=0 });
            //    options.Add(new Smart.Core.NoSql.Redis.RedisConfig() { C_IP = "10.0.3.6", C_Post = 6379, C_Password = "******", C_Defaultdatabase = 1 });
            //});
            services.AddConsoleLogger(options => { });
            services.AddSingleton <BalanceTasks>();
            var provider = services.BuildServiceProvider();
            var tasks    = provider.GetRequiredService <BalanceTasks>();
            //Task t1 = new Task(() => tasks.AgentIP());
            //t1.Start();
            //Task t2 = new Task(() => tasks.Run1122());
            //t2.Start();
            //Task t3 = new Task(() => tasks.XML());
            //t3.Start();
            Task t4 = new Task(() => tasks.RunCaikeBall());

            t4.Start();
            Console.WriteLine("Done.");
            Console.ReadLine();
        }
Esempio n. 3
0
        /// <summary>
        /// 使用Mongodb
        /// </summary>
        /// <param name="services"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static IServiceCollection AddMongodb(
            this IServiceCollection services,
            Action <MongodbConfig> options = null)
        {
            MongodbConfig option = new MongodbConfig();

            options?.Invoke(option);
            ObjectMapper.MapperTo <MongodbConfig>(option, ConfigFileHelper.Get <MongodbConfig>());//优先级装饰器
            services.AddSingleton(option);
            services.AddSingleton <MongodbManager>();
            return(services);
        }
Esempio n. 4
0
        /// <summary>
        /// 使用api日志
        /// </summary>
        /// <param name="services"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public static IServiceCollection AddConsoleLogger(
            this IServiceCollection services,
            Action <LoggerConfig> options)
        {
            var option = new LoggerConfig();

            options?.Invoke(option);
            ObjectMapper.MapperTo(option, ConfigFileHelper.Get <LoggerConfig>());
            services.AddSingleton(option);
            services.AddSingleton(typeof(ILogger), typeof(ConsoleLogger));
            return(services);
        }
Esempio n. 5
0
 public void UCCommon_Redis()
 {
     try
     {
         XmlDocument   xmlDoc     = new XmlDocument();
         XmlSerializer serializer = new XmlSerializer(typeof(XmlDocument));
         xmlDoc = LoadXmlDocument("http://lottery.jdddata.com/uc/common");
         if (xmlDoc == null || xmlDoc.DocumentElement.ChildNodes.Count == 0)
         {
             return;
         }
         var commonConfig = ConfigFileHelper.Get <List <CommonModel> >("CommonModel");
         var nodes        = xmlDoc.DocumentElement.ChildNodes[0].ChildNodes;
         foreach (XmlElement CurrenNode in nodes)
         {
             var Common = commonConfig.Find((x) => x.key == CurrenNode.ChildNodes[0].InnerText);
             if (Common == null)
             {
                 continue;
             }
             var item = CurrenNode.ChildNodes[2];
             foreach (XmlElement Subitem in item.ChildNodes)
             {
                 if (Subitem.Name == "item")
                 {
                     var Lottery = Subitem.ChildNodes[0].Attributes["col0"].InnerText;
                     foreach (XmlElement Sub_subItem in Subitem)
                     {
                         if (Sub_subItem.Name == "link")
                         {
                             if (Sub_subItem.Attributes["linkcontent"].InnerText == "开奖详情")
                             {
                                 Sub_subItem.SetAttribute("linkurl", Common.Item.Where(x => x.Lottery == Lottery).FirstOrDefault().DetailLinkUrl);
                             }
                             else if (Sub_subItem.Attributes["linkcontent"].InnerText == "玩法说明")
                             {
                                 Sub_subItem.SetAttribute("linkurl", Common.Item.Where(x => x.Lottery == Lottery).FirstOrDefault().RemarkLinkUrl);
                             }
                         }
                     }
                 }
             }
         }
         MemoryStream ms = new MemoryStream();
         serializer.Serialize(ms, xmlDoc);
         RedisManager.DB_Other.Set("UC_Common", ms.ToArray());
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 6
0
        public AutoTask()
        {
            ConnectionConfig conn = new ConnectionConfig()
            {
                ConnectionString      = ConfigFileHelper.Get("Lottery:Data:Database:Connection"),
                DbType                = DbType.MySql,
                IsAutoCloseConnection = true,
                InitKeyType           = InitKeyType.Attribute,
                IsShardSameThread     = false
            };
            var fa = new DbFactory(conn);

            IApi_Service = new Api_DataService(fa);
        }
Esempio n. 7
0
 public async Task HK6()
 {
     //this._redisManager.RedisDb(0).Set("ceshi","11111",100000);
     while (true)
     {
         try
         {
             this._logger.Info("HK6开始采集。。。。");
             //this._userSvc.TestMethod();
             //Console.ForegroundColor = ConsoleColor.Blue;
             //this._logger.Warn("CQSSC未采集到最新的开奖结果");
             string type = ConfigFileHelper.Get("Analysis:HK6_config:type");
             var    list = AnalysisManager.HK6();
             if (list != null && list.Count > 0)
             {
                 foreach (var item in list)
                 {
                     var    arr         = item.Split('|');
                     string lotteryNo   = UseFullHelper.FormatIssuseNumber("HK6", arr[0]);
                     string lotteryData = arr[1];
                     this._logger.Info($"HK6{lotteryNo}开奖完成{lotteryData}");
                     //var (code, msg) = await this.manager_task.LotteryKaijiang(1, lotteryNo, lotteryData);
                     //if (code == 0)
                     //{
                     //    Console.ForegroundColor = ConsoleColor.DarkCyan;
                     //    Console.WriteLine($"CQSSC重庆时时彩{lotteryNo}开奖完成{lotteryData}");
                     //}
                     //else
                     //{
                     //    Console.ForegroundColor = ConsoleColor.Yellow;
                     //    Console.WriteLine($"CQSSC{lotteryNo}开奖报错{msg}");
                     //    SSCAnalysisManager.DelUpdData($"CQSSC_{type}");
                     //}
                 }
             }
             else
             {
                 Console.ForegroundColor = ConsoleColor.Blue;
                 Console.WriteLine("HK6未采集到最新的开奖结果");
             }
         }
         catch (Exception ex)
         {
             //Console.ForegroundColor = ConsoleColor.Red;
             this._logger.Error($"{nameof(CQSSC)}: {ex.Message}", ex);
         }
         await Task.Delay(10000);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 使用EF持久化
        /// </summary>
        /// <param name="services"></param>
        /// <param name="configure"></param>
        /// <returns></returns>
        public static IServiceCollection AddEf(this IServiceCollection services, Action <EFConfig> configure)
        {
            var options = new EFConfig();

            //装饰
            configure?.Invoke(options);
            //优先级控制
            ObjectMapper.MapperTo(options, ConfigFileHelper.Get <EFConfig>());
            //ef相关配置
            services.AddSingleton(options);
            //注册通用DbContext上下文,主要为通用的EFRepository仓储提供数据对象,单个数据上下文时不需要定义自己的仓储
            services.AddTransient(typeof(DbContext), options.DbContextType);
            //注册通用数据仓储
            services.AddTransient(typeof(IRepository <>), typeof(EFRepository <>));
            //注册当前数据上下文,主要为当前业务仓储提交数据对象,而业务仓储的注册在业务项目里,实例模式
            services.AddTransient(options.DbContextType);
            return(services);
        }
Esempio n. 9
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(options => { options.Filters.Add(typeof(ApiThrottleActionFilter)); }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1).AddJsonOptions(options =>
            {
                options.SerializerSettings.ContractResolver = new DefaultContractResolver();
                options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
            })
            .AddXmlDataContractSerializerFormatters()
            .AddXmlSerializerFormatters();
            ConfigFileHelper.Set("config.json");
            #region CORS
            //跨域第二种方法,声明策略,记得下边app中配置
            services.AddCors(c =>
            {
                //↓↓↓↓↓↓↓注意正式环境不要使用这种全开放的处理↓↓↓↓↓↓↓↓↓↓
                c.AddPolicy("AllRequests", policy =>
                {
                    policy
                    .AllowAnyOrigin()    //允许任何源
                    .AllowAnyMethod()    //允许任何方式
                    .AllowAnyHeader()    //允许任何头
                    .AllowCredentials(); //允许cookie
                });
                //↑↑↑↑↑↑↑注意正式环境不要使用这种全开放的处理↑↑↑↑↑↑↑↑↑↑


                ////一般采用这种方法
                //c.AddPolicy("LimitRequests", policy =>
                //{
                //    policy
                //    .WithOrigins("http://127.0.0.1:1818", "http://*****:*****@xxx.com", Url = "https://www.baidu.com" }
            //    });
            //});
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info
                {
                    Version        = "v0.1.0",
                    Title          = "Lottery.API",
                    Description    = "框架说明文档",
                    TermsOfService = "None",
                    Contact        = new Swashbuckle.AspNetCore.Swagger.Contact {
                        Name = "Lottery.API", Email = "*****@*****.**", Url = "https://www.baidu.com"
                    }
                });

                //就是这里
                var basePath = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath;
                var xmlPath  = Path.Combine(basePath, "Lottery.API.xml");       //这个就是刚刚配置的xml文件名
                c.IncludeXmlComments(xmlPath, true);                            //默认的第二个参数是false,这个是controller的注释,记得修改

                var xmlModelPath = Path.Combine(basePath, "Lottery.Modes.xml"); //这个就是Model层的xml文件名
                c.IncludeXmlComments(xmlModelPath);

                #region Token绑定到ConfigureServices
                //添加header验证信息
                //c.OperationFilter<SwaggerHeader>();
                var security = new Dictionary <string, IEnumerable <string> > {
                    { "Lottery.API", new string[] { } },
                };
                c.AddSecurityRequirement(security);
                //方案名称“Blog.Core”可自定义,上下一致即可
                c.AddSecurityDefinition("Lottery.API", new ApiKeyScheme
                {
                    Description = "JWT授权(数据将在请求头中进行传输) 直接在下框中输入Bearer {token}(注意两者之间是一个空格)\"",
                    Name        = "Authorization", //jwt默认的参数名称
                    In          = "header",        //jwt默认存放Authorization信息的位置(请求头中)
                    Type        = "apiKey"
                });
                #endregion
            });
            #endregion

            #region Token服务注册
            //services.AddAuthorization(options =>
            //{
            //    options.AddPolicy("Client", policy => policy.RequireRole("Client").Build());
            //    options.AddPolicy("Admin", policy => policy.RequireRole("Admin").Build());
            //    options.AddPolicy("AdminOrClient", policy => policy.RequireRole("Admin,Client").Build());
            //});
            #endregion

            services.AddSqlSugarClient <DbFactory>((sp, op) =>
            {
                op.ConnectionString      = ConfigFileHelper.Get("Lottery:Data:Database:Connection");
                op.DbType                = DbType.MySql;
                op.IsAutoCloseConnection = true;
                op.InitKeyType           = InitKeyType.Attribute;
                op.IsShardSameThread     = false;
                //op.MoreSettings = new ConnMoreSettings() { IsAutoRemoveDataCache = true, IsWithNoLockQuery = false };
            });
            services.AddServices();
            services.AddCSRedis(options =>
            {
                var RedisHost     = ConfigFileHelper.Get("RedisConfig:RedisHost");
                var RedisPost     = ConfigFileHelper.Get("RedisConfig:RedisPost");
                var RedisPassword = ConfigFileHelper.Get("RedisConfig:RedisPassword");
                for (int i = 0; i < 16; i++)
                {
                    options.Add(new Smart.Core.NoSql.Redis.RedisConfig()
                    {
                        C_IP = RedisHost, C_Post = Convert.ToInt32(RedisPost), C_Password = RedisPassword, C_Defaultdatabase = i
                    });
                }
                //options.Add(new Smart.Core.NoSql.Redis.RedisConfig() { C_IP = "10.0.3.27", C_Post = 6379, C_Password = "******", C_Defaultdatabase = 0 });
                //options.Add(new Smart.Core.NoSql.Redis.RedisConfig() { C_IP = "10.0.3.27", C_Post = 6379, C_Password = "******", C_Defaultdatabase = 1 });
            });
            services.AddConsoleLogger(options => { });

            services.AddApiThrottle(options =>
            {
                options.Global.AddValves(new BlackListValve
                {
                    Policy   = Policy.Ip,
                    Priority = 99
                }, new WhiteListValve
                {
                    Policy   = Policy.UserIdentity,
                    Priority = 88
                },
                                         new BlackListValve
                {
                    Policy    = Policy.Header,
                    PolicyKey = "throttle"
                });
            });
            var t1 = new Task(() => new AutoTask().AutoAddToRedis_LotteryList());
            t1.Start();
            var t2 = new Task(() => new AutoTask().UcAutoRedis());
            t2.Start();
        }
Esempio n. 10
0
 public XmlResult nonhighfreq()
 {
     try
     {
         XmlDocument   xmlDoc     = new XmlDocument();
         XmlSerializer serializer = new XmlSerializer(typeof(XmlDocument));
         var           b          = RedisManager.DB_Other.Get <byte[]>("UC_nonhighfreq");
         if (b == null || b.Length == 0)
         {
             xmlDoc = LoadXmlDocument("http://lottery.jdddata.com/uc/nonhighfreq");
             if (xmlDoc == null || xmlDoc.DocumentElement.ChildNodes.Count == 0)
             {
                 return(new XmlResult(xmlDoc));
             }
             var commonConfig = ConfigFileHelper.Get <List <NoHeightLottery> >("NoHeightLottery");
             var nodes        = xmlDoc.DocumentElement.ChildNodes;
             foreach (XmlElement element in nodes)
             {
                 var Common = commonConfig.Where(x => x.key == element.FirstChild.InnerText).FirstOrDefault();
                 if (Common == null)
                 {
                     continue;
                 }
                 //var Issue = ((XmlElement)element.GetElementsByTagName("qihao")[0]).InnerText;
                 //if (string.IsNullOrEmpty(Issue))
                 //{
                 //    continue;
                 //}
                 // + Issue
                 var titelUrl = Common.title_url;
                 var morelink = Common.morelink;
                 foreach (XmlElement Sub_element in element.LastChild)
                 {
                     if (Sub_element.Name == "source")
                     {
                         Sub_element.InnerText = Source;
                     }
                     if (Sub_element.Name == "title_url")
                     {
                         Sub_element.InnerText = titelUrl;
                     }
                     if (Sub_element.Name == "bet")
                     {
                         var remark = Common.foot_group.Where(x => x.remark == Sub_element.FirstChild.InnerText).FirstOrDefault();
                         if (remark == null)
                         {
                             continue;
                         }
                         ((XmlElement)Sub_element.LastChild).InnerText = remark.url;
                     }
                     if (Sub_element.Name == "foot_group")
                     {
                         foreach (XmlElement Sub_foot_group in Sub_element.ChildNodes)
                         {
                             if (Sub_foot_group.Attributes["name"].InnerText == "开奖详情")
                             {
                                 Sub_foot_group.SetAttribute("url", titelUrl);
                             }
                             else if (Sub_foot_group.Attributes["name"].InnerText == "玩法说明")
                             {
                                 Sub_foot_group.SetAttribute("url", Common.foot_group.Where(x => x.remark == Sub_foot_group.Attributes["name"].InnerText).FirstOrDefault().url);
                             }
                         }
                     }
                     if (Sub_element.Name == "morelink")
                     {
                         Sub_element.SetAttribute("url", morelink);
                     }
                 }
             }
             MemoryStream ms = new MemoryStream();
             serializer.Serialize(ms, xmlDoc);
             RedisManager.DB_Other.Set("UC_nonhighfreq", ms.ToArray(), 60 * 3);
         }
         else
         {
             MemoryStream ms1 = new MemoryStream(b);
             xmlDoc = serializer.Deserialize(ms1) as XmlDocument;
         }
         return(new XmlResult(xmlDoc));
     }
     catch (Exception ex)
     {
         XmlDocument xmlDoc = new XmlDocument();
         return(new XmlResult(xmlDoc));
     }
 }
Esempio n. 11
0
 public void UCNohighfreq_Redis()
 {
     try
     {
         XmlDocument   xmlDoc     = new XmlDocument();
         XmlSerializer serializer = new XmlSerializer(typeof(XmlDocument));
         xmlDoc = LoadXmlDocument("http://lottery.jdddata.com/uc/nonhighfreq");
         var commonConfig = ConfigFileHelper.Get <List <NoHeightLottery> >("NoHeightLottery");
         if (xmlDoc == null || xmlDoc.DocumentElement.ChildNodes.Count == 0)
         {
             return;
         }
         var nodes = xmlDoc.DocumentElement.ChildNodes;
         foreach (XmlElement element in nodes)
         {
             var Common = commonConfig.Where(x => x.key == element.FirstChild.InnerText).FirstOrDefault();
             if (Common == null)
             {
                 continue;
             }
             var titelUrl = Common.title_url;
             var morelink = Common.morelink;
             foreach (XmlElement Sub_element in element.LastChild)
             {
                 if (Sub_element.Name == "source")
                 {
                     Sub_element.InnerText = Source;
                 }
                 if (Sub_element.Name == "title_url")
                 {
                     Sub_element.InnerText = titelUrl;
                 }
                 if (Sub_element.Name == "bet")
                 {
                     var remark = Common.foot_group.Where(x => x.remark == Sub_element.FirstChild.InnerText).FirstOrDefault();
                     if (remark == null)
                     {
                         continue;
                     }
                     ((XmlElement)Sub_element.LastChild).InnerText = remark.url;
                 }
                 if (Sub_element.Name == "foot_group")
                 {
                     foreach (XmlElement Sub_foot_group in Sub_element.ChildNodes)
                     {
                         if (Sub_foot_group.Attributes["name"].InnerText == "开奖详情")
                         {
                             Sub_foot_group.SetAttribute("url", titelUrl);
                         }
                         else if (Sub_foot_group.Attributes["name"].InnerText == "玩法说明")
                         {
                             Sub_foot_group.SetAttribute("url", Common.foot_group.Where(x => x.remark == Sub_foot_group.Attributes["name"].InnerText).FirstOrDefault().url);
                         }
                     }
                 }
                 if (Sub_element.Name == "morelink")
                 {
                     Sub_element.SetAttribute("url", morelink);
                 }
             }
         }
         MemoryStream ms = new MemoryStream();
         serializer.Serialize(ms, xmlDoc);
         RedisManager.DB_Other.Set("UC_nonhighfreq", ms.ToArray());
     }
     catch (Exception ex)
     {
     }
 }