예제 #1
0
        //NM - At a high level, the primary steps should be broken out into their own methods, for instance
        // LoadConfiguration();
        // ProcessTaxDocument();
        // WriteToAzure();
        // WriteToDatabase();
        //
        // That way people can understand what is going on at a high level without diving deep into the code
        public Worker()
        {
            // NM - Modify this to read these values from a configuration file.  Google 'how to use appsettings'
            CloudStorageAccount csa = CloudStorageAccount.Parse(
                "DefaultEndpointsProtocol=https;AccountName=cminton;AccountKey=9/z9oCB6lMWHXjxBFEmxB79DUVx0bHF91iHMMjvpX1XXXBMwiJ5+ADpnAQhEhJgtBu8uw9qOtRAq/w2uQT723A==");
            CloudBlobClient    blobclient = csa.CreateCloudBlobClient();
            CloudBlobContainer container  = blobclient.GetContainerReference("mycontainer");

            string connectionstr =
                "Server=tcp:cminton.database.windows.net,1433;Database=cmintondb;User ID=cminton;Password=Foopass42;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

            // create a blob object, then get the document blob from azure
            CloudBlockBlob docblob = container.GetBlockBlobReference("myblob");

            docblob.FetchAttributes();

            // extract the scan data from the blob
            TaxDocumentScan tdscan = new TaxDocumentScan(docblob);

            // create OCRClient and send scan data through OCR
            // get tax document object with completed fields
            OCRClient   ocr    = new OCRClient();
            TaxDocument taxdoc = ocr.ProcessTaxDocument(tdscan);

            // populate azure sql database with tax document fields
            using (var connection = new SQL.SqlConnection(connectionstr))
            {
                connection.Open();
                Console.WriteLine("Connection opened successfully.");
                UploadTaxDocument(connection, taxdoc);
            }
        }
예제 #2
0
        public TaxDocument ProcessTaxDocument(TaxDocumentScan document)
        {
            // NM - you may want to rename this variable to something more readable.  Typing is cheap whereas understanding
            // a piece of code is expensive.  Something like 'taxDocument'.
            TaxDocument tdout = new TaxDocument();

            tdout.ImportantTaxNumber = 42;
            tdout.PropertyName       = "Six Flags over Atlanta";
            tdout.PropertyValue      = 988342.37;
            tdout.TaxRate            = 0.51;
            Console.WriteLine("ProcessTaxDocument called");
            Console.WriteLine("blob data: {0}", Encoding.Default.GetString(document.Data));
            Console.WriteLine("Returning TaxDocument with params:");
            Console.WriteLine("ImportantTaxNumber={0}", tdout.ImportantTaxNumber);
            Console.WriteLine("PropertyName={0}", tdout.PropertyName);
            Console.WriteLine("PropertyValue={0}", tdout.PropertyValue);
            Console.WriteLine("TaxRate={0}", tdout.TaxRate);

            return(tdout);
        }