private PreservationTaskViewModel ArchivePreservationModel(Guid id) { var service = new PreservationService(); var archive = ArchiveService.GetArchive(id); var schedule = service.GetPreservationScheduleWithinArchive(id); var SelectedScheduleIndex = -1; var schedulePeriod = GetArchivePeriods(id); var tasks = service.GetPreservationTasks(new System.ComponentModel.BindingList <DocumentArchive> { new DocumentArchive(id) }, 0, 2); DateTime nextPreservationDate = DateTime.Now; PreservationSchedule objSched = null; if (schedule != null) { objSched = schedulePeriod.Where(x => x.IdPreservationSchedule == schedule.IdPreservationSchedule).FirstOrDefault(); if (objSched != null) { SelectedScheduleIndex = schedulePeriod.IndexOf(objSched); } } if (tasks.Tasks.Count > 0) { nextPreservationDate = tasks.Tasks.First().EndDocumentDate.Value.AddDays(1); } var viewModel = new PreservationTaskViewModel { IdArchive = id, ArchiveName = archive.Name, SelectedScheduleIndex = SelectedScheduleIndex, PeriodSchedulers = schedulePeriod, NextPreservationTaskStartDocumentDate = nextPreservationDate }; return(viewModel); }
public FindDocumentByNameViewModel(ArchiveService archiveService) { this.archiveService = archiveService; Name = "Найти документ по имени"; FindCommand = new RelayCommand(Execute); Objects = new ObservableCollection <DocumentElementViewModel>(); }
public ArchiveSubreddit(Reddit reddit, ArchiveSubredditJson json) { sub = reddit.GetSubreddit(json.Name); SubredditArchiveService = new ArchiveService(json.ArchiveWebsite).CreateNewService(); ArchivePost = json.ArchivePost; ArchiveCommentLinks = json.ArchiveCommentLinks; }
public ActionResult Index() { return(ActionResultHelper.TryCatchWithLogger(() => { PreservationVerifyIndexModel model = new PreservationVerifyIndexModel(); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false") { DocumentCondition conditions = new DocumentCondition(); List <DocumentSortCondition> sortConditions = new List <DocumentSortCondition>(); conditions.DocumentAttributeConditions = new System.ComponentModel.BindingList <DocumentCondition>(); conditions.DocumentAttributeConditions.Add(new DocumentCondition() { Name = "IsLegal", Value = 1, Operator = Library.Common.Enums.DocumentConditionFilterOperator.IsEqualTo, Condition = Library.Common.Enums.DocumentConditionFilterCondition.And }); sortConditions.Add(new DocumentSortCondition { Name = "Name", Dir = "ASC" }); model.archives = ArchiveService.GetArchives(0, int.MaxValue, conditions, sortConditions, out int total, customerCompany.CompanyId).ToList(); } else { model.archives = UserArchive.GetUserArchivesPaged(User.Identity.Name, 0, int.MaxValue, out int total, customerCompany.CompanyId); } return View(model); }, _loggerService)); }
public EmptyResponseModel Process(ModifyArchivePreservationAttributesRequestModel request) { _logger.Info($"Process -> Edit preservation attributes for archive {request.IdArchive}"); DocumentArchive archive = ArchiveService.GetArchive(request.IdArchive); if (archive == null) { _logger.Error($"Archive with id {request.IdArchive} not found"); throw new Exception($"Archive with id {request.IdArchive} not found"); } ICollection <DocumentAttribute> attributes = AttributeService.GetAttributesFromArchive(request.IdArchive); if (attributes == null || attributes.Count == 0) { _logger.Error($"There aren't attributes for archive with id {request.IdArchive}"); throw new Exception($"There aren't attributes for archive with id {request.IdArchive}"); } foreach (DocumentAttribute attribute in attributes) { attribute.ConservationPosition = null; if (request.OrderedPreservationAttributes.ContainsKey(attribute.IdAttribute)) { attribute.ConservationPosition = request.OrderedPreservationAttributes[attribute.IdAttribute]; } _logger.Debug($"Update attribute {attribute.IdAttribute}: ConservationPosition = {attribute.ConservationPosition}"); AttributeService.UpdateAttribute(attribute); } return(new EmptyResponseModel()); }
public MostSearchableWorkerViewModel(ArchiveService archiveService) { this.archiveService = archiveService; Name = "Найти работника,\nнаиболее часто\nобращающихся к архиву"; FindCommand = new RelayCommand(Execute); Objects = new ObservableCollection <WorkerCountProjection>(); }
public LastRequestWorkerViewModel(ArchiveService archiveService) { this.archiveService = archiveService; Name = "Найти работника,\nобращавшийся последним\nк документу"; FindCommand = new RelayCommand(Execute); Objects = new ObservableCollection <WorkerDateProjection>(); }
public ActionResult ArchiveCompany(Guid archiveCompanyIdArchive, Guid archiveCompanySetIdCompany, string workingDir, string xmlFileTemplatePath, string templateXSLTFile, string awardBatchXSLTFile) { ArchiveCompanyViewModel model = new ArchiveCompanyViewModel(); var service = new PreservationService(); var company = service.GetCompany(archiveCompanySetIdCompany); ArchiveCompany archiveCompany = new Library.Common.Objects.ArchiveCompany() { Archive = ArchiveService.GetArchive(archiveCompanyIdArchive), IdArchive = archiveCompanyIdArchive, IdCompany = archiveCompanySetIdCompany, Company = company, CompanyName = company.CompanyName, WorkingDir = workingDir, TemplateXSLTFile = templateXSLTFile, XmlFileTemplatePath = xmlFileTemplatePath, AwardBatchXSLTFile = awardBatchXSLTFile }; model = new ArchiveCompanyViewModel() { ArchiveCompany = archiveCompany, Companies = new List <Company>() { company } }; try { ArchiveService.AddArchiveCompany(model.ArchiveCompany); } catch (Exception e) { View(model); } return(RedirectToAction("Index")); }
public ActionResult CheckArchivePreservationConfiguration(Guid id) { return(ActionResultHelper.TryCatchWithLogger(() => { CheckPreservationArchiveConfigurationViewModel model = new CheckPreservationArchiveConfigurationViewModel() { IdArchive = id }; DocumentArchive archive = ArchiveService.GetArchive(id); ICollection <DocumentAttribute> archiveAttributes = AttributeService.GetAttributesFromArchive(id); model.ArchiveName = archive.Name; model.ArchiveAttributes = archiveAttributes.Where(x => !x.KeyOrder.HasValue || x.KeyOrder == 0) .OrderBy(o => o.DisplayName) .ToDictionary(k => k.IdAttribute.ToString(), v => v.DisplayName); //model.DateAttributes.Add(Guid.Empty.ToString(), "--Crea attributo (Date)"); archiveAttributes.Where(x => x.AttributeType.Equals("System.DateTime", StringComparison.InvariantCultureIgnoreCase)) .OrderBy(o => o.DisplayName).ToList().ForEach(f => model.DateAttributes.Add(f.IdAttribute.ToString(), f.DisplayName)); model.PathPreservation = archive.PathPreservation; model.MainDateAttribute = archiveAttributes.Where(x => x.IsMainDate == true).Select(s => s.IdAttribute.ToString()).SingleOrDefault(); model.PrimaryKeyAttributes = archiveAttributes.Where(x => x.KeyOrder > 0).OrderBy(o => o.KeyOrder) .ToDictionary(k => k.IdAttribute.ToString(), v => v.DisplayName); ValidateArchiveForPreservationInteractor interactor = new ValidateArchiveForPreservationInteractor(_loggerService); ValidateArchiveForPreservationResponseModel response = interactor.Process(new ValidateArchiveForPreservationRequestModel() { IdArchive = id }); model.HasPreservations = response.HasPreservations; model.ValidationErrors = response.ValidationErrors; model.IsValidated = response.IsValidated; return PartialView("_CheckArchivePreservationConfiguration", model); }, _loggerService)); }
public ExtractArchivesViewModel() { ProgressMessage = "Extracting archives..."; _archiveService = new ArchiveService(); _archiveService.MessageReported += _archiveService_MessageReported; _archiveService.ArchivesExtracted += _archiveService_ArchivesExtracted; }
public ActionResult GetPreservationVerifyTask([DataSourceRequest] DataSourceRequest request) { DataSourceResult result = new DataSourceResult(); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; BindingList <DocumentArchive> archives = new BindingList <DocumentArchive>(); try { if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false") { archives = CustomerService.GetCustomerArchivesByUsername(User.Identity.Name); } else { archives = new BindingList <DocumentArchive>(ArchiveService.GetLegalArchives("", customerCompany.CompanyId).Select(x => x.Archive).ToList()); } var tasks = new PreservationService().GetPreservationVerify(archives.Select(x => x.IdArchive).ToArray(), true); result.Total = tasks.Count; result.Data = tasks; } catch (Exception ex) { result.Errors = ex; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Index(Guid id, Guid?idPreservation) { return(ActionResultHelper.TryCatchWithLogger(() => { DocumentArchive archive = ArchiveService.GetArchive(id); if (archive == null) { throw new Exception(string.Format("Nessun archivio trovato con id {0}", id)); } AwardBatchViewModel model = new AwardBatchViewModel() { ArchiveName = archive.Name, IdArchive = archive.IdArchive, IdPreservation = idPreservation }; if (idPreservation.HasValue && idPreservation.Value != Guid.Empty) { model.FromDate = null; model.ToDate = null; } return View(model); }, _loggerService)); }
/// <summary> /// Creates a new api from the currently registered /// repositories. /// </summary> public Api( IContentFactory contentFactory, IAliasRepository aliasRepository, IArchiveRepository archiveRepository, IMediaRepository mediaRepository, IPageRepository pageRepository, IPageTypeRepository pageTypeRepository, IParamRepository paramRepository, IPostRepository postRepository, IPostTypeRepository postTypeRepository, ISiteRepository siteRepository, ISiteTypeRepository siteTypeRepository, ICache cache = null, IStorage storage = null, IImageProcessor processor = null) { // Store the cache _cache = cache; // Create services without dependecies PageTypes = new PageTypeService(pageTypeRepository, cache); Params = new ParamService(paramRepository, cache); PostTypes = new PostTypeService(postTypeRepository, cache); Sites = new SiteService(siteRepository, contentFactory, cache); SiteTypes = new SiteTypeService(siteTypeRepository, cache); // Create services with dependencies Aliases = new AliasService(aliasRepository, Sites, cache); Media = new MediaService(mediaRepository, Params, storage, processor, cache); Pages = new PageService(pageRepository, contentFactory, Sites, Params, cache); Posts = new PostService(postRepository, contentFactory, Sites, Pages, cache); Archives = new ArchiveService(archiveRepository, Params, Posts); }
public AddDocumentViewModel(ArchiveService service) { Name = "Добавить документ"; this.service = service; AddDocument = new RelayCommand(AddDocumentCommand, CanExecuteAddDocument); }
public BindingList <Document> GetAllDocumentsWithThumbnail(string archiveName, bool visible, int skip, int take, out int docunentsInArchiveCount) { docunentsInArchiveCount = -1; try { logger.DebugFormat("GetAllDocuments archiveName:{0}, skip:{1}, take:{2}, visible:{3}", archiveName, skip, take, visible); var archive = ArchiveService.GetArchiveByName(archiveName); if (archive == null) { throw new BiblosDS.Library.Common.Exceptions.Archive_Exception("Archive: " + archiveName + " not found."); } var result = DocumentService.GetAllDocuments(archive, visible, skip, take, out docunentsInArchiveCount); using (var clientChannel = WCFUtility.GetClientConfigChannel <IServiceDocumentStorage>(ServerService.WCF_DocumentStorage_HostName)) { foreach (var item in result) { if (!string.IsNullOrEmpty(item.IdThumbnail)) { item.ThumbnailContent = (clientChannel as IServiceDocumentStorage).GetDocumentConformAttach(item, item.IdThumbnail).Content; } } } return(result); } catch (Exception ex) { logger.Error(ex); throw; } finally { logger.DebugFormat("GetAllDocuments archiveName:{0}, RETUNT: {1}", archiveName, docunentsInArchiveCount); } }
public DocumentResponse SearchQueryContextLatestVersion(string archiveName, BindingList <DocumentCondition> attributeConditions, BindingList <DocumentCondition> contentConditions, BindingList <DocumentCondition> inferConditions, int?skip, int?take) { try { logger.DebugFormat("SearchQueryContextLatestVersion AttributeConditions:{0}", attributeConditions != null ? attributeConditions.Count : 0); var archive = ArchiveService.GetArchiveByName(archiveName); if (archive == null) { throw new Archive_Exception(string.Concat("Archive: ", archiveName, " not found.")); } List <Document> documents = new List <Document>(); int documentsInArchiveCount = 0; if (attributeConditions != null && attributeConditions.Count > 0) { documents.AddRange(DocumentService.SearchDocumentsExt(archive.IdArchive, attributeConditions, out documentsInArchiveCount, skip, take)); } BindingList <Document> items = new BindingList <Document>(documents); logger.DebugFormat("SearchQueryContextLatestVersion Returns:{0}", items.Count); return(new DocumentResponse { Documents = items, TotalRecords = documentsInArchiveCount }); } catch (Exception ex) { logger.Error(ex); return(new DocumentResponse { HasErros = true, Error = new ResponseError(ex) }); } }
private ArchiveService CreateArchiveService() { var userID = Guid.Parse(User.Identity.GetUserId()); var archiveService = new ArchiveService(userID); return(archiveService); }
public async System.Threading.Tasks.Task <IHttpActionResult> UploadAsync() { if (!Request.Content.IsMimeMultipartContent()) { Request.CreateResponse(HttpStatusCode.UnsupportedMediaType); } Authorize(); string root = HttpContext.Current.Server.MapPath("~/temp"); var provider = new MultipartFormDataStreamProvider(root); var result = await Request.Content.ReadAsMultipartAsync(provider); // On upload, files are given a generic name like "BodyPart_26d6abe1-3ae1-416a-9429-b35f15e6e5d5" // so this is how you can get the original file name //var originalFileName = GetDeserializedFileName(result.FileData.First()); // var uploadedFileInfo = new FileInfo(result.FileData.First().LocalFileName); string path = result.FileData.First().LocalFileName; using (var fileStream = File.OpenRead(path)) { await ArchiveService.UnzipAsync(fileStream, User.Id).ConfigureAwait(false); } // Delete the file at the end File.Delete(path); return(Ok()); }
public ActionResult GetPreservationPendingTask([DataSourceRequest] DataSourceRequest request) { DataSourceResult result = new DataSourceResult(); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; ICollection <PreservationTask> items = new List <PreservationTask>(); try { BindingList <DocumentArchive> archives = null; if (WCFUtility.GetSettingValue("DBAdminLoginConnection") == "false") { archives = new BindingList <DocumentArchive>(ArchiveService.GetLegalArchives("", customerCompany.CompanyId).Select(x => x.Archive).ToList()); } else { archives = CustomerService.GetCustomerArchivesByUsername(User.Identity.Name); } items = _preservationService.GetPreservationActiveTasks(archives.Select(s => s.IdArchive).ToList()); result.Total = items.Count; result.Data = items; } catch (Exception ex) { result.Errors = ex; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult GetPreservationArchivesConfigurable([DataSourceRequest] DataSourceRequest request) { return(ActionResultHelper.TryCatchWithLogger(() => { ICollection <ArchiveConfigurableViewModel> results = new List <ArchiveConfigurableViewModel>(); CustomerCompanyViewModel customerCompany = Session["idCompany"] as CustomerCompanyViewModel; string archiveFilterName = string.Empty; if (request.Filters.Count > 0) { archiveFilterName = (request.Filters.First() as FilterDescriptor).Value.ToString(); } ICollection <DocumentArchive> archives = ArchiveService.GetPreservationArchivesConfigurable(customerCompany.CompanyId, archiveFilterName, (request.Page - 1) * request.PageSize, request.PageSize, out int totalItems); foreach (DocumentArchive archive in archives) { results.Add(new ArchiveConfigurableViewModel() { IdArchive = archive.IdArchive, IsPreservationEnabled = archive.IsLegal, ArchiveName = archive.Name }); } DataSourceResult result = new DataSourceResult() { Total = totalItems, Data = results }; return Json(result, JsonRequestBehavior.AllowGet); }, _loggerService)); }
public async Task <Response <List <DbFileModel> > > GetDbFile(DataBaseTypes sourceType) { var response = new Response <List <DbFileModel> >(); try { string dbAddress; switch (sourceType) { case DataBaseTypes.ASN: { dbAddress = AsnArchiveAddress; break; } case DataBaseTypes.CITY: { dbAddress = CityArchiveAddress; break; } default: { throw new CustomException(ResponseCodes.INTERNAL_BAD_REQUEST, ErrorMessages.WrongSourceType); } } var getLastArchive = await FileService.DownloadDbFile(dbAddress); if (getLastArchive.Length == 0) { response.Data = new List <DbFileModel>(); return(response); } var unzipArchive = await ArchiveService.GetCsvFilesFromZip(getLastArchive); if (unzipArchive.Count > 0) { response.Data = unzipArchive.Select(ua => new DbFileModel { FileData = ua.Data, FileName = ua.Name }).ToList(); } } catch (CustomException ce) { Console.WriteLine(ce.Errors.FirstOrDefault()?.ResultMessage); throw; } catch (Exception e) { Console.WriteLine(e); throw; } return(response); }
public ActionResult SetArchivePreservationConfiguration(ArchivePreservationConfigurationViewModel model) { DocumentArchive archive = ArchiveService.GetArchive(model.Archive.IdArchive); archive.PreservationConfiguration = JsonConvert.SerializeObject(model.ArchiveConfiguration); ArchiveService.UpdateArchive(archive); return(RedirectToAction("ArchivePreservationConfiguration", new { id = model.Archive.IdArchive })); }
public async Task ItCanGetArchivedFilesAndFolders() { var request = new ArchiveListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); var response = await ArchiveService.GetArchiveAsync(request); Assert.IsNotNull(response); Assert.IsNotNull(response.Folder); }
protected async Task <List <Models.Inbox.File> > GetFiles() { var request = new ArchiveListRequest(connectionSettings.AccessToken, connectionSettings.ClientSecret); return((await ArchiveService.GetArchiveAsync(request, "root")) .Folder .Files .ToList()); }
public Dictionary <string, string> GetPreservationParameter(string archiveName) { var archive = ArchiveService.GetArchiveByName(archiveName); if (archive == null) { throw new FaultException("Nessun archivio con il nome archivio: " + archiveName); } return(this.PreservationContext.GetPreservationParameter(archive.IdArchive)); }
private void Init(ListView listBox, ArchiveService archiver, FileService fileService) { Window = listBox; ArchiveService = archiver; ArchiveService.OnResponse = RefreshBoth; FileService = fileService; FileService.OnResponse = RefreshBoth; Root = FileService.Root; LastSelectedItems = new string[0]; }
private void Initialize() { archiveService = new ArchiveService <T>(_bufferCapacity); if (_useSaveSystem) { saveLoadService = new SaveLoadService <T>(archiveService, this, _autoSave, autoSaveInterval); saveLoadService.Load(); } }
public Expression <Func <Document, DocumentToViewListDto> > ToDto() { return(document => new DocumentToViewListDto { Id = document.Id, Title = document.Title, Description = document.Description, CreateDate = document.CreateDate, ArchiveUrl = ArchiveService.DownloadPath(document.Archive.Guid, document.Archive.Name), ArchiveName = document.Archive.Name, }); }
public void DeleteNotPassA() { //Arrange ArchiveService archiver = new ArchiveService(); bool expected = false; //Act bool actual = archiver.DeleteLog("FileNotExist.csv"); //Assert Assert.AreEqual(expected, actual); }
public void ArchiveableNotPass() { //Arrange ArchiveService archiver = new ArchiveService(); bool expected = false; //Act bool actual = archiver.Archiveable("BadName.csv"); //Assert Assert.AreEqual(expected, actual); }
public frmArchiveClient(IArchiveServer archiver, ArchiveService.Conference conference, int[] streams, FMain refFMain, frmArchiveConf refFrmArchiveConf) { InitializeComponent(); // Duration of the current conference totalDuration = conference.End - conference.Start; sliderRange = tbPlayBack.Maximum - tbPlayBack.Minimum; ratioTickBySlider = totalDuration.Ticks / sliderRange; Streams = streams; this.archiver = archiver; this.conference = conference; this.refFMain = refFMain; this.refFrmArchiveConf = refFrmArchiveConf; }
/// <summary> /// Display the playback info in the status bar /// </summary> private void DisplayPlayBackInfo(ArchiveService.Conference selectedConference) { MSR.LST.ConferenceXP.ArchiveService.Conference conf = selectedConference; // TODO: Put Debug.Assert instead of if ( conf != null ) if (conf != null) { DisplayStatusMessage("Playback of conference: " + conf.Description); } }
/// <summary> /// Play back an archive in the appropriate venue /// </summary> /// <param name="Streams">Streams ID to play back</param> /// <param name="selectedConference">Selected Conference</param> /// <returns>The IP adress where the archive is played back</returns> internal System.Net.IPEndPoint PlayArchive(int[] streams, ArchiveService.Conference selectedConference) { // TODO: Move PlayArchive out of BarUI // IP adresse where the archive is played back System.Net.IPEndPoint archivePlayBackIP = null; // TODO: Make sure we cannot get to an infinite loop by removing test on sender // if ( sender != this && (this.archiverState == ArchiverState.Stopped) ) if (this.archiverState == ArchiverState.Stopped) { if (Conference.ActiveVenue == null) // Join a venue to playback to (generally unicast) { // We've established a venue to join to, so do it JoinVenue(GetPlayBackVenue(), false); } // We're definitely in a venue now Debug.Assert(Conference.ActiveVenue != null); // We're in a venue - playback to it if (MSR.LST.Net.Utility.IsMulticast(Conference.ActiveVenue.EndPoint)) { // Multicast playback - send directly to the multicast group archivePlayBackIP = Conference.ActiveVenue.EndPoint; archiver.Play(Conference.ActiveVenue.EndPoint, streams); } else { // Unicast playback - send data directly to the local IP archivePlayBackIP = new IPEndPoint(Conference.RtpSession.MulticastInterface, Conference.ActiveVenue.EndPoint.Port); archiver.Play(archivePlayBackIP, streams); } DisplayPlayBackInfo(selectedConference); this.archiverState = ArchiverState.Playing; } SetArchiverMenuStatus(); return archivePlayBackIP; }
/// <summary> /// Display the playback info in the status bar /// </summary> private void DisplayPlayBackInfo(ArchiveService.Conference selectedConference) { MSR.LST.ConferenceXP.ArchiveService.Conference conf = selectedConference; // TODO: Put Debug.Assert instead of if ( conf != null ) if (conf != null) { DisplayStatusMessage(string.Format(CultureInfo.CurrentCulture, Strings.PlaybackConference, conf.Description)); } }