Exemple #1
0
        static void Main(string[] args)
        {
            List <Model.BetEasyModel> betEasyModels = new List <Model.BetEasyModel>();
            DirectoryInfo             feedData      = new DirectoryInfo("FeedData");

            FileInfo[] files = feedData.GetFiles();
            foreach (var file in files)
            {
                IProcessData processData = ProcessDataFactory.GetProcessDataType(file.Extension.ToLower());
                if (processData != null)
                {
                    var model = processData.Transform(file);
                    if (model != null)
                    {
                        betEasyModels.AddRange(model);
                    }
                }
            }

            betEasyModels = betEasyModels.OrderBy(t => t.Price).ToList();

            foreach (var model in betEasyModels)
            {
                Console.WriteLine(string.Format("Horse Name : {0}   Price : {1}", model.HorseName, model.Price));
            }

            Console.ReadLine();
        }
Exemple #2
0
        public static string CreateString(this IProcessData process, int verbosity = DefaultVerbosity)
        {
            var processes = process.Enumerate(new HashSet <IProcessData>()).ToList();
            var tags      = process.Data.Where(t => (t.Verbosity <= verbosity)).ToList();

            var cache = processes
                        .Select((p, k) => new { Key = (IProcessRange)p, Value = new ProcessInterval(k, k + 1) })
                        .ToDictionary(x => x.Key, x => x.Value);
            var range = tags.ToDictionary(tag => tag, tag => tag.Range(cache));

            tags = (from tag in tags
                    where range[tag].NonEmpty()
                    orderby range[tag].Max descending
                    select tag)
                   .ToList();

            var ranges = new List <ProcessInterval>();
            var depth  = tags.ToDictionary(
                tag => tag,
                tag => (ranges = ranges
                                 .Where(r => r.Min <= range[tag].Min)
                                 .Concat(new[] { range[tag] })
                                 .ToList())
                .Count() - 1);

            tags.Reverse();

            return(string.Join("\n",
                               from tag in tags
                               select String.Concat(Enumerable.Repeat("    ", depth[tag])) + tag.Label));
        }
        IProcessData GetProcessData(string type)
        {
            IProcessData result = null;

            switch (type.ToLower())
            {
            case "iexplorer":
                result = new InternetExplorerProcessData();
                break;

            case "firefox":
                result = new FirefoxProcessData();
                break;

            case "devenv":
                result = new VisualStudioProcessData();
                break;

            case "generic":
                result = new GenericProcessData();
                break;

            default:
                Debug.Assert(false, "Handle new process data type");
                break;
            }

            return(result);
        }
Exemple #4
0
        public bool save(IProcessData data, ISettings settings)
        {
            TimeBlockData timeBlockData = (TimeBlockData)data;

            var properties = timeBlockData.TimeBlock.ToJSON();
            //Console.WriteLine(properties);

            var manager      = Manager.SharedInstance;
            var timeblocksDb = manager.GetDatabase(settings.TimeblocksDb());

            //Create new Document
            var document = timeblocksDb.CreateDocument();
            var revision = document.PutProperties(properties);
            var docId    = document.Id;

            try
            {
                //Attach ScreenShot
                var couchDoc = timeblocksDb.GetDocument(docId);
                var newRev   = couchDoc.CurrentRevision.CreateRevision();
                newRev.SetAttachment("screenshot" + docId + ".jpg", "image/jpeg", timeBlockData.TimeBlock.ScreenShot);
                newRev.Save();
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR : " + e);
            }



            Console.WriteLine("Document created with ID = {0}", docId);
            return(true);
        }
Exemple #5
0
        public override async Task <bool> Process(IProcessData processData)
        {
            if (!processData.Validate())
            {
                //Console.WriteLine("Error");
                Debug.WriteLine(processData.GetErrors().Count);
                foreach (string error in processData.GetErrors())
                {
                    Debug.WriteLine(error);
                }

                return(false);
            }

            var settings = GetSettings();
            // TODO Get the source From API and/or CouchLite DB
            var manager  = Manager.SharedInstance;
            var database = manager.GetDatabase(settings.SubcontractorDetailsDb());

            StartWorkData startWorkData = (StartWorkData)processData;
            Task <string> taskResult    = Post(startWorkData.GetFormData(), "/rsm/start-work/");
            string        result        = await taskResult;
            dynamic       json          = JObject.Parse(result);
            bool          success       = json.success;

            Debug.WriteLine(success);
            return(success);
        }
Exemple #6
0
 public void AddInput(IProcessData process)
 {
     if (process != this)
     {
         m_InputProcesses.Add(process);
         MergeWith(process);
     }
 }
