예제 #1
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        /// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandAuthorId = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

            !Embedded
                       ? new JProperty("@context", JSONLDContext.ToString())
                       : null,

            new JProperty("headline", Headline.ToJSON()),
            new JProperty("text", Text.ToJSON()),

            new JProperty("author", JSONObject.Create(
                              new JProperty("@id", Author.Id.ToString()),
                              new JProperty("name", Author.Name)
                              )),

            new JProperty("publicationDate", PublicationDate.ToIso8601()),

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            Signatures.Any()
                       ? new JProperty("signatures", new JArray(Signatures.SafeSelect(signature => signature.ToJSON(Embedded: true))))
                       : null

            );
예제 #2
0
 public int CompareTo(Book other)
 {
     if (!Name.Equals(other.Name))
     {
         return(Name.CompareTo(other.Name));
     }
     if (!Author.Equals(other.Author))
     {
         return(Author.CompareTo(other.Author));
     }
     if (!Category.Equals(other.Category))
     {
         return(Category.CompareTo(other.Category));
     }
     if (!Language.Equals(other.Language))
     {
         return(Language.CompareTo(other.Language));
     }
     if (!PublicationDate.Equals(other.PublicationDate))
     {
         return(PublicationDate.CompareTo(other.PublicationDate));
     }
     if (!Isbn.Equals(other.Isbn))
     {
         return(Isbn.CompareTo(other.Isbn));
     }
     return(0);
 }
예제 #3
0
        public void Validate()
        {
            if (string.IsNullOrEmpty(Title) || string.IsNullOrEmpty(Theme) || string.IsNullOrEmpty(Author))
            {
                throw new BookFieldNullOrEmptyException();
            }

            if (Title.Length < 4)
            {
                throw new BookTitleLessThan4CharactersException();
            }

            if (Theme.Length < 4)
            {
                throw new BookThemeLessThan4CharactersException();
            }

            if (Author.Length < 4)
            {
                throw new BookAuthorLessThan4CharactersException();
            }

            if (Volume < 1)
            {
                throw new BookInvalidVolumeException();
            }

            if (!PublicationDate.CompareDateSmallerCurrent())
            {
                throw new BookDateOverFlowException();
            }
        }
예제 #4
0
            public override bool Equals(object obj)
            {
                if (obj == null)
                {
                    throw new ArgumentNullException();
                }

                if (!(obj is Data_ data))
                {
                    return(false);
                }

                if (!base.Equals(obj))
                {
                    return(false);
                }

                if (!NameOfSourceData.Equals(data.NameOfSourceData))
                {
                    return(false);
                }

                if (!PublicationDate.Equals(data.PublicationDate))
                {
                    return(false);
                }

                if (!Copyright.Equals(data.Copyright))
                {
                    return(false);
                }

                return(true);
            }
예제 #5
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        /// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

            !Embedded
                       ? new JProperty("@context", JSONLDContext.ToString())
                       : null,

            Text.IsNeitherNullNorEmpty()
                       ? new JProperty("text", Text.ToJSON())
                       : null,

            new JProperty("publicationDate", PublicationDate.ToIso8601()),

            GeoLocation.HasValue
                       ? new JProperty("geoLocation", GeoLocation.ToJSON())
                       : null,

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            PrivacyLevel.ToJSON(),

            Signatures.Any()
                       ? new JProperty("signatures", new JArray(Signatures.SafeSelect(signature => signature.ToJSON(Embedded: true))))
                       : null

            );
