Esempio n. 1
0
 public void Detach(IPublish pub)
 {
     if (pub != null)
     {
         pub.PublishArgs -= eventSubscribeArgs;
     }
 }
Esempio n. 2
0
 private static void CreateProxy()
 {
     string endpointAddressInString = Common.Config.PublisherEndpointAddres;
     EndpointAddress endpointAddress = new EndpointAddress(endpointAddressInString);
     NetTcpBinding netTcpBinding = new NetTcpBinding();
     _proxy = ChannelFactory<IPublish>.CreateChannel(netTcpBinding, endpointAddress);
 }
Esempio n. 3
0
 public PublishChanges(IPublish publisher, ISave nextSave, IDelete nextDelete, IGetById getter)
 {
     this.publisher  = publisher;
     this.nextSave   = nextSave;
     this.nextDelete = nextDelete;
     this.getter     = getter;
 }
Esempio n. 4
0
        /// <summary>
        /// Publishes an <see cref="IPublish{T}" /> to all subscribed <see cref="IPeer" />s.
        /// </summary>
        public void Publish(IPublish <Message> publish)
        {
            if (publish == null)
            {
                throw new ArgumentNullException("publish");
            }

            // If the publish is done inside a callback handler we know it's a request/response scheme
            // and therefore the PubSubContext will be initialized.
            if (PubSubContext.IsInitialized)
            {
                string callerId = PubSubContext.Current.Publish.Headers.Get("callerId");
                if (!string.IsNullOrEmpty(callerId))
                {
                    publish.Headers.Add("callerId", callerId);
                }
            }

            EventQueue.RaiseEvent(new PublishEvent
            {
                PipelineArgs = new PublishArgs {
                    Peer = this, Publish = publish
                }
            });
        }
Esempio n. 5
0
 public MainProccess(IConvert convert, IPublish publish, IValidate validate, IProcess process)
 {
     _validate = validate;
     _convert  = convert;
     _publish  = publish;
     _process  = process;
 }
