Ejemplo n.º 1
0
        public void EndlessProc(Object objState)
        {
            fProgress fp = new fProgress("Загрузка программы");

            fp.Show();
            while (!done)
            {
                Application.DoEvents();
            }
            fp.Close();
        }
Ejemplo n.º 2
0
        private void button5_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Продолжить?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.No)
            {
                return;
            }
            string     store_ip                 = XmlConnections.GetConnection("/Connections/store_ip");
            string     sTargetConnect           = @"\\" + store_ip + @"\BookAddInf\PERIOD\";
            string     sTarget                  = @"\\" + store_ip + @"\BookAddInf\PERIOD\";
            string     sTargetConnectBookAddInf = @"\\" + store_ip + @"\BookAddInf";
            DBScanInfo db = new DBScanInfo();

            Package = "";

            int Number = 1;
            int Total  = new PdfReader(fPDF.FullName).NumberOfPages;

            fp           = new fProgress(Total);
            this.Enabled = false;
            fp.Show();
            Application.DoEvents();

            //преобразовать и скопиировать все изображения номера
            //int Total = new PdfReader(fPDF.FullName).NumberOfPages;
            //fp.ResetProgress(Total, Number, Total);
            try
            {
                CopyPDFToTarget(store_ip, sTarget, fPDF.DirectoryName, fPDF, Number, Total, fp, sTargetConnectBookAddInf);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Произошла ошибка: " + ex.Message + ". Попробуйте еще раз!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                fp.Close();
                this.Enabled = true;
                return;
            }
        }
