Beispiel #1
0
        // ------------------------------Sending the data to database-------------------------//
        private void Run_Click(object sender, EventArgs e)
        {
            SelectFolder selectFolder = new SelectFolder();

            try
            {
                string folderpath = "";
                foreach (string path in RootFoldersPath)  // getting each folderpath in list
                {
                    folderpath = path;
                }
                if (folderpath == "" || folderpath == null)          // if folderpath is empty
                {
                    throw new Exception("Please Browse the folder"); //throw exception
                }
                else
                {
                    Errorlabel2.Text = "";
                    Errorlabel1.Text = "";
                    string[] subfolders = Directory.GetDirectories(folderpath, "*", SearchOption.AllDirectories); // getting all subfolders into variable
                    string[] files      = Directory.GetFiles(folderpath, "*", SearchOption.AllDirectories);       // getting all files into variable
                    foreach (String Rootfolder in RootFoldersPath)                                                //Getting each rootfolder from list
                    {
                        try
                        {
                            DAL.Repository.FileInformation dbcall = new DAL.Repository.FileInformation();
                            RootFolder RootFolderDetails          = selectFolder.GetRootFolderdetails(Rootfolder); //Getting rootfolder details
                            int        ID = dbcall.UploadRootFolder(RootFolderDetails);                            //Upload into the database and method is return the inserted id. ID is usefully for files
                            selectFolder.GetSubDirectories(Rootfolder, ID);                                        //Getting all sub folders and files
                        }
                        catch (Exception Ex)
                        {
                            ErrrorLog.ErrorlogWrite(Ex);
                        }
                    }
                }

                /*----------------- Assigning the Data to FolderComboBox Again-------------------------*/

                GetRootFolderRepository getRootFolder = new GetRootFolderRepository();
                CBfoldername.DataSource    = getRootFolder.BindingFolders();
                CBfoldername.DisplayMember = "Name";
                CBfoldername.ValueMember   = "Path";
                FileInfoTable = RepObj.GetFileInfoTable();
            }
            catch (Exception Ex)
            {
                Errorlabel1.Text = Ex.Message;
                ErrrorLog.ErrorlogWrite(Ex);
            }
            SelectedFolders.Items.Clear();
            MessageBox.Show("Run Completed");
        }
Beispiel #2
0
        public Main()
        {
            InitializeComponent();
            DataTable data = RepObj.GetFileType();

            foreach (DataRow Dr in data.Rows)
            {
                foreach (var item in Dr.ItemArray)
                {
                    FileTypeComboBox.Items.Add(item);
                }
            }

            UnsupportedButton.Text = RepObj.GetUnsupportedFiles();

            /*----------------- Assigning the Data to FolderComboBox-------------------------*/

            GetRootFolderRepository getRootFolder = new GetRootFolderRepository();

            CBfoldername.DataSource    = getRootFolder.BindingFolders();
            CBfoldername.DisplayMember = "Name";
            CBfoldername.ValueMember   = "Path";

            FileInfoTable = RepObj.GetFileInfoTable();

            /*----------------- Assigning the Data to TypeOfInformation ComboBox-------------------------*/

            Dictionary <string, string> ComboBoxItems = new Dictionary <string, string>();

            ComboBoxItems.Add("CreatedOn", "Created");
            ComboBoxItems.Add("ModifiedOn", "Modified");
            ComboBoxItems.Add("FileAccessed", "Accesed");
            InformationBox.DataSource    = new BindingSource(ComboBoxItems, null);
            InformationBox.DisplayMember = "Value";
            InformationBox.ValueMember   = "Key";
            MonthsBox.SelectedItem       = "1";
        }