public List <Address> Get(string originAddress)
        {
            List <Address> addressList = new List <Address>();

            try
            {
                using (var balObj = new BAL())
                {
                    //function call for get all the address from either in cache or CSV file.
                    addressList = balObj.GetAllAddresses();
                    if (addressList.Count > 0)
                    {
                        addressList = addressList.OrderBy(x => x.KM).Take(Convert.ToInt32(Constants.NumberOfAddress != null ? Constants.NumberOfAddress : "4")).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                LogWrite.LogError(ex);
            }
            return(addressList);
        }
Example #2
0
        public Task Execute(IJobExecutionContext context)
        {
            var isMarketDay = InitService.IsMarketDay(DateTime.Now.Date);


            if (!isMarketDay)
            {
                Console.WriteLine("非交易日,不进行微信推送");
                LogWrite.WriteLogInfo("非交易日,不进行微信推送");
                return(Task.FromResult(0));
            }
            Console.WriteLine("微信推送");

            #region 正式数据

            /*
             * 思路
             * 首先 扫库 这应该放到其他类中
             * 循环在线用户
             * 对比扫库中的List和在线用户对应的codeList
             * 取交集推送
             */
            DateTime time2         = DateTime.Now.AddHours(8);
            var      signalNowList = MongoService.GetStockSignalSingleByTime(_time1, time2);

            if (signalNowList != null && signalNowList.Count > 0)
            {
                foreach (var single in signalNowList)
                {
                    single.time = single.time.AddHours(-8);
                }

                Console.WriteLine($"时间:{signalNowList[0].time}");
                DirectExchangeSendMsg(signalNowList);
            }
            _time1 = time2;
            #endregion
            return(Task.FromResult(0));
        }
Example #3
0
        public static void Main(string[] args)
        {
            //删除rabbitMQ积压的数据
            WxPopJob.DeleteQueue();
            Console.WriteLine("删除rabbitMQ积压的数据");
            InitService initService = new InitService();

            //移除在线用户
            initService.InitOnline();
            //重启时,更新所有 userid-codeList的缓存
            initService.CreateUserIdCodeListCache();
            Console.WriteLine("更新所有 userid-codeList的缓存---完毕");
            Console.WriteLine("主进程开始..");
            LogWrite.WriteLogInfo("主进程开始");

            var url = Config.GetValue("SignalRUrl");

            LogWrite.WriteLogInfo($"服务地址{url}");
            Console.WriteLine($"服务地址{url}");
            using (WebApp.Start(url))
            {
                try
                {
                    LogWrite.WriteLogInfo("服务端口开启成功");
                    Console.WriteLine("服务端口开启成功");
                    QuartzJob();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    LogWrite.WriteLogError(e);
                }
                finally
                {
                    Console.ReadKey();
                }
            }
        }
Example #4
0
 public AEMSSender(LogWrite logwrite, AEMSClient aemsClient)
 {
     this.logwrite   = logwrite;
     this.aemsClient = aemsClient;
 }
Example #5
0
        public void WriteEventLogTest1()
        {
            string Temp_strLog = Environment.CurrentDirectory + "\\RemoveAlarmException";

            Assert.IsTrue(LogWrite.WriteEventLog("123", "312", Temp_strLog));
        }
Example #6
0
 public static void RegisterWriter(LogWrite writer)
 {
     callback = writer;
 }
Example #7
0
 public static void Log(LogTitle logTitle, string content, LogLevel logLevel, Exception exception = null)
 {
     LogWrite?.Invoke(null, LogEventArgs.GetLogEventArgs(logTitle, content, logLevel, exception));
 }
Example #8
0
        //private string serverIP;

        public HttpHandler(LogWrite logwrite)
        {
            this.logwrite   = logwrite;
            this.xmlHandler = new XMLHandler();
            this.urlHandler = new URLHandler();
        }
Example #9
0
 public XMLParser(LogWrite logwrite)
 {
     this.logwrite = logwrite;
     xmlDoucment   = new XmlDocument();
 }
Example #10
0
 protected override void Execute()
 {
     LogWrite.CreateLog().WritLog("这个是测试TestJob1");
 }
Example #11
0
 public ISPSSender(LogWrite logwrite, ISPSClient ispsClient)
 {
     this.logwrite   = logwrite;
     this.ispsClient = ispsClient;
 }
Example #12
0
        public Task Execute(IJobExecutionContext context)
        {
            var isMarketDay = InitService.IsMarketDay(DateTime.Now.Date);

            if (!isMarketDay)
            {
                Console.WriteLine("非交易日,不进行信号推送");
                LogWrite.WriteLogInfo("非交易日,不进行信号推送");
                return(Task.FromResult(0));
            }

            Console.WriteLine("右下角推送任务");
            LogWrite.WriteLogInfo($"------------右下角推送任务,时间:{DateTime.Now.ToLongTimeString()}---------------");

            /*
             * 思路
             * 首先 扫库 这应该放到其他类中
             * 循环在线用户
             * 对比扫库中的List和在线用户对应的codeList
             * 取交集推送
             *
             * 修改思路 不用count值作为推送条件 用时间作为推送筛选条件
             */
            DateTime time2 = DateTime.Now.AddHours(8);

            LogWrite.WriteLogInfo($"time1:{_time1}");
            LogWrite.WriteLogInfo($"time2:{time2}");
            var signalNowList = MongoService.GetStockSignalSingleByTime(_time1, time2);

            if (signalNowList != null && signalNowList.Count > 0)
            {
                #region debug代码,影响应能
                foreach (var stockSignalSingle in signalNowList)
                {
                    LogWrite.WriteLogInfo($"signalNowList-mongodb中新增的 未经用户过滤的信号:{stockSignalSingle.code}");
                }
                #endregion


                var onlineCache = InitService.GetOnlineCache();
                if (onlineCache == null || onlineCache.Count <= 0)
                {
                    return(Task.FromResult(0));
                }
                LogWrite.WriteLogInfo($"InitService.OnlineList-在线用户列表:{onlineCache.Count}");
                foreach (var online in onlineCache)
                {
                    LogWrite.WriteLogInfo($"online-循环的在线用户:{online}");

                    var codeList = InitService.GetOnlineCodeList(online);
                    LogWrite.WriteLogInfo($"codeList-用户关注的信号个数:{codeList.Count}");
                    #region debug代码 影响性能
                    foreach (var code in codeList)
                    {
                        LogWrite.WriteLogInfo($"当前用户:{online}关注的信号code:{code}");
                    }
                    #endregion
                    //signalNowList和codeList取交集
                    var nowCodeList = signalNowList.Select(m => m.code).ToList();
                    //得到了交集
                    if (codeList.Count <= 0 || nowCodeList.Count <= 0)
                    {
                        continue;
                    }
                    var intersect = codeList.Intersect(nowCodeList).ToList();
                    #region debug代码 影响性能 交集信号
                    foreach (var code in intersect)
                    {
                        LogWrite.WriteLogInfo($"交集信号有{code}");
                    }
                    #endregion
                    if (intersect.Count <= 0)
                    {
                        continue;
                    }
                    //构建推送架构
                    List <HashPop> hashPops = MongoService.CreatePopList(signalNowList, intersect);
                    LogWrite.WriteLogInfo($"hashPops-构建好的准备推送信号个数:{nowCodeList.Count}");

                    if (hashPops == null || hashPops.Count <= 0)
                    {
                        continue;
                    }
                    Console.WriteLine($"信号推送:用户{online},信号{hashPops.Count}");
                    LogWrite.WriteLogInfo("---------信号推送start-------------");
                    LogWrite.WriteLogInfo($"用户:{online}");
                    foreach (var pop in hashPops)
                    {
                        LogWrite.WriteLogInfo($"信号代码:{pop.Code}");
                    }
                    LogWrite.WriteLogInfo("---------信号推送end-------------");
                    GlobalHost.ConnectionManager.GetHubContext <SignalHub>().Clients
                    .User(online)
                    .alert_signal(hashPops);
                }
            }

            _time1 = time2;

            return(Task.FromResult(0));
        }
Example #13
0
        /// <summary>
        /// 设置Eterm数据
        /// </summary>
        /// <param name="hwnd"></param>
        /// <param name="data"></param>
        public void SetEtermData(string config, string guid, string cmd, string data)
        {
            EtermHelper.EtermData[config + guid + cmd] = data;

            LogWrite.WriteLog(string.Format("config={0} guid={1} cmd={2}\r\ndata={3}", config, guid, cmd, data));
        }
Example #14
0
 public UseDll(Form1 form)
 {
     this.form     = form;
     this.logwrite = LogWrite.getInstance();
 }
Example #15
0
        private bool isAlreadyAuth;     // 이벤트를 받기위해 XMPP 인증 절차 여부, XMPP 세션이 끊어지지 않으면, XMPP 인증은 한번만 받아야 한다.

        public FinesseClient(LogWrite logwrite, Finesse finesseObj) : base(logwrite)
        {
            this.finesseObj    = finesseObj;
            this.isAlreadyAuth = false;
        }
Example #16
0
 public ISPSClient(LogWrite logwrite, Finesse finesseObj) : base(logwrite)
 {
     this.finesseObj = finesseObj;
 }
Example #17
0
 public ISPSReceiver(StreamReader reader)
 {
     this.reader   = reader;
     this.logwrite = LogWrite.getInstance();
 }
Example #18
0
 public FinesseSender(LogWrite logwrite, FinesseClient finesseClient)
 {
     this.finesseClient = finesseClient;
     this.logwrite      = LogWrite.getInstance();
 }
Example #19
0
 public Result Run(JobInfo jobInfo)
 {
     LogWrite.CreateLog().WritLog("启动作业:" + $"id:{jobInfo.Id},{jobInfo.SchedName}:{jobInfo.JobGroup}.{jobInfo.JobName}");
     return(Execute(() => SchedulerManager.Singleton.CreateJob(jobInfo)));
 }
Example #20
0
        //测试数据方法
        public Task Execute2(IJobExecutionContext context)
        {
            Console.WriteLine("PopSend任务调度");
            LogWrite.WriteLogInfo("PopSend任务调度");
            #region 测试

            var stockSignalSingles          = MongoService.GetAllStockSignalSingle();
            var model1                      = stockSignalSingles.FindLast(m => m.code == "000001");
            var model2                      = stockSignalSingles.FindLast(m => m.code == "600000");
            var model3                      = stockSignalSingles.FindLast(m => m.code == "000063");
            var model4                      = stockSignalSingles.FindLast(m => m.code == "603999");
            var model5                      = stockSignalSingles.FindLast(m => m.code == "603998");
            List <stock_signal_single> list = new List <stock_signal_single>
            {
                model1, model2, model3, model4, model5
            };
            foreach (var online in InitService.GetOnlineCache())
            {
                var memoryCacheManager = new MemoryCacheManager();
                var cacheUserId        = memoryCacheManager.Get <string>(online);
                Console.WriteLine($"signal:{online}-userId:{cacheUserId}");
                var cacheCodeList = memoryCacheManager.Get <List <string> >(cacheUserId);
                foreach (var s in cacheCodeList)
                {
                    Console.WriteLine($"user:{cacheUserId}-codeList{s}");
                }

                var cacheCodeList1 = memoryCacheManager.Get <List <string> >($"push{online}");
                Console.WriteLine($"signal:push{online}-codeList{cacheCodeList1.Count}");
                var codeList = InitService.GetOnlineCodeList(online);
                //signalNowList和codeList取交集
                var nowCodeList = list.Select(m => m.code).ToList();
                //得到了交集
                if (codeList == null || codeList.Count <= 0 || nowCodeList.Count <= 0)
                {
                    continue;
                }
                var intersect = codeList.Intersect(nowCodeList).ToList();
                if (intersect.Count <= 0)
                {
                    continue;
                }
                //构建推送架构
                List <HashPop> hashPops = MongoService.CreatePopList(list, intersect);
                if (hashPops == null || hashPops.Count <= 0)
                {
                    continue;
                }
                Console.WriteLine($"信号推送:用户{online},信号{hashPops.Count}");
                //                LogWrite.WriteLogInfo("---------信号推送start-------------");
                //                LogWrite.WriteLogInfo($"用户:{online}");
                //                foreach (var pop in hashPops)
                //                {
                //                    LogWrite.WriteLogInfo($"信号代码:{pop.Code}");
                //                }
                //                LogWrite.WriteLogInfo("---------信号推送end-------------");
                GlobalHost.ConnectionManager.GetHubContext <SignalHub>().Clients
                .User(online)
                .alert_signal(hashPops);
            }

            #endregion
            return(Task.FromResult(0));
        }
Example #21
0
 public static void Write(string msg)
 {
     LogWrite?.Invoke(msg);
 }
Example #22
0
 public AEMSReceiver(StreamReader reader, Finesse finesseObj)
 {
     this.reader     = reader;
     this.logwrite   = LogWrite.getInstance();
     this.finesseObj = finesseObj;
 }
Example #23
0
 protected override void Execute()
 {
     LogWrite.CreateLog().DuggerLog("这个是测试TestJob2");
 }
Example #24
0
 protected ClientSocket(LogWrite logwrite)
 {
     this.logwrite        = logwrite;
     this.isDisconnectReq = false;
     this.currentServer   = new Hashtable();
 }