Ejemplo n.º 3
0
        private bool CopyJPGToTarget(string ip, string sTarget, string sSource, DirectoryInfo SF, bool FirstPass, int number, int total, fProgress fp,string sTargetConnect)
        {
            DirectoryInfo diTarget = new DirectoryInfo(sTarget);
            DirectoryInfo diSource = new DirectoryInfo(sSource);
            char[] invalid_chars = System.IO.Path.GetInvalidFileNameChars();

            DirectoryInfo TargetFolder = new DirectoryInfo(diTarget.FullName + "\\" + FolderYear);
            string outside_ip = @"\\" + XmlConnections.GetConnection("/Connections/outside_ip") + @"\Backup\BookAddInf\PERIOD\";
            string outsideIPConnect = @"\\" + XmlConnections.GetConnection("/Connections/outside_ip") + @"\Backup";
            string PIN = PINFormat(this.PIN);

            outside_ip += PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";

            DirectoryInfo TargetFolderOutside = new DirectoryInfo(outside_ip + @"\" + this.Year.ToString() );

            //string sTargetConnect = @"\\192.168.4.30\BookAddInf\";
            //MessageBox.Show(TargetFolder.FullName);
            using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
            {
                TargetFolder.Refresh();
            }
            //MessageBox.Show("11");
            if (!TargetFolder.Exists)
            {
                try
                {
                    TargetFolder.Create();
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                    {
                        TargetFolder.Create();
                    }
                }
            }
            else
            {
                if (!FirstPass)
                {
                    try
                    {
                        TargetFolder.Delete(true);
                        TargetFolder.Create();
                    }
                    catch
                    {

                        using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                        {
                            TargetFolder.Delete(true);
                            TargetFolder.Create();
                        }
                    }
                }
            }

            //MessageBox.Show(TargetFolderOutside.FullName + "11111111111111111111");
            //            MessageBox.Show(TargetFolderOutside.Exists.ToString());
               /* using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
            {
                TargetFolderOutside.Refresh();
                //MessageBox.Show(TargetFolderOutside.Exists.ToString());
            }
            //MessageBox.Show(Directory.Exists(TargetFolderOutside.FullName).ToString());

            if (!Directory.Exists(TargetFolderOutside.FullName))
            {
                try
                {
                    //MessageBox.Show(TargetFolderOutside.FullName + "1");
                    TargetFolderOutside.Create();
                }
                catch
                {
                    //MessageBox.Show(outsideIPConnect);
                    //MessageBox.Show(TargetFolderOutside.FullName);
                    using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
                    {
                        TargetFolderOutside.Create();
                        //MessageBox.Show(TargetFolderOutside.FullName);
                    }
                }
            }
            else
            {
                if (!FirstPass)
                {
                    try
                    {
                        //MessageBox.Show(TargetFolderOutside.FullName+"2");
                        TargetFolderOutside.Delete(true);
                        TargetFolderOutside.Create();
                        //MessageBox.Show(TargetFolderOutside.FullName + "rrrrrrrrrrrrrrrrrrrrrr");
                    }
                    catch
                    {
                        using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
                        {
                            //MessageBox.Show(TargetFolderOutside.FullName + "3");
                            TargetFolderOutside.Delete(true);
                            TargetFolderOutside.Create();
                            //MessageBox.Show(TargetFolderOutside.FullName + "ttttttttttttttt");
                        }
                    }
                }
            }*/

            DirectoryInfo[] di = diSource.GetDirectories();
            max_img = di.Length;

            FileInfo[] fi = SF.GetFiles();
            DirectoryInfo To = new DirectoryInfo(TargetFolder.FullName + "\\" + SF.Name);
            //DirectoryInfo ToOutside = new DirectoryInfo(TargetFolderOutside.FullName + "\\" + SF.Name);
            using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
            {
                To.Refresh();
            }
               /* using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
            {
                ToOutside.Refresh();
            }*/

            if (!To.Exists)
            {
                try
                {
                    To.Create();
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                    {
                        To.Create();
                    }
                }
            }
            /*if (!ToOutside.Exists)
            {
                try
                {
                    ToOutside.Create();
                }
                catch
                {
                    using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
                    {
                        ToOutside.Create();
                    }
                }
            }*/
            if ((Package + To.Name + ";").Length >= 3000)
            {
                PackageList.Add(Package);
                Package = "";
            }
            Package += To.Name + ";";

            foreach (FileInfo f in fi)
            {
                try
                {
                    f.CopyTo(To + "\\" + f.Name);
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                    {
                        f.CopyTo(To + "\\" + f.Name);
                    }
                }
                //fp.IncProgress();
                Application.DoEvents();
            }
            /*foreach (FileInfo f in fi)
            {
                try
                {
                    f.CopyTo(ToOutside + "\\" + f.Name);
                }
                catch
                {
                    using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
                    {
                        f.CopyTo(ToOutside + "\\" + f.Name);
                    }
                }
                //fp.IncProgress();
                Application.DoEvents();
            }*/
            return true;
        }
Ejemplo n.º 4
0
        private void button5_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Продолжить?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.No)
            {
                return;
            }
            string store_ip = XmlConnections.GetConnection("/Connections/store_ip");
            string sTargetConnect = @"\\" + store_ip + @"\BookAddInf\PERIOD\";
            string sTarget = @"\\" + store_ip + @"\BookAddInf\PERIOD\";
            DBScanInfo db = new DBScanInfo();
            string PIN = this.PIN;
            PIN = PINFormat(PIN);
            sTarget += PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";

            DirectoryInfo diSource = new DirectoryInfo(YearPath);
            Package = "";
            DirectoryInfo[] diNumbers = diSource.GetDirectories();
            if (diNumbers.Length == 0)
            {
                throw new Exception("В источнике нет папок: " + diSource.ToString());
            }
            bool FirstPass = false;
            int Number = 1;
            int Total = diNumbers.Length;
            fp = new fProgress("Подождите...");
            this.Enabled = false;
            fp.Show();
            Application.DoEvents();

            foreach (DirectoryInfo d in diNumbers)
            {
                Set = d.Name + "; ";
                FileInfo[] fi = d.GetFiles();
                foreach (FileInfo f in fi)
                {
                    //скопиировать все изображения номера
                    //fp.ResetProgress(d.GetFiles("*.jpg").Length, Number, Total);
                    fp.IncProgress(Total, Number, Total);
                    Application.DoEvents();
                    //try
                    //{
                        bool result = CopyJPGToTarget(store_ip, sTarget, YearPath, f.Directory, FirstPass, Number, Total, fp,sTargetConnect);
                    //}
                    //catch (Exception ex)
                    if (!result)
                    {
                        //MessageBox.Show("Произошла ошибка: " + ex.Message + ". Попробуйте еще раз!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        fp.Close();
                        this.Enabled = true;
                        return;
                    }
                    FirstPass = true;
                    Number++;
                    break;
                }
            }

            #region _info.txt
            FileInfo[] _infotxtsearch = diSource.GetFiles();
            FileInfo _infotxt = null;
            foreach (FileInfo f in _infotxtsearch)
            {
                if (f.Name == "_info.txt")
                {
                    _infotxt = f;
                }
            }
            if (_infotxt != null)
            {
                DirectoryInfo d = new DirectoryInfo(sTarget + this.Year + @"\");
                try
                {
                    _infotxt.CopyTo(sTarget + this.Year + @"\_info.txt",true);
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnect, new NetworkCredential("libfl\\DigitCentreWork01", "DigCW_01")))
                    {
                        _infotxt.CopyTo(sTarget + this.Year + @"\_info.txt", true);
                    }
                }

                string outside_ip = @"\\" + XmlConnections.GetConnection("/Connections/outside_ip") + @"\Backup\BookAddInf\PERIOD\";
                outside_ip += PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";
                try
                {
                    _infotxt.CopyTo(outside_ip + this.Year.ToString() + @"\_info.txt", true);
                }
                catch
                {
                    using (new NetworkConnection(outside_ip, new NetworkCredential("bj\\CopyPeriodAddInf", "Period_Copy")))
                    {
                        _infotxt.CopyTo(outside_ip + this.Year.ToString() + @"\_info.txt", true);
                    }
                }
            }
            #endregion
            AddInfo();
        }
