Exemplo n.º 1
0
        /// <summary>
        /// Create a new submission
        /// </summary>
        public Components.Submission Create(int asstid, int principalID, IExternalSource files)
        {
            //TODO: Verify parameters
            Components.Submission sub = new Components.Submission();
            sub.AsstID = asstid;
            sub.PrincipalID = principalID;
            sub.Status = Submission.UNGRADED;

            //Check for locked for evaluation
            if (!new Assignments(m_ident).IsSubmissionAvailable(asstid))
                throw new DataAccessException("Submission is locked. No more submissions are being accepted. Please contact course staff to proceed");

            //Create submission
            m_dp.CreateSubmission(sub);

            //Update to commit files
            sub = GetInfo(sub.ID);
            try {
                Update(sub, files);
            } catch (DataAccessException er) {
                UnsafeDelete(sub.ID);
                throw er;
            }

            //Queue autosubmit tests
            QueueSubmitTests(sub);

            //Log submission
            Assignment asst = new Assignments(m_ident).GetInfo(asstid);
            Log("User submitted " + asst.Description + " successfully", sub.ID);

            return sub;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to download the issues for the given project
        /// </summary>
        /// <param name="source">the external data source to use</param>
        /// <param name="project">the project to download the issues for</param>
        /// <returns>the list of issues corresponding to the given project</returns>
        private static IList <IssueInfo> DownloadIssuesForProject(IExternalSource source, ProjectInfo project)
        {
            // get parameter and action
            var parameters = new DataSourceParameter()
            {
                ProjectId = project.Id, StatusId = -1
            };
            Action <int, int> action =
                (i, overall) =>
            {
                if (Globals.ThisAddIn == null)
                {
                    return;
                }
                Globals.ThisAddIn.SyncState.Status = string.Format(
                    "Lade Issues für neues Projekt {0} ({1}/{2})",
                    project.Name,
                    Math.Min(i, overall),
                    overall);
            };

            try
            {
                // load data and add the issues. Note that we load all issues here
                var newIssuesOfProject = source.GetTotalIssueInfoList(parameters, action);
                return(newIssuesOfProject);
            }
            catch (Exception exception)
            {
                Log.Error(string.Format("Error while loading project {0}", project.Name), exception);
                return(new List <IssueInfo>());
            }
        }
Exemplo n.º 3
0
        private int CommitTestSource(AutoEvaluation eval, IExternalSource zone)
        {
            FileSystem fs = new FileSystem(m_ident);

            //Make sure toplevel zone directory exists
            CFile zonedir = fs.GetFile(@"c:\zones");

            if (null == zonedir)
            {
                zonedir = fs.CreateDirectory(@"c:\zones", true, null);
            }

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            CourseRole.CourseRoleList          staff = new Courses(m_ident).GetTypedRoles(eval.CourseID, true, null);
            foreach (CourseRole role in staff)
            {
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
            }

            //Create zone directory
            string zpath = @"c:\zones\" + eval.ID;
            CFile  ezonedir;

            if (null == (ezonedir = fs.GetFile(zpath)))
            {
                ezonedir       = fs.CreateDirectory(zpath, false, perms);
                ezonedir.Alias = eval.Name; ezonedir.SpecType = CFile.SpecialType.TEST;
                fs.UpdateFileInfo(ezonedir, false);
            }
            fs.ImportData(zpath, zone, false, true);             //Import the data

            return(ezonedir.ID);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Downloads all redmine projects and update the cache with the new data
        /// </summary>
        /// <param name="source">the data source to use</param>
        /// <returns>The projects that are downloaded from redmine.</returns>
        public static ProjectLists GetCurrentProjectsAndUpdateCache(IExternalSource source)
        {
            if (Globals.ThisAddIn != null)
            {
                Globals.ThisAddIn.SyncState.Status = "Lade Projekte...";
            }

            var parameters = new DataSourceParameter();
            var projects   = source.GetTotalProjectList(
                parameters,
                (cur, total) =>
            {
                if (Globals.ThisAddIn != null)
                {
                    Globals.ThisAddIn.SyncState.Status = string.Format("Lade Projekte ({0}/{1})", Math.Min(cur, total), total);
                }
            }).Where(p => p.Id.HasValue).ToDictionary(p => p.Id.Value, p => p);

            // Get the known projects from localcache
            var knownProjects = LocalCache.ReadObject(LocalCache.KnownProjects, new List <ProjectInfo>()) as List <ProjectInfo> ?? new List <ProjectInfo>();

            // Find those projects which are new
            var newProjects = projects.Values.Except(knownProjects).ToList();

            // Write all currently known projects
            LocalCache.WriteObject(LocalCache.KnownProjects, projects.Values.ToList());

            return(new ProjectLists()
            {
                AllProjects = projects, NewProjects = newProjects
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// Create the evaluation
        /// Inserts the test files into the file system
        /// Create the record for the auto evaluation
        /// </summary>
        public bool CreateAuto(AutoEvaluation eval, IExternalSource zone)
        {
            //Create the record for the val
            m_dp.CreateAutoEvaluation(eval);
            eval.CourseID = new Assignments(m_ident).GetInfo(eval.AsstID).CourseID;

            return(UpdateAuto(eval, zone));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create the evaluation
        /// Inserts the test files into the file system
        /// Create the record for the auto evaluation
        /// </summary>
        public bool CreateAuto(AutoEvaluation eval, IExternalSource zone)
        {
            //Create the record for the val
            m_dp.CreateAutoEvaluation(eval);
            eval.CourseID = new Assignments(m_ident).GetInfo(eval.AsstID).CourseID;

            return UpdateAuto(eval, zone);
        }
Exemplo n.º 7
0
 public NCDController (IExternalSource external)
 {
     External = (NCDExternalSource) external;
     CurrentInputState = new Dictionary<byte, IEnumerable<bool>>();
     CurrentOutputState = new Dictionary<byte, IEnumerable<bool>>();
     OutputStack = new Stack<ushort>();
     InputStack = new Stack<ushort>();
     EndpointCoupleDictionary = new Dictionary<Tuple<byte, byte>, Couple>();
 }
Exemplo n.º 8
0
 public NCDController(IExternalSource external)
 {
     External                 = (NCDExternalSource)external;
     CurrentInputState        = new Dictionary <byte, IEnumerable <bool> >();
     CurrentOutputState       = new Dictionary <byte, IEnumerable <bool> >();
     OutputStack              = new Stack <ushort>();
     InputStack               = new Stack <ushort>();
     EndpointCoupleDictionary = new Dictionary <Tuple <byte, byte>, Couple>();
 }
Exemplo n.º 9
0
        private IExternalSource CreateSource(HttpPostedFile tarchive)
        {
            ArchiveToolFactory afact = ArchiveToolFactory.GetInstance();
            IExternalSource    ztool = afact.CreateArchiveTool(".zip") as IExternalSource;

            ztool.CreateSource(tarchive.InputStream);

            return(ztool);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Method to get the list of all activity infos
        /// </summary>
        /// <param name="source">the external data source</param>
        /// <returns>the activities</returns>
        public static Dictionary <int, ActivityInfo> GetActivityInfos(IExternalSource source)
        {
            var parameters = new DataSourceParameter()
            {
                UseLimit = false
            };
            var activities = source.GetTotalActivityInfoList(parameters).ToDictionary(act => act.Id.Value, act => act);

            return(activities);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Update an automatic evaluation
        /// </summary>
        public bool UpdateAuto(AutoEvaluation eval, IExternalSource esrc)
        {
            //Check version
            if (!ValidateVersion(eval.ToolVersion))
            {
                throw new DataAccessException("Illegal version number");
            }

            eval.ZoneID = CommitTestSource(eval, esrc);

            return(m_dp.UpdateAutoEvaluation(eval));
        }
Exemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExternalDataSourceFactory"/> class.
 /// </summary>
 /// <param name="address">
 /// The host address.
 /// </param>
 /// <param name="apiKey">
 /// The api key.
 /// </param>
 /// <param name="limitForNumberIssues">the limit to use for the number of issues to download</param>
 private ExternalDataSourceFactory(string address, string apiKey, int limitForNumberIssues)
 {
     // UseTestManager = true;
     if (UseTestManager)
     {
         manager       = new LocalListsExternalDataSourceTest();
         manager.Limit = limitForNumberIssues;
     }
     else
     {
         manager = new RedmineManagerInstance(address, apiKey, limitForNumberIssues);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Method to get the up to date issue information and store them in the issue dictionary
        /// </summary>
        /// <param name="newProjects">the list of new projects to be loaded</param>
        /// <param name="source">the external data source</param>
        /// <param name="knownIssueList">the list of known issues</param>
        /// <param name="issues">the dictionary to store the current state in</param>
        private static void UpdateCurrentIssues(
            List <ProjectInfo> newProjects,
            IExternalSource source,
            List <IssueInfo> knownIssueList,
            Dictionary <int, IssueInfo> issues)
        {
            // initialize the list of all issues
            var allIssues = new List <IssueInfo>();

            // get download parameter
            var issuesKnown = knownIssueList.Any();
            var parameters  = GetDataSourceParameterForDownloadOfIssues(issuesKnown);

            if (Globals.ThisAddIn != null)
            {
                Globals.ThisAddIn.SyncState.Status = "Lade neue Issues";
            }

            // get and add new issues
            var newIssueInfos = source.GetIssueInfoList(parameters).Distinct().ToList();

            allIssues.AddRange(newIssueInfos);

            // get and add issues of new projects
            // do not check condition of their last change date (#14644)
            var allIssuesOfNewProjects = DownloadAllIssuesForNewProjects(newProjects, source);

            allIssues.AddRange(allIssuesOfNewProjects.Values);

            // update and add known issues (we only want to add the issues not contained in the new issue list or new project issue list, which can contain an update
            knownIssueList = knownIssueList.Except(newIssueInfos).ToList();
            knownIssueList = knownIssueList.Except(allIssuesOfNewProjects.Values).ToList();
            allIssues.AddRange(knownIssueList);

            // store the values in the local variable
            // distinct is needed to ensure, each ticket is only contained once
            allIssues.Where(i => i.Id.HasValue).Distinct().ForEach(i => issues[i.Id.Value] = i);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Method to download the issue list from the given source, known issues are read, updated are done, updated list is returned. In case of an exception, an empty list is returned.
        /// </summary>
        /// <param name="newProjects">the list of new projects to be considered</param>
        /// <param name="currentIssues">the current issue list, which should be updated</param>
        /// <param name="source">the external data source</param>
        /// <returns>the updated list of issues</returns>
        public static Dictionary <int, IssueInfo> DownloadIssues(
            List <ProjectInfo> newProjects,
            IDictionary <int, IssueInfo> currentIssues,
            IExternalSource source)
        {
            if (Globals.ThisAddIn != null)
            {
                Globals.ThisAddIn.SyncState.Status = "Lade Issues...";
            }

            var oldIssues = currentIssues.ToDictionary(k => k.Key, v => v.Value);
            var issues    = new Dictionary <int, IssueInfo>();

            try
            {
                // get the issue cache and store the issues as the list of old issues
                var knownIssueList = LocalCache.GetKnownIssueListFromCache();
                if (knownIssueList.Any())
                {
                    oldIssues = knownIssueList.Distinct().Where(i => i.Id.HasValue).ToDictionary(k => k.Id.Value, v => v);
                }

                // stores the current issue information in the issue dictionary
                UpdateCurrentIssues(newProjects, source, knownIssueList, issues);

                // update the issue cache
                LocalCache.UpdateKnownIssuesListInCache(issues);
            }
            catch (Exception exception)
            {
                // if an exception occurs, roll back to the last known issue state
                Log.Error("Fehler während Download Issues", exception);
                issues = oldIssues;
                LocalCache.UpdateKnownIssuesListInCache(issues);
            }

            return(issues);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Create a new submission
        /// </summary>
        public Components.Submission Create(int asstid, int principalID, IExternalSource files)
        {
            //TODO: Verify parameters
            Components.Submission sub = new Components.Submission();
            sub.AsstID      = asstid;
            sub.PrincipalID = principalID;
            sub.Status      = Submission.UNGRADED;

            //Check for locked for evaluation
            if (!new Assignments(m_ident).IsSubmissionAvailable(asstid))
            {
                throw new DataAccessException("Submission is locked. No more submissions are being accepted. Please contact course staff to proceed");
            }

            //Create submission
            m_dp.CreateSubmission(sub);

            //Update to commit files
            sub = GetInfo(sub.ID);
            try {
                Update(sub, files);
            } catch (DataAccessException er) {
                UnsafeDelete(sub.ID);
                throw er;
            }

            //Queue autosubmit tests
            QueueSubmitTests(sub);

            //Log submission
            Assignment asst = new Assignments(m_ident).GetInfo(asstid);

            Log("User submitted " + asst.Description + " successfully", sub.ID);

            return(sub);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Create a new directory
 /// </summary>
 public void ImportData(string name, string path, IExternalSource extsource, bool modupdate, bool over)
 {
     ImportData(Path.Combine(path, name), extsource, modupdate, over);
 }
Exemplo n.º 17
0
        /// <summary>
        /// Update an automatic evaluation
        /// </summary>
        public bool UpdateAuto(AutoEvaluation eval, IExternalSource esrc)
        {
            //Check version
            if (!ValidateVersion(eval.ToolVersion))
                throw new DataAccessException("Illegal version number");

            eval.ZoneID = CommitTestSource(eval, esrc);

            return m_dp.UpdateAutoEvaluation(eval);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Downloads all issues for a specified set of projects.
        /// </summary>
        /// <param name="newProjects">The projects that were not previously known to scorpio, which have to have all their issues downloaded</param>
        /// <param name="source">the data source to use</param>
        /// <returns>A dictionary that contains all issues for the provided projects, identified by their issue id.</returns>
        private static Dictionary <int, IssueInfo> DownloadAllIssuesForNewProjects(List <ProjectInfo> newProjects, IExternalSource source)
        {
            // initialize the list of new project
            var allIssuesForNewProjects = new HashSet <IssueInfo>();

            // download the issues for each project
            foreach (var project in newProjects)
            {
                var issuesForProject = DownloadIssuesForProject(source, project);
                issuesForProject.ToList().ForEach(i => allIssuesForNewProjects.Add(i));
                if (issuesForProject.Any(i => !i.Id.HasValue))
                {
                    Log.Warn(string.Format("Project {0} (ID {1}) has at least one issue without id set", project.Name, project.Id));
                }
            }

            // convert the hash set to a dictionary
            var resultDictionary = new Dictionary <int, IssueInfo>();

            allIssuesForNewProjects.Where(i => i.Id.HasValue).ForEach(i => resultDictionary[i.Id.Value] = i);

            return(resultDictionary);
        }
Exemplo n.º 19
0
        /// <summary>
        /// The extended reload issue info method, reloads all issues, because reloading for a given issue number where the issue status is done, is not working with the api.
        /// </summary>
        /// <param name="issueId">
        /// The issue id to obtain.
        /// </param>
        /// <param name="source">
        /// The source to use.
        /// </param>
        /// <param name="knownIssueList">
        /// The known issue list.
        /// </param>
        /// <returns>
        /// The <see cref="Dictionary"/> containing all issues.
        /// </returns>
        public static Dictionary <int, IssueInfo> ReloadIssueInfoExtended(int issueId, IExternalSource source, List <IssueInfo> knownIssueList)
        {
            var issues = new Dictionary <int, IssueInfo>();

            // stores the current issue information in the issue dictionary
            UpdateCurrentIssues(new List <ProjectInfo>(), source, knownIssueList, issues);

            // update the issue cache
            LocalCache.UpdateKnownIssuesListInCache(issues);

            return(issues);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Constructor - for unit test
 /// </summary>
 /// <param name="externalSource"></param>
 /// <param name="source"></param>
 public ThermometerModel(string externalSource, IExternalSource source)
 {
     _extSource      = externalSource;
     _externalSource = source;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Load submission directory with new files, updates time
        /// </summary>
        public bool Update(Submission sub, IExternalSource files)
        {
            FileSystem fs = new FileSystem(m_ident);
            bool       markcmp, unmarkcmp, defunct;

            //Get old sub
            Components.Submission oldsub = GetInfo(sub.ID);
            markcmp = (oldsub.Status == Components.Submission.UNGRADED &&
                       sub.Status == Components.Submission.GRADED);
            unmarkcmp = (oldsub.Status == Components.Submission.GRADED &&
                         sub.Status == Components.Submission.UNGRADED);
            defunct = (oldsub.Status != Components.Submission.DEFUNCT &&
                       sub.Status == Components.Submission.DEFUNCT);

            //Make sure toplevel zone directory exists
            CFile subdir = fs.GetFile(@"c:\subs");

            if (null == subdir)
            {
                subdir = fs.CreateDirectory(@"c:\subs", true, null, false);
            }

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            int courseID = new Assignments(m_ident).GetInfo(sub.AsstID).CourseID;

            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(courseID, true, null);
            foreach (CourseRole role in staff)
            {
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
            }
            perms.AddRange(CFilePermission.CreateOprFullAccess(sub.PrincipalID));

            //Create zone directory
            CFile  esubdir;
            string zpath = @"c:\subs\" + sub.ID;

            if (null == (esubdir = fs.GetFile(zpath)))
            {
                esubdir          = fs.CreateDirectory(zpath, false, perms, false);
                esubdir.SpecType = CFile.SpecialType.SUBMISSION;
                string name = new Principals(m_ident).GetInfo(sub.PrincipalID).Name;
                esubdir.Alias = String.Format("{0}: {1}",
                                              name, GetNextSubmission(sub.AsstID, sub.PrincipalID));
                fs.UpdateFileInfo(esubdir, false);
            }
            //Update sub entry
            sub.LocationID = esubdir.ID;
            m_dp.UpdateSubmission(sub);


            //Load files
            try {
                fs.ImportData(zpath, files, false, false);                 //Import the data
            } catch (Exception) {
                throw new DataAccessException("Invalid external file source. This means the system does " +
                                              "not understand how to extract files from the source. Please create a valid source");
            }

            //Verify submission structure
            VerifyFormat(sub.AsstID, zpath);

            //Log
            if (markcmp)
            {
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " completed", sub.ID);
            }
            else if (unmarkcmp)
            {
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " incomplete", sub.ID);
            }
            else if (defunct)
            {
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " defunct", sub.ID);
            }

            return(true);
        }
Exemplo n.º 22
0
        private int CommitTestSource(AutoEvaluation eval, IExternalSource zone)
        {
            FileSystem fs = new FileSystem(m_ident);

            //Make sure toplevel zone directory exists
            CFile zonedir = fs.GetFile(@"c:\zones");
            if (null == zonedir)
                zonedir = fs.CreateDirectory(@"c:\zones", true, null);

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(eval.CourseID, true, null);
            foreach (CourseRole role in staff)
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));

            //Create zone directory
            string zpath = @"c:\zones\" + eval.ID;
            CFile ezonedir;
            if (null == (ezonedir = fs.GetFile(zpath))) {
                ezonedir = fs.CreateDirectory(zpath, false, perms);
                ezonedir.Alias = eval.Name; ezonedir.SpecType = CFile.SpecialType.TEST;
                fs.UpdateFileInfo(ezonedir, false);
            }
            fs.ImportData(zpath, zone, false, true); //Import the data

            return ezonedir.ID;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Load submission directory with new files, updates time
        /// </summary>
        public bool Update(Submission sub, IExternalSource files)
        {
            FileSystem fs = new FileSystem(m_ident);
            bool markcmp, unmarkcmp, defunct;

            //Get old sub
            Components.Submission oldsub = GetInfo(sub.ID);
            markcmp = (oldsub.Status == Components.Submission.UNGRADED &&
                      sub.Status == Components.Submission.GRADED);
            unmarkcmp = (oldsub.Status == Components.Submission.GRADED &&
                         sub.Status == Components.Submission.UNGRADED);
            defunct = (oldsub.Status != Components.Submission.DEFUNCT &&
                        sub.Status == Components.Submission.DEFUNCT);

            //Make sure toplevel zone directory exists
            CFile subdir = fs.GetFile(@"c:\subs");
            if (null == subdir)
                subdir = fs.CreateDirectory(@"c:\subs", true, null, false);

            //Build file perms
            CFilePermission.FilePermissionList perms = new CFilePermission.FilePermissionList();
            int courseID = new Assignments(m_ident).GetInfo(sub.AsstID).CourseID;
            CourseRole.CourseRoleList staff = new Courses(m_ident).GetTypedRoles(courseID, true, null);
            foreach (CourseRole role in staff)
                perms.AddRange(CFilePermission.CreateFullAccess(role.PrincipalID));
            perms.AddRange(CFilePermission.CreateOprFullAccess(sub.PrincipalID));

            //Create zone directory
            CFile esubdir;
            string zpath = @"c:\subs\" + sub.ID;
            if (null == (esubdir = fs.GetFile(zpath))) {
                esubdir = fs.CreateDirectory(zpath, false, perms, false);
                esubdir.SpecType = CFile.SpecialType.SUBMISSION;
                string name = new Principals(m_ident).GetInfo(sub.PrincipalID).Name;
                esubdir.Alias = String.Format("{0}: {1}",
                    name, GetNextSubmission(sub.AsstID, sub.PrincipalID));
                fs.UpdateFileInfo(esubdir, false);
            }
            //Update sub entry
            sub.LocationID = esubdir.ID;
            m_dp.UpdateSubmission(sub);

            //Load files
            try {
                fs.ImportData(zpath, files, false, false); //Import the data
            } catch (Exception) {
                throw new DataAccessException("Invalid external file source. This means the system does " +
                    "not understand how to extract files from the source. Please create a valid source");
            }

            //Verify submission structure
            VerifyFormat(sub.AsstID, zpath);

            //Log
            if (markcmp)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " completed", sub.ID);
            else if (unmarkcmp)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " incomplete", sub.ID);
            else if (defunct)
                Log("User [" + m_ident.Name + "] marked submission " + esubdir.Alias + " defunct", sub.ID);

            return true;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Create a new directory
        /// </summary>
        public void ImportData(string fullpath, IExternalSource extsource, bool modupdate, bool over)
        {
            ExternalFile efile;

            CFile idir = GetFile(fullpath);

            if (!idir.IsDirectory())
            {
                throw new FileOperationException("Cannot import data into a non-directory");
            }

            //Authorize
            if (!Authorize(idir, FileAction.WRITE))
            {
                throw new FileOperationException("Permission denied on action: WRITE");
            }

            //Do the import
            try {
                while (null != (efile = extsource.NextFile()))
                {
                    string fpath = Path.Combine(fullpath, efile.Path);
                    CFile  file;
                    if (efile.Directory)
                    {
                        try {
                            file = CreateDirectory(fpath, false, null, false);
                        } catch (FileExistsException) { }
                    }
                    else
                    {
                        if (over)
                        {
                            if (null == (file = GetFile(fpath)))
                            {
                                file = CreateFile(fpath, false, null, false);
                            }
                        }
                        else
                        {
                            file = CreateFile(fpath, false, null, false);
                        }

                        //Read file
                        MemoryStream memstr = new MemoryStream();
                        int          size = 4096; byte[] data = new byte[size];
                        while (true)
                        {
                            size = efile.DataStream.Read(data, 0, data.Length);
                            if (size > 0)
                            {
                                memstr.Write(data, 0, size);
                            }
                            else
                            {
                                break;
                            }
                        }
                        //Commit data to database
                        memstr.Seek(0, SeekOrigin.Begin);
                        data         = Globals.ReadStream(memstr, (int)memstr.Length);
                        file.RawData = data; file.Size = data.Length;
                        m_dp.SyncFile(file);
                        CommitData(file);
                    }
                    extsource.CloseFile(efile);
                }
                extsource.CloseSource();
            } catch (Exception er) {
                throw new FileOperationException("Error during the import of the external source. If this source is an archive, please make sure that the format is supported by FrontDesk: MESSAGE: " + er.Message);
            }

            if (modupdate)
            {
                PercolateModified(idir, DateTime.Now);
            }
        }