Пример #1
0
 /// <summary>
 /// 发送给所有商户
 /// </summary>
 /// <param name="command">命令</param>
 /// <param name="message">消息</param>
 public void Send(EnumMessageCommand command, string message)
 {
     try
     {
         clientHub.Invoke("sendAllMessage", command, command.ToEnumDesc(), message).ContinueWith(t =>
         {
             if (t.IsFaulted)
             {
                 Logger.WriteLog(LogType.ERROR, "web发送消息错误" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff"), t.Exception);
             }
         });
     }
     catch (Exception e)
     {
         Logger.WriteLog(LogType.ERROR, "web发送消息异常" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff"), e);
     }
 }
Пример #2
0
 /// <summary>
 /// 发送给指定的商户号
 /// </summary>
 /// <param name="command">命令</param>
 /// <param name="code">商户号</param>
 /// <param name="message">消息内容</param>
 public void Send(EnumMessageCommand command, string code, string message)
 {
     try
     {
         Logger.WriteLog(LogType.ERROR, string.Format("Command:{0},Code:{1},Message:{2}", command, code, message));
         clientHub.Invoke("sendGroupMessage", command, command.ToEnumDesc(), message, code).ContinueWith(t =>
         {
             if (t.IsFaulted)
             {
                 Logger.WriteLog(LogType.ERROR, "web发送消息错误" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff"), t.Exception);
             }
         });
     }
     catch (Exception e)
     {
         Logger.WriteLog(LogType.ERROR, "web发送消息异常" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss fff"), e);
     }
 }
Пример #3
0
 /// <summary>
 /// 发送给所有连接用户
 /// </summary>
 /// <param name="command"></param>
 /// <param name="message"></param>
 public void SendAllMessage(EnumMessageCommand command, string title, string message)
 {
     Clients.All.Remind(command, title, message);
 }
Пример #4
0
 /// <summary>
 /// 发送给指定商户组
 /// </summary>
 /// <param name="command"></param>
 /// <param name="message"></param>
 /// <param name="roomList"></param>
 public void SendGroupList(EnumMessageCommand command, string title, string message, List <string> roomList)
 {
     Clients.Groups(roomList).Remind(command, title, message);
 }
Пример #5
0
 /// <summary>
 /// 发送单个组
 /// </summary>
 /// <param name="command"></param>
 /// <param name="message"></param>
 /// <param name="roomName"></param>
 public void SendGroupMessage(EnumMessageCommand command, string title, string message, string roomName)
 {
     Clients.Group(roomName).Remind(command, title, message);
 }
Пример #6
0
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        static void Main()
        {
            #region MyCode

            //Stopwatch watch = new Stopwatch();
            //watch.Start();

            Func <Type[]> funcs = new Func <Type[]>(() =>
            {
                Type[] types =
                {
                    typeof(DateTimeService),
                    typeof(LoginService),
                    typeof(PublisherService),
                    typeof(BusinessmanService),
                    typeof(OrderService),
                    typeof(PlatformRefundOrderService),
                    typeof(AccountService),
                    typeof(FundService),
                    typeof(FinancialService),
                    typeof(RiskControlService),
                    typeof(TPosService),
                    typeof(FlightDestineService),
                    typeof(TravelPaperService),
                    typeof(PlatformCfgService),
                    typeof(DeductionGroupService),
                    typeof(BehaviorStatService),
                    typeof(PidService),
                    typeof(FrePasserService),
                    typeof(ConsoLocalPolicyService),
                    typeof(InsuranceService),
                    typeof(NoticeService),
                    typeof(MemoryService),
                    typeof(MyMessageService),
                    typeof(PlatformPointGroupService),
                    typeof(OperationLogService)
                };           // 这里耗时最多。
                return(types);
            });

            IAsyncResult result = funcs.BeginInvoke(new AsyncCallback(Callback), funcs);
            BootStrapper.Boot(); // 耗时!


            while (true)
            {
                if (isGoOn)
                {
                    var        ser    = SettingSection.GetInstances().HttpServer;
                    HttpServer server = new HttpServer(ser.Host, ser.Port);
                    server.Start();
                    Console.WriteLine("Web服务启动成功");
                    //1106
                    //JoveZhao.Framework.DDD.Events.DomainEvents.Raise(new BPiaoBao.DomesticTicket.Domain.Models.RefundEvent.RefundTicketEvent() { SaleOrderId = 3797 });
                    while (true)
                    {
                        Console.WriteLine("请输入命令数字:");
                        EnumMessageCommand command = (EnumMessageCommand)int.Parse(Console.ReadLine());
                        Console.WriteLine("请输入商户号:");
                        string code = Console.ReadLine();
                        Console.WriteLine("请输入发送内容");
                        string content = Console.ReadLine();
                        WebMessageManager.GetInstance().Send(command, code, content);
                        MessagePushManager.SendMsgByBuyerCodes(new string[] { code }, (Common.Enums.EnumPushCommands)(command), content, true);
                        Console.WriteLine("消息已发送");
                    }
                }
            }

            #endregion



            #region OldCode
            //ServiceBase[] ServicesToRun;
            //ServicesToRun = new ServiceBase[]
            //{
            //    new Service1()
            //};
            //ServiceBase.Run(ServicesToRun);

            //Stopwatch watch = new Stopwatch();
            //watch.Start();
            //BootStrapper.Boot();
            //Type[] types = {
            //                  typeof(DateTimeService),
            //                  typeof(LoginService),
            //                  typeof(PublisherService),
            //                  typeof(BusinessmanService),
            //                  typeof(OrderService),
            //                  typeof(PlatformRefundOrderService),
            //                  typeof(AccountService),
            //                  typeof(FundService),
            //                  typeof(FinancialService),
            //                  typeof(RiskControlService),
            //                  typeof(TPosService),
            //                  typeof(FlightDestineService),
            //                  typeof(TravelPaperService),
            //                  typeof(PlatformCfgService),
            //                  typeof(DeductionGroupService),
            //                  typeof(BehaviorStatService),
            //                  typeof(PidService),
            //                  typeof(FrePasserService),
            //                  typeof(ConsoLocalPolicyService),
            //                  typeof(InsuranceService),
            //                  typeof(NoticeService)
            //              };
            //watch.Stop();
            //var c = watch.ElapsedMilliseconds;  // 反射耗时:6486(ms)  = 6.486(s)

            //foreach (var t in types)
            //{
            //    ServiceHost host = new ServiceHost(t);
            //    host.Opened += (p, q) =>
            //    {
            //        Console.WriteLine(t.Name + "启动成功");
            //    };
            //    host.Open();
            //}


            //AutoIssueManage.Start();
            //Console.WriteLine("自动出票服务启动");
            //DomesticService domesticService = ObjectFactory.GetInstance<DomesticService>();
            //domesticService.AutoIssue("04654475181900151211");



            //while (true)
            //{
            //    Console.WriteLine("清输入命令[数字]:");
            //    string inputCommand = Console.ReadLine();
            //    Console.WriteLine("输入发送内容:");
            //    string inputContent = Console.ReadLine();
            //    Console.WriteLine("请输入发送商户号");
            //    string code = Console.ReadLine();
            //    MessagePushManager.SendMsgByBuyerCodes(new string[] { code }, (Common.Enums.EnumPushCommands)(inputCommand.ToInt
            //        ()), inputContent, true);
            //    Console.WriteLine("消息已发送");
            //}

            //while (true)
            //{
            //    Console.WriteLine("请输入Token:");
            //    string token = Console.ReadLine();
            //    MemAuthInfoStroage mi = new MemAuthInfoStroage();
            //    var u = mi.GetUserByToken(token);
            //    Console.WriteLine(u.ToJson());
            //}

            #endregion
        }