Ejemplo n.º 5
0
 //    try
 //    {
 //        NumberFolderList = GetNumberFolderList(this.IDZ);
 //    }
 //    catch (Exception ex)
 //    {
 //        done = true;
 //        DialogResult dr = MessageBox.Show("Произошла ошибка: " + ex.Message + "\". Попробовать еше раз?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
 //        if (dr == DialogResult.Yes)
 //        {
 //            done = false;
 //            ThreadPool.QueueUserWorkItem(new WaitCallback(EndlessProc));
 //            GetNumberFolderList();
 //        }
 //        else
 //        {
 //            Environment.Exit(0);
 //        }
 //    }
 //}
 //private fSelectExistsTitle ChooseFromTmpStg()
 //{
 //    fSelectExistsTitle fSET = new fSelectExistsTitle();
 //    //выбираем существующее издание во временном хранилище
 //    try
 //    {
 //        fSET = new fSelectExistsTitle(mTitle, mYear);
 //        fSET.StartPosition = FormStartPosition.CenterScreen;
 //        fSET.ShowDialog();
 //    }
 //    catch (Exception ex)
 //    {
 //        DialogResult dr = MessageBox.Show("Произошла ошибка: " + ex.Message + "\". Попробовать еше раз?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
 //        if (dr == DialogResult.Yes)
 //        {
 //            fSET = ChooseFromTmpStg();
 //        }
 //        else
 //        {
 //            Environment.Exit(0);
 //        }
 //    }
 //    return fSET;
 //}
 public void EndlessProc(Object objState)
 {
     fProgress fp = new fProgress("Загрузка программы");
     fp.Show();
     while (!done)
         Application.DoEvents();
     fp.Close();
 }