예제 #6
0
파일: Item.cs 프로젝트: felixwatts/PodPuppy
        public string ExpandTagString(string tagString)
        {
            tagString = tagString.Replace("%t", Title);
            tagString = tagString.Replace("%p", Feed.Title);
            tagString = tagString.Replace("%d", PublicationDate.ToShortDateString());

            tagString = tagString.Replace("%D", PublicationDate.Day.ToString("00"));
            tagString = tagString.Replace("%M", PublicationDate.Month.ToString("00"));
            tagString = tagString.Replace("%Y", PublicationDate.Year.ToString());

            int numComplete = 0;

            foreach (Item item in Feed.Items)
            {
                if (item.Status == ItemStatus.Complete)
                {
                    numComplete++;
                }
            }
            tagString = tagString.Replace("%n", numComplete.ToString("000"));

            tagString = tagString.Replace("%N", (999 - numComplete).ToString("000"));

            return(tagString);
        }
 // Override of the ToString Method
 public string ToString()
 {
     // Serializing Object as CSV
     return(String.Join(",",
                        ("\"" + Url + "\""),
                        ("\"" + ReferenceDate.ToString("yyyy-MM-dd").Replace(",", "") + "\""),
                        ("\"" + Name.Replace(",", "") + "\" "),
                        ("\"" + Developer.Replace(",", "") + "\""),
                        ("\"" + IsTopDeveloper + "\""),
                        ("\"" + DeveloperURL.Replace(",", "") + "\""),
                        ("\"" + PublicationDate.ToString("yyyy-MM-dd").Replace(",", "") + "\""),
                        ("\"" + Category.Replace(",", "") + "\""),
                        ("\"" + IsFree + "\""),
                        ("\"" + Price + "\""),
                        ("\"" + Reviewers + "\""),
                        ("\"" + Score.Total + "\""),
                        ("\"" + Score.Count + "\""),
                        ("\"" + Score.FiveStars + "\""),
                        ("\"" + Score.FourStars + "\""),
                        ("\"" + Score.ThreeStars + "\""),
                        ("\"" + Score.TwoStars + "\""),
                        ("\"" + Score.OneStars + "\""),
                        ("\"" + LastUpdateDate.ToString("yyyy-MM-dd") + "\""),
                        //("\"" + AppSize                + "\""),
                        ("\"" + Instalations.Replace(",", ".") + "\""),
                        ("\"" + CurrentVersion.Replace(",", "") + "\""),
                        ("\"" + MinimumOSVersion.Replace(",", "") + "\""),
                        ("\"" + ContentRating.Replace(",", "") + "\""),
                        ("\"" + HaveInAppPurchases + "\""),
                        ("\"" + DeveloperEmail.Replace(",", "") + "\""),
                        ("\"" + DeveloperWebsite.Replace(",", "") + "\""),
                        ("\"" + DeveloperPrivacyPolicy.Replace(",", "") + "\""),
                        ("\"" + Description.Replace(",", "") + "\"")));
 }
예제 #8
0
        public override string ToString()
        {
            return($"Book Name: {Name}, Book Author {Author}, Book Category {Category}, Book Language {Language}," +
                   $"Book Publication Date {PublicationDate.ToString("dd.MM.yyyy")}, Book ISBN {Isbn}, Is Book Taken: {Taken}");

            ;
        }
예제 #9
0
        public string GetPortalDate()
        {
            var    culture     = new System.Globalization.CultureInfo("uk-UA");
            string dateDoW     = culture.DateTimeFormat.GetDayName(PublicationDate.DayOfWeek);
            string dateDoWNorm = dateDoW.ToUpper().First() + dateDoW.Substring(1, dateDoW.Length - 1);

            return(dateDoWNorm + ", " + PublicationDate.ToString("dd.MM.yyyy"));
        }
예제 #10
0
        public int CompareTo(Projection?obj)
        {
            if (obj == null)
            {
                return(1);
            }

            return(PublicationDate.CompareTo(obj.PublicationDate));
        }
예제 #11
0
 public bool Equals(Book other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(object.ReferenceEquals(this, null));
     }
     return(Name.Equals(other.Name) && Author.Equals(other.Author) && Category.Equals(other.Category) &&
            Language.Equals(other.Language) && PublicationDate.Equals(other.PublicationDate) && Isbn.Equals(other.Isbn));
 }
예제 #12
0
        // book data
        public override string ToString()
        {
            StringBuilder buffer = new StringBuilder();

            buffer.AppendLine($"ISBN: {ISBN}");
            buffer.AppendLine($"Title: {Title}");
            buffer.AppendLine($"Author: {Author}");
            buffer.AppendLine($"Publisher: {Publisher}");
            buffer.AppendLine($"Publication date: {PublicationDate.ToShortDateString()}");
            return(buffer.ToString());
        }