Exemple #7
0
        public ServiceBusConsumer(IProcessData processData,
                                  IConfiguration configuration)
        {
            _processData   = processData;
            _configuration = configuration;

            // ServiceBus_Connection= _configuration.GetConnectionString("ServiceBusConnectionString")
            _queueClient = new QueueClient(ServiceBus_Connection, QUEUE_NAME);
        }
 public ServiceBusConsumer(IProcessData processData,
                           IConfiguration configuration,
                           ILogger <ServiceBusConsumer> logger)
 {
     _processData   = processData;
     _configuration = configuration;
     _logger        = logger;
     _queueClient   = new QueueClient(_configuration.GetConnectionString("ServiceBusConnectionString"), QUEUE_NAME);
 }
 public ProcessDataController(IProcessData processDataUsecase, ILogger <ProcessDataController> logger,
                              IPostInitialProcessDocumentRequestValidator postInitDocValidator, IUpdateProcessDocumentRequestValidator updateValidator,
                              IGetProcessDocumentRequestValidator getValidator)
 {
     _processDataUsecase = processDataUsecase;
     _logger             = logger;
     _postValidator      = postInitDocValidator;
     _updateValidator    = updateValidator;
     _getValidator       = getValidator;
 }
Exemple #10
0
        public override async Task <bool> Process(IProcessData processData, ICouchSave couchSave)
        {
            var result = await Process();

            StartWorkData startData = (StartWorkData)processData;

            startData.Work        = RESULT;
            startData.Work.Subcon = startData.Subcon;
            couchSave.save((IProcessData)startData, GetSettings());
            return(true);
        }
Exemple #11
0
        public ProcessTag(string label, int verbostiy, IProcessData start, IProcessData end)
        {
            Label     = label;
            Verbosity = verbostiy;
            m_Start   = start;
            m_End     = end ?? start;

            if (m_End == null)
            {
                throw new ArgumentNullException("Either 'start' or 'end' needs to be non-null.");
            }
        }
Exemple #12
0
 public ServiceBusTopicSubscriber(IProcessData processData,
                                  IConfiguration configuration,
                                  ILogger <ServiceBusTopicSubscriber> logger)
 {
     _configuration      = configuration;
     _logger             = logger;
     _processData        = processData;
     _subscriptionClient = new SubscriptionClient(
         _configuration["ServiceBusConnectionString"],
         TOPIC_PATH,
         SUBSCRIPTION_NAME);
 }
Exemple #13
0
        public ServiceBusConsumer(IProcessData processData,
                                  IConfiguration configuration,
                                  ILogger <ServiceBusConsumer> logger)
        {
            _processData   = processData;
            _configuration = configuration;
            _logger        = logger;
            var connectStr = _configuration.GetSection("SeviceBusSetting").GetSection("ServiceBusConnectionString").Value;
            var queue      = _configuration.GetSection("SeviceBusSetting").GetSection("QueueName").Value;

            _queueClient = new QueueClient(connectStr, queue);
        }
Exemple #14
0
        public Form1(IGenericRepository <Product> productRepo, IGenericRepository <ProductSales> productSalesRepo,
                     IAddData addData, ILoadData loadData, IClearData clearData, IProcessData processData)
        {
            _productRepo      = productRepo;
            _productSalesRepo = productSalesRepo;
            _addData          = addData;
            _loadData         = loadData;
            _clearData        = clearData;
            _processData      = processData;

            InitializeComponent();
        }
        public override async Task <bool> Process(IProcessData processData, ICouchSave couchSave)
        {
            if (!processData.Validate())
            {
                Debug.WriteLine("Error");
                return(false);
            }

            SyncData syncData = (SyncData)processData;

            couchSave.save(syncData, GetSettings());
            return(true);
        }
        public async override Task <bool> Process(IProcessData processData, ICouchSave couchSave)
        {
            if (!processData.Validate())
            {
                Debug.WriteLine("Error");
                return(false);
            }

            TimeBlockData timeBlockData = (TimeBlockData)processData;

            couchSave.save(timeBlockData, GetSettings());
            return(true);
        }
        public TopicsAndSubscription(IProcessData processData,
                                     IConfiguration configuration,
                                     ILogger <TopicsAndSubscription> logger)
        {
            _processData   = processData;
            _configuration = configuration;
            _logger        = logger;

            _subscriptionClient = new SubscriptionClient(
                _configuration.GetConnectionString("ServiceBusConnectionString"),
                TOPIC_PATH,
                SUBSCRIPTION_NAME);
        }
        public ServiceBusTopicSubscription(IProcessData processData,
                                           IConfiguration configuration,
                                           ILogger <ServiceBusTopicSubscription> logger)
        {
            _processData   = processData;
            _configuration = configuration;
            _logger        = logger;

            _subscriptionClient = new SubscriptionClient(
                //_configuration.GetConnectionString("ServiceBusConnectionString"),
                "Endpoint=sb://busgalaxylema.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=nMmVHcnIqrHgD6e1P/RPGHtMyGBtPKysZkbNMqz3JMY=",
                TOPIC_PATH,
                SUBSCRIPTION_NAME);
        }
        public bool save(IProcessData data, ISettings settings)
        {
            StartWorkData startData = (StartWorkData)data;

            var properties = startData.Work.ToJSON();
            var manager    = Manager.SharedInstance;
            var workDb     = manager.GetDatabase(settings.WorkDb());
            var document   = workDb.CreateDocument();
            var revision   = document.PutProperties(properties);
            var docId      = document.Id;

            startData.Work.DocId = docId;
            return(true);
        }
        public static IProcessData GetProcessDataType(string fileExtension)
        {
            IProcessData processData = null;

            switch (fileExtension)
            {
            case ".xml":
                processData = new ProcessXMLData();
                break;

            case ".json":
                processData = new ProcessJSONData();
                break;
            }
            return(processData);
        }
