예제 #1
0
        /// <summary>
        /// Load the project and get all the data.
        /// </summary>
        /// <param name="fileName">File path of the project.</param>
        /// <param name="ssConfig">Subsystem configuration. If Null display all the data</param>
        /// <param name="minIndex">Minimum ensemble index to display.</param>
        /// <param name="maxIndex">Minimum ensemble index to display.</param>
        public virtual void LoadProject(string fileName, SubsystemConfiguration ssConfig, int minIndex = 0, int maxIndex = 0)
        {
            // Set the selected values
            _ProjectFilePath = fileName;
            this.NotifyOfPropertyChange(() => this.ProjectFilePath);

            // Set the select Subsystem configuration
            SubsystemConfig = ssConfig;

            // Reset settings
            _firstLoad = true;

            // Clear the current list and get the new file list from the project
            Application.Current.Dispatcher.Invoke((Action) delegate
            {
                ProjectFileList.Clear();
            });

            GetFileList(fileName);

            // Clear the current list and get the new subsystem configurations list from the project
            Application.Current.Dispatcher.Invoke((Action) delegate
            {
                SubsystemConfigList.Clear();
            });

            // Populate the list of all available subsystem configurations
            GetSubsystemConfigList(fileName);

            // Select the configuration based off the subsystem configuration given
            SelectSubsystemConfig(ssConfig);
        }
예제 #2
0
        public async Task <IActionResult> ProjectDiffResult()
        {
            Stopwatch stopwatch = new Stopwatch();

            // Get the path to project files
            string filesPath = Path.Combine(_environment.WebRootPath, "files/project1");

            string[] filesListStr = Directory.GetFiles(filesPath, "*.*", SearchOption.AllDirectories);

            ProjectFileList ProjectFileListModel = new ProjectFileList
            {
                List = new List <FileList>(),
            };

            int id = 0;

            stopwatch.Start();
            foreach (string name in filesListStr)
            {
                FileList fileList = await DirDiffResult(name, id ++);

                FileInfo fInfo = new FileInfo(name);
                fileList.size = fInfo.Length;

                ProjectFileListModel.List.Add(fileList);
                ProjectFileListModel.overallSimilarity += fileList.bestMatch * fileList.size;
                ProjectFileListModel.overallSize       += fileList.size;
            }

            ProjectFileListModel.processingTime    = stopwatch.ElapsedMilliseconds;
            ProjectFileListModel.overallSimilarity = ProjectFileListModel.overallSimilarity / ProjectFileListModel.overallSize;

            return(View(ProjectFileListModel));
        }
예제 #3
0
        private void CopyProjectFolder(string currentPath)
        {
            string[] stFolders = System.IO.Directory.GetDirectories(currentPath);
            string[] stFiles   = System.IO.Directory.GetFiles(currentPath);

            // Examine all the files within the folder.
            foreach (string stFile in stFiles)
            {
                if ((!IsFileExcluded(stFile)))
                {
                    string stToPath = FolderPath_Substitute(stFile);
                    try
                    {
                        AddFolder2Folder(stToPath, true);
                        System.IO.File.Copy(stFile, stToPath, true);
                        ProjectFileList.Add(ProjectPath_Substitute(stFile));
                    }
                    catch
                    {
                        //'Error
                    }

                    FileStream   myStream       = new FileStream(stToPath, FileMode.Open);
                    StreamReader myReader       = new StreamReader(myStream);
                    string       tmpFiletextSel = myReader.ReadToEnd();
                    myReader.Close();
                    myStream.Close();

                    string s1 = tmpFiletextSel.Replace("#NAME#", LISTNAME.ItemSpec);

                    /*
                     * Guid myGuid = System.Guid.NewGuid();
                     * string stMyGuid = myGuid.ToString();
                     * string s = s1.Replace("#GUID-FEATURE#", stMyGuid);
                     */

                    myStream = new FileStream(stToPath, FileMode.Truncate);
                    StreamWriter myWriter = new StreamWriter(myStream);
                    myWriter.Write(s1);
                    myWriter.Close();
                    myStream.Close();
                }
            }

            // Examine all the subfolders.
            foreach (string stFolder in stFolders)
            {
                if ((!IsFileExcluded(stFolder)))
                {
                    CopyProjectFolder(stFolder);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Populate the list with all the available unique files in the project.
        /// </summary>
        /// <param name="fileName">File path of project.</param>
        protected void GetFileList(string fileName)
        {
            try
            {
                // Create data Source string
                string dataSource = string.Format("Data Source={0};Version=3;", fileName);

                // Create a new database connection:
                using (SQLiteConnection cnn = new SQLiteConnection(dataSource))
                {
                    // Open the connection:
                    cnn.Open();

                    // Ensure a connection was made
                    if (cnn == null)
                    {
                        return;
                    }

                    // Create a command to query
                    using (DbCommand cmd = cnn.CreateCommand())
                    {
                        string query = string.Format("SELECT DISTINCT {0} FROM {1};", "FileName", "tblEnsemble");
                        cmd.CommandText = query;

                        // Get all the results
                        DbDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            if (reader == null)
                            {
                                break;
                            }

                            // Create a file entry
                            FileEntry fe = new FileEntry()
                            {
                                FileName = reader["FileName"].ToString(), IsCheckable = true, IsChecked = true, Command = FileSelectionCommand
                            };

                            // Get the number of ensembles for the file
                            fe.NumEnsembles = GetNumEnsemblesPerFile(cnn, fe.FileName);

                            // Get the first and last date
                            fe.MinDateTime = GetFirstDateTimePerFile(cnn, fe.FileName);
                            fe.MaxDateTime = GetLastDateTimePerFile(cnn, fe.FileName);

                            // Add file name to list
                            ProjectFileList.Add(fe);
                        }
                    }
                }
            }
            catch (SQLiteException e)
            {
                Debug.WriteLine("Error using database to get file names", e);
                return;
            }
            catch (Exception e)
            {
                Debug.WriteLine("Error using database to get file names", e);
                return;
            }
        }