예제 #1
0
파일: Topic.cs 프로젝트: nonintanon/SignalR
 public Topic(uint storeSize, TimeSpan ttl)
 {
     _ttl = ttl;
     Subscriptions = new List<ISubscription>();
     Store = new MessageStore<Message>(storeSize);
     SubscriptionLock = new ReaderWriterLockSlim();
 }
 public LocalEventKeyInfo(string key, ulong id, MessageStore<Message> store)
 {
     // Don't hold onto MessageStores that would otherwise be GC'd
     _storeReference = new WeakReference(store);
     Key = key;
     Id = id;
 }
예제 #3
0
 public Topic(uint storeSize, TimeSpan lifespan)
 {
     _lifespan = lifespan;
     Subscriptions = new List<ISubscription>();
     Store = new MessageStore<Message>(storeSize);
     SubscriptionLock = new ReaderWriterLockSlim();
 }
예제 #4
0
        static void Main(string[] args)
        {
            MessageStore<object> ms = new MessageStore<object>(capacity: 80000);
            ThreadPool.SetMinThreads(32, 32);

            Console.WriteLine("{0}-bit process", IntPtr.Size * 8);
            Console.WriteLine("{0} writer(s), {1} reader(s)", NumWriters, NumReaders);
            Console.WriteLine("Running for {0}..", RunTime);

            // queue writers
            for (int writerNum = 0; writerNum < NumWriters; writerNum++)
            {
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    for (int i = 0; ; i++)
                    {
                        ms.Add("This is my awesome object!");
                    }
                }, null);
            }

            // queue readers
            long totalMessagesRecvd = 0;
            for (int readerNum = 0; readerNum < NumReaders; readerNum++)
            {
                ThreadPool.QueueUserWorkItem(_ =>
                {
                    ulong firstMessageIdToReceive = 0;
                    while (true)
                    {
                        var x = ms.GetMessages(firstMessageIdToReceive);
                        ulong firstMessageIdReceived = x.FirstMessageId;
                        firstMessageIdToReceive = firstMessageIdReceived + (ulong)x.Messages.Length;

                        if (x.Messages.Length > 0)
                        {
                            Interlocked.Add(ref totalMessagesRecvd, x.Messages.Length);
                        }
                        else
                        {
                            // back off if there is no more data
                            Thread.Sleep(10);
                        }

                    }
                }, null);
            }

            // let the program run for 10 seconds
            Thread.Sleep(RunTime);
            ulong totalMessagesWritten = ms.GetMessageCount();

            Console.WriteLine();
            Console.WriteLine("Throughput:");
            Console.WriteLine("{0:N0} total messages written", totalMessagesWritten);
            Console.WriteLine("  ({0:N0} messages per writer per second)", totalMessagesWritten / RunTime.TotalSeconds / NumWriters);
            Console.WriteLine("{0:N0} total messages received", totalMessagesRecvd);
            Console.WriteLine("  ({0:N0} messages per reader per second)", totalMessagesRecvd / RunTime.TotalSeconds / NumReaders);
        }
예제 #5
0
        public void Gets_Display_Name()
        {
            var stream = TestHelper.GetTestDataStream("test.pst");
            var reader = new PstReader(stream);

            var messageStore = new MessageStore(0x21, reader);

            Assert.AreEqual("Outlook Data File", messageStore.DisplayName);
        }
예제 #6
0
        public static void UseSmtp4dev(this IServiceCollection services)
        {
            SettingsStore settingsStore = new SettingsStore();
            services.AddSingleton<ISettingsStore>(settingsStore);

            MessageStore messageStore = new MessageStore();
            services.AddSingleton<IMessageStore>(messageStore);

            services.AddTransient<ISmtp4devEngine, Smtp4devEngine>();
        }
예제 #7
0
        public void Gets_Record_Key()
        {
            var expectedBytes = new byte[]
            {
                0x97, 0x7b, 0x45, 0xcb, 0xdb, 0xc2, 0x82, 0x43,
                0x92, 0x10, 0x55, 0x19, 0xe9, 0x93, 0x28, 0xfa
            };
            var stream = TestHelper.GetTestDataStream("test.pst");
            var reader = new PstReader(stream);

            var messageStore = new MessageStore(0x21, reader);

            CollectionAssert.AreEqual(expectedBytes, messageStore.RecordKey);
        }
예제 #8
0
 public JsonResult Update(WArticleViewModel wViewModel)
 {
     try
     {
         wViewModel.WArticle.UpdatedBy = ((UserInfo)Session["User"]).UserId;
         wViewModel.WArticle.UpdatedOn = DateTime.Now;
         _wArticleMan.Update_WArticle(wViewModel.WArticle);
         wViewModel.Friendly_Message.Add(MessageStore.Get("WA002"));
     }
     catch (Exception ex)
     {
         wViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
         Logger.Error("WArticle Controller - Update " + ex.ToString());
     }
     return(Json(wViewModel));
 }
예제 #9
0
        public JsonResult DeleteFlightDetails(BookingViewModel bViewModel)
        {
            try
            {
                _bRepo.DeleteFlightDetails(bViewModel.BookingCartDetailsInfo.Train_FlightMainId);
                bViewModel.BookingCartDetailsInfo.TrainFlightDetails = _bRepo.GetTrainFlightDetails(bViewModel.BookingCartDetailsInfo.BookingId);
                bViewModel.FriendlyMessage.Add(MessageStore.Get("Booking07"));
            }
            catch (Exception ex)
            {
                bViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Booking Controller - DeleteFlightDetails" + ex.ToString());
            }
            return(Json(bViewModel));
        }
        // public Command SendCommand { get; }
        // public UserMessage UM { get; set; }
        public MessageViewModel(UserDetailData recip, string senderId)
        {
            Recip    = recip;
            Title    = Recip.FirstName + " " + Recip.LastName;
            SenderId = senderId;
            Messages = new ObservableCollection <UserMessage>();

            LoadMessagesCommand = new Command(async() => await ExecuteLoadMessages());
            //SendCommand = new Command(Send);
            MessagingCenter.Subscribe <MessagePage, UserMessage>(this, "SendMessage", async(obj, message) =>
            {
                var newMessage = message as UserMessage;
                await MessageStore.AddMessageAsync(newMessage);
                Messages.Add(newMessage);
            });
        }
