PublicationItem ProcessItem(string path, string evergreenName) { PublicationItem item; try { item = PublicationItem.CreateFromFile(path); } catch (Exception e) { Log.LogError($"error creating ingestion item for '{path}': {e.Message}"); return(null); } var fileName = Path.GetFileName(path); item.IngestionUri = new Uri(fileName, UriKind.Relative); item.RelativePublishUrl = new Uri( $"{RelativePublishBaseUrl}/{fileName}", UriKind.Relative); if (!string.IsNullOrEmpty(evergreenName)) { item.RelativePublishEvergreenUrl = new Uri( $"{RelativePublishBaseUrl}/{evergreenName}", UriKind.Relative); } return(ProcessItem(item)); }
public KBArticle(string id, bool archived, string title, KBBook book, KBFolder folder, PublicationItem item, DateTime created, string alias, CPrincipal?createdBy = null, DateTime?updated = null, CPrincipal?updatedBy = null) { Id = id; IsArchived = archived; Title = title; Book = book; Folder = folder; Item = item; Created = created; CreatedBy = createdBy; Updated = updated; UpdatedBy = updatedBy; Alias = alias; }
public bool SaveItem(PublicationItem publicationItem) { #region Just a bit of output to show what's going on... string message = string.Empty; switch (publicationItem.Status) { case -1: message = "Cancelled: " + publicationItem.PublicationItemID.ToString(); break; case 0: message = "Default: " + publicationItem.PublicationItemID.ToString(); break; case 1: message = "Queued: " + publicationItem.PublicationItemID.ToString(); break; case 2: message = "Published: " + publicationItem.PublicationItemID.ToString(); break; default: message = "Unknown: " + publicationItem.PublicationItemID.ToString(); break; } HelperClasses.Output.WriteMessage(message); #endregion bool saved = false; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress)) { saved = DAL.PublicationDAL.PublicationItem.SavePublicationItem(publicationItem); scope.Complete(); } return(saved); }
private void ImportCollectionItem(CsvRow csvRow) { logger.LogInformation($"Start importing {csvRow}"); var externalId = CreateExternalId(csvRow); logger.LogInformation($"Created externalId '{externalId}'"); if (unitOfWork.PublicationItems.GetByImportOrigin((int)ImportOriginEnum.CustomCsv, externalId) != null) { logger.LogWarning($"Publication item with id {externalId} already imported - skipping."); return; } logger.LogInformation($"Creating new publication item of {csvRow}."); var publication = GetPublication(csvRow, externalId); var publicationItem = new PublicationItem { Production = GetProduction(csvRow), ImportOriginId = (int)ImportOriginEnum.CustomCsv, IdInImportOrigin = externalId }; publicationItem.MediaItems.AddRange(GetMediaItems(csvRow)); publication.PublicationItems.Add(publicationItem); publicationItem.SubtitleLanguages.AddRange(CreateSubtitles(csvRow)); logger.LogInformation($"Created publication item {publicationItem}"); if (publication.Id == 0) { logger.LogInformation($"Adding publication item {publicationItem} to db."); unitOfWork.Publications.Add(publication); } else { logger.LogInformation($"Updating publication item {publicationItem.Id} to db."); unitOfWork.Publications.Update(publication); } logger.LogInformation($"Finish importing {csvRow}"); }
PublicationItem ProcessItem(PublicationItem item) { var relativePath = item.RelativePublishUrl.ToString(); var relativePathFileName = Path.GetFileName(relativePath); if (pdbArchiveRegex.IsMatch(relativePathFileName)) { item.RelativePublishUrl = null; return(item); } var updaterItem = updaterFileRegex.Match(relativePathFileName); if (updaterItem == null || !updaterItem.Success) { return(item); } if (string.IsNullOrEmpty(ReleaseName)) { ReleaseName = $"{updaterItem.Groups ["name"]}-{updaterItem.Groups ["version"]}"; } if (UpdateInfoFile != null) { item.UpdaterProduct = UpdaterProduct.FromUpdateInfo( File.ReadAllText(UpdateInfoFile)); } else { item.UpdaterProduct = new UpdaterProduct(); } item.UpdaterProduct.Size = item.Size; item.UpdaterProduct.Version = updaterItem.Groups ["version"].Value; if (UpdaterReleaseNotes != null) { item.UpdaterProduct.ReleaseNotes = string .Join("\n", UpdaterReleaseNotes) .Trim(); } if (ReleaseVersion.TryParse(item.UpdaterProduct.Version, out var version)) { if (version.CandidateLevel == ReleaseCandidateLevel.Stable) { item.RelativePublishEvergreenUrl = new Uri( Path.GetDirectoryName(relativePath) + "/" + updaterItem.Groups ["name"].Value + updaterItem.Groups ["extension"].Value, UriKind.Relative); } switch (version.CandidateLevel) { case ReleaseCandidateLevel.Alpha: item.UpdaterProduct.IsAlpha = true; break; case ReleaseCandidateLevel.Beta: case ReleaseCandidateLevel.StableCandidate: item.UpdaterProduct.IsAlpha = true; item.UpdaterProduct.IsBeta = true; break; case ReleaseCandidateLevel.Stable: item.UpdaterProduct.IsAlpha = true; item.UpdaterProduct.IsBeta = true; item.UpdaterProduct.IsStable = true; break; } } return(item); }