Пример #1
0
        public GContentClass(GDataSet.GContentRow row, GPackageClass parentPackage, GGenreClass grandparentGenre)
            : this()
        {
            this.contentKey = row.ContentKey;
            this.packageKey = row.IsPackageKeyNull() ? (int?)null : row.PackageKey;
            this.genreKey = row.IsGenreKeyNull() ? (int?)null : row.GenreKey;
            this.title = row.IsTitleNull() ? null : row.Title;
            this.seriesNumber = row.IsSeriesNumberNull() ? null : row.SeriesNumber;
            this.subtitle = row.IsSubtitleNull() ? null : row.Subtitle;
            this.summaryHtml = row.IsSummaryHtmlNull() ? null : row.SummaryHtml;
            this.durationValue = row.IsDurationValueNull() ? (TimeSpan?)null : row.DurationValue;
            this.deadlineText = row.IsDeadlineTextNull() ? null : row.DeadlineText;
            this.created = row.Created;
            this.lastModified = row.LastModified;

            this.parentPackage = parentPackage;
            this.grandparentGenre = grandparentGenre;
        }
Пример #2
0
        private GContentClass CreateContentAndStoreOrUpdate(int contKey, GPackageClass package, GGenreClass genre, string title, string seriesNumber, string subtitle, string summaryHtml, TimeSpan durationValue, string deadlineText)
        {
            int? pacKey = (null != package) ? package.PackageKey : (int?)null;
            int? genreKey = (null != genre) ? genre.GenreKey : (int?)null;
            GDataSet.GContentRow row = this.dataSet.GContent.FindByContentKey(contKey);
            if (null != row) {
                if (null == package && !row.IsPackageKeyNull()) {
                    this.TryFindPackage(row.PackageKey, out package);
                }
                if (null == genre && !row.IsGenreKeyNull()) {
                    genre = this.GetCachedGenre(row.GenreKey);
                }

                bool updateFlag = false;
                if (pacKey.HasValue && (row.IsPackageKeyNull() || pacKey.Value != row.PackageKey)) {
                    row.PackageKey = pacKey.Value;
                    updateFlag = true;
                }
                if (genreKey.HasValue && (row.IsGenreKeyNull() || genreKey.Value != row.GenreKey)) {
                    row.GenreKey = genreKey.Value;
                    updateFlag = true;
                }
                if (row.IsTitleNull() || !row.Title.Equals(title)) {
                    row.Title = title;
                    updateFlag = true;
                }
                if (row.IsSeriesNumberNull() || !row.SeriesNumber.Equals(seriesNumber)) {
                    row.SeriesNumber = seriesNumber;
                    updateFlag = true;
                }
                if (row.IsSubtitleNull() || !row.Subtitle.Equals(subtitle)) {
                    row.Subtitle = subtitle;
                    updateFlag = true;
                }
                if (row.IsSummaryHtmlNull() || !row.SummaryHtml.Equals(summaryHtml)) {
                    row.SummaryHtml = summaryHtml;
                    updateFlag = true;
                }
                if (row.IsDurationValueNull() || !row.DurationValue.Equals(durationValue)) {
                    row.DurationValue = durationValue;
                    updateFlag = true;
                }
                if (row.IsDeadlineTextNull() || !row.DeadlineText.Equals(deadlineText)) {
                    row.DeadlineText = deadlineText;
                    updateFlag = true;
                }

                if (updateFlag) {
                    row.LastModified = DateTime.Now;
                }
                return new GContentClass(row, package, genre);
            } else {
                row = this.dataSet.GContent.NewGContentRow();
                row.ContentKey = contKey;
                if(pacKey.HasValue) row.PackageKey = pacKey.Value;
                if(genreKey.HasValue) row.GenreKey = genreKey.Value;
                row.Title = title;
                row.SeriesNumber = seriesNumber;
                row.Subtitle = subtitle;
                row.SummaryHtml = summaryHtml;
                row.DurationValue = durationValue;
                row.DeadlineText = deadlineText;
                DateTime now = DateTime.Now;
                row.Created = now;
                row.LastModified = now;

                this.dataSet.GContent.AddGContentRow(row);
                return new GContentClass(row, package, genre);
            }
        }
Пример #3
0
 public bool TryFindPackage(int pacKey, out GPackageClass package)
 {
     GDataSet.GPackageRow row = this.dataSet.GPackage.FindByPackageKey(pacKey);
     if (null != row) {
         package = new GPackageClass(row, this.GetCachedGenre(row));
         return true;
     } else {
         package = null;
         return false;
     }
 }