Exemplo n.º 1
0
        private void NoCard(string[] args)
        {
            TreeNode treeNode   = classTree.TreeViewDialog("Добавление документа", "Добавить");
            int      idFolder   = Convert.ToInt32(treeNode.Name.Split('_')[1]);
            int      idTypeCard = classTypeCard.getIdByName("Пустая");
            string   res        = "";

            foreach (string arg in args)
            {
                if (arg == "noCard")
                {
                    continue;
                }

                string fileName = Path.GetFileName(arg);
                string pathSave = treeNode.FullPath;
                string fullPath = arg;
                if (classFile.Create(idFolder, idTypeCard, fileName, fullPath, pathSave) == 0)
                {
                    res += arg + " Ошибка загрузки! \n";
                }
            }

            if (res != "")
            {
                MessageBox.Show(res);
            }
        }
Exemplo n.º 2
0
        private void Scan()
        {
            List <Image> images = scan2.start();

            if (images.Count < 1)
            {
                return;
            }

            TreeNode      treeNode      = classTree.TreeViewDialog("Выберите папку", "Выбрать");
            ClassFiles    classFiles    = new ClassFiles();
            int           idFolder      = Convert.ToInt32(treeNode.Name.Split('_')[1]);
            ClassTypeCard classTypeCard = new ClassTypeCard();
            int           idCard        = classTypeCard.getIdByName(ClassTypeCard.EMPTY_CARD);
            string        pathSave      = treeNode.FullPath;
            string        tmpPath       = classSettings.GetProperties().generalsSttings.programPath + @"\tmp";

            Directory.CreateDirectory(tmpPath);

            int iterator = 0;

            foreach (Image image in images)
            {
                PictureBox pictureBox = new PictureBox
                {
                    Size     = new System.Drawing.Size(800, 600),
                    SizeMode = PictureBoxSizeMode.Zoom,
                    Image    = image
                };

                if (pictureBox.Image == null)
                {
                    pictureBox.Dispose();
                    continue;
                }

                string fileName = "image_" + DateTime.UtcNow.ToString().Replace(":", "-") + "_" + iterator + ".jpg";
                pictureBox.Image.Save(tmpPath + @"\" + fileName);
                classFiles.Create(idFolder, idCard, fileName, tmpPath + @"\" + fileName, pathSave);
                classTree.InitTreeView(treeView1);

                iterator++;
            }
        }