예제 #11
0
        public ActionResult View_Quality(QualityViewModel qViewModel)
        {
            ViewBag.Title = "KPCL ERP :: Search";

            try
            {
                qViewModel.Quality = _qualityMan.Get_Quality_By_Id(qViewModel.Quality.Quality_Id);
            }
            catch (Exception ex)
            {
                qViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Quality Controller - Search " + ex.ToString());
            }

            return(View("View", qViewModel));
        }
예제 #12
0
        public ActionResult Service_Listing(HomeViewModel homeViewModel)
        {
            ViewBag.Page = "Service";

            ViewBag.Title = "MagniPi | Services";

            try
            {
            }
            catch (Exception ex)
            {
                homeViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Home Controller - Service_Listing: " + ex.ToString());
            }
            return(View("ServiceListing", homeViewModel));
        }
예제 #13
0
        public ActionResult Testimonial_Listing(HomeViewModel homeViewModel)
        {
            ViewBag.Page = "Testimonial";

            ViewBag.Title = "MagniPi | Testimonial";

            try
            {
            }
            catch (Exception ex)
            {
                Logger.Error("Home Controller - Testimonial_Listing: " + ex.ToString());

                homeViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));
            }
            return(View("TestimonialListing", homeViewModel));
        }
예제 #14
0
        public ActionResult GetEnquiryById(EnquiryViewModel enqViewModel)
        {
            try
            {
                enqViewModel.Enquiry = _enqRepo.GetEnquiryById(enqViewModel.EnquiryFilter.EnquiryId);
            }
            catch (Exception ex)
            {
                enqViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Enquiry Controller - GetEnquiryById" + ex.ToString());
            }

            TempData["enqViewModel"] = enqViewModel;

            return(Index(enqViewModel));
        }
