Пример #1
0
        public JsonResult GetOrphanDocuments()
        {
            string conStr = Session["conStr"].ToString(); //ConfigurationManager.ConnectionStrings["MySQLConnectionString"].ConnectionString;
            int    id     = Convert.ToInt32(Session["CURENT_USER_ID"]);
            DocumenteScanateRepository dsr = new DocumenteScanateRepository(id, conStr);

            DocumentScanat[]      docs = (DocumentScanat[])dsr.GetOrphanDocuments().Result;
            List <OrphanDocument> ofs  = new List <OrphanDocument>();

            foreach (DocumentScanat ds in docs)
            {
                OrphanDocument od = new OrphanDocument();
                od.DOCUMENT_SCANAT = ds; od.SELECTED = true;
                ofs.Add(od);
            }
            return(Json(ofs, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public static void RestoreOrphanDocuments()
        {
            string   LOG_FILE = "c:\\Uploads\\Log.txt";
            response r        = new response();
            string   conStr   = CommonFunctions.StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ToString(), CommonFunctions.StringCipher.RetrieveKey());
            int      id       = 1;
            DocumenteScanateRepository dsr = new DocumenteScanateRepository(id, conStr);

            DocumentScanat[] docs = (DocumentScanat[])dsr.GetOrphanDocuments().Result;
            //FileManager.RestoreFilesFromDb(docs);
            StreamWriter sw = File.AppendText(LOG_FILE);

            sw.Write(String.Format("{0} documente orfane\r\n*****************************************************\r\n\r\n", docs.Length));
            sw.Flush(); sw.Dispose();
            foreach (DocumentScanat ds in docs)
            {
                r = FileManager.RestoreFileFromDb(ds);
                string message = String.Format("{0} ({1}) - {2}\r\n", ds.CALE_FISIER, ds.ID_DOSAR, r.Status ? "Recuperat" : r.Message);
                Console.Write(message);
                sw = File.AppendText(LOG_FILE);
                sw.Write(message);
                sw.Flush(); sw.Dispose();
            }
        }