コード例 #1
0
        /// <summary>
        /// Send the exception report using the configured send method
        /// </summary>
        public void SendReport()
        {
            View.EnableEmailButton = false;
            View.ShowProgressBar   = true;

            var sender = new SenderFactory(ReportInfo, View, new WinFormsScreenShooter()).Get();

            View.ProgressMessage = sender.ConnectingMessage;

            try
            {
                var report = ReportInfo.IsSimpleMAPI() ? new EmailReporter(ReportInfo).Create() : CreateReport();
                sender.Send(report);
            }
            catch (Exception exception)
            {
                View.Completed(false);
                View.ShowError(Resources.Unable_to_setup + $" {sender.Description}" +
                               Environment.NewLine + exception.Message, exception);
            }
            finally
            {
                if (ReportInfo.IsSimpleMAPI())
                {
                    View.MapiSendCompleted();
                }
            }
        }
コード例 #2
0
ファイル: Edge.cs プロジェクト: ikaragkiozoglou/brunet
        /** Return the edge specified in the given URI
         * this matches the SenderFactory
         */
        public static Edge CreateInstance(object n, string uri)
        {
            string scheme;
            IDictionary <string, string> args = SenderFactory.DecodeUri(uri, out scheme);

            return(GetEdgeNum(Int64.Parse(args["num"])));
        }
コード例 #3
0
        private void start()
        {
            //Loading system startup data for all the exchanges
            List <Exchange> exchanges = new List <Exchange>();

            exchanges.Add(Exchange.FAKE_NASDAQ);

            InMemoryObjects.LoadInMemoryObjects(exchanges);

            //Initiate fake data generation from fake market
            //Later it will also include data generation from google finance
            TimeSpan updateDuration = TimeSpan.FromMilliseconds(Constants.FAKE_DATA_GENERATE_PERIOD);

            FakeDataGenerator.StartFakeDataGeneration(300);


            IFeeder feeder = FeederFactory.GetFeeder(FeederSourceSystem.FAKEMARKET);
            ISender sender = SenderFactory.GetSender(FeederQueueSystem.REDIS_CACHE);

            List <StockModel.Symbol> symbols = InMemoryObjects.ExchangeSymbolList.SingleOrDefault(x => x.Exchange == Exchange.FAKE_NASDAQ).Symbols;

            while (true)
            {
                Parallel.ForEach(symbols, (symbol) =>
                {
                    feedList = feeder.GetFeedList(symbol.Id, 1, 10);                      // Get the list of values for a given symbolId of a market for given time-span
                    sender.SendFeed(feedList);
                });
            }
        }
コード例 #4
0
        private DispatchNotificationResult SendNotificationsAndSetDispatchDate(IEnumerable <Notification> notifications)
        {
            var factory = new SenderFactory(_configuration, _logger, _smsService);
            var respone = new DispatchNotificationResult();

            foreach (var notification in notifications)
            {
                var message = _messageService.CreateMessage(notification);
                var sender  = new MessageSender(factory.CreateSenderObject(notification.MessageType), message);
                var result  = sender.Send();
                if (result)
                {
                    var dateOfDisptach = SystemTime.Now;
                    notification.DateOfLastDispatch = dateOfDisptach;
                    respone.sentNotifications.Add(Mapper.Map <NotificationDto>(notification));
                    message.DateOfSending = dateOfDisptach;
                    _messageService.AddMessage(message);
                    continue;
                }
                respone.notSentNotifications.Add(Mapper.Map <NotificationDto>(notification));
            }

            _notificationRepository.Save();

            return(respone);
        }