Exemple #21
0
        /// <summary>
        /// Creates an instance of <see cref="MessageConsumer"/>.
        /// This constructor is called by DI.
        /// </summary>
        /// <param name="processData">An interface that provides logic to further process a message.</param>
        /// <param name="configuration">The app's configuration. An instance of <see cref="IConfiguration"/> is injected by DI.</param>
        /// <param name="logger">A generic logger injected by DI.</param>
        /// <param name="telemetryClient">A fully fletched instance of <see cref="TelemetryClient"/> for further logging.</param>
        public MessageConsumer(IProcessData processData,
                               IConfiguration configuration,
                               ILogger <MessageConsumer> logger,
                               TelemetryClient telemetryClient)
        {
            this.configuration   = configuration;
            this.logger          = logger;
            this.telemetryClient = telemetryClient;

            // instantiate an instance of a SubscriptionClient.
            // The is used to handle messages
            subscriptionClient = new SubscriptionClient(
                this.configuration["ServiceBus:MessageInTopicConnectionString"],
                this.configuration["ServiceBus:TopicName"],
                this.configuration["ServiceBus:SubscriptionName"], ReceiveMode.PeekLock);
        }
        public override async Task <bool> Process(IProcessData processData)
        {
            if (!processData.Validate())
            {
                Debug.WriteLine(processData.GetErrors().Count);
                foreach (string error in processData.GetErrors())
                {
                    Debug.WriteLine(error);
                }

                return(false);
            }

            CacheData cacheData = (CacheData)processData;



            return(true);
        }
        public override async Task <bool> Process(IProcessData processData)
        {
            if (!processData.Validate())
            {
                Debug.WriteLine("Error");
                Debug.WriteLine(processData.GetErrors().Count);
                foreach (string error in processData.GetErrors())
                {
                    Debug.WriteLine(error);
                }

                return(false);
            }

            LoginData     loginData  = (LoginData)processData;
            Task <string> taskResult = Post(loginData.GetFormData(), "/rsm/signin/");
            string        result     = await taskResult;
            dynamic       json       = jParser.Parser.Parse(result);
            bool          success    = json["success"];

            Debug.WriteLine("LoginModule : " + success);


            if (success)
            {
                Staff staff = new Staff();
                staff.EmailAddress = json["result"]["email"];
                staff.FirstName    = json["result"]["fname"];
                staff.LastName     = json["result"]["lname"];
                staff.Id           = json["result"]["userid"];
                staff.Password     = loginData.Password;
                LoggedInStaff      = staff;
            }



            RESULT = json;
            return(success);
        }
Exemple #24
0
        public static string CreateString(this IProcessData data, int verbosity = DefaultVerbosity)
        {
            var tags = data.Tags.Where(t => (t.Verbosity <= verbosity)).ToList();

            var range = tags.ToDictionary(
                tag => tag,
                tag => tag.Range());

            tags = tags.Where(t => (range[t].Item1 < range[t].Item2)).ToList();

            var depth = tags.ToDictionary(
                tag => tag,
                tag => tags.Count(t =>
                                  range[t].Item1 <= range[tag].Item1 && range[tag].Item2 <= range[t].Item2 &&
                                  (range[t].Item1 != range[tag].Item1 || range[tag].Item2 != range[t].Item2)));

            var labels = tags
                         .Where(n => - n.Verbosity <= verbosity)
                         .Select(n => String.Concat(Enumerable.Repeat("    ", depth[n])) + n.Label);

            return(string.Join("\n", labels));
        }
        public override async Task <bool> Process(IProcessData processData)
        {
            if (!processData.Validate())
            {
                //Console.WriteLine("Error");
                Debug.WriteLine(processData.GetErrors().Count);
                foreach (string error in processData.GetErrors())
                {
                    Debug.WriteLine(error);
                }

                return(false);
            }
            VersionData versionData = (VersionData)processData;

            Task <string> taskResult = Post(versionData.GetFormData(), "/rsm/version/");
            string        result     = await taskResult;
            dynamic       json       = jParser.Parser.Parse(result);
            bool          success    = json["success"];

            Debug.WriteLine("VersionModule : " + success);
            RESULT = json;
            return(success);
        }
