Esempio n. 1
0
        private void Run(string message)
        {
            var container = new Container();

            container.RegisterInstance(null, typeof(IConfigurationRoot), this.configurationRootMock.Object);

            FrameworkBuilder.Create()
            .AddModule(m => m.Module(new SerializationModule()))
            .AddModule(m => m.Module(new BotModule()))
            .AddModule(m => m.Module(new BotAzureModule()))
            .AddModule(m => m.Module(new AzureApplicationInsightsModule()))
            .AddBotAction <TestReplyAction>()
            .AddBotForm <MyModel>()
            .Bootstrapp();

            string queueItem = QueueItem(message);

            BotRunner.Run(queueItem).Wait();
        }
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            var kernel = new StandardKernel();

            // services dependency injections
            kernel.Bind <AuthenticationService>().To <AuthenticationService>().InSingletonScope();
            kernel.Bind <IMessangerService>().To <MessangerService>().InSingletonScope();
            kernel.Bind <IUserSearchingService>().To <UserSearchingService>().InSingletonScope();
            kernel.Bind <MessageSearchingService>().To <MessageSearchingService>().InSingletonScope();
            kernel.Bind <RegistrationService>().To <RegistrationService>().InSingletonScope();
            kernel.Bind <CsvUserExportService>().To <CsvUserExportService>().InSingletonScope();
            kernel.Bind <CsvMessageExportService>().To <CsvMessageExportService>().InSingletonScope();
            kernel.Bind <IFriendsService>().To <FriendsService>().InSingletonScope();
            kernel.Bind <UserValidationService>().To <UserValidationService>().InSingletonScope();
            kernel.Bind <IMessageSearchingService>().To <MessageSearchingService>().InSingletonScope();
            kernel.Bind <IMessageHistoryService>().To <MessagesHistoryService>().InSingletonScope();
            kernel.Bind <IShortestUserPathService>().To <ShortestUserPathService>().InSingletonScope();
            kernel.Bind <IPathProvider>().To <PathProvider>().InSingletonScope();
            kernel.Bind <IImageService>().To <ImageService>().InSingletonScope();
            kernel.Bind <IEndPointSetter>().To <AuthenticationService>().InSingletonScope();


            config.DependencyResolver = new NinjectResolver(kernel);
            // Run Bot1
            var botRunner = new BotRunner();

            botRunner.Run();

            // Configure Web API to use only bearer token authentication.
            config.SuppressDefaultHostAuthentication();
            config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
        }