Esempio n. 6
0
        private void WorkMethod(int taskindex, int threadindex)
        {
            string        Title = string.Empty, Content = string.Empty;
            StringBuilder sbContent = new StringBuilder();

            if (Model != null)
            {
                IPublish iPublish = Utility.GetIPublishByName(Model.PublishName);
                iPublish.Publish_Init(Model.WebSiteUrl, Model.WebSiteLoginUrl,
                                      Model.LoginUserName, Model.LoginUserPwd,
                                      0, string.Empty);
                iPublish.Publish_OutResult = OPR_SendData;
                string[] files = Directory.GetFiles(Model.FileSourcePath, "*.html");
                int      lLen  = files.Length;
                for (int i = 0; i < lLen; i++)
                {
                    if (IsOpen)
                    {
                        IsOpen = false;
                        try {
                            string   file   = files[i];
                            FileInfo fiFile = new FileInfo(file);
                            Title = fiFile.Name.Replace(fiFile.Extension, "");
                            int l = fiFile.Name.LastIndexOf("_");
                            if (l > -1)
                            {
                                Title = Title.Substring(0, l);
                            }
                            StreamReader sr = new StreamReader(file, Encoding.Default);
                            sbContent.Append(sr.ReadToEnd());
                            sr.Close();
                            if (sbContent.Length >= 300)
                            {
                                //发布文章
                                ModelGatherItem mGatherItem = new ModelGatherItem();
                                mGatherItem.Title   = Title;
                                mGatherItem.Content = sbContent.ToString();
                                ModelClassItem mClassList = new ModelClassItem();
                                mClassList.ClassID   = "1";
                                mClassList.ClassName = "美容知识";
                                iPublish.Publish_PostData(mGatherItem, mClassList);
                            }
                            sbContent.Remove(0, sbContent.Length);
                            //
                            File.Delete(file);
                            Thread.Sleep(1000);//这个可以自定义时间
                        }
                        catch (Exception ex) {
                            Log4Helper.Write(LogLevel.Error, "文件发布错误!", ex);
                            continue;
                        }
                    }
                    else
                    {
                        Thread.Sleep(5000);
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 加载插件
        /// </summary>
        public static void LoadAllDlls()
        {
            #region  发布
            try {
                ListIPublish.Clear();
                string[] publishFiles = Directory.GetFiles(PublishModulesPath, "*Modules.dll");
                foreach (string str2 in publishFiles)
                {
                    try {
                        Assembly assembly = Assembly.LoadFrom(str2);
                        FileInfo fi       = new FileInfo(str2);
                        string   ff       = fi.Name.Replace(fi.Extension, "");
                        ff = ff.Replace("V5.", "");
                        IPublish item = (IPublish)Activator.CreateInstance(assembly.GetType("V5.DataPlugins." + ff));
                        ListIPublish.Add(item);
                        continue;
                    }
                    catch (Exception ex) {
                        Log4Helper.Write(LogLevel.Error, ex);
                        continue;
                    }
                }
            }
            catch (Exception ex) {
                Log4Helper.Write(LogLevel.Error, ex);
            }
            #endregion

            #region PublishContent
            try {
                ListIPublishContent.Clear();
                string[] publiscContentDirs = Directory.GetDirectories(BaseDirectory + "\\Plugins\\V5.DataPublish.PublishContent\\");
                foreach (string dir in publiscContentDirs)
                {
                    string[] filess = Directory.GetFiles(dir, "*PublishContent.dll");
                    try {
                        if (filess.Length == 0)
                        {
                            break;
                        }
                        string   file     = filess[0];
                        Assembly assembly = Assembly.LoadFrom(file);
                        FileInfo fi       = new FileInfo(file);
                        string   ff       = fi.Name.Replace(fi.Extension, "");
                        ff = ff.Replace("V5.", "");
                        IPublishContent item = (IPublishContent)Activator.CreateInstance(assembly.GetType("V5.DataPlugins." + ff));
                        ListIPublishContent.Add(item);
                    }
                    catch (Exception ex) {
                        Log4Helper.Write(LogLevel.Error, ex);
                        continue;
                    }
                }
            }
            catch (Exception ex) {
                Log4Helper.Write(LogLevel.Error, ex);
            }
            #endregion
        }
Esempio n. 8
0
        static private void CreateProxy()
        {
            string          endpointAddressInString = Common.Config.PublisherEndpointAddres;
            EndpointAddress endpointAddress         = new EndpointAddress(endpointAddressInString);
            NetTcpBinding   netTcpBinding           = new NetTcpBinding();

            _proxy = ChannelFactory <IPublish> .CreateChannel(netTcpBinding, endpointAddress);
        }
Esempio n. 9
0
 public CommandHandler(IUserList userList, IPublish publish, IReading reading, IFollow follow, IWall wall)
 {
     _userList = userList;
     _publish = publish;
     _reading = reading;
     _follow = follow;
     _wall = wall;
 }
Esempio n. 10
0
        public void Execute(CallbackArgs args)
        {
            IPublish <Message> response     = args.Publish;
            ISubscription      subscription = args.Peer.GetSubscription(response.Key);

            if (subscription == null)
            {
                return;
            }

            ICachingOptions cachingOptions = subscription.CachingOptions;

            if (cachingOptions == null || !cachingOptions.EnableCaching)
            {
                return;
            }

            if (!cachingOptions.HasCacheKey)
            {
                return;
            }

            string callbackKey = string.Format("callback#{0}#{1}", args.Peer.Node.Contact.NodeId, response.Key);

            string cacheKey = callbackKey;

            if (string.Equals(cachingOptions.Key, response.Key))
            {
                string extraKey = cachingOptions.GetCacheKey(response.Message);

                if (!string.IsNullOrEmpty(extraKey))
                {
                    cacheKey = string.Format("{0}#{1}", callbackKey, extraKey);
                }
            }

            CacheManager.Add(cacheKey, args.Publish.Message, cachingOptions);

            // Request response scheme
            if (string.Equals(subscription.Key, cachingOptions.Key))
            {
                return;
            }

            IPublish <Message> request =
                CacheManager.Get <IPublish <Message> >(string.Format("publish#{0}#{1}", args.Peer.Node.Contact.NodeId,
                                                                     cachingOptions.Key));

            if (request != null && string.Equals(request.Key, cachingOptions.Key))
            {
                string extraKey = cachingOptions.GetCacheKey(request.Message);
                if (!string.IsNullOrEmpty(extraKey))
                {
                    cacheKey = string.Format("{0}#{1}", callbackKey, extraKey);
                    CacheManager.Add(cacheKey, args.Publish.Message, cachingOptions);
                }
            }
        }
        public async Task PublisherSimplySendsWithoutQueueReturnsFailure()
        {
            IBunny bunny = Bunny.ConnectSingle(ConnectSimple.BasicAmqp);
            IPublish <TestMessage> publisher = bunny.Publisher <TestMessage>(Exchange);

            OperationResult <TestMessage> result = await publisher.SendAsync(new TestMessage());

            Assert.True(result.IsSuccess);
            bunny.Dispose();
        }
Esempio n. 12
0
        public void Must_be_able_to_publish_a_message()
        {
            _userList = new UserList();
            _userList.AddUser("Alice");
            _sut = new Publish(_userList);

            _sut.PublishMessage(usersMessage, "Alice");

            var user = _userList.GetUser("Alice");
            Assert.AreEqual(user._messages.Count, 1);
        }
Esempio n. 13
0
 /// <summary>
 /// Builds the current <see cref="PubSubContext" /> using information from the specified <see cref="IPublish{T}" />.
 /// </summary>
 /// <param name="publish"></param>
 internal static void BuildContext(IPublish <Message> publish)
 {
     try
     {
         Initialize();
         Current.Publish = publish;
     }
     catch (Exception ex)
     {
         Log.Error(ex);
     }
 }
Esempio n. 14
0
 public static void RemoveSubscriber(String topicName, IPublish subscriberCallbackReference)
 {
     lock (typeof(Filter))
     {
         if (SubscribersList.ContainsKey(topicName))
         {
             if (SubscribersList[topicName].Contains(subscriberCallbackReference))
             {
                 SubscribersList[topicName].Remove(subscriberCallbackReference);
             }
         }
     }
 }
        public async Task ForceCreatesTheExchangeIfNotExists()
        {
            IBunny bunny = Bunny.ConnectSingle(ConnectSimple.BasicAmqp);
            IPublish <TestMessage> publisher = bunny.Publisher <TestMessage>("test-exchange");

            OperationResult <TestMessage> result = await publisher.SendAsync(new TestMessage(), force : true);

            Assert.True(result.IsSuccess);
            bool removed_exchange = await bunny.Setup().DeleteExchangeAsync("test-exchange", force: true);

            Assert.True(removed_exchange);
            bunny.Dispose();
        }
Esempio n. 16
0
 static public void RemoveSubscriber(String topicName, IPublish subscriberCallbackReference)
 {
     lock (typeof(Filter))
     {
         if (SubscribersList.ContainsKey(topicName))
         {
             if (SubscribersList[topicName].Contains(subscriberCallbackReference))
             {
                 SubscribersList[topicName].Remove(subscriberCallbackReference);
             }
         }
     }
 }
Esempio n. 17
0
        /// <summary>
        /// Is invoked when a relevant <see cref="Message" /> is published.
        /// </summary>
        public void Callback(IPublish <Message> publish)
        {
            if (publish == null)
            {
                throw new ArgumentNullException("publish");
            }

            EventQueue.RaiseEvent(new CallbackEvent
            {
                PipelineArgs = new CallbackArgs {
                    Peer = this, Publish = publish
                }
            });
        }
Esempio n. 18
0
        /// <summary>
        /// Publishes an <see cref="IPublish{T}" /> to all subscribed <see cref="IPeer" />s and waits for a response.
        /// </summary>
        public T Publish <T>(IPublish <Message> publish, TimeSpan timeout) where T : Message
        {
            if (publish == null)
            {
                throw new ArgumentNullException("publish");
            }

            if (timeout == null)
            {
                throw new ArgumentNullException("timeout");
            }

            if (GetSubscription(publish.Key) == null)
            {
                Subscribe(new Subscription <T>());
            }

            string        callerId    = Guid.NewGuid().ToString();
            string        responseKey = typeof(T).Key();
            SemaphoreSlim handle      = new SemaphoreSlim(0);

            string cacheKeyHandle  = string.Format("publish#{0}#{1}#handle", responseKey, callerId);
            string cacheKeyMessage = string.Format("publish#{0}#{1}#message", responseKey, callerId);

            CacheManager.Add(cacheKeyHandle, handle, new CachingOptions <SemaphoreSlim>
            {
                EnableCaching = true,
                Expiration    = timeout + timeout
            });

            publish.Headers.Add("callerId", callerId);

            ISubscription subscription = new Subscription <T>();

            if (!_subscriptions.ContainsKey(subscription.Key))
            {
                Subscribe(subscription);
            }

            Publish(publish);

            handle.Wait(timeout);

            T message = CacheManager.Get <T>(cacheKeyMessage);

            CacheManager.Remove(cacheKeyMessage);

            return(message);
        }
        public static void Publish <TDomainEvent>(this IPublish me, TDomainEvent domainEvent)
        {
            if (!(me is IPublish <TDomainEvent>))
            {
                throw new NotSupportedException(
                          string.Format(
                              "{0} has not been configured to publish events of type {1}",
                              me.GetType().FullName,
                              typeof(TDomainEvent).GetType()));
            }

            dynamic context = DomainEventAggregation.GlobalContext;

            context.Aggregate(domainEvent);
        }
        /// <summary>
        /// 获取分类
        /// </summary>
        private void btnGetClassList_Click(object sender, EventArgs e)
        {
            Application.DoEvents();
            IPublish iPublish = _Class.Utility.GetIPublishByName(this.cmbPublishName.Text);

            iPublish.Publish_OutResult = OPR_SendData;
            iPublish.Publish_Type      = PublishType.GetClassList;
            iPublish.Publish_Init(this.txtWebSiteUrl.Text,
                                  this.txtWebSiteLoginUrl.Text,
                                  this.txtLoginUserName.Text,
                                  this.txtLoginUserPwd.Text,
                                  0,
                                  string.Empty);
            iPublish.Publish_GetClassList();
        }
        public async Task PublisherSimplySendsWitQueueReturnsSuccess()
        {
            IBunny bunny = Bunny.ConnectSingle(ConnectSimple.BasicAmqp);
            IPublish <TestMessage> publisher = bunny.Publisher <TestMessage>(Exchange);

            OperationResult <TestMessage> result = await publisher
                                                   .WithQueueDeclare()
                                                   .SendAsync(new TestMessage());

            bool success = await bunny.Setup().DeleteQueueAsync(typeof(TestMessage).FullName, force: true);

            Assert.True(result.IsSuccess);
            Assert.True(success);
            bunny.Dispose();
        }
Esempio n. 22
0
 /// <summary>
 /// 加载发布模块
 /// </summary>
 /// <param name="publishName"></param>
 public void LoadPublishModule(string publishName)
 {
     if (publishName.IndexOf(".pmod") > -1)
     {
         iPublish = new PublishCommon();
         iPublish.Publish_OutResult = OPR_SendData;
         iPublish.Publish_Name      = publishName;
         iPublish.Publish_Model     = Load_PublishItem(publishName);
     }
     else
     {
         iPublish = Utility.ListIPublish.Where(p => p.Publish_Name == ModelWebSite.PublishName).FirstOrDefault();
         iPublish.Publish_OutResult = OPR_SendData;
         iPublish.Publish_Name      = ModelWebSite.PublishName;
     }
 }
 void bwLogin_DoWork(object sender, DoWorkEventArgs e)
 {
     this.btnTestStatus.Invoke(new MethodInvoker(delegate() {
         iPublish = _Class.Utility.GetIPublishByName(this.cmbPublishName.Text);
         iPublish.Publish_OutResult = OPR_SendData;
         iPublish.Publish_Type      = PublishType.Login;
         iPublish.Publish_Init(this.txtWebSiteUrl.Text,
                               this.txtWebSiteLoginUrl.Text,
                               this.txtLoginUserName.Text,
                               this.txtLoginUserPwd.Text,
                               0,
                               string.Empty);
         iPublish.Publish_Login();
         this.btnTestStatus.Enabled = true;
     }));
 }
Esempio n. 24
0
        /// <summary>
        /// Is invoked when a relevant <see cref="Message" /> is published.
        /// </summary>
        /// <param name="publish"></param>
        public void Callback(IPublish <Message> publish)
        {
            if (publish == null)
            {
                throw new ArgumentNullException("publish");
            }

            try
            {
                _peer.Callback(publish);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Esempio n. 25
0
        public Form1()
        {
            InitializeComponent();
            Main    = this;
            Publish = IocManager.ServiceProvider.GetRequiredService <IPublish>();
            Control.CheckForIllegalCrossThreadCalls = false;
            queue = new System.Collections.Concurrent.ConcurrentQueue <IpInfo>();
            url   = "https://www.google.com";
            regex = @"\.google\.com";
            find  = @"<td>(?<ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})</td>\s+<td>(?<port>\d+)</td>";
            var path = AppDomain.CurrentDomain.BaseDirectory + "config.db";

            if (System.IO.File.Exists(path))
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(path))
                {
                    this.setValue(sr.ReadLine(), sr.ReadLine(), sr.ReadLine());
                    sr.Close();
                }
            }

            var list = AppDomain.CurrentDomain.BaseDirectory + "list.db";

            if (System.IO.File.Exists(list))
            {
                button7_Click(null, null);
            }

            var dictPat = AppDomain.CurrentDomain.BaseDirectory + "Url.db";

            if (System.IO.File.Exists(dictPat))
            {
                using (System.IO.StreamReader sr = new System.IO.StreamReader(dictPat))
                {
                    while (!sr.EndOfStream)
                    {
                        dictList.Add(new Dict()
                        {
                            url   = sr.ReadLine(),
                            regex = sr.ReadLine()
                        });
                    }
                }
            }
            this.FormClosed += Form1_FormClosed;
            closeTag         = true;
        }
Esempio n. 26
0
        public void Execute(PublishArgs args)
        {
            IEnumerable <ISubscription> subscriptions = args.Peer.Subscriptions
                                                        .Where(x => x.CachingOptions != null && x.CachingOptions.EnableCaching &&
                                                               x.CachingOptions.HasCacheKey && string.Equals(x.CachingOptions.Key, args.Publish.Key));

            IPublish <Message> request = args.Publish;

            string key = string.Format("publish#{0}#{1}",
                                       args.Peer.Node.Contact.NodeId,
                                       request.Key);

            foreach (ISubscription subscription in subscriptions)
            {
                CacheManager.Add(key, request, subscription.CachingOptions);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Publishes an <see cref="IPublish{T}" /> to all subscribed <see cref="IBroker" />s.
        /// </summary>
        /// <param name="publish"></param>
        public void Publish(IPublish <Message> publish)
        {
            if (publish == null)
            {
                throw new ArgumentNullException("publish");
            }

            try
            {
                Peer.Publish(publish);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
Esempio n. 28
0
 private void CreateProxy()
 {
     try
     {
         EndpointAddress endpointAddres = new EndpointAddress(ConfigurationManager.AppSettings["EndpointAddress"]);
         NetTcpBinding   binding        = new NetTcpBinding();
         TimeSpan        ts             = new TimeSpan(1, 0, 0);
         binding.CloseTimeout   = ts;
         binding.OpenTimeout    = ts;
         binding.SendTimeout    = ts;
         binding.ReceiveTimeout = ts;
         proxy = ChannelFactory <IPublish> .CreateChannel(binding, endpointAddres);
     }
     catch (Exception ex)
     {
         CrFSMLogger.CrFSMLogger.Instance.WriteToLog(ex);
     }
 }
Esempio n. 29
0
        /// <summary>
        /// Builds the current <see cref="PubSubContext" /> using information from the specified <see cref="WebOperationContext" />.
        /// </summary>
        /// <param name="webOperationContext"></param>
        internal static void BuildContext(WebOperationContext webOperationContext)
        {
            if (webOperationContext == null)
            {
                throw new ArgumentNullException("webOperationContext");
            }

            try
            {
                IncomingWebRequestContext request = webOperationContext.IncomingRequest;
                IPublish <Message>        publish = ResolvePublish(request);
                BuildContext(publish);
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
Esempio n. 30
0
 static public void AddSubscriber(String topicName, IPublish subscriberCallbackReference)
 {
     lock (typeof(Filter))
     {
         if (SubscribersList.ContainsKey(topicName))
         {
             if (!SubscribersList[topicName].Contains(subscriberCallbackReference))
             {
                 SubscribersList[topicName].Add(subscriberCallbackReference);
             }
         }
         else
         {
             List <IPublish> newSubscribersList = new List <IPublish>();
             newSubscribersList.Add(subscriberCallbackReference);
             SubscribersList.Add(topicName, newSubscribersList);
         }
     }
 }
Esempio n. 31
0
 public static void AddSubscriber(String topicName, IPublish subscriberCallbackReference)
 {
     lock (typeof(Filter))
     {
         if (SubscribersList.ContainsKey(topicName))
         {
             if (!SubscribersList[topicName].Contains(subscriberCallbackReference))
             {
                 SubscribersList[topicName].Add(subscriberCallbackReference);
             }
         }
         else
         {
             List<IPublish> newSubscribersList = new List<IPublish>();
             newSubscribersList.Add(subscriberCallbackReference);
             SubscribersList.Add(topicName, newSubscribersList);
         }
     }
 }
Esempio n. 32
0
        public static void Run()
        {
            IPublish <ExampleMessage> queue = Configuration.GetQueue <ExampleMessage>();

            int i = 0;

            while (true)
            {
                Reset.WaitOne();
                i++;

                var message = new ExampleMessage(i, "I am number " + i);
                queue.Send(message);
                Interlocked.Increment(ref _writeCount);

                if (i == int.MaxValue)
                {
                    i = 0;
                }
            }
        }
        public Publish_ViewModel_WPF(
            ILogger Logger_, 
            INavigationService NavigationService_,
            IDialogService DialogService_,
            IPublish iPublish_)
        {
            if (!IsInDesignModeNet())
            {
                Logger = Logger_;
                NavigationService = NavigationService_;
                DialogService = DialogService_;
                iPublish = iPublish_;

                CommandDispatcher = new MvxCommand<string>(CmdDispatcher);

            } else
            {
                LearningItem = new LearningItem { Name = "Futurama" };
            }

        }
Esempio n. 34
0
        /// <summary>
        /// Publishes an <see cref="IPublish{T}" /> to all subscribed <see cref="IBroker" />s and waits for a response.
        /// Blocks until a <see cref="Message" /> is returned or the specified timeout occurs.
        /// </summary>
        /// <typeparam name="T">The expected return type.</typeparam>
        /// <param name="publish">The <see cref="IPublish{T}" /> to publish.</param>
        /// <param name="timeout">The amount of time to wait for a response.</param>
        /// <returns>
        /// A <see cref="Message" /> of type T if it was published within the specified timeout. Otherwise null is
        /// returned.
        /// </returns>
        public T Publish <T>(IPublish <Message> publish, TimeSpan timeout) where T : Message
        {
            if (publish == null)
            {
                throw new ArgumentNullException("publish");
            }

            if (timeout == null)
            {
                throw new ArgumentNullException("timeout");
            }

            try
            {
                return(Peer.Publish <T>(publish, timeout));
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                throw;
            }
        }
Esempio n. 35
0
        /// <summary>
        /// Retrieves a cached <see cref="Message" /> of type T based on the specified <see cref="Message" />.
        /// Use this method for request/response schemes.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="message"></param>
        /// <returns></returns>
        public T GetCachedMessage <T>(Message message) where T : Message
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            string             subscriptionKey = typeof(T).Key();
            string             callbackKey     = string.Format("callback#{0}#{1}", Node.Contact.NodeId, subscriptionKey);
            ISubscription      subscription    = GetSubscription(subscriptionKey);
            IPublish <Message> request         = CacheManager.Get <IPublish <Message> >(string.Format("publish#{0}#{1}",
                                                                                                      Node.Contact.NodeId,
                                                                                                      message.GetType().Key()));

            if (request == null)
            {
                return(null);
            }

            string extraKey = subscription.CachingOptions.GetCacheKey(request.Message);
            string cacheKey = string.Format("{0}#{1}", callbackKey, extraKey);

            return(CacheManager.Get <T>(cacheKey));
        }
Esempio n. 36
0
        private void InitTcp()
        {
            if (this.isServiceCkb.Checked)
            {
                _service.InitTcpService();
                _service.Start();
            }

            serverPort = Convert.ToInt32(ConfigurationSettings.AppSettings["ServerPort"]);
            _subscriber = new TcpSubscribers(serverIP, serverPort, new TimeSpan(0, 0, 0, 0, 50));

            _publish = new TcpPublish();
            _publish.Init(serverIP, 10002);
        }
Esempio n. 37
0
 protected CommandBase( IPublish<IMessage> publisher)
 {
     Publisher = publisher;
     Shell = (IVsUIShell)Package.GetGlobalService(typeof(SVsUIShell));
 }
Esempio n. 38
0
 public DeployCommand(IPublish<IMessage> publisher)
     : base(publisher)
 {
 }
Esempio n. 39
0
        async public static Task PublishDomainEvents(this ChangeTracker changeTracker, IPublish publish)
        {
            var entitiesWithEvents = changeTracker.Entries <IGeneratesDomainEvents>()
                                     .Select(e => e.Entity)
                                     .Where(e => e.Events.Any())
                                     .ToArray();

            foreach (var entity in entitiesWithEvents)
            {
                var events = entity.Events.ToArray();
                entity.Events.Clear();
                foreach (var domainEvent in events)
                {
                    await publish.Publish(domainEvent.GetType().Name, JsonConvert.SerializeObject(domainEvent));
                }
            }
        }
Esempio n. 40
0
        private void InitSocket()
        {
            if (this.isServiceCkb.Checked)
            {
                //_producterService = new ProducerSocketService();
                //_producterService.StartService();
                //_subscriberService = new SocketSubscriberService();
                //_subscriberService.StartService();
                _service.InitSocketService();
                _service.Start();
            }
            serverPort = Convert.ToInt32(ConfigurationSettings.AppSettings["ServerPort"]);
            _subscriber = new MyMq.SocketSubscriber(serverIP, serverPort, new TimeSpan(0, 0, 0, 0, 50));
            _publish = new SocketPublish();

            _publish.Init(serverIP, 10002);
        }
Esempio n. 41
0
 public ToolWindowCommand(EventStorePackage package, IPublish<IMessage> publisher)
 {
     _package = package;
     _publisher = publisher;
 }