Ejemplo n.º 1
0
        public string PushHtmlMessage(HtmlMsg msg)
        {
            try
            {
                bool suc = PushServer.Instance().PushHtml(msg.RegName, msg.Content);
                if (suc)
                {
                    #region 添加到已发送成功列表

                    using (var db = new MPModel())
                    {
                        MsgSent model = new MsgSent()
                        {
                            Title       = msg.Title,
                            Content     = msg.Content,
                            RequestTime = msg.RequestTime,
                            ExpriedTime = msg.ExpriedTime,
                            MType       = (int)MsgType.Html,
                            RegName     = msg.RegName,
                            Phone       = "",
                            Address     = "",
                            SendTime    = DateTime.Now
                        };
                        db.MsgSents.Add(model);
                        int rows = db.SaveChanges();
                        return(rows > 0 ? "SUCCESS" : "ERROR");
                    }

                    #endregion
                }
                else
                {
                    #region 添加到待发送成功列表

                    using (var db = new MPModel())
                    {
                        MsgToBeSent model = new MsgToBeSent()
                        {
                            Title       = msg.Title,
                            Content     = msg.Content,
                            RequestTime = msg.RequestTime,
                            ExpriedTime = msg.ExpriedTime,
                            MType       = (int)MsgType.Html,
                            RegName     = msg.RegName,
                            Phone       = "",
                            Address     = ""
                        };
                        db.MsgToBeSents.Add(model);
                        int rows = db.SaveChanges();
                        return(rows > 0 ? "SUCCESS" : "ERROR");
                    }

                    #endregion
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 protected override void OnStop()
 {
     host.Close();
     host = null;
     PushServer.Instance().StopWebSocket();
     //System.IO.File.AppendAllText(@"D:\Log.txt", "\r\nService Stop :" + DateTime.Now.ToString());
 }
Ejemplo n.º 3
0
        static void StartListen()
        {
            string      port = System.Configuration.ConfigurationManager.AppSettings["port"].ToString();
            ServiceHost host = new ServiceHost(typeof(MPService));

            host.Opened += (s, e) => { Console.WriteLine("WCF opened on " + host.BaseAddresses[0]); };
            host.Open();
            PushServer.Instance().StartWebSocket(port);
        }
Ejemplo n.º 4
0
        protected override void OnStart(string[] args)
        {
            string port = System.Configuration.ConfigurationManager.AppSettings["port"].ToString();

            host         = new ServiceHost(typeof(MPService));
            host.Opened += (s, e) => { Console.WriteLine("WCF opened on " + host.BaseAddresses[0]); };
            host.Open();
            PushServer.Instance().StartWebSocket(port, Fleck.LogLevel.Error);
            //System.IO.File.AppendAllText(@"D:\Log.txt", "\r\nService Start :" + DateTime.Now.ToString());
        }