Ejemplo n.º 6
0
        private void CopyPDFToTarget(string ip, string sTarget, string sSource, FileInfo fPDF, int number, int total, fProgress fp, string sTargetConnectBookAddInf)
        {
            sTarget += GetPath(this.PIN, Year.ToString());
            sTarget += fPDF.Name.Remove(fPDF.Name.LastIndexOf(".")) + "\\JPEG_HQ";
            DirectoryInfo diTarget     = new DirectoryInfo(sTarget);
            DirectoryInfo diSource     = new DirectoryInfo(sSource);
            DirectoryInfo TargetFolder = new DirectoryInfo(sTarget);
            string        outside_ip   = @"\\" + XmlConnections.GetConnection("/Connections/outside_ip") + @"\Backup\BookAddInf\PERIOD\";
            string        PIN          = PINFormat(this.PIN);

            outside_ip += PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";
            DirectoryInfo TargetFolderOutside = new DirectoryInfo(outside_ip + @"\" + this.Year.ToString() + @"\" + fPDF.Name.Remove(fPDF.Name.LastIndexOf(".")));



            PdfReader reader = new PdfReader(fPDF.FullName);

            max_img = reader.NumberOfPages;
            if ((Package + fPDF.Name + ";").Length >= 3000)
            {
                PackageList.Add(Package);
                Package = "";
            }
            Package += fPDF.Name.Remove(fPDF.Name.LastIndexOf(".")) + ";";
            MagickReadSettings settings = new MagickReadSettings();

            using (new NetworkConnection(sTargetConnectBookAddInf, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
            {
                TargetFolder.Refresh();
            }

            if (!TargetFolder.Exists)
            {
                try
                {
                    TargetFolder.Create();
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnectBookAddInf, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                    {
                        TargetFolder.Create();
                    }
                }
            }
            else
            {
                MessageBox.Show("Такой файл уже добавлялся! Выберите другой файл!");
                fp.Close();
                this.Enabled = true;
                return;
            }
            using (MagickImageCollection images = new MagickImageCollection())
            {
                for (int i = 0; i < max_img; i++)
                {
                    settings.Density    = new MagickGeometry(300, 300); //качество изображения
                    settings.FrameIndex = i;                            // Первая страница
                    settings.FrameCount = 1;                            // Количество страниц. (10 значит 10, а не 11)

                    images.Read(fPDF.FullName, settings);
                    DirectoryInfo To        = new DirectoryInfo(TargetFolder.FullName);
                    DirectoryInfo ToOutside = new DirectoryInfo(TargetFolderOutside.FullName);

                    if (!To.Exists)
                    {
                        To.Create();
                    }
                    string fileTo = To.FullName + "\\" + i.ToString() + ".jpg";
                    //string fileToOutside = ToOutside.FullName + "\\" + i.ToString() + ".jpg";
                    try
                    {
                        images[0].ToBitmap().Save(fileTo);
                    }
                    catch
                    {
                        using (new NetworkConnection(sTargetConnectBookAddInf, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                        {
                            images[0].ToBitmap().Save(fileTo);
                        }
                    }

                    /*try
                     * {
                     *  images[0].ToBitmap().Save(fileToOutside);
                     * }
                     * catch
                     * {
                     *  using (new NetworkConnection(outside_ip, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
                     *  {
                     *      images[0].ToBitmap().Save(fileToOutside);
                     *  }
                     * }*/
                    //fp.IncProgress();
                    fp.IncProgress(total, i + 1, total);
                    Application.DoEvents();
                    GC.Collect();
                }
            }
            AddInfo();
        }
Ejemplo n.º 7
0
        private bool CopyJPGToTarget(string ip, string sTarget, string sSource, DirectoryInfo SF, bool FirstPass, int number, int total, fProgress fp, string sTargetConnect)
        {
            DirectoryInfo diTarget = new DirectoryInfo(sTarget);
            DirectoryInfo diSource = new DirectoryInfo(sSource);

            char[] invalid_chars = System.IO.Path.GetInvalidFileNameChars();

            //string outside_ip = @"\\" + XmlConnections.GetConnection("/Connections/outside_ip") + @"\Backup\BookAddInf\PERIOD\";
            //string outsideIPConnect = @"\\" + XmlConnections.GetConnection("/Connections/outside_ip") + @"\Backup";
            string PIN = PINFormat(this.PIN);

            //outside_ip += PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";
            sTarget += SF.Name;//имя папки = название номер
            sTarget += "\\JPEG_HQ";
            DirectoryInfo TargetFolderOutside = new DirectoryInfo(sTarget);
            DirectoryInfo TargetFolder        = new DirectoryInfo(sTarget);

            //string sTargetConnect = @"\\192.168.4.30\BookAddInf\";
            //MessageBox.Show(TargetFolder.FullName);
            using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
            {
                TargetFolder.Refresh();
            }
            //MessageBox.Show("11");
            if (!TargetFolder.Exists)
            {
                try
                {
                    TargetFolder.Create();
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                    {
                        TargetFolder.Create();
                    }
                }
            }
            else
            {
                if (!FirstPass)
                {
                    try
                    {
                        TargetFolder.Delete(true);
                        TargetFolder.Create();
                    }
                    catch
                    {
                        using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                        {
                            TargetFolder.Delete(true);
                            TargetFolder.Create();
                        }
                    }
                }
            }


            DirectoryInfo[] di = diSource.GetDirectories();
            max_img = di.Length;



            FileInfo[]    fi = SF.GetFiles();
            DirectoryInfo To = new DirectoryInfo(TargetFolder.FullName);

            using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
            {
                To.Refresh();
            }

            /* using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
             * {
             *   ToOutside.Refresh();
             * }*/


            if (!To.Exists)
            {
                try
                {
                    To.Create();
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                    {
                        To.Create();
                    }
                }
            }

            /*if (!ToOutside.Exists)
             * {
             *  try
             *  {
             *      ToOutside.Create();
             *  }
             *  catch
             *  {
             *      using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
             *      {
             *          ToOutside.Create();
             *      }
             *  }
             * }*/
            if ((Package + To.Name + ";").Length >= 3000)
            {
                PackageList.Add(Package);
                Package = "";
            }
            Package += To.Name + ";";

            foreach (FileInfo f in fi)
            {
                try
                {
                    f.CopyTo(To + "\\" + f.Name);
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnect, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                    {
                        f.CopyTo(To + "\\" + f.Name);
                    }
                }
                //fp.IncProgress();
                Application.DoEvents();
            }

            /*foreach (FileInfo f in fi)
             * {
             *  try
             *  {
             *      f.CopyTo(ToOutside + "\\" + f.Name);
             *  }
             *  catch
             *  {
             *      using (new NetworkConnection(outsideIPConnect, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
             *      {
             *          f.CopyTo(ToOutside + "\\" + f.Name);
             *      }
             *  }
             *  //fp.IncProgress();
             *  Application.DoEvents();
             * }*/
            return(true);
        }
Ejemplo n.º 8
0
        private void button5_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Продолжить?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr == DialogResult.No)
            {
                return;
            }
            string     store_ip       = XmlConnections.GetConnection("/Connections/store_ip");
            string     sTargetConnect = @"\\" + store_ip + @"\BookAddInf\PERIOD\";
            string     sTarget        = @"\\" + store_ip + @"\BookAddInf\PERIOD\";
            DBScanInfo db             = new DBScanInfo();
            string     PIN            = this.PIN;

            PIN = PINFormat(PIN);
            string ExactPath = GetPath(PIN, FolderYear);

            sTarget += ExactPath;//PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";

            DirectoryInfo diSource = new DirectoryInfo(YearPath);

            Package = "";
            DirectoryInfo[] diNumbers = diSource.GetDirectories();
            if (diNumbers.Length == 0)
            {
                throw new Exception("В источнике нет папок: " + diSource.ToString());
            }
            bool FirstPass = false;
            int  Number    = 1;
            int  Total     = diNumbers.Length;

            fp           = new fProgress("Подождите...");
            this.Enabled = false;
            fp.Show();
            Application.DoEvents();

            foreach (DirectoryInfo d in diNumbers)
            {
                Set = d.Name + "; ";
                FileInfo[] fi = d.GetFiles();
                foreach (FileInfo f in fi)
                {
                    //скопиировать все изображения номера
                    //fp.ResetProgress(d.GetFiles("*.jpg").Length, Number, Total);
                    fp.IncProgress(Total, Number, Total);
                    Application.DoEvents();
                    //try
                    //{
                    bool result = CopyJPGToTarget(store_ip, sTarget, YearPath, f.Directory, FirstPass, Number, Total, fp, sTargetConnect);
                    //}
                    //catch (Exception ex)
                    if (!result)
                    {
                        //MessageBox.Show("Произошла ошибка: " + ex.Message + ". Попробуйте еще раз!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        fp.Close();
                        this.Enabled = true;
                        return;
                    }
                    FirstPass = true;
                    Number++;
                    break;
                }
            }

            #region _info.txt
            FileInfo[] _infotxtsearch = diSource.GetFiles();
            FileInfo   _infotxt       = null;
            foreach (FileInfo f in _infotxtsearch)
            {
                if (f.Name == "_info.txt")
                {
                    _infotxt = f;
                }
            }
            if (_infotxt != null)
            {
                DirectoryInfo d = new DirectoryInfo(sTarget + this.Year + @"\");
                try
                {
                    _infotxt.CopyTo(sTarget + this.Year + @"\_info.txt", true);
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnect, new NetworkCredential("libfl\\DigitCentreWork01", "DigCW_01")))
                    {
                        _infotxt.CopyTo(sTarget + this.Year + @"\_info.txt", true);
                    }
                }

                string outside_ip = @"\\" + XmlConnections.GetConnection("/Connections/outside_ip") + @"\Backup\BookAddInf\PERIOD\";
                outside_ip += PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";
                try
                {
                    _infotxt.CopyTo(outside_ip + this.Year.ToString() + @"\_info.txt", true);
                }
                catch
                {
                    using (new NetworkConnection(outside_ip, new NetworkCredential("bj\\CopyPeriodAddInf", "Period_Copy")))
                    {
                        _infotxt.CopyTo(outside_ip + this.Year.ToString() + @"\_info.txt", true);
                    }
                }
            }
            #endregion
            AddInfo();
        }
Ejemplo n.º 9
0
        private void CopyPDFToTarget(string ip, string sTarget, string sSource, FileInfo fPDF, int number, int total, fProgress fp,string sTargetConnectBookAddInf)
        {
            DirectoryInfo diTarget = new DirectoryInfo(sTarget);
            DirectoryInfo diSource = new DirectoryInfo(sSource);
            DirectoryInfo TargetFolder = new DirectoryInfo(sTarget + @"\" + this.Year.ToString() + @"\" + fPDF.Name.Remove(fPDF.Name.LastIndexOf(".")));
            string outside_ip = @"\\" + XmlConnections.GetConnection("/Connections/outside_ip") + @"\Backup\BookAddInf\PERIOD\";
            string PIN = PINFormat(this.PIN);

            outside_ip += PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";
            DirectoryInfo TargetFolderOutside = new DirectoryInfo(outside_ip + @"\" + this.Year.ToString() + @"\" + fPDF.Name.Remove(fPDF.Name.LastIndexOf(".")));

            PdfReader reader = new PdfReader(fPDF.FullName);
            max_img = reader.NumberOfPages;
            if ((Package + fPDF.Name + ";").Length >= 3000)
            {
                PackageList.Add(Package);
                Package = "";
            }
            Package += fPDF.Name.Remove(fPDF.Name.LastIndexOf(".")) + ";";
            MagickReadSettings settings = new MagickReadSettings();
            using (new NetworkConnection(sTargetConnectBookAddInf, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
            {
                TargetFolder.Refresh();
            }

            if (!TargetFolder.Exists)
            {
                try
                {
                    TargetFolder.Create();
                }
                catch
                {
                    using (new NetworkConnection(sTargetConnectBookAddInf, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                    {
                        TargetFolder.Create();
                    }
                }
            }
            else
            {
                MessageBox.Show("Такой файл уже добавлялся! Выберите другой файл!");
                fp.Close();
                this.Enabled = true;
                return;
            }
            /*using (new NetworkConnection(outside_ip, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
            {
                TargetFolderOutside.Refresh();
            }

            if (!TargetFolderOutside.Exists)
            {
                try
                {
                    TargetFolderOutside.Create();
                }
                catch
                {
                    using (new NetworkConnection(outside_ip, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
                    {
                        TargetFolderOutside.Create();
                    }
                }
            }*/
            using (MagickImageCollection images = new MagickImageCollection())
            {

                for (int i = 0; i < max_img; i++)
                {
                    settings.Density = new MagickGeometry(300, 300);//качество изображения
                    settings.FrameIndex = i; // Первая страница
                    settings.FrameCount = 1; // Количество страниц. (10 значит 10, а не 11)
                    images.Read(fPDF.FullName, settings);
                    DirectoryInfo To = new DirectoryInfo(TargetFolder.FullName);
                    DirectoryInfo ToOutside = new DirectoryInfo(TargetFolderOutside.FullName);

                    if (!To.Exists)
                    {
                        To.Create();
                    }
                    string fileTo = To.FullName + "\\" + i.ToString() + ".jpg";
                    //string fileToOutside = ToOutside.FullName + "\\" + i.ToString() + ".jpg";
                    try
                    {
                        images[0].ToBitmap().Save(fileTo);
                    }
                    catch
                    {
                        using (new NetworkConnection(sTargetConnectBookAddInf, new NetworkCredential(@"bj\DigitCentreWork01", "DigCW_01")))
                        {
                            images[0].ToBitmap().Save(fileTo);
                        }
                    }
                    /*try
                    {
                        images[0].ToBitmap().Save(fileToOutside);
                    }
                    catch
                    {
                        using (new NetworkConnection(outside_ip, new NetworkCredential(@"bj\CopyPeriodAddInf", "Period_Copy")))
                        {
                            images[0].ToBitmap().Save(fileToOutside);
                        }
                    }*/
                    //fp.IncProgress();
                    fp.IncProgress(total, i + 1, total);
                    Application.DoEvents();
                    GC.Collect();
                }
            }
            AddInfo();
        }
Ejemplo n.º 10
0
        private void button5_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Продолжить?", "Внимание!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.No)
            {
                return;
            }
            string store_ip = XmlConnections.GetConnection("/Connections/store_ip");
            string sTargetConnect = @"\\" + store_ip + @"\BookAddInf\PERIOD\";
            string sTarget = @"\\" + store_ip + @"\BookAddInf\PERIOD\";
            string sTargetConnectBookAddInf = @"\\" + store_ip + @"\BookAddInf";
            DBScanInfo db = new DBScanInfo();
            string PIN = this.PIN;
            PIN = PINFormat(PIN);
            sTarget += PIN.Substring(0, 1) + @"\" + PIN.Substring(1, 3) + @"\" + PIN.Substring(4, 3) + @"\";

            Package = "";

            int Number = 1;
            int Total = new PdfReader(fPDF.FullName).NumberOfPages;
            fp = new fProgress(Total);
            this.Enabled = false;
            fp.Show();
            Application.DoEvents();

            //преобразовать и скопиировать все изображения номера
            //int Total = new PdfReader(fPDF.FullName).NumberOfPages;
            //fp.ResetProgress(Total, Number, Total);
            try
            {
                CopyPDFToTarget(store_ip, sTarget, fPDF.DirectoryName, fPDF, Number, Total, fp, sTargetConnectBookAddInf);

            }
            catch (Exception ex)
            {
                MessageBox.Show("Произошла ошибка: " + ex.Message + ". Попробуйте еще раз!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                fp.Close();
                this.Enabled = true;
                return;
            }
        }