Exemplo n.º 1
0
        public IList <Published> getPublishedInf(string lx)
        {
            string SQL_getTableInf = "";

            if (lx == "11")
            {
                SQL_getTableInf = "select M_Area.AreaID,M_Area.ParentID,M_Area.AreaName,ISNULL(M_Area.ChildNum,'0')   from M_Area where  ParentID='-1' or ParentID='1' or ParentID='2'  or ParentID='3' or ParentID='4'";
            }
            else
            {
                SQL_getTableInf = "";
            }
            SQL_getTableInf = "select M_Area.AreaID,M_Area.ParentID,M_Area.AreaName,ISNULL(M_Area.ChildNum,'0')   from M_Area where  ParentID='-1' or ParentID='1' or ParentID='2'  or ParentID='3' or ParentID='4'";

            IList <Published> PublishedInf = new List <Published>();

            using (SqlDataReader SqlData = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, SQL_getTableInf))
            {
                while (SqlData.Read())
                {
                    Published TableMsg = new Published(SqlData.GetInt32(0), SqlData.GetString(1), SqlData.GetString(2), SqlData.GetString(3));
                    PublishedInf.Add(TableMsg);
                }
            }
            return(PublishedInf);
        }
        public void Publish <T>(T item)
        {
            if (_connection == null || !_connection.IsOpen)
            {
                _connection = _factory.CreateConnection();
            }

            using (IModel channel = _connection.CreateModel())
            {
                channel.QueueDeclare(queue: queueName,
                                     durable: false,
                                     exclusive: false,
                                     autoDelete: false,
                                     arguments: null);

                var message = JsonConvert.SerializeObject(item);
                var body    = Encoding.UTF8.GetBytes(message);

                channel.BasicPublish(exchange: "",
                                     routingKey: queueName,
                                     basicProperties: null,
                                     body: body);
                Published?.Invoke(this, new QueuePublisherEventArgs(message));
            }
        }
Exemplo n.º 3
0
        public Dictionary <string, string> GetExtendedProperties()
        {
            Dictionary <string, string> properties = new Dictionary <string, string>();

            properties.Add("Date", Published != DateTime.MinValue ? Published.ToShortDateString() : "N/A");
            return(properties);
        }