예제 #13
0
        /// <summary>
        /// Показывает стрицу ria.ru в форме приложения.
        /// </summary>
        private void ShowPage()
        {
            var pageName  = PageList.GetItemText(PageList.SelectedItem);
            var pageModel = _reader.GetPage(pageName);

            try
            {
                CleaningWorkArea();

                Title.AppendText(pageModel.Title);
                PublicationDate.AppendText(pageModel.PublicationDate.ToString());
                LastChangeDate.AppendText(pageModel.LastChangeDate.ToString());
                TextPage.AppendText(pageModel.Text + Environment.NewLine);

                foreach (var textLink in pageModel.LinksInText)
                {
                    UrlList.Items.Add(textLink.Url);
                    DescriptionList.Items.Add(textLink.Description);
                }

                foreach (var imgBase64 in pageModel.ImagesInBase64)
                {
                    var byteArray    = Convert.FromBase64String(imgBase64);
                    var memoryStream = new MemoryStream(byteArray);
                    var newImage     = Image.FromStream(memoryStream);
                    _listImage.Add(newImage);
                }

                if (_listImage.Count > 1)
                {
                    ButtonNextPicture.Enabled     = true;
                    ButtonPreviousPicture.Enabled = false;

                    _numberPictures   = 0;
                    ImageInPage.Image = _listImage[_numberPictures];
                }
                else if (_listImage.Count == 1)
                {
                    _numberPictures   = 0;
                    ImageInPage.Image = _listImage[_numberPictures];
                }
                else
                {
                    var currentDirPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                    ImageInPage.Image =
                        Image.FromFile(Path.Combine(currentDirPath ?? string.Empty, "No images in page.png"));
                }
            }
            catch (Exception ex)
            {
                TextPage.Text = ex.Message;
            }
        }
예제 #14
0
 public override Data Convert()
 {
     return(new ComicData()
     {
         Title = Title,
         Description = Description,
         PublicationDate = PublicationDate.Split('/').ToInt().ToDate(),
         Pages = Int32.Parse(Pages),
         Category = ComicsContext.Instance.Categories.Where(x => x.Name.ToUpper() == Category.ToUpper()).FirstOrDefault(),
         PublishingHouse = ComicsContext.Instance.PublishingHouses.Where(x => x.Name.ToUpper() == PublicationDate.ToUpper()).FirstOrDefault()
     });
 }
예제 #15
0
        public int CompareTo(object obj)
        {
            Post post = obj as Post;

            if (post != null)
            {
                return(PublicationDate.CompareTo(post.PublicationDate));
            }
            else
            {
                throw new Exception("Невозможно сравнить два объекта");
            }
        }
        public virtual NewsPost PassToNewsPost(NewsPost newsPost = null)
        {
            newsPost             = newsPost ?? new NewsPost();
            newsPost.Name        = Name;
            newsPost.Description = Description;
            newsPost.CreatedDate = DateTime.Now.ToUniversalTime();
            newsPost.EditDate    = null;
            newsPost.ImageId     = ImageId;
            newsPost.AuthorId    = AuthorId;
            newsPost.IsVisible   = IsVisible;

            newsPost.PublicationDate = PublicationDate?.AddMinutes(MinutesOffset ?? 0) ?? DateTime.Now.ToUniversalTime();
            return(newsPost);
        }
예제 #17
0
        public override string ToString()
        {
            string shortReturnDate;

            if (ReturnDate.HasValue)
            {
                shortReturnDate = ReturnDate.Value.ToShortDateString();
            }
            else
            {
                shortReturnDate = "";
            }
            return(String.Format("|{0,-3}|{1,-15}|{2,-15}|{3,-15}|{4,-15}|{5,-15}|{6,-5}|{7,-8}|{8, -12}|",
                                 Id, Name, Author, Category, Language, PublicationDate.ToShortDateString(), ISBN, TakenBy, shortReturnDate));
        }