예제 #15
0
        public ActionResult Save_Customer(CustomerViewModel cViewModel)
        {
            try
            {
                SessionInfo session = new SessionInfo();

                if (Session["SessionInfo"] != null)
                {
                    session = (SessionInfo)Session["SessionInfo"];
                }

                cViewModel.customer.Updated_By = session.User_Id;
                cViewModel.customer.Updated_On = DateTime.Now;
                cViewModel.customer.Created_By = session.User_Id;
                cViewModel.customer.Created_On = DateTime.Now;

                if (cViewModel.customer.Is_Indivisual)
                {
                    cViewModel.customer.member.Updated_By = session.User_Id;
                    cViewModel.customer.member.Updated_On = DateTime.Now;
                    cViewModel.customer.member.Created_By = session.User_Id;
                    cViewModel.customer.member.Created_On = DateTime.Now;
                }

                if (cViewModel.customer.Customer_Id != 0)
                {
                    _customerMan.Update_Customer(cViewModel.customer);

                    cViewModel.FriendlyMessage.Add(MessageStore.Get("CST02"));
                }
                else
                {
                    _customerMan.Insert_Customer(cViewModel.customer);

                    cViewModel.FriendlyMessage.Add(MessageStore.Get("CST01"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Customer Controller - Save_Customer: " + ex.ToString());

                cViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));
            }

            return(View("Search", cViewModel));
        }
예제 #16
0
        public JsonResult DeleteContactPerson(VendorViewModel vViewModel)
        {
            try
            {
                _vRepo.DeleteContactPerson(vViewModel.ContactPerson.ContactPersonId, vViewModel.ContactPerson.RefId);

                Logger.Debug("Vendor Controller DeleteContactPerson");
            }
            catch (Exception ex)
            {
                vViewModel.FriendlyMessage.Add(MessageStore.Get("CP03"));

                Logger.Error("Vendor Controller - DeleteContactPerson" + ex.ToString());
            }

            return(Json(vViewModel));
        }
예제 #17
0
        public JsonResult DeleteVendorBank(VendorViewModel vViewModel)
        {
            try
            {
                _vRepo.DeleteVendorBank(vViewModel.Bank.BankId, vViewModel.Bank.VendorId);

                Logger.Debug("Vendor Controller DeleteVendorBank");
            }
            catch (Exception ex)
            {
                vViewModel.FriendlyMessage.Add(MessageStore.Get("VB03"));

                Logger.Error("Vendor Controller - DeleteVendorBank" + ex.ToString());
            }

            return(Json(vViewModel));
        }
예제 #18
0
        public ActionResult View_P_Article(PArticleViewModel pViewModel)
        {
            ViewBag.Title = "KPCL ERP :: Search";

            try
            {
                pViewModel.PArticle = _particleMan.Get_PArticles_By_Id(pViewModel.PArticle.P_Article_Id);
            }
            catch (Exception ex)
            {
                pViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("PArticle Controller - View_G_Article " + ex.ToString());
            }

            return(View("View", pViewModel));
        }
예제 #19
0
        public ActionResult View_Y_Article(YArticleViewModel yViewModel)
        {
            ViewBag.Title = "KPCL ERP :: Search";

            try
            {
                yViewModel.YArticle = _yArticleMan.Get_YArticle_By_Id(yViewModel.YArticle.Y_Article_Id);
            }
            catch (Exception ex)
            {
                yViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("YArticle Controller - View_Y_Article " + ex.ToString());
            }

            return(View("View", yViewModel));
        }
예제 #20
0
        public ActionResult View_C_Article(CArticleViewModel cViewModel)
        {
            ViewBag.Title = "KPCL ERP :: Search";

            try
            {
                cViewModel.CArticle = _cArticleMan.Get_CArticle_By_Id(cViewModel.CArticle.C_Article_Id);
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("CArticle Controller - View_C_Article " + ex.ToString());
            }

            return(View("View", cViewModel));
        }
예제 #21
0
        //[AuthorizeUser(RoleModule.HotelTariff, Function.View)]
        //public JsonResult DeleteCustomerCategory(HotelTariffViewModel htViewModel)
        //{
        //	try
        //	{
        //		_htRepo.DeleteCustomerCategory(htViewModel.HotelTariffCustomerCategory.HotelTariffDurationDetailsId,htViewModel.HotelTariffCustomerCategory.HotelTariffRoomDetailsId, htViewModel.HotelTariffCustomerCategory.HotelTariffCustomerCategoryId);

        //		htViewModel.FriendlyMessage.Add(MessageStore.Get("HotelTariffCustomerCategory03"));

        //	}
        //	catch (Exception ex)
        //	{
        //		htViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));


        //		Logger.Error("HotelTariff Controller - DeleteCustomerCategory" + ex.ToString());
        //	}

        //	return Json(htViewModel);
        //}

        #endregion

        public PartialViewResult GetCustomerCategoryByOccupencyIdTariffDate(int hotelTariffRoomOccupancyId, DateTime tariffDate)
        {
            HotelTariffViewModel htViewModel = new HotelTariffViewModel();

            try
            {
                htViewModel.HotelTariffCustomerCategories = _htRepo.GetHotelTariffCustomerCategory(hotelTariffRoomOccupancyId, tariffDate);
            }

            catch (Exception ex)
            {
                htViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("Hotel Tariff Controller - GetHotelTariffDuration  " + ex.Message);
            }
            return(PartialView("_CustomerCategory", htViewModel));
        }
예제 #22
0
        public async Task DeliversSubsequentMessage()
        {
            var command = new CommandPublishingEvent();

            var commandStore = new MessageStore <CommandPublishingEvent>();
            var eventStore   = new MessageStore <Event>();

            await this.testee.Subscribe(new CommandPublishingEventHandlerFactory(commandStore));

            await this.testee.Subscribe(new EventHandlerFactory(eventStore));

            await this.testee.Publish(command);

            await this.testee.WaitForCompletion();

            eventStore.Messages.Should().HaveCount(1);
        }
예제 #23
0
 public void AddMessage(string from, string data, bool fromMe)
 {
     if (this.flowLayoutPanel1.InvokeRequired)
     {
         AddMessageCustomCallback call = new AddMessageCustomCallback(AddMessage);
         this.Invoke(call, new object[] { from, data, fromMe });
     }
     else
     {
         WappMessage msg = new WappMessage(from, data, fromMe);
         this.messages.Add(msg);
         this.limitMessages();
         MessageStore.AddMessage(msg);
         this.addChatMessage(msg);
         this.ScrollToBottom();
     }
 }
예제 #24
0
        public ActionResult View_Contact(ContactViewModel cViewModel)
        {
            ViewBag.Title = "KPCL ERP :: Search";

            try
            {
                cViewModel.Contact = _contactMan.Get_Contact_By_Id(cViewModel.Contact.Contact_Id);
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Contact Controller - Search " + ex.ToString());
            }

            return(View("View", cViewModel));
        }
예제 #25
0
        public ActionResult Index(AboutUsViewModel auViewModel)
        {
            try
            {
                auViewModel.aboutus = _aboutusMan.Get_About_Us_By_Id(1);

                auViewModel.aboutus.Header_Image_Url = ConfigurationManager.AppSettings["Upload_Image_Path"].ToString() + @"\" + auViewModel.aboutus.File_Type_Str + @"\" + auViewModel.aboutus.Header_Image_Url;
            }
            catch (Exception ex)
            {
                auViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("AboutUs Controller - Index: " + ex.ToString());
            }

            return(View("Index", auViewModel));
        }
예제 #26
0
        public JsonResult Update_Staggered_Order(EnquiryViewModel eViewModel)
        {
            try
            {
                _enquiryMan.Update_Staggered_Order(eViewModel.Enquiry.Staggered_Order);

                eViewModel.Friendly_Message.Add(MessageStore.Get("EQ004"));
            }
            catch (Exception ex)
            {
                eViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Enquiry Controller - Update_Staggered_Order " + ex.ToString());
            }

            return(Json(eViewModel));
        }
예제 #27
0
 public ActionResult Update(PackingViewModel pViewModel)
 {
     try
     {
         pViewModel.Packing.UpdatedBy = ((UserInfo)Session["User"]).UserId;
         pViewModel.Packing.UpdatedOn = DateTime.Now;
         _packingMan.Update_Packing(pViewModel.Packing);
         pViewModel.Friendly_Message.Add(MessageStore.Get("PC002"));
     }
     catch (Exception ex)
     {
         pViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
         Logger.Error("Packing Controller - Update " + ex.ToString());
     }
     TempData["pViewModel"] = pViewModel;
     return(RedirectToAction("Search"));
 }
        public JsonResult Insert(ConsumableViewModel cViewModel)
        {
            try
            {
                int consumableId = _consumableMan.Insert_Consumable(cViewModel.Consumable);

                cViewModel.Consumable.Consumable_Id = consumableId;

                cViewModel.Friendly_Message.Add(MessageStore.Get("C011"));
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }

            return(Json(cViewModel, JsonRequestBehavior.AllowGet));
        }
예제 #29
0
 public void AddMessage(string message)
 {
     if (this.flowLayoutPanel1.InvokeRequired)
     {
         AddMessageCallback r = new AddMessageCallback(AddMessage);
         this.Invoke(r, new object[] { message });
     }
     else
     {
         WappMessage msg = new WappMessage(message, this.target);
         this.messages.Add(msg);
         this.limitMessages();
         MessageStore.AddMessage(msg);
         this.addChatMessage(msg);
         this.ScrollToBottom();
     }
 }
        public ActionResult Delete_Vendor_By_Id(int consumable_Vendor_Id)
        {
            List <FriendlyMessageInfo> Friendly_Message = new List <FriendlyMessageInfo>();

            try
            {
                _consumableMan.Delete_Vendor_By_Id(consumable_Vendor_Id);

                Friendly_Message.Add(MessageStore.Get("CV012"));
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Json(new { Friendly_Message }, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Update_Consumable_Vendors(ConsumableViewModel cViewModel)
        {
            try
            {
                _consumableMan.Update_Consumable_Vendors(cViewModel.Consumable);

                cViewModel.Consumable.Consumable_Vendors = _consumableMan.Get_Consumable_Vendor_By_Consumable_Id(cViewModel.Consumable.Consumable_Id);

                cViewModel.Friendly_Message.Add(MessageStore.Get("CV014"));
            }
            catch (Exception ex)
            {
                cViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }

            return(Json(cViewModel));
        }
예제 #32
0
        //public ActionResult Update_Product_Service(VendorViewModel vViewModel)
        //{
        //    try
        //    {
        //        //vViewModel.Product_Vendor.Product_Vendor_Entity.UpdatedBy = 1;

        //        _vendorMan.Update_Product_Services(vViewModel.Product_Vendor);

        //        vViewModel.Product_Vendor_Grid = _vendorMan.Get_Product_Vendor_By_Id(vViewModel.Product_Vendor.Product_Vendor_Entity.Vendor_Id);

        //        vViewModel.Friendly_Message.Add(MessageStore.Get("PS012"));

        //    }
        //    catch (Exception ex)
        //    {
        //        vViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

        //        Logger.Error("Vendor Controller - Update_Product_Vendor_Details " + ex.ToString());
        //    }

        //    return Json(vViewModel);
        //}

        public ActionResult Get_Vendor_By_Id(VendorViewModel vViewModel)
        {
            try
            {
                vViewModel.Vendor = _vendorMan.Get_Vendor_By_Id(vViewModel.Vendor.Vendor_Id);

                //vViewModel.Product_Vendor_Grid = _vendorMan.Get_Product_Vendor_By_Id(vViewModel.Vendor.Vendor_Id);
            }
            catch (Exception ex)
            {
                vViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));

                Logger.Error("Vendor Controller - Get_Vendor_By_Id " + ex.ToString());
            }

            return(Index(vViewModel));
        }
예제 #33
0
        public JsonResult Insert_Industrial_Vendor(IndustrialViewModel iViewModel)
        {
            PaginationInfo pager = new PaginationInfo();

            try
            {
                iViewModel.Industrial_Vendor.Industrial_Vendor_Id = _industrialMan.Insert_Industrial_Vendor(iViewModel.Industrial_Vendor);
                iViewModel.Friendly_Message.Add(MessageStore.Get("IND003"));
                iViewModel.Industrial_Vendors   = _industrialMan.Get_Industrial_Vendors_By_Id(iViewModel.Industrial_Vendor.Industrial_Master_Id, ref pager);
                iViewModel.Pager.PageHtmlString = PageHelper.NumericPager("javascript:PageMore({0})", iViewModel.Pager.TotalRecords, iViewModel.Pager.CurrentPage + 1, iViewModel.Pager.PageSize, 10, true);
            }
            catch (Exception ex)
            {
                iViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
            }
            return(Json(iViewModel, JsonRequestBehavior.AllowGet));
        }
예제 #34
0
        public ActionResult GetCustomerCategoryMargin(SightSeeingTariffViewModel sstViewModel)
        {
            try
            {
                sstViewModel.CustomerCategories = _vtRepo.GetCustomerCategoryDetailsById(sstViewModel.SightSeeingTariffCustomerCategory.CustomerCategoryId);

                Logger.Debug("SightSeeingTariff Controller GetCustomerCategoryById");
            }
            catch (Exception ex)
            {
                sstViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("VehicleTariff Controller - GetCustomerCategoryById  " + ex.Message);
            }

            return(Json(sstViewModel, JsonRequestBehavior.AllowGet));
        }
예제 #35
0
        public PartialViewResult GetCustomerCategoryByOccupencyIdTariffDate(int sightseeingTariffOccupancyId, DateTime tariffDate)
        {
            SightSeeingTariffViewModel sstViewModel = new SightSeeingTariffViewModel();

            try
            {
                sstViewModel.SightSeeingTariffCustomerCategories = _sstRepo.GetSightSeeingTariffCustomerCategory(sightseeingTariffOccupancyId, tariffDate);
            }

            catch (Exception ex)
            {
                sstViewModel.FriendlyMessage.Add(MessageStore.Get("SYS01"));

                Logger.Error("SightSeeing Tariff Controller - GetSightSeeingTariffDuration  " + ex.Message);
            }
            return(PartialView("_CustomerCategory", sstViewModel));
        }
예제 #36
0
        internal bool SaveMessageToWinlink()
        {
            // Saves the image in the mime property into the "To Winlink" table...

            EncodeMime();
            if (!string.IsNullOrEmpty(Mime))
            {
                var messageStore = new MessageStore(DatabaseFactory.Get());
                messageStore.SaveToWinlinkMessage(MessageId, UTF8Encoding.UTF8.GetBytes(Mime));
                messageStore.AddMessageIdSeen(MessageId);
                LocalDelivery();
                return(true);
            }

            ErrorDescription = "Failure to encode mime format";
            return(false);
        }
예제 #37
0
 public JsonResult Insert(MaterialViewModel mViewModel)
 {
     try
     {
         mViewModel.Material.CreatedBy   = ((UserInfo)Session["User"]).UserId;
         mViewModel.Material.UpdatedBy   = ((UserInfo)Session["User"]).UserId;
         mViewModel.Material.CreatedOn   = DateTime.Now;
         mViewModel.Material.UpdatedOn   = DateTime.Now;
         mViewModel.Material.Material_Id = _materialMan.Insert_Material(mViewModel.Material);
         mViewModel.Friendly_Message.Add(MessageStore.Get("M001"));
     }
     catch (Exception ex)
     {
         mViewModel.Friendly_Message.Add(MessageStore.Get("SYS01"));
     }
     return(Json(mViewModel));
 }
예제 #38
0
        public static ConsoleEnvironment Build()
        {
            var handler = new SynchronousEventHandler();

            var inbox = new InboxProjection();
            handler.RegisterHandler(inbox);

            //var store = new InMemoryStore(handler);

            var store = new FileAppendOnlyStore(new DirectoryInfo(Directory.GetCurrentDirectory()));
            store.Initialize();
            var messageStore = new MessageStore(store);
            messageStore.LoadDataContractsFromAssemblyOf(typeof(ActionDefined));
            var currentVersion = store.GetCurrentVersion();
            var log = LogManager.GetLoggerFor<ConsoleEnvironment>();
            log.Debug("Event Store ver {0}", currentVersion);

            if (currentVersion > 0)
            {
                log.Debug("Running in-memory replay");
                foreach (var record in messageStore.EnumerateAllItems(0, int.MaxValue))
                {
                    foreach (var item in record.Items.OfType<Event>())
                    {
                        handler.Handle(item);
                    }
                }
                log.Debug("Replay complete");
            }

            var events = new EventStore(messageStore,handler);

            var tenant = new TenantAppService(events, new RealTimeProvider());
            var build = new ConsoleEnvironment
                {
                    Store = events,
                    Tenant = tenant,
                    Commands = ConsoleCommands.Actions,
                    Id = new TenantId(1),
                    Inbox = inbox
                };
            return build;
        }
예제 #39
0
        public void Deposits_and_withdraws_should_not_interfere_with_each_other()
        {
            var SUT = new YakShayBus();
            // register all types under test
            SUT.RegisterType<Account>();
            SUT.RegisterType<AccountTransferSaga>();
            SUT.RegisterType<AccountBalances>();

            var ms = new MessageStore();

            SUT.HandleUntilAllConsumed(Message.FromAction(x => x.RegisterAccount(AccountId: "account/1", OwnerName: "Tom")), ms.Add, ms.Filter);
            SUT.HandleUntilAllConsumed(Message.FromAction(x => x.RegisterAccount(AccountId: "account/2", OwnerName: "Ben")), ms.Add, ms.Filter);
            SUT.HandleUntilAllConsumed(Message.FromAction(x => x.DepositAmount(AccountId: "account/1", Amount: 126m)), ms.Add, ms.Filter);
            SUT.HandleUntilAllConsumed(Message.FromAction(x => x.DepositAmount(AccountId: "account/2", Amount: 10m)), ms.Add, ms.Filter);
            SUT.HandleUntilAllConsumed(Message.FromAction(x => x.Transfer(AccountId: "account/1", TargetAccountId: "account/2", Amount: 26m)), ms.Add, ms.Filter);
            SUT.HandleUntilAllConsumed(Message.FromAction(x => x.WithdrawAmount(AccountId: "account/2", Amount: 10m)), ms.Add, ms.Filter);

            var bal = new AccountBalances();
            SUT.ApplyHistory(bal, ms.Filter);
            bal.Balances.Count.ShouldBe(2);
            bal.Balances["account/1"].ShouldBe(100m);
            bal.Balances["account/2"].ShouldBe(26m);
        }
예제 #40
0
        public void Send(ushort receiverUID, byte[] messageBody, MessageArriveDelegate callBack = null)
        {
            var messsageID = _messageID++;

            var configuration = MessageConfigurationEnum.None;
            if (callBack != null)
                configuration |= MessageConfigurationEnum.NeedConfirmation;

            var package = new MessagePackage(_UID, receiverUID, messsageID, configuration, messageBody);

            var messageStore = new MessageStore
            {
                Package = package,
                Callback = callBack
            };

            var time = new Timer(WaitingTimeoutCallback, messageStore, TimeOut, Timeout.Infinite);
            messageStore.TimeoutTimer = time;

            lock (_messageskLock)
            {
                var hasInStack = _messageStack
                    .Where(ms => ms.Package.ReceiverUID == receiverUID);

                if (hasInStack.Any())
                {
                    _messageQueue.Add(messageStore);
                }
                else
                {
                    _messageStack.Add(messageStore);
                }

                Monitor.Pulse(_messageskLock);
            }
        }
예제 #41
0
 public EventStore(MessageStore store)
 {
     _store = store;
 }
예제 #42
0
		private void FolderView_Load(object sender, EventArgs e)
		{
			// Set Owner Draw Mode to Text
			if ((null == this.Site) || (!this.Site.DesignMode))
			{
				this.folderTreeView.DrawMode = TreeViewDrawMode.OwnerDrawText;
			}

			// Set Selected Item
			foreach (TreeNode node in this.folderTreeView.Nodes[0].Nodes)
			{
				if (node.Text.Contains("Inbox"))
				{
					this.folderTreeView.SelectedNode = node;
					node.Expand();
					break;
				}
			}

            // Attach to the MessageStore
            this._store = Facade.GetInstance().GetMessageStore();

            this._unreadCount = _store.UnreadCount;
            this._draftsCount = _store.DraftsCount;
            this._deletedCount = _store.DeletedCount;

            // Check for changes
            this._store.PropertyChanged += new PropertyChangedEventHandler(MessageStore_PropertyChanged);
		}
예제 #43
0
 /// <summary>
 /// Method for load the selected message.
 /// </summary>
 /// <param name="store">The MessageStore.</param>
 public void LoadSelectedMessage(MessageStore store)
 {
     // load the selected message
     this.rightSpine1.LoadSelectedMessage(store);
 }
예제 #44
0
 public void messageReceived(byte[] a_msg, int a_length)
 {
     try
     {
         if ((a_length > 0) && (a_msg[0] == 0x80))
         {
             _log.Error("0x80 received");
         }
         else
         {
             byte[] buffer = new byte[a_length];
             for (int i = 0; i < a_length; i++)
             {
                 buffer[i] = a_msg[i];
             }
             string str = this.convertMessageToHex(buffer, a_length);
             MessageStore item = new MessageStore(buffer, str);
             this._messageList.Add(item);
             if (this._messageList.Count > 200)
             {
                 this._messageList.RemoveAt(0);
                 this.lstReceivedMessages.Items.RemoveAt(0);
             }
             this.lstReceivedMessages.Items.Add(str);
             this.lstReceivedMessages.TopIndex = this.lstReceivedMessages.Items.Count - 1;
             if (this.lstReceivedMessages.Items.Count == 1)
             {
                 this.lstReceivedMessages.SelectedIndex = 0;
             }
             if (this.chkAutoExtract.Checked)
             {
                 this.lstReceivedMessages.SelectedIndex = this.lstReceivedMessages.Items.Count - 1;
             }
         }
     }
     catch (Exception exception)
     {
         _log.Warn("ViewDataReceiver: messageReceived: " + exception.Message);
     }
 }
예제 #45
0
        /// <summary>
        /// Method used for load the messages store.
        /// </summary>
        /// <param name="mailbox">The mail box name.</param>
        /// <param name="messageStore">The message store object for fill.</param>
        public void LoadMessageStore(string mailbox, MessageStore messageStore)
        {
            // Create the data connector.
            messageStore.Messages = new SortableBindingList<MailMessage>();

            // Load data from Inbox (XML file).
            Assembly assembly = this.GetType().Assembly;
            MailMessage message;
            DataSet ds = new DataSet();
            DataView view;
            int unread = 0;

            string resourceName = string.Concat(this.GetType().Namespace, ".Mail.Inbox.xsd");
            ds.ReadXmlSchema(assembly.GetManifestResourceStream(resourceName));

            string inboxPath = Path.Combine(Constants.Messages, mailbox + ".xml");
            string directory = Constants.Messages;

            if (Directory.Exists(directory) && File.Exists(inboxPath))
            {
                ds.ReadXml(inboxPath);
                view = ds.Tables[0].DefaultView;

                foreach (DataRowView row in view)
                {
                    // Creat the message
                    message = new MailMessage();
                    message.Id = row["Id"] as string;
                    message.Cc = row["CC"] as string;
                    message.From = row["From"] as string;
                    message.To = row["To"] as string;
                    message.SentDate = (DateTime)row["SentDate"];
                    message.Subject = row["Subject"] as string;
                    message.Path = row["Path"] as string;
                    message.Read = (bool)row["Read"];
                    message.BaseIndex = (int)row["BaseIndex"];
                    message.ParentFolder = (string)row["ParentFolder"];

                    // Add the message
                    messageStore.Messages.Add(message);

                    // Update count
                    if (!message.Read)
                    {
                        unread++;
                    }
                }

                messageStore.UnreadCount = unread;

                //// Select first message
                //if (messageStore.Messages.Count > 0)
                //{
                //    messageStore.SelectedMessage = (messageStore.Messages[0] as MailMessage);
                //}
            }
        }
예제 #46
0
		private void MessageView_Load(object sender, EventArgs e)
		{
			// Set Dock Stlye
			this.Dock = DockStyle.Fill;

			// Set loaded flag
			_loaded = true;

			// Load the Message (if not in design mode)
			if (null == this.Site)
			{
				_store = Facade.GetInstance().GetMessageStore();

                if ((null != _store) && (null != _store.SelectedMessage))
                {
                    // Hook change notification
                    _store.PropertyChanged += new PropertyChangedEventHandler(MessageStore_PropertyChanged);

                    // Get Current
                    this.Message = _store.SelectedMessage;
                }
			}
			else if ((null != this.Parent) && (this.Parent.Site != null) && (this.Parent.Site.DesignMode == true))
			{
				this.webBrowser1.Visible = false;
			}

			// Set parent padding
			if (null != this.Parent)
			{
				this.Parent.Padding = new Padding(0, 3, 3, 3);
			}
		}
예제 #47
0
        /// <summary>
        /// Method for load the selected message.
        /// </summary>
        /// <param name="store">The MessageStore.</param>
        public void LoadSelectedMessage(MessageStore store)
        {
            this._store = store;

            if ((null != _store) && (null != _store.SelectedMessage))
            {
                this.SetFieldsVisible(true);

                // Hook change notification
                _store.PropertyChanged += new PropertyChangedEventHandler(MessageStore_PropertyChanged);

                // Get Current
                this.Message = _store.SelectedMessage;
            }
            else
            {
                this.SetFieldsVisible(false);
            }
        }
예제 #48
0
        public void Message_should_get_processed_and_generate_a_single_InterceptThis_message_with_the_correct_parameters()
        {
            var SUT = new YakShayBus();
            SUT.RegisterType<SomeTestClass>();
            var ms = new MessageStore();
            var msg = new Message("MethodToInvoke", new
            {
                SomePartOfTheUID = "A",
                AnotherPartOfTheUID = "B",
                SomeFlag = true,
                SomeString = "ABC"
            });

            SUT.Handle(msg, ms.Add);

            ms.msgs.Count.ShouldBe(1);
            ms.msgs.First().ToFriendlyString().ShouldBe(new Message("OnMethodWasInvoked", new
            {
                SomePartOfTheUID = "A",
                AnotherPartOfTheUID = "B",
                SomeString = "ABC",
                AnotherInt = 123
            }).ToFriendlyString());

            var ArInstance = new SomeTestClass { SomePartOfTheUID = "A", AnotherPartOfTheUID = "B" };
            var AnotherArInstance = new SomeTestClass { SomePartOfTheUID = "X", AnotherPartOfTheUID = "Y" };
            SUT.ApplyHistory(ArInstance, ms.Filter);
            SUT.ApplyHistory(AnotherArInstance, ms.Filter);

            ArInstance.HasMethodBeenCalled.ShouldBe(true);
            AnotherArInstance.HasMethodBeenCalled.ShouldBe(false);
        }
예제 #49
0
 public Topic()
 {
     Subscriptions = new List<Subscription>();
     Store = new MessageStore<Message>(DefaultMessageStoreSize);
 }
예제 #50
0
        /// <summary>
        /// Method for load messages.
        /// </summary>
        /// <param name="messageListType">The Message List Type.</param>
        public void LoadMessages(MessageListType messageListType)
        {
            Facade facade = Facade.GetInstance();
            string selectedFolder = string.Empty;

            if (messageListType == MessageListType.Inbox ||
                messageListType == MessageListType.Unread ||
                messageListType == MessageListType.Read)
            {
                // Attach to Message Store
                this._store = facade.GetMessageStore();
            }
            else if (messageListType == MessageListType.SentItems)
            {
                // Attach to Message Store Sent items
                this._store = facade.GetMessageStoreSent();
            }
            else if (messageListType == MessageListType.DeletedItems)
            {
                // Attach to Message Store Sent items
                this._store = facade.GetMessageStoreDelete();
            }
            else if (messageListType == MessageListType.Custom)
            {
                // Attach to Message Store Sent items
                this._store = facade.GetMessageStoreCustom();
                selectedFolder = MainForm.GetInstance().GetSelectedFolder();
            }
            else
            {
                this._store = new MessageStore();
            }

            // Reset DataSource
            this.messageBS.DataSource = this._store.Messages;
            this.dataGridView.DataSource = this.messageBS;

            this.dataGridView.CurrentCell = null;

            CurrencyManager cm = (CurrencyManager)this.dataGridView.BindingContext[this.dataGridView.DataSource];
            cm.SuspendBinding();

            foreach (DataGridViewRow row in this.dataGridView.Rows)
            {
                MailMessage mailMessage = (MailMessage)row.DataBoundItem;

                if (messageListType == MessageListType.Unread && mailMessage.Read)
                {
                    row.Visible = false;
                }
                else if (messageListType == MessageListType.Read && !mailMessage.Read)
                {
                    row.Visible = false;
                }
                else if (messageListType == MessageListType.Custom && 
                    !mailMessage.ParentFolder.Equals(selectedFolder))
                {
                    row.Visible = false;
                }
                else
                {
                    row.Visible = true;
                }
            }

            cm.ResumeBinding();

            if (this.messageBS.Count > 0)
            {
                this.dataGridView.Sort(this.dataGridView.Columns[2], ListSortDirection.Descending);
            }

            MainForm mainForm = this.ParentForm as MainForm;
            mainForm.LoadSelectedMessage(this._store);

            this.Invalidate(true);
        }
예제 #51
0
 public AppEventStore(MessageStore msgStore)
 {
     _msgStore = msgStore;
 }
예제 #52
0
파일: Program.cs 프로젝트: vishal-h/btw-gtd
        static void Main()
        {
            // this Client App uses a standard "Windows Forms" application as its host
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            
            

            #region This WinForms host uses its own in-memory message bus to manage the UI...
            // It uses this in-memory bus to wire user-interface "UI" elements ("controls") to the
            // logic (in controllers) that will be triggered when the user interacts with those elements.
            // This allows us to send messages to the uiBus so that interested UI classes can 
            // subscribe to the messages they care about, and react to them
            // when the bus publishes the messages to tell the UI controls what happened.
            #endregion
            var uiBus = new InMemoryBus("UI");

            // .dat file to write Domain Events to this session
            var fileToStoreEventsIn = 
                new FileAppendOnlyStore(new DirectoryInfo(Directory.GetCurrentDirectory()));
            fileToStoreEventsIn.Initialize();

            // provide serialization stuff for our file storage
            var messageStore = new MessageStore(fileToStoreEventsIn);
            messageStore.LoadDataContractsFromAssemblyOf(typeof(ActionDefined));

            // this WinForm App's own local file-based event storage
            var appEventStore = new AppEventStore(messageStore);

            #region Does App care about this msg? This class controls the App's "main message loop"...
            // It reads all msgs from in-memory queue (mainQueue below) and determines which messages 
            // the App will/will not handle at a given time (based on specific app state).
            // For each queued message that it determines should be handled by
            // uiBus subscribers, it passes the messages through to our in-memory uiBus,
            // so bus subscribers can be called to react to the current message when the bus publishes it.
            #endregion
            var appController = new AppController(uiBus, appEventStore);

            #region In-memory structure that all events we defined will go through...
            // All domain & system messages we defined are captured 
            // and accumulated in this queue until some code picks up
            // each message and processes it.
            // (ex: AppController, declared above, will do that processing in this case).
            #endregion
            var mainQueue = new QueuedHandler(appController, "Main Queue");

            appController.SetMainQueue(mainQueue);
            appEventStore.SetDispatcher(mainQueue);

            var provider = new ClientPerspective();

            ClientModelController.WireTo(appEventStore, provider, uiBus, mainQueue);
            
            // create services and bind them to the bus

            // we wire all controls together in a native way.
            // then we add adapters on top of that
            var form = new MainForm();

            var navigation = new NavigationView();
            form.NavigationRegion.RegisterDock(navigation, "nav");
            form.NavigationRegion.SwitchTo("nav");
            
            LogController.Wire(form, uiBus);

            #region View Controllers - Decoupling (UI) Views from their Controllers...
            // The intent with this design was to enable us to
            // write components or UI elements in a separated manner.
            // Provide the ability to develop new functionality independently and
            // it will sit in its own kind of "sandbox" so you can work on your stuff
            // without impacting everyone else.
            // It also sets us up for potential controller/code reuse and sharing in the future.

            // The UI is broken down into kinda "SEDA standalone controllers"
            // that communicate with each other via events.  This event-driven
            // separation allows for cleanly implementing logic like:
            // "If the Inbox is selected, then only display these two menu items,
            // but if a project is displayed, then display these additional menu items."
            // See the Handle methods inside of MainFormController.cs for an example.

            // Event-centric approaches are one of the nicest ways to build
            // plug-in systems because plug-ins have services and contracts which are linked
            // to behaviors (and in our case, these are events).
            // Example:  All CaptureThoughtController knows is that it gets handed a View
            // that it controls (CaptureThoughtForm) and then it has two other injections points,
            // a Bus and a MainQueue.
            // See CaptureThoughtController for more comments on how this design works.

            // The big idea here is that in the future, a controller can be passed an
            // INTERFACE (say, ICaptureThoughtForm) INSTEAD OF a concrete Windows Forms
            // implementation (CaptureThoughtForm) like it currently uses.
            // So we may have a WPF form in the future that implements ICaptureThoughtForm
            // and we could use that View implementation with the SAME CONTROLLER we already have.
            // Very similar to how you could use the MVVM pattern with MvvmCross to
            // reuse common code from the ViewModel down, but implement
            // platform-specific Views on top of that common/shared code.
            #endregion

            #region Wiring up our Views to Controllers... 
            // A "Controller" or "Service" in this client-side ecosystem would usually
            // define at least two parameters:
            // MainQueue
            // and
            // "Bus"
            // MainQueue is the place where it would send events that happen inside of it.
            // Bus is what it subscribes to so that it will be called when specifc events happen.

            // "Wire" is a static method defined on these controllers that our setup
            // can call to let them know which form they control,
            // the bus they can use as a source to subscribe to UI events to react to,
            // and the target queue that they can use tell the rest of the world about events they generate.
            #endregion

            MainFormController.Wire(form, mainQueue, uiBus);
            AddStuffToInboxController.Wire(new AddStuffToInboxForm(form), uiBus, mainQueue);
            AddActionToProjectController.Wire(new AddActionToProjectForm(form),uiBus, mainQueue );
            DefineProjectController.Wire(new DefineProjectForm(form), uiBus, mainQueue);
            InboxController.Wire(form.MainRegion, mainQueue, uiBus, provider);
            NavigationController.Wire(navigation, mainQueue, uiBus, provider);
            ProjectController.Wire(form.MainRegion, mainQueue, uiBus, provider);

            NavigateBackController.Wire(uiBus, mainQueue, form);

            mainQueue.Enqueue(new AppInit());
            mainQueue.Start();
            
            Application.Run(form);
        }
예제 #53
0
        // Region for Construcor
        #region Constructor
        
        /// <summary>
        /// Constructor for Facade class.
        /// Use GetInstance() instead.
        /// </summary>
        private Facade()
        {
            // Load Account Settings.
            this._accSettings = AccountSettings.Load("Account.Settings");

            // Load Client Settings.
            this._clientSettings = ClientSettings.Load("Client.Settings");

            // Setup Message Server.
            this._store = new MessageStore();

            // Setup Message Server Sent Items.
            this._storeSent = new MessageStore();

            // Setup Message Server Deleted Items.
            this._storeDelete = new MessageStore();

            // Setup Message Server Custom Folders.
            this._storeCustom = new MessageStore();

            // Imap4 controller instance.
            this._imap4Controller = new Imap4Controller(this.GetDefaultAccountInfo());

            // Pop3 controller instance.
            this._pop3Controller = new Pop3Controller(this.GetDefaultAccountInfo());

            // Smtp controller instance.
            this._smtpController = new SmtpController();
        }
예제 #54
0
		private void MessageList_Load(object sender, EventArgs e)
		{
			// Auto dock fill
			this.Dock = DockStyle.Fill;

			// Get images
			_readImage = Properties.Resources.Read;
			_readImage.MakeTransparent(Color.FromArgb(238, 238, 238));
			_unreadImage = Properties.Resources.Unread;

			// Set font
			SetFont();

			// Add UPChanged
			SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);

            // Attach to Message Store
            this._store = Facade.GetInstance().GetMessageStore();

            // Reset DataSource
            this.messageBS.DataSource = this._store.Messages;
            this.dataGridView.DataSource = this.messageBS;

            // sort.
            //this.dataGridView.Sort(this.dataGridView.Columns[2], ListSortDirection.Descending);
        }
예제 #55
0
 public LocalEventKeyInfo(string key, ulong id, MessageStore<Message> store)
 {
     Key = key;
     Id = id;
     MessageStore = store;
 }
예제 #56
0
 public LocalEventKeyInfo(ulong id, MessageStore<Message> store)
 {
     Id = id;
     MessageStore = store;
 }
예제 #57
0
        private void Receiver(MessagePackage package)
        {
            if (package.ReceiverUID != _UID)
                return;

            if ((package.Configuration & MessageConfigurationEnum.NeedConfirmation) != 0)
            {
                var packageConfirmation = new MessagePackage(_UID, package.SenderUID, package.MessageID, MessageConfigurationEnum.IsConfirmation, new byte[0]);

                var messageStack = new MessageStore
                {
                    Package = packageConfirmation
                };

                lock (_messageskLock)
                {
                    _messageStack.Add(messageStack);
                    Monitor.Pulse(_messageskLock);
                }
            }

            if ((package.Configuration & MessageConfigurationEnum.IsConfirmation) != 0)
            {
                MessageStore message;
                lock (_messageWaiting)
                {
                    message = _messageWaiting
                        .Where(s => s.Package.ReceiverUID == package.SenderUID && s.Package.MessageID == package.MessageID)
                        .FirstOrDefault();
                }

                if (message == null)
                {
                    Task.Run(() => MessageArrive(MessageArriveCode.ConfirmationWithoutWaiting, package));
                }
                else
                {
                    lock (_messageWaiting)
                    {
                        _messageWaiting.Remove(message);
                    }
                    message.TimeoutTimer?.Dispose();
                    message.Callback?.Invoke(MessageArriveCode.Ok, message.Package);
                }
            }
            else
            {
                var hasQueue = _messageQueue
                    .Where(s => s.Package.ReceiverUID == package.SenderUID)
                    .FirstOrDefault();

                if (hasQueue != null)
                {
                    lock (_messageskLock)
                    {
                        _messageQueue.Remove(hasQueue);

                        _messageStack.Add(hasQueue);

                        Monitor.Pulse(_messageskLock);
                    }
                }

                Task.Run(() => MessageArrive(MessageArriveCode.Ok, package));
            }
        }