コード例 #5
0
        /// <summary>
        /// Send the exception report using the configured send method
        /// </summary>
        public void SendReport()
        {
            View.EnableEmailButton = false;
            View.ShowProgressBar   = true;

            var sender = new SenderFactory(ReportInfo, View).Get();

            View.ProgressMessage = sender.ConnectingMessage;

            try
            {
                var report = ReportInfo.IsSimpleMAPI() ? CreateEmailReport() : CreateReport();
                sender.Send(report);
            }
            catch (Exception exception)
            {                           // most exceptions will be thrown in the Sender - this is just a backup
                View.Completed(false);
                View.ShowError(string.Format("Unable to setup {0}", sender.Description) +
                               Environment.NewLine + exception.Message, exception);
            }
            finally
            {
                if (ReportInfo.IsSimpleMAPI())
                {
                    View.MapiSendCompleted();
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Send the exception report using the configured send method
        /// </summary>
        public async Task SendReport()
        {
            View.EnableEmailButton = false;
            View.ShowProgressBar   = true;

            var sender = new SenderFactory(ReportInfo, View).Get();

            View.ProgressMessage = sender.ConnectingMessage;

            try
            {
                await Task.Run(() =>
                {
                    //string command = "mailto:info[at]codegain.com?subject=The Subject&bcc=vrrave[at]codegaim.com";
                    //System.Diagnostics.Process.Start(command);

                    var report = ReportInfo.IsSimpleMAPI() || ReportInfo.SendMethod == ReportSendMethod.Mailto? CreateEmailReport() : CreateReport();
                    sender.Send(report);
                });
            }
            catch (Exception exception)
            {                           // most exceptions will be thrown in the Sender - this is just a backup
                View.Completed(false);
                View.ShowError(string.Format("Unable to setup {0}", sender.Description) +
                               Environment.NewLine + exception.Message, exception);
            }
            finally
            {
                if (ReportInfo.IsSimpleMAPI())
                {
                    View.MapiSendCompleted();
                }
            }
        }
コード例 #7
0
        protected Pair <ISender, string> ParseTarget(IList targ)
        {
            var send = SenderFactory.CreateInstance(_node, (string)targ[0]);
            var meth = (string)targ[1];

            return(new Pair <ISender, string>(send, meth));
        }
コード例 #8
0
        public void Can_Get_None_Silent_Sender()
        {
            var factory = new SenderFactory(new ExceptionReportInfo {
                SendMethod = ReportSendMethod.None
            }, _sendEvent);

            Assert.That(factory.Get(), Is.TypeOf <GhostSender>());
        }
コード例 #9
0
        private FactoryContext CreateFactoryContext(SenderFactory customFactory)
        {
            FactoryContext factoryContext = new FactoryContext();

            factoryContext.SetSenderFactory(customFactory);

            return(factoryContext);
        }
コード例 #10
0
        public void Can_Get_WebService_Sender()
        {
            var factory = new SenderFactory(new ExceptionReportInfo
            {
                SendMethod = ReportSendMethod.WebService
            }, _sendEvent);

            Assert.That(factory.Get(), Is.TypeOf <WebServiceSender>());
        }
コード例 #11
0
        public void Can_Get_SimpleMAPI_Sender()
        {
            var factory = new SenderFactory(new ExceptionReportInfo
            {
                SendMethod = ReportSendMethod.SimpleMAPI
            }, _sendEvent);

            Assert.That(factory.Get(), Is.TypeOf <MapiMailSender>());
        }
コード例 #12
0
        public void Can_Get_SMTP_Sender()
        {
            var factory = new SenderFactory(new ExceptionReportInfo
            {
                SendMethod = ReportSendMethod.SMTP
            }, _sendEvent);

            Assert.That(factory.Get(), Is.TypeOf <SmtpMailSender>());
        }
コード例 #13
0
        /// <summary>
        /// Send the report, asynchronously, without showing a dialog (silent send)
        /// <see cref="ExceptionReportInfo.SendMethod"/>must be SMTP or WebService, else this is ignored (silently)
        /// </summary>
        /// <param name="screenShooter">The screen-shotting code might be specific to WinForms, so this is an option to send anything that implements IScreenshooter</param>
        /// <param name="sendEvent">Provide implementation of IReportSendEvent to receive error/updates on calling thread</param>
        /// <param name="exceptions">The exception/s to include in the report</param>
        protected void Send(IScreenShooter screenShooter, IReportSendEvent sendEvent = null, params Exception[] exceptions)
        {
            _info.SetExceptions(exceptions);

            var sender = new SenderFactory(_info, sendEvent ?? new SilentSendEvent(), screenShooter).Get();
            var report = new ReportGenerator(_info);

            sender.Send(report.Generate());
        }
コード例 #14
0
        /// <summary>
        /// Send the report, asynchronously, without showing a dialog (silent send)
        /// <see cref="ExceptionReportInfo.SendMethod"/>must be SMTP or WebService, else this is ignored (silently)
        /// </summary>
        /// <param name="sendEvent">Provide implementation of IReportSendEvent to receive error/updates on calling thread</param>
        /// <param name="exceptions">The exception/s to include in the report</param>
        public void Send(IReportSendEvent sendEvent = null, params Exception[] exceptions)
        {
            _info.SetExceptions(exceptions);

            var sender = new SenderFactory(_info, sendEvent ?? new SilentSendEvent()).Get();
            var report = new ReportGenerator(_info);

            sender.Send(report.Generate());
        }
コード例 #15
0
        /// <summary>
        /// Send the report without showing a dialog (silent send)
        /// <see cref="ExceptionReportInfo.SendMethod"/>must be SMTP or WebService, else this is ignored (silently)
        /// </summary>
        /// <param name="sendEvent">Provide implementation of IReportSendEvent to receive error/updates</param>
        /// <param name="exceptions">The exception/s to include in the report</param>
        public void Send(IReportSendEvent sendEvent = null, params Exception[] exceptions)
        {
            _reportInfo.SetExceptions(exceptions);

            var generator = new ReportGenerator(_reportInfo);
            var sender    = new SenderFactory(_reportInfo, sendEvent ?? new SilentSendEvent()).Get();

            sender.Send(generator.Generate().ToString());
        }
コード例 #16
0
        public Type Can_Determine_Sender(ReportSendMethod method)
        {
            var factory = new SenderFactory(new ExceptionReportInfo
            {
                SendMethod = method
            }, new Mock <IReportSendEvent>().Object);

            return(factory.Get().GetType());
        }
コード例 #17
0
ファイル: AHSender.cs プロジェクト: pcbing/brunet
        protected static AHSender CreateInstance(object node_ctx, string uri)
        {
            Node   n = (Node)node_ctx;
            string ahscheme; //Should be "ah"
            IDictionary <string, string> kvpairs = SenderFactory.DecodeUri(uri, out ahscheme);
            Address target = AddressParser.Parse("brunet:node:" + kvpairs["dest"]);
            ushort  option = AHHeader.Options.StringToUShort(kvpairs["mode"]);

            return(new AHSender(n, target, option));
        }
コード例 #18
0
        /// <summary>
        /// Application arguments:
        /// arg0: Selected Exchange. Has to be enum StockModel.Master.Exchange
        /// arg1: Data generator to use. Has to be IDataPublisher.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //Loading system startup data for all the exchanges
            List <Exchange> exchanges = new List <Exchange>();

            //defaults selected...
            selectedExchange = Exchange.FAKE_NASDAQ;
            dataGenerator    = YahooDataGenerator.Instance;

            ResolveAppArgs(args);

            exchanges = Enum.GetValues(typeof(Exchange)).OfType <Exchange>().ToList();

            InMemoryObjects.LoadInMemoryObjects(exchanges);

            TimeSpan updateDuration = TimeSpan.FromMilliseconds(Constants.FAKE_DATA_GENERATE_PERIOD);

            //Start data generation - this will start fetching data for all symbols of current exchange
            //Later, need to change this to only subscribe to the specific symbol(s) selected.
            dataGenerator.StartDataGeneration(300, selectedExchange);

            sender = SenderFactory.GetSender(FeederQueueSystem.REDIS_CACHE);

            List <StockModel.Symbol> symbols = InMemoryObjects.ExchangeSymbolList.SingleOrDefault(x => x.Exchange == selectedExchange).Symbols;

            List <SymbolFeeds>       generatedData = new List <SymbolFeeds>();
            List <StockModel.Symbol> symbolList    = new List <StockModel.Symbol>();


            Action <double, string> addMovingAverage = new Action <double, string>((val, MVA_id) => {
                sender.SendMVA(val, MVA_id);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Sent value {0} to redis", val);
                Console.ResetColor();
            });

            Parallel.ForEach(symbols, (symbol) =>
            {
                //subscribe
                dataGenerator.SubscribeFeed(symbol.Id, (Feed fd) =>
                {
                    sender.SendFeed(fd, selectedExchange.ToString());

                    Console.WriteLine(fd.ToString());
                });

                //add subscription for each aggregator configured
                //RXProcessing.AddAggregator(dataGenerator, new MovingAverage(),
                //    addMovingAverage
                //    , symbol.Id);
            });

            Console.Read();
        }
コード例 #19
0
        public static ForwardingSender CreateInstance(object node_ctx, string uri)
        {
            Node   n = (Node)node_ctx;
            string fw_scheme; //Should be "fw"
            IDictionary <string, string> kvpairs = SenderFactory.DecodeUri(uri, out fw_scheme);
            Address forwarder   = AddressParser.Parse("brunet:node:" + kvpairs["relay"]);
            ushort  init_option = AHHeader.Options.StringToUShort(kvpairs["init_mode"]);
            Address target      = AddressParser.Parse("brunet:node:" + kvpairs["dest"]);
            short   ttl         = (short)Int16.Parse(kvpairs["ttl"]);
            ushort  option      = AHHeader.Options.StringToUShort(kvpairs["mode"]);

            //Console.WriteLine("{0}, {1}, {2}, {3}, {4}", forwarder, init_option, target, ttl, option);
            return(new ForwardingSender(n, forwarder, init_option, target, ttl, option));
        }
コード例 #20
0
        /// <summary>
        /// Loads the Traffic Viewer extensions
        /// </summary>
        public void LoadExtensions()
        {
            SdkSettings.Instance.ExtensionInfoList = TrafficViewerOptions.Instance.GetExtensionInfo();

            //load modules
            TrafficParserFactory parserFactory = new TrafficParserFactory();

            _trafficParsers = parserFactory.GetExtensions();
            ExporterFactory exporterFactory = new ExporterFactory();

            _trafficExporters = exporterFactory.GetExtensions();
            AnalysisModulesFactory analysisModulesFactory = new AnalysisModulesFactory();

            _analysisModules = analysisModulesFactory.GetExtensions();
            ExploiterFactory exploitersFactory = new ExploiterFactory();

            _exploiters = exploitersFactory.GetExtensions();

            SenderFactory senderFactory = new SenderFactory();

            _senders = senderFactory.GetExtensions();
            HttpClientExtensionFactory clientFactoryLoader = new HttpClientExtensionFactory();

            _httpClientFactoryList = clientFactoryLoader.GetExtensions();
            _httpClientFactoryList.Add(new WebRequestClientFactory());
            _httpClientFactory = null;
            //find in the list of client factories the one with the name specified in options
            foreach (IHttpClientFactory clientFactory in _httpClientFactoryList)
            {
                if (String.Compare(clientFactory.ClientType, TrafficViewerOptions.Instance.HttpClientName) == 0)
                {
                    _httpClientFactory = clientFactory;
                    break;
                }
            }

            if (_httpClientFactory == null)
            {
                //if the factory was not found use the default
                _httpClientFactory = new TrafficViewerHttpClientFactory();
                //log a warning
                SdkSettings.Instance.Logger.Log(TraceLevel.Warning, "Could not find HTTP client factory for {0}", TrafficViewerOptions.Instance.HttpClientName);
                TrafficViewerOptions.Instance.HttpClientName = _httpClientFactory.ClientType;
            }

            HttpProxyFactory proxyFactory = new HttpProxyFactory();

            _httpProxyFactoryList = proxyFactory.GetExtensions();
        }
コード例 #21
0
ファイル: AHSender.cs プロジェクト: pcbing/brunet
        public void Test()
        {
            RandomNumberGenerator rng     = new RNGCryptoServiceProvider();
            AHAddress             tmp_add = new AHAddress(rng);
            Node             n            = new StructuredNode(tmp_add, "unittest");
            AHSender         ah           = new AHSender(n, AddressParser.Parse("brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4"));
            ForwardingSender fs           = new ForwardingSender(n,
                                                                 AddressParser.Parse("brunet:node:JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4"),
                                                                 AddressParser.Parse("brunet:node:5FMQW3KKJWOOGVDO6QAQP65AWVZQ4VUQ"));

            string  uri = "sender:ah?dest=JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&mode=exact";
            ISender s   = SenderFactory.CreateInstance(n, uri);

            Assert.IsTrue(s is AHSender);
            Assert.AreEqual(uri, s.ToUri());
            uri = "sender:ah?dest=JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&mode=greedy";

            //Create the above programatically
            IDictionary <string, string> param_args = new Dictionary <string, string>();

            param_args["dest"] = "JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4";
            param_args["mode"] = "greedy";
            string uri0 = SenderFactory.EncodeUri("ah", param_args);

            Assert.AreEqual(uri, uri0, "EncodeUri works");
            //Check decode:
            string scheme;

            param_args = SenderFactory.DecodeUri(uri, out scheme);
            Assert.AreEqual(scheme, "ah", "Scheme decoded");
            Assert.AreEqual(param_args.Count, 2, "2 parameters in uri");
            Assert.AreEqual(param_args["dest"], "JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4", "Extracted address");
            Assert.AreEqual(param_args["mode"], "greedy", "got mode");

            s = SenderFactory.CreateInstance(n, uri);
            Assert.IsTrue(s is AHSender);
            Assert.AreEqual(uri, s.ToUri());
            string furi = "sender:fw?relay=JOJZG7VO6RFOEZJ6CJJ2WOIJWTXRVRP4&init_mode=greedy&dest=5FMQW3KKJWOOGVDO6QAQP65AWVZQ4VUQ&ttl=3&mode=path";

            s = SenderFactory.CreateInstance(n, furi);
            Assert.IsTrue(s is ForwardingSender);
            Assert.AreEqual(furi, s.ToUri());
        }
コード例 #22
0
        private static void SubscribeRedis()
        {
            ConnectionMultiplexer connection = null;

            connection = GetRedisConnection();
            ISubscriber sub = connection.GetSubscriber();

            sub.Subscribe(_exchange, (channel, message) =>
            {
                lock (_lockQueue)
                {
                    byte[] binary       = Convert.FromBase64String(message);
                    MemoryStream stream = new MemoryStream(binary);
                    Feed feed           = (Feed)ObjectSerialization.DeserializeFromStream(stream);

                    //send to NEsper
                    _runtime.SendEvent(feed);
                }
            });
            sender = SenderFactory.GetSender(FeederQueueSystem.REDIS_CACHE);
        }
コード例 #23
0
ファイル: TestBase.cs プロジェクト: GraphDefined/SMSAPI
        public void SetUp()
        {
            client = new Client(ConfigurationManager.AppSettings["username"]);
            client.SetPasswordHash(ConfigurationManager.AppSettings["password"]);

            proxy = new ProxyHTTP(ConfigurationManager.AppSettings["baseUrl"]);

            smsFactory    = new SMSFactory(client, proxy);
            senderFactory = new SenderFactory(client, proxy);
            userFactory   = new UserFactory(client, proxy);

            contactsFactory = new ContactsFactory(client, proxy);

            var clientLegacy = new Client(ConfigurationManager.AppSettings["usernameOldPhonebook"]);

            clientLegacy.SetPasswordHash(ConfigurationManager.AppSettings["passwordOldPhonebook"]);
            phonebookFactory = new PhonebookFactory(clientLegacy, proxy);

            subUserName     = ConfigurationManager.AppSettings["subUserName"];
            validTestNumber = ConfigurationManager.AppSettings["validTestNumber"];
        }
コード例 #24
0
        protected void TreeHandler(object o, EventArgs eargs)
        {
            Channel result = (Channel)o;
            Channel q      = (Channel)result.State;

            try {
                RpcResult r    = (RpcResult)result.Dequeue();
                var       mris = new List <MapReduceInfo>();
                foreach (IDictionary d in (IList)r.Result)
                {
                    var uri    = (string)d["sender"];
                    var sender = SenderFactory.CreateInstance(_node, uri);
                    var args   = new MapReduceArgs((IDictionary)d["args"]);
                    mris.Add(new MapReduceInfo(sender, args));
                }
                q.Enqueue(mris.ToArray());
            }
            catch (Exception x) {
                //Some kind of problem:
                q.Enqueue(x);
            }
        }
コード例 #25
0
 public async Task SendMessageAsync <T>(T message, string queueOrTopicName, ServiceBusType type)
 {
     ISender sender = new SenderFactory(_connectionString).GetConcreteSender(type, queueOrTopicName);
     await sender.SendMessage <T>(message);
 }
コード例 #26
0
        public object[] uriproxy(string uri, int maxResultsToWait, string method, params object[] args)
        {
            ISender s = SenderFactory.CreateInstance(_node, uri);

            return(this.Proxy(s, maxResultsToWait, method, args));
        }
コード例 #27
0
 public override void SetUp()
 {
     base.SetUp();
     _factory = new SenderFactory(_client, _proxyAddress);
 }
コード例 #28
0
 static ForwardingSender()
 {
     SenderFactory.Register("fw", CreateInstance);
 }
コード例 #29
0
        /**
         * This dispatches the particular methods this class provides.
         * Currently, the only invokable method is:
         * "Start".
         */
        public void HandleRpc(ISender caller, string method, IList args, object req_state)
        {
            int part_idx = method.IndexOf(':');

            if (part_idx == -1)
            {
                if (method == "Start")
                {
                    IDictionary   ht        = (IDictionary)args[0];
                    MapReduceArgs mr_args   = new MapReduceArgs(ht);
                    string        task_name = mr_args.TaskName;
                    MapReduceTask task;
                    if (_name_to_task.TryGetValue(task_name, out task))
                    {
                        MapReduceComputation mr = new MapReduceComputation(_node, req_state, task, mr_args);
                        mr.Start();
                    }
                    else
                    {
                        throw new AdrException(-32608, "No mapreduce task with name: " + task_name);
                    }
                }
                else if (method == "AddHandler")
                {
                    //Make sure this is local:
                    ISender tmp_call = caller;
                    bool    islocal  = tmp_call is Node;
                    while (!islocal && tmp_call is IWrappingSender)
                    {
                        tmp_call = ((IWrappingSender)tmp_call).WrappedSender;
                        islocal  = tmp_call is Node;
                    }
                    if (!islocal)
                    {
                        throw new AdrException(-32601, "AddHandler only valid for local callers");
                    }
                    SubscribeTask(new RpcMapReduceTask(_node, (IDictionary)args[0]));
                    _rpc.SendResult(req_state, null);
                }
                else
                {
                    throw new AdrException(-32601, "No Handler for method: " + method);
                }
            }
            else
            {
                //This is a reference to a specific part of a task:
                string        part      = method.Substring(0, part_idx);
                string        task_name = method.Substring(part_idx + 1);
                MapReduceTask task;
                if (false == _name_to_task.TryGetValue(task_name, out task))
                {
                    throw new AdrException(-32608, "No mapreduce task with name: " + task_name);
                }
                if (part == "tree")
                {
                    var mra = new MapReduceArgs((IDictionary)args[0]);

                    var tree_res = new Channel(1, req_state);
                    tree_res.CloseEvent += this.HandleTree;
                    task.GenerateTree(tree_res, mra);
                }
                else if (part == "reduce")
                {
                    //Prepare the RpcResult:
                    var     rres_d = (IDictionary)args[2];
                    ISender send   = SenderFactory.CreateInstance(_node, (string)rres_d["sender"]);
                    var     rres   = new RpcResult(send, rres_d["result"]);

                    Channel reduce_res = new Channel(1, req_state);
                    reduce_res.CloseEvent += this.HandleReduce;
                    task.Reduce(reduce_res, args[0], args[1], rres);
                }
                else if (part == "map")
                {
                    Channel map_res = new Channel(1, req_state);
                    map_res.CloseEvent += this.HandleMap;
                    task.Map(map_res, args[0]);
                }
                else
                {
                    throw new AdrException(-32608,
                                           String.Format("No mapreduce task({0}) part with name: {1}", task_name, part));
                }
            }
        }
コード例 #30
0
ファイル: MessageManager.cs プロジェクト: fdwdy/SchoolAdmin
 public IMessageSender ResolveSender(Employee emp)
 {
     return(SenderFactory.GetSender(emp));
 }