예제 #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string PMID  = Request["PMID"];
            string MPID  = Request["MPID"];
            string PubID = Request["PubID"];

            PublicationDate pd = GetPubDate(PMID, MPID, PubID);
            Response.Write(pd.pubDate + Environment.NewLine);
        }
        catch (Exception ex)
        {
            Response.Write("ERROR" + Environment.NewLine + ex.Message + Environment.NewLine);
        }
    }
예제 #19
0
        public void SaveRssDocument()
        {
            XmlTextWriter rssFeed = new XmlTextWriter(RSSFilePath, Encoding.UTF8);

            rssFeed.Formatting = Formatting.Indented;
            rssFeed.WriteStartDocument();
            rssFeed.WriteStartElement("rss");
            rssFeed.WriteAttributeString("version", "2.0");
            rssFeed.WriteStartElement("channel");
            rssFeed.WriteElementString("title", Title);
            rssFeed.WriteElementString("link", Link);
            rssFeed.WriteElementString("description", Description);
            rssFeed.WriteElementString("language", Language);
            rssFeed.WriteElementString("pubDate", PublicationDate.ToUniversalTime().ToString("r"));
            rssFeed.WriteElementString("Generator", Generator);
            rssFeed.WriteElementString("ttl", "1");

            foreach (InMemoryRSSDocumentLine line in (from l in Lines
                                                      where l.PubDate.AddDays(KeepEntriesDays) > DateTime.Now
                                                      orderby l.PubDate descending
                                                      select l))
            {
                rssFeed.WriteStartElement("item");
                rssFeed.WriteElementString("title", line.Title);
                rssFeed.WriteElementString("link", line.LineLink);
                rssFeed.WriteElementString("guid", line.GUID);
                rssFeed.WriteElementString("pubDate", line.PubDate.ToUniversalTime().ToString("r")); //ToString("yyyy MMM dd HH:mm:ss"));
                if (line.Category != null && line.Category.Length > 0)
                {
                    foreach (string category in line.Category.Split(','))
                    {
                        rssFeed.WriteElementString("category", category.Trim());
                    }
                }
                //rssFeed.WriteElementString("comments", line.Comments);
                rssFeed.WriteStartElement("description");
                rssFeed.WriteCData(line.Description);
                rssFeed.WriteEndElement();
                rssFeed.WriteEndElement();
            }

            rssFeed.WriteEndElement();
            rssFeed.WriteEndElement();
            rssFeed.WriteEndDocument();
            rssFeed.Flush();
            rssFeed.Close();
        }
예제 #20
0
        /// <summary>
        /// Очищает информацию во всех полях в форме приложения.
        /// </summary>
        private void CleaningWorkArea()
        {
            ImageInPage.Image = null;
            UrlList.Items.Clear();
            DescriptionList.Items.Clear();
            TextPage.Clear();
            Title.Clear();
            PublicationDate.Clear();
            LastChangeDate.Clear();

            foreach (var img in _listImage)
            {
                img.Dispose();
            }

            _listImage.Clear();
            ButtonNextPicture.Enabled     = false;
            ButtonPreviousPicture.Enabled = false;
        }
예제 #21
0
 public string GetPublicationDateByFormat(string format = "MM d, yyyy")
 {
     return(PublicationDate?.ToString(format) ?? string.Empty);
 }
