Exemple #1
0
 public static void Run(MSMQ queuer, QueueMessage message)
 {
     if (message.topic == "product_created")
     {
         queuer.Acknowledge(message.id);
     }
 }
Exemple #2
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            MSMQ   message = new MSMQ();
            string value   = message.ReceiveMessage();

            CreateWebHostBuilder(args).Build().Run();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            List <KirimModel> list = new List <KirimModel>()
            {
                new KirimModel("John Hadikusumo", "0431343034", "*****@*****.**", "Registration", "Your registration is complete"),
                new KirimModel("Masdi Chandra", "042724022", "*****@*****.**", "Forget Password", "Your password has been resetted"),
                new KirimModel("Diana Mangunsong", "047032995", "*****@*****.**", "Registration", "Your registration is complete"),
                new KirimModel("Robert Raharjo", "048820104", "*****@*****.**", "Registration", "Your registration is complete"),
                new KirimModel("Kathy Sondak", "049211525", "*****@*****.**", "Registration", "Your registration is complete"),
                new KirimModel("Lilian Wu", "046455532", "*****@*****.**", "Registration", "Your registration is complete"),
                new KirimModel("Freddy Mc Mahon", "04230078", "*****@*****.**", "Registration", "Your registration is complete"),
                new KirimModel("Ram Ram Don", "0431343034", "*****@*****.**", "Registration", "Your registration is complete"),
                new KirimModel("Suratj Pakir", "044673079", "*****@*****.**", "Forget Password", "Your password has been resetted"),
                new KirimModel("Simon Ryu", "04620039", "*****@*****.**", "Registration", "Your registration is complete"),
                new KirimModel("Rhea Tobari", "048832044", "*****@*****.**", "Registration", "Your registration is complete")
            };

            for (int i = 0; i < list.Count; i++)
            {
                MSMQModel <KirimModel> model = new MSMQModel <KirimModel>();
                model.QueueName    = ConfigurationManager.AppSettings["Queue_Name"].ToString();
                model.QueueMessage = list[i];
                MSMQ <KirimModel> msmq = new MSMQ <KirimModel>();
                string            id   = msmq.WriteQueueMessage(model);
                Console.WriteLine("Id => " + id);
            }
            Console.ReadLine();
        }
Exemple #4
0
        public void TestSendMessage()
        {
            var queuer = MSMQ.GetNotificationsQueuer();
            var result = queuer.Send("product_created", new ArrayList());

            Assert.IsTrue(result.IsSuccess());
        }
        public ActionResult ForgetPassword(ForgetPasswordModel forgetPasswordModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    MSMQModel result = bookBL.ForgetPassword(forgetPasswordModel);                   //getting the data from BusinessLayer
                    var       msmq   = new MSMQ(Configuration);
                    msmq.MSMQSender(result);
                    if (result != null)
                    {
                        return(this.Ok(new { Success = true, Message = "Your password has been forget sucessfully now you can reset your password" }));   //(smd format)    //this.Ok returns the data in json format
                    }

                    else
                    {
                        return(this.Ok(new { Success = true, Message = "Other User is trying to login from your account" }));   //(smd format)    //this.Ok returns the data in json format
                    }
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { Success = false, ex.Message }));
            }
        }
Exemple #6
0
        private void processMessageQueueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int count = MSMQ.GetMessageCount(Strings.All_SaveQueueName);

            foreach (var data in MSMQ.ReceiveAllFromQueue <Hashtable>(Strings.All_SaveQueueName, TimeSpan.FromSeconds(15), count))
            {
                ServerDataAccess.InsertFileAsync(data, OnInsertErrorCallback);
            }
        }
Exemple #7
0
        public void TestAcknowledgeMessage()
        {
            var queuer  = MSMQ.GetNotificationsQueuer();
            var result  = queuer.Read(1);
            var message = (result.GetResult() as List <QueueMessage>).FirstOrDefault();

            var ack = queuer.Acknowledge(message.id);

            Assert.IsTrue(ack.IsSuccess());
        }
Exemple #8
0
 private static void OnError(object sender, ThreadExceptionEventArgs args)
 {
     Trace.WriteLine("ReceivingWebService::OnInsertErrorCallback send to msmq -> ".concat(Strings.All_SaveQueueName));
     using (SQLWorker.CommandInfo info = (SQLWorker.CommandInfo)sender)
     {
         Debug.Assert(info != null, "Info is null");
         Hashtable ht = SQL.CreateSerializationData(info.Command);
         MSMQ.SendToQueue(Strings.All_SaveQueueName, DateTime.Now.ToString(), ht);
     }
 }
Exemple #9
0
 private void Timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     log.Info("Timer_Elapsed starts here");
     model                       = new MSMQModel <KirimModel>();
     model.QueueName             = ConfigurationManager.AppSettings["Queue_Name"].ToString();
     messaging                   = new MSMQ <KirimModel>();
     messaging.ReadEventHandler += Messaging_ReadEventHandler;
     messaging.ReadQueueMessage(model);
     log.Info("Timer_Elapsed stops here");
 }