Exemplo n.º 4
0
 private static void LoadCatalog()
 {
     // load epub
     foreach (var lang in Directory.GetDirectories("epubs"))
     {
         if (lang.StartsWith("."))
         {
             continue;
         }
         Console.WriteLine(" - Load EPubs from language " + lang);
         var locale = Path.GetFileName(lang);
         // put all books in the first categorie of the suitable language
         foreach (var file in Directory.GetFiles(lang, "*.epub"))
         {
             string   coverPath = Path.Combine(lang, Path.GetFileNameWithoutExtension(file) + ".jpg");
             byte[]   content   = File.ReadAllBytes(file);
             EpubBook book      = EBookFactory.Create(content);
             book.CoverImage       = File.Exists(coverPath) ? File.ReadAllBytes(coverPath) : null;
             book.CoverDescription = String.Format("{0} of {1} published at {2}",
                                                   book.PackageData.MetaData.Title,
                                                   book.PackageData.MetaData.Creator,
                                                   book.PackageData.MetaData.Publisher);
             Console.WriteLine(" - EPub done " + file);
             // the published book simulates a book as it were written be an author, based on the uploaded EPUB
             Published p = new Published();
             SpineParser(book, p);
             WriteFragments(p, Path.GetFileNameWithoutExtension(file) + ".txt");
         } // epubs
     }     // epub
     Console.WriteLine(" - Done");
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Office,Year,BookId")] Published published)
        {
            if (id != published.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(published);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PublishedExists(published.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BookId"] = new SelectList(_context.Books, "Id", "Name", published.BookId);
            return(View(published));
        }
Exemplo n.º 6
0
        public XElement ToXElement()
        {
            XElement xElements = new XElement("xml");

            foreach (BorgerDkElement element in Elements)
            {
                xElements.Add(element.ToXElement());
            }

            XElement xArticle = new XElement(
                "article",
                new XElement("id", Id),
                new XElement("domain", Domain),
                new XElement("url", Url),
                new XElement("municipalityid", Municipality.Code),
                new XElement("lastreloaded", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")),
                new XElement("publishingdate", Published.ToString("yyyy-MM-dd HH:mm:ss")),
                new XElement("lastupdated", Modified.ToString("yyyy-MM-dd HH:mm:ss")),
                new XElement("title", Title),
                new XElement("header", Header),
                new XElement("html", new XCData(Content)),
                xElements
                );

            return(xArticle);
        }
        /// <summary>
        /// Call to fire event that updating the published content has finalized.
        /// </summary>
        /// <remarks>
        /// This seperation of the OnPublished event is done to ensure that the Content
        /// has been properly updated (committed unit of work) and xml saved in the db.
        /// </remarks>
        /// <param name="content"><see cref="IContent"/> thats being published</param>
        public override void PublishingFinalized(IContent content)
        {
            var evtMsgs = _eventMessagesFactory.Get();

            Published.RaiseEvent(
                new PublishEventArgs <IContent>(content, false, false, evtMsgs), this);
        }
        /// <summary>
        /// Call to fire event that updating the published content has finalized.
        /// </summary>
        /// <param name="content">An enumerable list of <see cref="IContent"/> thats being published</param>
        /// <param name="isAllRepublished">Boolean indicating whether its all content that is republished</param>
        public override void PublishingFinalized(IEnumerable <IContent> content, bool isAllRepublished)
        {
            var evtMsgs = _eventMessagesFactory.Get();

            Published.RaiseEvent(
                new PublishEventArgs <IContent>(content, false, isAllRepublished, evtMsgs), this);
        }
Exemplo n.º 9
0
        public bool Publishing <T>(DrawingsBase entity, Published published) where T : DrawingsBase
        {
            try
            {
                using (var carlzhu = BaseUtility.ContextFactory.ContextHelper)
                {
                    //将图纸状态改为已发行,并添加标识
                    var model = carlzhu.Set <T>().Single <T>(c => c.FormNo == entity.FormNo);
                    model.IsPublished          = true;
                    model.Identity             = published.Identity;
                    carlzhu.Entry(model).State = EntityState.Modified;
                    //published.CustomerNo = entity.CustomerNo;

                    //增加发行记录
                    carlzhu.Publisheds.Add(published);

                    return(carlzhu.SaveChanges() > 0);
                }
            }
            catch (Exception exception)
            {
                DbEntityValidationException ex = exception as DbEntityValidationException;

                if (ex != null)
                {
                    var    entityError      = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                    string exceptionMessage = string.Concat(ex.Message, "errors are: ", string.Join("; ", entityError));
                    Console.Write(exceptionMessage);
                }

                return(false);
            }
        }
 /// <summary>
 /// Liefert den Hashcode dieser Instanz.
 /// </summary>
 /// <returns>Der Hashcode dieser Instanz.</returns>
 public override int GetHashCode()
 {
     return(Articles.GetHashCode() ^ ArticleUrl.GetHashCode() ^ Author.GetHashCode() ^ ImageDescription.GetHashCode()
            ^ Image.GetHashCode() ^ Language.GetHashCode() ^ Published.GetHashCode()
            ^ SkipDays.GetHashCode() ^ SkipHours.GetHashCode() ^ TextInput.GetHashCode() ^ TimeToLive.GetHashCode()
            ^ Title.GetHashCode() ^ Updated.GetHashCode() ^ Version.GetHashCode() ^ WebMaster.GetHashCode());
 }
Exemplo n.º 11
0
        public void Convert(EpubBook book, Published p, PortalContext context)
        {
            Published = p;
            Context   = context;
            // 1. The spine is used to create one single document as a source
            var spineIds = book.PackageData.Spine.ItemRefs.Select(i => i.IdRef).ToList();
            // all elements
            var data = book.PackageData.Manifest.Items;
            // 2. Get the content elements only
            var content = data.Where(i => spineIds.Any(sid => sid == i.Identifier)).Select(i => i).ToList();
            // fragments form a hierarchy, beginning with <h1> on the first level
            FrozenFragment rootFragment = new FrozenFragment {
                Name           = book.PackageData.MetaData.Title.Text,
                ItemHref       = "Opus (Import)",
                Published      = p,
                TypeOfFragment = FragmentType.Meta,
                Children       = new List <FrozenFragment>()
            };

            switch (_method)
            {
            case Method.NcxToc:
            case Method.Html:
                // 3. Create source
                var complete = new StringBuilder();
                complete.AppendLine("<body>");
                foreach (var html in content)
                {
                    complete.AppendFormat(@"<a name=""{0}"" ></a>", html.Identifier);
                    complete.Append(GetBodyFromManifest(html.Data));
                }
                complete.AppendLine("</body>");
                // 5.
                HtmlDocument allHtml = new HtmlDocument();
                allHtml.OptionAutoCloseOnEnd = true;
                allHtml.OptionFixNestedTags  = true;
                allHtml.OptionOutputAsXml    = true;
                allHtml.LoadHtml(complete.ToString());
                var body = allHtml.DocumentNode.SelectSingleNode("//body");
                switch (_method)
                {
                case Method.NcxToc:
                    NcxParser(book, body, rootFragment);
                    break;

                case Method.Html:
                    var htmlConverter = new HtmlToFrozenFragments();
                    htmlConverter.Convert(body.InnerHtml, data);
                    break;
                }
                break;

            case Method.Spine:
                SpineParser(content, rootFragment, data);
                break;
            }
            //Context.SaveChanges();
        }
Exemplo n.º 12
0
        internal static void OnPublished(DomainEventArgs args)
        {
            if (Published == null)
            {
                throw new NotImplementedException("No one has subscribed to this event.");
            }

            Published.Invoke(null, args);
        }
Exemplo n.º 13
0
 public bool PdfView(Guid publishKey, string md5)
 {
     using (var context = BaseUtility.ContextFactory.ContextHelper)
     {
         Published published = context.Publisheds.Find(publishKey);
         published.Visit = published.Visit + 1;
         return(context.SaveChanges() > 0);
     }
 }
Exemplo n.º 14
0
        private void OnNotificationPublished(object sender, INotification notification)
        {
            // Add this facade to the notification to find it on restore
            var managed = (IManagedNotification)notification;

            managed.Source = Name;

            Published?.Invoke(this, notification);
        }
        public void QueuePublishedEvent(Published @event)
        {
            if (@event == null)
            {
                throw new ArgumentNullException(nameof(@event));
            }

            _publishedItems.Enqueue(@event);
            _publishedSignal.Release();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Slugs the specified title.
        /// </summary>
        /// <returns>A properly slugged title.</returns>
        private string SlugTitle()
        {
            string title = Title;

            title = HttpUtility.HtmlDecode(title.ToLower().Trim());
            title = new string(title.Where(c => !char.IsPunctuation(c) || char.IsSeparator(c)).ToArray());
            title = title.Replace(' ', '-');

            return(string.Format("{0}-{1}", Published.ToString("yyyy-MM-dd"), title));
        }
Exemplo n.º 17
0
        public void Publish(string news)
        {
            if (Published != null)
            {
                Published.Invoke(this, news);
            }

            // In C# 6.0 posso usare l'operatore Elvis sui metodi.
            // per fare i check sui null:
            // Published?.Invoke(this, news);
        }
        public async Task <IActionResult> Create(int BookId, [Bind("Id,Office,Year,BookId")] Published published)
        {
            published.BookId = BookId;
            if (ModelState.IsValid)
            {
                _context.Add(published);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Publisheds", new { id = BookId }));
            }
            return(RedirectToAction("Index", "Publisheds", new { id = BookId }));
        }
Exemplo n.º 19
0
 public ActionResult StAnswers(int? chann, int? publish)
 {
     if (Session["type"] == null)
     {
         log.Error("Session missing");
         return RedirectToAction("Login", "Account");
     }
     if (Session["type"].ToString() != "Professor")
     {
         log.Error("wrong user type");
         return RedirectToAction("Logout", "Account");
     }
     if ((chann == null) || (publish == null))
     {
         log.Error("parameters are missing");
         return RedirectToAction("Logout", "Account");
     }
     var channels = from m in db.Channels select m;
     channels = channels.Where(s => s.IdC == chann);
     string email = Session["email"].ToString();
     var users = from m in db.Users select m;
     users = users.Where(s => s.Mail.Equals(email));
     if (users.Any() && channels.Any())
     {
         User user = users.First();
         Channel channel = channels.First();
         if (channel.OpenTime == null)
         {
             log.Error("channel " + channel.Name + " not opened");
             return RedirectToAction("Logout", "Account");
         }
         if (channel.IdU != user.IdU)
         {
             log.Error("user and channel not combinable");
             return RedirectToAction("Logout", "Account");
         }
         var published = from m in db.Publisheds select m;
         published = published.Where(s => s.IdC == chann);
         published = published.Where(s => s.IdPub == publish);
         ViewBag.chann = channel.IdC;
         if (published.Any())
         {
             Published pub = published.First();
             var responses = from m in db.Responses select m;
             responses = responses.Where(s => s.IdP == pub.IdP);
             responses = responses.Where(s => s.IdC == channel.IdC);
             return View(responses);
         }
     }
     log.Error("user or channel or published missing in database");
     return RedirectToAction("Logout", "Account");
 }
Exemplo n.º 20
0
 public PostDisplay(Post post)
 {
     Published          = post.Published.GetValueOrDefault(DateTime.MinValue);
     LocalPublishedDate = Published.ToLongDateString(); //TODO: To local time
     Slug          = post.Slug;
     Comments      = post.GetComments().OrderBy(c => c.Published).Select(c => new CommentDisplay(c));
     CommentsCount = post.GetComments().Count();
     Title         = post.Title;
     Body          = post.Body;
     Tags          = post.GetTags().OrderByDescending(t => t.CreatedDate).Select(t => new TagDisplay(t)); //TODO: this (OrderByDescending) is business logic and needs to be moved outta here most likely
     User          = post.User;
     DateValue     = Convert.ToInt32((Published.Day + Published.Month + Published.Hour) * Published.Minute);
 }
Exemplo n.º 21
0
            public async Task <ResponseResult> Handle(Published request, CancellationToken cancellationToken)
            {
                using (var scope = _databaseScopeFactory.CreateWithTransaction())
                {
                    await _materialRepository.PublishedAsync(
                        request.Ids,
                        string.IsNullOrWhiteSpace(request.UserId)?null : request.UserId);

                    scope.SaveChanges();
                }

                return(ResponseResult.Ok());
            }
        public async Task Publish(string eventName, IIntegrationEvent @event, string replyTo = null, string correlationId = null)
        {
            if (!string.IsNullOrEmpty(replyTo) && correlationId == null)
            {
                throw new ArgumentNullException(nameof(correlationId));
            }

            var json  = JsonConvert.SerializeObject(@event, _options.JsonSettings);
            var entry = Published.CreateEventLog(@event.Id, eventName, json, correlationId, replyTo);
            await _publishedStore.AddAsync(entry);

            _pendings = _pendings ?? new List <Published>();
            _pendings.Add(entry);
        }
Exemplo n.º 23
0
        internal virtual void OnShowHexValuesChanged(ModelPropertyChangedEventArgs e)
        {
            foreach (var trigger in Triggers)
            {
                foreach (var group in trigger.Groups)
                {
                    group.OnShowHexValuesChanged(e);
                }
            }

            Generated.OnShowHexValuesChanged(e);
            Local.OnShowHexValuesChanged(e);
            Published.OnShowHexValuesChanged(e);
        }
Exemplo n.º 24
0
        public void UnpublishWebservice()
        {
            const string address = "/mylalala";

            using var app = new Application();
            LaraUI.Publish(new WebServiceContent
            {
                Address = address,
                Factory = () => new MyWebService()
            });
            LaraUI.UnPublish("/mylalala", "POST");
            var combined = Published.CombinePathMethod(address, "POST");

            Assert.False(app.TryGetNode(combined, out _));
        }
Exemplo n.º 25
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     unchecked {
         int hashCode = (Code != null ? Code.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Existed.GetHashCode();
         hashCode = (hashCode * 397) ^ (Text != null ? Text.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ LastWriteTime.GetHashCode();
         hashCode = (hashCode * 397) ^ (Owner != null ? Owner.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Editor != null ? Editor.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Version != null ? Version.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Published.GetHashCode();
         hashCode = (hashCode * 397) ^ (Locker != null ? Locker.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemplo n.º 26
0
        public void UnpublishMethod()
        {
            var service = new Mock <IWebService>();

            using var x = new Published();
            x.Publish(new WebServiceContent
            {
                Address = "/myws",
                Method  = "PUT",
                Factory = () => service.Object
            });
            var combined = Published.CombinePathMethod("/myws", "PUT");

            Assert.True(x.TryGetNode(combined, out _));
            x.UnPublish("/myws", "PUT");
            Assert.False(x.TryGetNode(combined, out _));
        }
Exemplo n.º 27
0
        private static void WriteFragments(Published p, string fileName)
        {
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            var sb = new StringBuilder();

            WriteFragment(sb, p.FrozenFragments, 0);
            StreamWriter fs = null;

            try {
                fs = File.CreateText(fileName);
                fs.Write(sb.ToString());
            } finally {
                fs.Close();
                fs.Dispose();
            }
        }
Exemplo n.º 28
0
        public void PublishAssembliesBinaryService()
        {
            const string address = "/mydummy2";

            using var app = new Application();
            app.PublishService(new BinaryServiceContent
            {
                Address = address,
                Method  = "POST",
                Factory = () => new DummyBinaryWs()
            });
            var combined = Published.CombinePathMethod(address, "POST");
            var found    = app.TryGetNode(combined, out var item);

            Assert.True(found);
            var service = item as BinaryServicePublished;

            Assert.NotNull(service);
            Assert.NotNull(service !.Factory());
        }
Exemplo n.º 29
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteElementString("title", Title);
     writer.WriteElementString("link", AbsoluteUrl);
     writer.WriteElementString("encoded", Rss.NS_CONTENT, Content);
     //writer.WriteElementString("thread_identified", Rss.NS_DSQ, ThreadIdentified);
     writer.WriteElementString("thread_identified", Rss.NS_DSQ, "");
     writer.WriteElementString("post_date_gmt", Rss.NS_WP, Published.ToString(Rss.DISQUS_DATE_FORMAT));
     writer.WriteElementString("comment_status", Rss.NS_WP, Status);
     if (Comments != null)
     {
         XmlSerializer serializer = new XmlSerializer(typeof(Comment));
         var           xmlnsEmpty = new XmlSerializerNamespaces();
         xmlnsEmpty.Add("", "");
         foreach (var comment in Comments)
         {
             serializer.Serialize(writer, comment, xmlnsEmpty);
         }
     }
 }
Exemplo n.º 30
0
 public void WriteXml(XmlWriter writer)
 {
     //if (Author.Equals("Red Folder"))
     //{
     //    XmlSerializer serializer = new XmlSerializer(typeof(Remote));
     //    var xmlnsEmpty = new XmlSerializerNamespaces();
     //    xmlnsEmpty.Add("", "");
     //    serializer.Serialize(writer, Remote.RedFolder(), xmlnsEmpty);
     //}
     writer.WriteElementString("comment_id", Rss.NS_WP, Id);
     writer.WriteElementString("comment_author", Rss.NS_WP, Author);
     writer.WriteElementString("comment_author_email", Rss.NS_WP, AuthorEmail);
     writer.WriteElementString("comment_author_url", Rss.NS_WP, AuthorUrl);
     writer.WriteElementString("comment_author_IP", Rss.NS_WP, AuthorIP);
     writer.WriteElementString("comment_date_gmt", Rss.NS_WP, Published.ToString(Rss.DISQUS_DATE_FORMAT));
     writer.WriteStartElement("comment_content", Rss.NS_WP);
     writer.WriteCData(Content);
     writer.WriteEndElement();
     writer.WriteElementString("comment_approved", Rss.NS_WP, Approved ? "1": "0");
     writer.WriteElementString("comment_parent", Rss.NS_WP, ParentId);
 }