Esempio n. 1
0
        public void TestGetDownloadQItem()
        {
            var dal  = new SECFormsManager();
            var dtst = dal.GetFormDownloadQueue();

            Assert.IsNotNull(dtst);
        }
Esempio n. 2
0
        public int ProcessQueue()
        {
            var itemsProcessed = 0;

            try
            {
                var manager = new SECFormsManager();
                var dtst    = manager.GetFormDownloadQueue();
                Log("Read" + dtst.tblSEC_Forms.Rows.Count);
                var ftpClient = new FtpClient(_remotePath, _basePath);
                //to prevent concurrency errors, mark as downloaded immediately:
                foreach (var form in dtst.tblSEC_Forms)
                {
                    form.LastDownloaded = DateTime.Now;
                }
                manager.Save(dtst);
                Log("Blocked rows from parallel processes");
                foreach (var form in dtst.tblSEC_Forms)
                {
                    string error;
                    Log("form type: " + form.FormType + " company name: " + form.CompanyName);
                    ftpClient.Download(form.FormPartialURL, _useConsole, out error);
                    if (error == null)
                    {
                        error = string.Empty;
                    }
                    if (error == string.Empty)
                    {
                        form.LastDownloaded = DateTime.Now;
                        itemsProcessed++;
                    }
                    else
                    {
                        Log(error);
                    }
                }
                manager.Save(dtst);
                Log("saved rows");
                dtst.Clear();
            }
            catch (Exception ex)
            {
                Log(ex.Message);
            }
            return(itemsProcessed);
        }