예제 #22
0
        /// <summary>
        /// Create Xml node from this instance of AppCastItem
        /// </summary>
        /// <returns>An XML node</returns>
        public XElement GetXElement()
        {
            var item = new XElement(_itemNode);

            item.Add(new XElement(_titleNode)
            {
                Value = Title
            });

            if (!string.IsNullOrEmpty(ReleaseNotesLink))
            {
                var releaseNotes = new XElement(XMLAppCast.SparkleNamespace + _releaseNotesLinkNode)
                {
                    Value = ReleaseNotesLink
                };
                if (!string.IsNullOrEmpty(ReleaseNotesSignature))
                {
                    releaseNotes.Add(new XAttribute(XMLAppCast.SparkleNamespace + _signatureAttribute, ReleaseNotesSignature));
                }
                item.Add(releaseNotes);
            }

            if (!string.IsNullOrEmpty(Description))
            {
                item.Add(new XElement(_descriptionNode)
                {
                    Value = Description
                });
            }

            if (PublicationDate != DateTime.MinValue && PublicationDate != DateTime.MaxValue)
            {
                item.Add(new XElement(_pubDateNode)
                {
                    Value = PublicationDate.ToString("ddd, dd MMM yyyy HH:mm:ss zzz", System.Globalization.CultureInfo.InvariantCulture)
                });
            }

            if (!string.IsNullOrEmpty(DownloadLink))
            {
                var enclosure = new XElement(_enclosureNode);
                enclosure.Add(new XAttribute(_urlAttribute, DownloadLink));
                enclosure.Add(new XAttribute(XMLAppCast.SparkleNamespace + _versionAttribute, Version));

                if (!string.IsNullOrEmpty(ShortVersion))
                {
                    enclosure.Add(new XAttribute(XMLAppCast.SparkleNamespace + _shortVersionAttribute, ShortVersion));
                }

                enclosure.Add(new XAttribute(_lengthAttribute, UpdateSize));
                enclosure.Add(new XAttribute(XMLAppCast.SparkleNamespace + _operatingSystemAttribute, OperatingSystemString ?? _defaultOperatingSystem));
                enclosure.Add(new XAttribute(_typeAttribute, MIMEType ?? _defaultType));

                if (!string.IsNullOrEmpty(DownloadSignature))
                {
                    enclosure.Add(new XAttribute(XMLAppCast.SparkleNamespace + _signatureAttribute, DownloadSignature));
                }
                item.Add(enclosure);
            }
            return(item);
        }
예제 #23
0
 public override string ToString()
 {
     if (Name != null && Author != null && Category != null && Language != null && PublicationDate != null && Isbn != null)
     {
         return(String.Format("{0,-14} | {1,-42} | {2,-20} | {3,-20} | {4,-3} | {5,-15}", Isbn, Name, Author, Category, Language, PublicationDate.ToString("dd/MM/yyyy")));
     }
     return(base.ToString());
 }
예제 #24
0
 public override string Info()
 {
     return($"Patent {Name} - {Author}, {PublicationDate.ToShortDateString()} {RegistrationNumber}");
 }
        //////////////////////////////////////////////////////////////////////////
        //Операции общего назначения

        private void EditField_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox textBox = (TextBox)sender;

            if (Name.Equals(textBox))
            {
                if (Name.Text.Length > 0)
                {
                    NameWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    NameWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (Surname.Equals(textBox))
            {
                if (Surname.Text.Length > 0)
                {
                    SurnameWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    SurnameWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (Patronymic.Equals(textBox))
            {
                if (Patronymic.Text.Length > 0)
                {
                    PatronymicWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    PatronymicWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (Password.Equals(textBox))
            {
                if (Password.Text.Length > 0)
                {
                    PasswordWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    PasswordWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (AuthorSurname.Equals(textBox))
            {
                if (AuthorSurname.Text.Length > 0)
                {
                    AuthorSurnameWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    AuthorSurnameWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (AuthorName.Equals(textBox))
            {
                if (AuthorName.Text.Length > 0)
                {
                    AuthorNameWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    AuthorNameWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (AuthorPatronymic.Equals(textBox))
            {
                if (AuthorPatronymic.Text.Length > 0)
                {
                    AuthorPatronymicWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    AuthorPatronymicWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (BookName.Equals(textBox))
            {
                if (BookName.Text.Length > 0)
                {
                    BookNameWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    BookNameWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (Publisher.Equals(textBox))
            {
                if (Publisher.Text.Length > 0)
                {
                    PublisherWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    PublisherWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (PublicationDate.Equals(textBox))
            {
                if (PublicationDate.Text.Length > 0)
                {
                    PublicationDateWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    PublicationDateWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (PageCount.Equals(textBox))
            {
                if (PageCount.Text.Length > 0)
                {
                    PageCountWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    PageCountWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (Location.Equals(textBox))
            {
                if (Location.Text.Length > 0)
                {
                    LocationWatermark.Visibility = Visibility.Hidden;
                }
                else
                {
                    LocationWatermark.Visibility = Visibility.Visible;
                }
            }
            else if (Search.Equals(textBox))
            {
                SearchUpdate();
            }
        }