Exemple #26
0
 public CommentsViewComponent(IProcessData process)
 {
     _process = process;
 }
        public Bootstrapper()
        {
            _fileRepository       = new FileRepository();
            _logger               = CreateLogger();
            _dataProcessingParams = new DataProcessingParams();

            _httpDownloader = new HttpDownloader();
            _webCrawlerMain = new WebCrawlerMain(
                httpDownloader: _httpDownloader,
                measurementPointUtility: new MeasurementPointConfigUtility(
                    timeConverter: new TimeConverter(),
                    fileRepository: _fileRepository),
                stringEditUtility: new StringEditUtility());

            _modelRule0             = new ModelRule(0);
            _modelRule1             = new ModelRule(1);
            _modelRule2             = new ModelRule(2);
            _modelRule3             = new ModelRule(3);
            _modelRule4             = new ModelRule(4);
            _modelRule5             = new ModelRule(5);
            _modelRule6             = new ModelRule(6);
            _modelRule7             = new ModelRule(7);
            _modelRule8             = new ModelRule(8);
            _modelRule9             = new ModelRule(9);
            _modelRuleNoMatch       = new ModelRuleNoMatch();
            _bitmapProcessingParams = new BitmapProcessingParams();
            _inputCreator           = new InputCreator();

            _imageLoader = new ImageLoader(
                fileRepository: _fileRepository,
                bitmapProcessingParams: _bitmapProcessingParams,
                bitmapProcessor: new BitmapProcessor(
                    crop: new Crop(
                        rect: new Rectangle()),
                    grayscale: new Grayscale(0, 0, 0),
                    contrastStretch: new ContrastStretch(),
                    resizeBilinear: new ResizeBilinear(1, 1),
                    bitmapProcessingParams: _bitmapProcessingParams));

            _imageRecognitionMain = new ImageRecognitionMain(
                fileRepository: _fileRepository,
                bitmapProcessingParams: _bitmapProcessingParams,
                machine: new Machine(
                    inputCreator: _inputCreator,
                    outputCreator: new OutputCreator(),
                    learning: new Learning(),
                    imageLoader: _imageLoader),
                imageRecognizer: new ImageRecognizer(
                    fileRepository: _fileRepository,
                    imageLoader: _imageLoader,
                    inputCreator: _inputCreator,
                    predictionHandler: new PredictionHandler(
                        fileRepository: _fileRepository,
                        firstDigitModelMatcher: new FirstDigitModelMatcher(
                            modelRules: GetFirstModelRules()),
                        secondDigitModelMatcher: new SecondDigitModelMatcher(
                            modelRules: GetSecondModelRules()),
                        logger: _logger)),
                logger: _logger);

            _dataProcessor = GetDataProcessor();

            _inputValidator = new InputValidator();
            _csvUtility     = new CsvUtility(_fileRepository);
            _contextLoader  = new ProcessingContextLoader(
                folderChooser: new FolderChooser(
                    fileRepository: _fileRepository,
                    folderInfo: new FolderInfo(),
                    inputValidator: _inputValidator),
                configLoader: new LocatioSettingsLoader(
                    fileRepository: _fileRepository),
                configChooser: new ConfigChooser(
                    fileRepository: _fileRepository,
                    inputValidator: _inputValidator),
                csvUtility: _csvUtility);

            UIMain = new UIMain(GetTasks(), _inputValidator, new ProcessingContext());
        }
Exemple #28
0
 public UnitTest1()
 {
     _processData = new ProcessSqlData();
 }
        public void ProcessDataFactory_XML_Pass()
        {
            IProcessData processData = ProcessDataFactory.GetProcessDataType(".xml");

            Assert.Equal(typeof(ProcessXMLData), processData.GetType());
        }
        public void ProcessDataFactory_OtherType_Pass()
        {
            IProcessData processData = ProcessDataFactory.GetProcessDataType(".jpeg");

            Assert.Null(processData);
        }