Пример #1
0
        public void GetLoginPopNotice()
        {
            var user = AuthManager.GetCurrentUser();

            if (user == null)
            {
                //throw  new CustomException(10001,"获取当前用户出错");
                Logger.WriteLog(LogType.ERROR, "获取当前用户出错");
            }
            var code    = user == null ? "" : user.Code;
            var account = user == null ? "" : user.OperatorAccount;
            var curDate = DateTime.Now;
            var list    = FindNoticeList(EnumNoticeType.LoginEject, "", null, null, 1, 20);
            var models  = list.List.Where(p => p.NoticeShowType.Contains(((int)EnumNoticeShowType.Mpb).ToString()) && p.EffectiveStartTime <= curDate && p.EffectiveEndTime >= curDate).ToList();

            var sb = new StringBuilder();

            foreach (var noticeDto in models)
            {
                sb.Append(noticeDto.ID + ",");
            }
            if (sb.Length <= 0)
            {
                return;
            }
            var s = sb.ToString().Substring(0, sb.Length - 1);

            MessagePushManager.Send(code, account, EnumPushCommands.LoginPopNoticeWindow, "公告", new object[] { s });
        }
Пример #2
0
        public void SendMessage(string jsonStr, string contentTemplate)
        {
            try
            {
                if (string.IsNullOrEmpty(jsonStr))
                {
                    return;
                }
                MatchCollection matchs     = Regex.Matches(contentTemplate, @"(\[(?<val>.*?)\])+");
                List <string>   properties = new List <string>();
                foreach (Match item in matchs)
                {
                    properties.Add(item.Groups["val"].Value);
                }


                Newtonsoft.Json.Linq.JArray objList = Newtonsoft.Json.Linq.JArray.Parse(jsonStr);
                foreach (var item in objList)
                {
                    string contentMessage = contentTemplate;
                    foreach (string propertyName in properties)
                    {
                        contentMessage = contentMessage.Replace(string.Format("[{0}]", propertyName), item[propertyName].ToString());
                    }
                    MessagePushManager.SendMsgByBuyerCodes(new string[] { item["Code"].ToString() }, (EnumPushCommands)Convert.ToInt32(item["command"]), contentMessage, true);
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog(LogType.ERROR, "发送消息异常", e);
            }
        }
Пример #3
0
        public void Subscriber(Guid guid, string code, string account)
        {
            IPublisherEvents callback = OperationContext.Current.GetCallbackChannel <IPublisherEvents>();

            OperationContext.Current.Channel.Closing += Channel_Closing;


            MessagePushManager.Subscriber(guid, code, account, callback);
            //是否有离线消息
            if (MessagePushManager.OffLineMessages != null && MessagePushManager.OffLineMessages.Count != 0)
            {
                MessagePushManager.OffLineMessages.Where(p => p.Value.Code == code).ToList().ForEach(p =>
                {
                    callback.Notify(p.Value.Command, p.Value.MessageContent, null);
                    OffLineMessage of = null;
                    MessagePushManager.OffLineMessages.TryRemove(p.Key, out of);
                });
            }
        }
Пример #4
0
        public void AddNotice(RequestNotice requestNotice)
        {
            var currentuser = AuthManager.GetCurrentUser();
            var model       = AutoMapper.Mapper.Map <RequestNotice, Notice>(requestNotice);

            model.CreateName       = currentuser.OperatorName;
            model.CreateTime       = DateTime.Now;
            model.Code             = "";
            model.State            = true;
            model.EffectiveEndTime = model.EffectiveEndTime.AddHours(23).AddMinutes(59).AddSeconds(59);
            this.unitOfWorkRepository.PersistCreationOf(model);
            this.unitOfWork.Commit();
            try
            {
                if (string.IsNullOrEmpty(model.NoticeShowType))
                {
                    return;
                }
                List <string> list = new List <string>();
                if (model.NoticeShowType.Contains("1"))
                {
                    list.AddRange(this.businessmanRepository.FindAllNoTracking().OfType <Carrier>().Select(x => x.Code).ToList());
                }
                if (model.NoticeShowType.Contains("2"))
                {
                    list.AddRange(this.businessmanRepository.FindAllNoTracking().OfType <Supplier>().Select(x => x.Code).ToList());
                }
                if (list.Count > 0)
                {
                    WebMessageManager.GetInstance().Send(EnumMessageCommand.Aannouncement, list.ToArray(), model.Title);
                }
                if (model.NoticeShowType.Contains("0"))
                {
                    MessagePushManager.SendAll(EnumPushCommands.EnforcePopNoticeWindow, model.Title, false, new object[] { model.ID });
                }
            }
            catch (Exception e)
            {
                Logger.WriteLog(LogType.ERROR, "公告异常", e);
            }
        }
Пример #5
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
        }
Пример #6
0
 public void SendNormalMsg(string content, bool isRepeatSend = false)
 {
     MessagePushManager.SendAll(EnumPushCommands.NormalMsg, content, isRepeatSend);
 }
Пример #7
0
 public void UnSubscriber(Guid guid)
 {
     MessagePushManager.UnSubscriber(guid);
 }