コード例 #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         repo.Dispose();
     }
     base.Dispose(disposing);
 }
コード例 #2
0
        public void Dispose()
        {
            if (_transaction != null)
            {
                _transaction.Dispose();
                _transaction = null;
            }

            if (_quizRepository != null)
            {
                _quizRepository.Dispose();
                _quizRepository = null;
            }

            if (_ruleRepository != null)
            {
                _ruleRepository.Dispose();
                _ruleRepository = null;
            }

            if (_stageRepository != null)
            {
                _stageRepository.Dispose();
                _stageRepository = null;
            }

            if (_questionRepository != null)
            {
                _questionRepository.Dispose();
                _questionRepository = null;
            }

            if (_endingRepository != null)
            {
                _endingRepository.Dispose();
                _endingRepository = null;
            }

            if (_fileRepository != null)
            {
                _fileRepository.Dispose();
                _fileRepository = null;
            }

            if (_connection != null)
            {
                _connection.Dispose();
                _connection = null;
            }
        }
コード例 #3
0
 public virtual void Dispose()
 {
     FileRepository?.Dispose();
 }
コード例 #4
0
 public void Dispose()
 {
     repo.Dispose();
 }
コード例 #5
0
 public void Dispose()
 {
     IntegrationFactHelper.ResetPhysicalContentDirectoryAndConfigureStore(Configuration.Store.LocalDiskStore, Timeout.Infinite);
     repo.Dispose();
 }
コード例 #6
0
        private static void Run()
        {
            var cmsRepository  = new CmsRepository();
            var fileRepository = new FileRepository();
            var errorFiles     = new List <SiteContent>();
            var logFilePath    = ConfigurationManager.AppSettings["LogFilePath"] ?? ".";
            var logFileName    = string.Format(@"{0}\{1}-{2:yyyyMMdd-hhmmsstt}.txt", logFilePath, ApplicationName, DateTime.Now);
            var logFile        = new StreamWriter(logFileName);

            try
            {
                logFile.WriteLine(SettingsMessage);
                logFile.LogInfo("Retrieving files to copy.");

                var directories = Directory.GetDirectories(CmsFilePath);

                foreach (var directory in directories)
                {
                    var file = Directory.GetFiles(directory).FirstOrDefault();

                    if (string.IsNullOrEmpty(file))
                    {
                        logFile.LogError(null, string.Format("Could not find file in directory: {0}", directory));
                    }

                    var fileInfo  = new System.IO.FileInfo(file);
                    var contentId = int.Parse(fileInfo.Directory.Name);

                    var content = cmsRepository.FindBy <SiteContent>(s => s.SiteContentID == contentId).FirstOrDefault();

                    logFile.LogInfo("Uploading File: {0} ({1:#,00.00} KB)", fileInfo.Name, fileInfo.Length / 1024);

                    if (content == null)
                    {
                        logFile.LogError(null, string.Format("SiteContent Record not found: {0}", contentId));
                        continue;
                    }

                    var fileBytes = System.IO.File.ReadAllBytes(file);

                    var newFile = new Portal.Model.File
                    {
                        Data = fileBytes,
                        Info = new Portal.Model.FileInfo
                        {
                            Name         = fileInfo.Name,
                            Extension    = Path.GetExtension(fileInfo.Name),
                            SizeBytes    = fileBytes.Length,
                            CreateUserID = 0,
                            CreateDate   = DateTime.Now
                        }
                    };

                    // Save File
                    fileRepository.Add(newFile);
                    fileRepository.Save();

                    if (newFile.FileID > 0)
                    {
                        content.FileID       = newFile.FileID;
                        content.ModifyUserID = 0;
                        content.ModifyDate   = DateTime.Now;

                        // Update SiteContent with FileID
                        cmsRepository.Update(content);
                        cmsRepository.Save();
                    }

                    logFile.LogInfo("\tSaved file: {0}, FileID: {1}.", fileInfo.Name, newFile.FileID);
                }

                logFile.LogInfo("Import Completed.\r\n\r\nSummary:\r\nTotal Files: {0}\r\nErrored Files: {1}", directories.Length, errorFiles.Count);

                //if (errorFiles.Count > 0)
                //{
                //    logFile.Log(EventTypes.Warning, null, "Files that could not be imported:");
                //    errorFiles.ForEach(f => logFile.Log(EventTypes.Warning, null, "\tSiteContentID: {0}, File: {1}:{2}/{3}", f.SiteContentID, f.FileContentLocation, f.FileSubdirectory, f.FileName));
                //}

                logFile.LogInfo("\r\n\r\nDone!  Log file saved to: {0}.", Path.GetFullPath(logFileName));
            }
            catch (Exception ex)
            {
                logFile.LogError(ex, "\t{0}", ex.FullMessage());
            }
            finally
            {
                logFile.Dispose();
                cmsRepository.Dispose();
                fileRepository.Dispose();
            }
        }
コード例 #7
0
ファイル: UnitOfWork.cs プロジェクト: Sowatech/TestAnwendung
 public override void Dispose()
 {
     FileRepository.Dispose();
     base.Dispose();
 }