예제 #1
0
파일: Form1.cs 프로젝트: namo18/namoBackup
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            listView1.Items.Clear();
            MyNodeTag nodeTag = (MyNodeTag)e.Node.Tag;

            textBox1.Text = nodeTag.pathid.ToString();
            DataTable dt = sql.GetFileList(nodeTag.histroy_id, nodeTag.pathid, nodeTag.backupTable);

            foreach (DataRow row in dt.Rows)
            {
                string md5 = row["md5"].ToString();

                string sub1 = md5.Substring(0, 2);
                string sub2 = md5.Substring(2, 2);
                string sub3 = md5.Substring(4, 2);

                DirectoryInfo d = new DirectoryInfo(SAVE_FOLDER);

                FileInfo zipFileInfo = new FileInfo(string.Format(@"{0}\{1}\{2}\{3}.7z", d.FullName, sub1, sub2, md5));
                if (zipFileInfo.Exists)
                {
                    d = new DirectoryInfo(d.FullName + "\\" + sub3);
                    if (!d.Exists)
                    {
                        d.Create();
                    }
                    zipFileInfo.MoveTo(string.Format(@"{0}\{1}.7z", d.FullName, md5));
                }

                ListViewItem item = new ListViewItem(new string[] { row["filename"].ToString(), row["modifydate"].ToString(), row["md5"].ToString() }, 1);
                listView1.Items.Add(item);
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: namo18/namoBackup
        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            treeView1.Nodes.Clear();
            DateTime dt;

            DateTime.TryParse(dateTimePicker1.Text, out dt);

            Dictionary <int, ID_Table> basePathIds = sql.GetRestoreBasePath(dt);

            textBox1.Text = basePathIds.Keys.Count.ToString();


            DataTable pathTable = sql.GetPathList(basePathIds.Keys);

            foreach (DataRow row in pathTable.Rows)
            {
                DirectoryInfo dirInfo = new DirectoryInfo(row["path"].ToString());

                TreeNode  node    = new TreeNode(dirInfo.Name, 0, 0);
                MyNodeTag nodeTag = new MyNodeTag
                {
                    pathid      = (int)row["id"],
                    loaded      = false,
                    histroy_id  = basePathIds[(int)row["id"]].histroy_id,
                    backupTable = basePathIds[(int)row["id"]].table_name
                };
                node.Tag = nodeTag;
                node.Nodes.Add("None");
                treeView1.Nodes.Add(node);
            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: namo18/namoBackup
        private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            TreeNode  currNode = e.Node;
            MyNodeTag tag      = (MyNodeTag)currNode.Tag;

            if (!tag.loaded)
            {
                currNode.Nodes.Clear();
                tag.loaded = true;

                currNode.Tag = tag;

                DataTable pathTable = sql.GetChildDirectory(tag.pathid);


                foreach (DataRow row in pathTable.Rows)
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(row["path"].ToString());

                    TreeNode  node    = new TreeNode(dirInfo.Name, 0, 0);
                    MyNodeTag nodeTag = new MyNodeTag
                    {
                        pathid      = (int)row["id"],
                        loaded      = false,
                        histroy_id  = tag.histroy_id,
                        backupTable = tag.backupTable
                    };

                    node.Tag = nodeTag;
                    node.Nodes.Add("None");
                    currNode.Nodes.Add(node);
                }
            }
        }