Esempio n. 3
0
        private static void Main()
        {
            using (var work = new UnitOfWork())
            {
                var res = work.Cities;
            }

            var iOService = NinjectKernel.Get <IInputOutputSevice>();

            // Run Bot1
            var botRunner = new BotRunner();

            botRunner.Run();

            iOService.Out.WriteLine(Resources.InfoGreeting);
            Logger.Info(Resources.InfoGreeting);

            Command authenHandlers   = GetAuthenticationCommand();
            Command loggedInHandlers = GetLoggedInCommand();

            var exitCommand = false;

            exitMethod = (sender, e) => { exitCommand = true; };
            while (!exitCommand)
            {
                while (!CommandHandler.Session.IsLogged)
                {
                    iOService.Out.WriteLine(Resources.InfoFirsUsage);
                    iOService.Out.Write(Resources.InfoNewCommandLine);

                    authenHandlers.Execute(iOService.In.ReadLine());

                    iOService.Out.WriteLine();
                }

                iOService.Out.Write(Resources.InfoNewCommandLine);
                loggedInHandlers.Execute(iOService.In.ReadLine());

                iOService.Out.WriteLine();
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var included = new StreamReader(File.OpenRead("categories.txt")).ReadToEnd().Split('\n').Select(a => a.Trim('\r'));

            var restAPIKey         = ConfigurationManager.AppSettings["wooCommerceRestAPIKey"];
            var restAPISecret      = ConfigurationManager.AppSettings["wooCommerceRestAPISecret"];
            var priceLowCap        = ConfigurationManager.AppSettings["priceLowCap"];
            var priceHighCap       = ConfigurationManager.AppSettings["priceHighCap"];
            var maxItemPerCategory = int.Parse(ConfigurationManager.AppSettings["maxItemPerCategory"]);

            var markUpPercentage     = Double.Parse(ConfigurationManager.AppSettings["markUpPercentage"]);
            var usdtoMyrCurrencyRate = Double.Parse(ConfigurationManager.AppSettings["usdtoMyrCurrencyRate"]);
            var postTypeStr          = ConfigurationManager.AppSettings["postAs"];

            var productPauseDelay = int.Parse(ConfigurationManager.AppSettings["productPauseDelay"]);

            var productMinPriceAfterConvert = Double.Parse(ConfigurationManager.AppSettings["productMinPriceAfterConvert"]);
            var productBelowMinMarkup       = Double.Parse(ConfigurationManager.AppSettings["productBelowMinMarkup"]);

            var bot = new BotRunner(
                postTypeStr,
                included,
                priceLowCap,
                priceHighCap,
                restAPIKey,
                restAPISecret,
                markUpPercentage,
                usdtoMyrCurrencyRate,
                productMinPriceAfterConvert,
                productBelowMinMarkup,
                maxItemPerCategory,
                productPauseDelay,
                new ConsoleLogger(),
                new ConsoleResultHandler(),
                15 * 60 * 1000);

            bot.Run();
        }
Esempio n. 5
0
        public override int Run(string[] remainingArguments)
        {
            BotRunner.Run();

            return(1);
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!started)
            {
                button1.Text = "Pause";

                var included = new StreamReader(File.OpenRead("categories.txt")).ReadToEnd().Split('\n').Select(a => a.Trim('\r'));

                var restAPIKey         = ConfigurationManager.AppSettings["wooCommerceRestAPIKey"];
                var restAPISecret      = ConfigurationManager.AppSettings["wooCommerceRestAPISecret"];
                var priceLowCap        = ConfigurationManager.AppSettings["priceLowCap"];
                var priceHighCap       = ConfigurationManager.AppSettings["priceHighCap"];
                var maxItemPerCategory = int.Parse(ConfigurationManager.AppSettings["maxItemPerCategory"]);

                var markUpPercentage     = Double.Parse(ConfigurationManager.AppSettings["markUpPercentage"]);
                var usdtoMyrCurrencyRate = Double.Parse(ConfigurationManager.AppSettings["usdtoMyrCurrencyRate"]);
                var postTypeStr          = ConfigurationManager.AppSettings["postAs"];

                var productPauseDelay = int.Parse(ConfigurationManager.AppSettings["productPauseDelay"]);

                var productMinPriceAfterConvert = Double.Parse(ConfigurationManager.AppSettings["productMinPriceAfterConvert"]);
                var productBelowMinMarkup       = Double.Parse(ConfigurationManager.AppSettings["productBelowMinMarkup"]);

                var loginPageAppearedPauseDelay = int.Parse(ConfigurationManager.AppSettings["loginPageAppearedPauseDelay"]);

                var restAPIUrl = ConfigurationManager.AppSettings["wooCommerceRestAPIUrl"];

                bot = new BotRunner(
                    restAPIUrl,
                    postTypeStr,
                    included,
                    priceLowCap,
                    priceHighCap,
                    restAPIKey,
                    restAPISecret,
                    markUpPercentage,
                    usdtoMyrCurrencyRate,
                    productMinPriceAfterConvert,
                    productBelowMinMarkup,
                    maxItemPerCategory,
                    productPauseDelay,
                    new FormLogger(this, this.txtLog),
                    new FormResultHandler(this, this.listView1),
                    loginPageAppearedPauseDelay);

                thread = new Thread(() =>
                {
                    bot.Run();
                });

                thread.Start();
                started = true;
            }
            else
            {
                if (!paused)
                {
                    button1.Text = "Unpause";
                    bot.Pause();
                    paused = true;
                }
                else
                {
                    button1.Text = "Pause";
                    bot.Resume();
                    paused = false;
                }
            }
        }