Exemple #10
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            #region  初始化配置
            var sysConfPath = Server.MapPath("/App_Data/SysConfKey.xml");
            var SMSConfPath = Server.MapPath("/App_Data/SMSConfig.xml");
            ThreadPool.QueueUserWorkItem(o =>
            {
                #region 系统配置
                var keys   = YunXiu.Commom.CommomClass.GetXmlNodeValue(sysConfPath, "/keys/key");
                var isLoad = YunXiu.Commom.CommomClass.LoadConfigDictionary(keys);
                if (!isLoad)
                {
                    //如果配置没有加载成功通知运维
                }
                #endregion

                #region 短信供应商配置
                GlobalDictionary.SMSConfDic = CommomClass.GetXmlNodeVal(SMSConfPath, "/SMS/SMSProvider[IsUse=1]");
                #endregion
            });
            #endregion

            #region 初始化库存
            ThreadPool.QueueUserWorkItem(o =>
            {
                // ProductStock_Cache cache = new ProductStock_Cache();
                ProductStock_BLL productStockBLL = new ProductStock_BLL();
                //  cache.SaveProductStock(productStockBLL.GetProductStock());
            });
            #endregion

            #region 读取MQ的订单(MSMQ)
            MSMQ m = new MSMQ
            {
                MSMQIP   = "192.168.9.32",
                MSMQName = "orderQueue"
            };

            ThreadPool.QueueUserWorkItem(o =>
            {
                while (true)
                {
                    Thread.Sleep(100);
                    m.BeginReceive("", "");
                    m.receiveComplete += MQMQReceiveComplete;
                }
            });
            #endregion
        }
        static void Main(string[] args)
        {
            IMessageLoader _loader = new MessageLoader();

            const long numberOfMessages = 500;

            var msmq = new MSMQ <string>(_loader);

            new PerfomanceTest(msmq, msmq).Run(500, numberOfMessages);

            Console.ReadKey();
        }
Exemple #12
0
        static void UnattendedMain(string[] args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            Beep("start_app");

            //Locked = false;
            MSMQ.Install();

            //TRACE = true;
            RunApplication();
            return;
        }
Exemple #13
0
        protected override void OnStart(string[] args)
        {
            var queuer = MSMQ.GetNotificationsQueuer();
            var result = queuer.Read();

            if (result.IsSuccess())
            {
                var messages = (List <QueueMessage>)result.GetResult();

                foreach (var message in messages)
                {
                    var thread = new Thread(() => Processor.Run(queuer, message));
                    thread.Start();
                }
            }
            else
            {
                // Log error
            }
        }
Exemple #14
0
        public async Task <bool> Kirim(KirimModel model)
        {
            bool result = await Task.Run <bool>(() => {
                MSMQModel <KirimModel> newmodel = new MSMQModel <KirimModel>();
                newmodel.QueueMessage           = model;
                newmodel.QueueName     = ConfigurationManager.AppSettings["Queue_Name"].ToString();
                MSMQ <KirimModel> msmq = new MSMQ <KirimModel>();
                msmq.WriteQueueMessage(newmodel);

                SMSMessage message = new SMSMessage();
                message.Message    = message.Message.Replace("{PENGIRIM}", model.Name).Replace("{NEWLINE}", Environment.NewLine + Environment.NewLine);

                SMS sms     = new SMS();
                sms.Message = message;
                sms.Send();
                return(true);
            });

            return(result);
        }
Exemple #15
0
        public void TestReadMessages()
        {
            var queuer = MSMQ.GetNotificationsQueuer();
            var status = queuer.Send("test", new object());

            switch (status)
            {
            case Response ok when ok.type == Types.Returns.OK:
                var result = queuer.Read();
                Assert.IsTrue(result.IsSuccess());
                break;

            case Response error when error.type == Types.Returns.Error:
                Assert.IsTrue(false);
                break;

            default:
                Assert.IsTrue(false);
                break;
            }
        }
        public ActionResult ForgetPassword(ForgetPasswordModel forgetPasswordModel)
        {
            if (ModelState.IsValid)
            {
                ForgetClass result = userBL.ForgetPassword(forgetPasswordModel);
                var         msmq   = new MSMQ(Configuration);
                msmq.MSMQSender(result);
                if (result != null)
                {
                    return(this.Ok(new { Success = true, Message = "Your password has been forget sucessfully now you can reset your password" }));
                }

                else
                {
                    return(this.Ok(new { Success = true, Message = "Other User is trying to login from your account" }));
                }
            }
            else
            {
                throw new Exception("Model is not valid");
            }
        }
Exemple #17
0
        /// <summary>
        /// Forgets the password.
        /// </summary>
        /// <param name="email">The email.</param>
        /// <returns>return the result</returns>
        public async Task <string> ForgetPassword(string email)
        {
            var emailId = await this.userManager.FindByEmailAsync(email);

            if (emailId != null)
            {
                MSMQ msmq = new MSMQ();
                //
                string token = await this.userManager.GeneratePasswordResetTokenAsync(emailId);

                // await this.userManager.ConfirmEmailAsync(emailId, token);

                //var encodeToken = System.Text.Encoding.UTF32.GetBytes(token);

                msmq.SendEmailToQueue(email, token);
                return(token.ToString());
            }
            else
            {
                var message = "EmailId Is Invalid";
                return(message);
            }
        }
 public CustomerOrderBL(ICustomerOrderRL customerOrderRL, IConfiguration config)
 {
     CustomerOrderRL = customerOrderRL;
     mSMQ            = new MSMQ(config);
 }
Exemple #19
0
 static void Main()
 {
     T.Initialize("mqtool");
     MSMQ.Install();
     Application.Run(new QueueLoopback());
 }