Пример #1
0
        public void TestMethod1()
        {
            var content2  = new Content();
            var languages = new List <ContentLanguage>();

            content2.ContentLanguages = languages;

            var lang1 = new ContentLanguage();

            languages.Add(lang1);

            var lockingLang1 = new Locking();
            var pubLang1     = new Publishing();

            lang1.Locking    = lockingLang1;
            lang1.Publishing = pubLang1;

            var iterator      = new ContentGraphIterator(content2);
            var iteratedItems = new List <object>();

            foreach (var item in iterator)
            {
                iteratedItems.Add(item);
            }

            Assert.IsTrue(iteratedItems.Contains(content2));
            Assert.IsTrue(iteratedItems.Contains(lang1));
            Assert.IsTrue(iteratedItems.Contains(lockingLang1));
            Assert.IsTrue(iteratedItems.Contains(pubLang1));
        }
Пример #2
0
        public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
        {
            using (var scope = new PnPMonitoredScope(this.Name))
            {
                if (web.IsFeatureActive(PUBLISHING_FEATURE_WEB))
                {
                    web.EnsureProperty(w => w.Language);
                    var webTemplates = web.GetAvailableWebTemplates(web.Language, false);
                    web.Context.Load(webTemplates, wts => wts.Include(wt => wt.Name, wt => wt.Lcid));
                    web.Context.ExecuteQueryRetry();
                    Publishing publishing = new Publishing();
                    publishing.AvailableWebTemplates.AddRange(webTemplates.AsEnumerable <WebTemplate>().Select(wt => new AvailableWebTemplate()
                    {
                        TemplateName = wt.Name, LanguageCode = (int)wt.Lcid
                    }));
                    publishing.AutoCheckRequirements = AutoCheckRequirementsOptions.MakeCompliant;
                    publishing.DesignPackage         = null;
                    publishing.PageLayouts.AddRange(GetAvailablePageLayouts(web));
                    template.Publishing = publishing;

                    ExtractMasterPagesAndPageLayouts(web, template, scope, creationInfo);
                }
            }
            return(template);
        }
Пример #3
0
        public ActionResult Update(Models.Publisher publisher)
        {
            Data.Publisher persistentPublisher = Mapper.Map<Models.Publisher, Data.Publisher>(publisher);
            Publishing.UpdatePublisher(persistentPublisher);

            return Content(JsonConvert.SerializeObject(Mapper.Map<Data.Publisher, Models.Publisher>(persistentPublisher)));
        }
Пример #4
0
        public bool Validate(Publishing source, Publishing target, ClientContext clientContext)
        {
            bool isAvailableWebTemplatesMatch = ValidateObjects(source.AvailableWebTemplates, target.AvailableWebTemplates, new List <string> {
                "LanguageCode", "TemplateName"
            });

            if (!isAvailableWebTemplatesMatch)
            {
                return(false);
            }

            bool isPageLayoutsMatch = ValidateObjects(source.PageLayouts, target.PageLayouts, new List <string> {
                "IsDefault", "Path"
            });

            if (!isPageLayoutsMatch)
            {
                return(false);
            }

            bool isValidDesignPackage = ValidateDesginPackage(source.DesignPackage, clientContext);

            if (!isValidDesignPackage)
            {
                return(false);
            }

            return(true);
        }
Пример #5
0
        void IEventWriter.OnEvent(byte[] data)
        {
            Publishing publising = new Publishing(url);
            AlertData  adata     = new AlertData();

            adata.Data = data;
            publising.OnEvent(adata);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Publishing publishing = db.Publishings.Find(id);

            db.Publishings.Remove(publishing);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #7
0
        public void Create(Publishing publishing)
        {
            var topicIds = publishing.Topics.Select(t => t.Id);

            publishing.Topics = context.Topics.Where(t => topicIds.Contains(t.Id)).ToList();

            context.Publishings.Add(publishing);
        }
Пример #8
0
 public void Dispose()
 {
     Apps.Dispose();
     Entities.Dispose();
     Examples.Dispose();
     Intents.Dispose();
     Publishing.Dispose();
     Versions.Dispose();
     Training.Dispose();
 }
 public ActionResult Edit([Bind(Include = "PublishingId,PublishingName")] Publishing publishing)
 {
     if (ModelState.IsValid)
     {
         db.Entry(publishing).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(publishing));
 }
        public ActionResult Create([Bind(Include = "PublishingId,PublishingName")] Publishing publishing)
        {
            if (ModelState.IsValid)
            {
                db.Publishings.Add(publishing);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(publishing));
        }
Пример #11
0
        public void UpdatePublishing(PublishingDTO publishing)
        {
            Publishing publishingEntity = mapper.Map <Publishing>(publishing);
            var        employees        = publishing.Journalists.Concat(publishing.Editors);

            publishingEntity.PublishingEmployees = employees
                                                   .Select(e => new PublishingEmployee {
                EmployeeId = e.Id, PublishingId = publishing.Id
            }).ToList();
            unitOfWork.Publishings.Update(publishingEntity);
            unitOfWork.Save();
        }
        public bool Validate(Publishing source, Publishing target, ClientContext clientContext)
        {
            bool isAvailableWebTemplatesMatch = ValidateObjects(source.AvailableWebTemplates, target.AvailableWebTemplates, new List<string> { "LanguageCode", "TemplateName" });
            if (!isAvailableWebTemplatesMatch) { return false; }

            bool isPageLayoutsMatch = ValidateObjects(source.PageLayouts, target.PageLayouts, new List<string> { "IsDefault", "Path" });
            if (!isPageLayoutsMatch) { return false; }

            bool isValidDesignPackage = ValidateDesginPackage(source.DesignPackage, clientContext);
            if (!isValidDesignPackage) return false;

            return true;
        }
Пример #13
0
        public void OnPublish(int flag)
        {
            //initialize the splash screen and set it as the application main window
            var splashScreen  = new Publishing();
            var currentWindow = this.MainWindow;

            this.MainWindow = splashScreen;
            splashScreen.Show();

            //in order to ensure the UI stays responsive, we need to
            //do the work on a different thread
            Task.Factory.StartNew(() =>
            {
                //we need to do the work in batches so that we can report progress
                for (int i = 1; i <= 100; i++)
                {
                    //simulate a part of work being done
                    System.Threading.Thread.Sleep(10);

                    //because we're not on the UI thread, we need to use the Dispatcher
                    //associated with the splash screen to update the progress bar
                    splashScreen.Dispatcher.Invoke(() => splashScreen.Progress = i);
                }

                //once we're done we need to use the Dispatcher
                //to create and show the main window
                this.Dispatcher.Invoke(() =>
                {
                    //initialize the main window, set it as the application main window
                    //and close the splash screen
                    //var mainWindow = new MainWindow();
                    //this.MainWindow = mainWindow;
                    this.MainWindow = currentWindow;
                    currentWindow.Show();

                    //  mainWindow.Show();

                    splashScreen.Close();

                    if (flag == 1)
                    {
                        MessageBox.Show("File has been Published Successfully!!");
                    }
                    else
                    {
                        MessageBox.Show("Error Occurred while Publishing the File!!");
                    }
                });
            });
        }
        // GET: Publishings/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Publishing publishing = db.Publishings.Find(id);

            if (publishing == null)
            {
                return(HttpNotFound());
            }
            return(View(publishing));
        }
Пример #15
0
 public bool Edit(Publishing publishing)
 {
     if (validation.Validate(publishing).Count > 0)
     {
         foreach (var res in validation.Validate(publishing))
         {
             if (res.IsValidate)
             {
                 logger.Error(res.ValidationMessage.ToString());
             }
         }
     }
     return(publishingDao.Edit(publishing));
 }
Пример #16
0
        /// <summary>
        /// Publishes a list of Content
        /// </summary>
        /// <param name="content">An enumerable list of <see cref="IContent"/></param>
        /// <param name="userId">Id of the User issueing the publish operation</param>
        /// <returns>True if the publish operation was successfull and not cancelled, otherwise false</returns>
        public override bool PublishWithChildren(IEnumerable <IContent> content, int userId)
        {
            /* Only update content thats not already been published - we want to loop through
             * all unpublished content to write skipped content (expired and awaiting release) to log.
             */
            foreach (var item in content.Where(x => x.Published == false))
            {
                //Fire Publishing event
                if (Publishing.IsRaisedEventCancelled(new PublishEventArgs <IContent>(item), this))
                {
                    return(false);
                }

                //Check if the Content is Expired to verify that it can in fact be published
                if (item.Status == ContentStatus.Expired)
                {
                    LogHelper.Info <PublishingStrategy>(
                        string.Format("Content '{0}' with Id '{1}' has expired and could not be published.",
                                      item.Name, item.Id));
                    continue;
                }

                //Check if the Content is Awaiting Release to verify that it can in fact be published
                if (item.Status == ContentStatus.AwaitingRelease)
                {
                    LogHelper.Info <PublishingStrategy>(
                        string.Format("Content '{0}' with Id '{1}' is awaiting release and could not be published.",
                                      item.Name, item.Id));
                    continue;
                }

                //Check if the Content is Trashed to verify that it can in fact be published
                if (item.Status == ContentStatus.Trashed)
                {
                    LogHelper.Info <PublishingStrategy>(
                        string.Format("Content '{0}' with Id '{1}' is trashed and could not be published.",
                                      item.Name, item.Id));
                    continue;
                }

                item.ChangePublishedState(PublishedState.Published);

                LogHelper.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' has been published.",
                                  item.Name, item.Id));
            }

            return(true);
        }
Пример #17
0
        private async Task <Publishing> GetData()
        {
            var data = new Publishing();
            HttpResponseMessage resp = _httpClient.GetAsync("xml").Result;

            if (resp.IsSuccessStatusCode)
            {
                XmlSerializer xmls           = new XmlSerializer(typeof(Publishing));
                var           responseString = await resp.Content.ReadAsStringAsync();

                data = (Publishing)xmls.Deserialize(new StringReader(responseString));
            }

            return(data);
        }
        public List <ValidationResult> Validate(Publishing publishing)
        {
            List <ValidationResult> results = new List <ValidationResult>();

            if (publishing == null)
            {
                results.Add(new ValidationResult(true, new ArgumentNullException(nameof(publishing)).Message.ToString()));
            }

            if (string.IsNullOrWhiteSpace(publishing.Name))
            {
                results.Add(new ValidationResult(true, new ArgumentException("Name").Message.ToString()));
            }

            return(results);
        }
        /// <summary>
        /// Publishes a single piece of Content
        /// </summary>
        /// <param name="content"><see cref="IContent"/> to publish</param>
        /// <param name="userId">Id of the User issueing the publish operation</param>
        internal Attempt <PublishStatus> PublishInternal(IContent content, int userId)
        {
            var evtMsgs = _eventMessagesFactory.Get();

            if (Publishing.IsRaisedEventCancelled(
                    new PublishEventArgs <IContent>(content, evtMsgs), this))
            {
                _logger.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' will not be published, the event was cancelled.", content.Name, content.Id));
                return(Attempt <PublishStatus> .Fail(new PublishStatus(content, PublishStatusType.FailedCancelledByEvent, evtMsgs)));
            }

            //Check if the Content is Expired to verify that it can in fact be published
            if (content.Status == ContentStatus.Expired)
            {
                _logger.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' has expired and could not be published.",
                                  content.Name, content.Id));
                return(Attempt <PublishStatus> .Fail(new PublishStatus(content, PublishStatusType.FailedHasExpired, evtMsgs)));
            }

            //Check if the Content is Awaiting Release to verify that it can in fact be published
            if (content.Status == ContentStatus.AwaitingRelease)
            {
                _logger.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' is awaiting release and could not be published.",
                                  content.Name, content.Id));
                return(Attempt <PublishStatus> .Fail(new PublishStatus(content, PublishStatusType.FailedAwaitingRelease, evtMsgs)));
            }

            //Check if the Content is Trashed to verify that it can in fact be published
            if (content.Status == ContentStatus.Trashed)
            {
                _logger.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' is trashed and could not be published.",
                                  content.Name, content.Id));
                return(Attempt <PublishStatus> .Fail(new PublishStatus(content, PublishStatusType.FailedIsTrashed, evtMsgs)));
            }

            content.ChangePublishedState(PublishedState.Published);

            _logger.Info <PublishingStrategy>(
                string.Format("Content '{0}' with Id '{1}' has been published.",
                              content.Name, content.Id));

            return(Attempt.Succeed(new PublishStatus(content, evtMsgs)));
        }
Пример #20
0
        /// <summary>
        /// Publishes a single piece of Content
        /// </summary>
        /// <param name="content"><see cref="IContent"/> to publish</param>
        /// <param name="userId">Id of the User issueing the publish operation</param>
        internal Attempt <PublishStatus> PublishInternal(IContent content, int userId)
        {
            if (Publishing.IsRaisedEventCancelled(new PublishEventArgs <IContent>(content), this))
            {
                LogHelper.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' will not be published, the event was cancelled.", content.Name, content.Id));
                return(new Attempt <PublishStatus>(false, new PublishStatus(content, PublishStatusType.FailedCancelledByEvent)));
            }


            //Check if the Content is Expired to verify that it can in fact be published
            if (content.Status == ContentStatus.Expired)
            {
                LogHelper.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' has expired and could not be published.",
                                  content.Name, content.Id));
                return(new Attempt <PublishStatus>(false, new PublishStatus(content, PublishStatusType.FailedHasExpired)));
            }

            //Check if the Content is Awaiting Release to verify that it can in fact be published
            if (content.Status == ContentStatus.AwaitingRelease)
            {
                LogHelper.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' is awaiting release and could not be published.",
                                  content.Name, content.Id));
                return(new Attempt <PublishStatus>(false, new PublishStatus(content, PublishStatusType.FailedAwaitingRelease)));
            }

            //Check if the Content is Trashed to verify that it can in fact be published
            if (content.Status == ContentStatus.Trashed)
            {
                LogHelper.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' is trashed and could not be published.",
                                  content.Name, content.Id));
                return(new Attempt <PublishStatus>(false, new PublishStatus(content, PublishStatusType.FailedIsTrashed)));
            }

            content.ChangePublishedState(PublishedState.Published);

            LogHelper.Info <PublishingStrategy>(
                string.Format("Content '{0}' with Id '{1}' has been published.",
                              content.Name, content.Id));

            return(new Attempt <PublishStatus>(true, new PublishStatus(content)));
        }
Пример #21
0
        private List <NewsData> TransformToNewsData(Publishing publishings)
        {
            var data = new List <NewsData>();

            foreach (var story in publishings.Stories.Story)
            {
                data.Add(new NewsData()
                {
                    AddedDateTime = DateTime.Now,
                    ImagePath     = story.Image,
                    NewsStory     = story.NewstoryText,
                    SupplierName  = _supplier,
                    Title         = story.Title
                });
            }

            return(data);
        }
Пример #22
0
        /// <summary>
        /// Publishes a single piece of Content
        /// </summary>
        /// <param name="content"><see cref="IContent"/> to publish</param>
        /// <param name="userId">Id of the User issueing the publish operation</param>
        /// <returns>True if the publish operation was successfull and not cancelled, otherwise false</returns>
        public override bool Publish(IContent content, int userId)
        {
            if (Publishing.IsRaisedEventCancelled(new PublishEventArgs <IContent>(content), this))
            {
                return(false);
            }

            //Check if the Content is Expired to verify that it can in fact be published
            if (content.Status == ContentStatus.Expired)
            {
                LogHelper.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' has expired and could not be published.",
                                  content.Name, content.Id));
                return(false);
            }

            //Check if the Content is Awaiting Release to verify that it can in fact be published
            if (content.Status == ContentStatus.AwaitingRelease)
            {
                LogHelper.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' is awaiting release and could not be published.",
                                  content.Name, content.Id));
                return(false);
            }

            //Check if the Content is Trashed to verify that it can in fact be published
            if (content.Status == ContentStatus.Trashed)
            {
                LogHelper.Info <PublishingStrategy>(
                    string.Format("Content '{0}' with Id '{1}' is trashed and could not be published.",
                                  content.Name, content.Id));
                return(false);
            }

            content.ChangePublishedState(PublishedState.Published);

            LogHelper.Info <PublishingStrategy>(
                string.Format("Content '{0}' with Id '{1}' has been published.",
                              content.Name, content.Id));

            return(true);
        }
Пример #23
0
 public override ProvisioningTemplate ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
 {
     using (var scope = new PnPMonitoredScope(this.Name))
     {
         if (web.IsFeatureActive(PUBLISHING_FEATURE_WEB))
         {
             web.EnsureProperty(w => w.Language);
             var webTemplates = web.GetAvailableWebTemplates(web.Language, false);
             web.Context.Load(webTemplates, wts => wts.Include(wt => wt.Name, wt => wt.Lcid));
             web.Context.ExecuteQueryRetry();
             Publishing publishing = new Publishing();
             publishing.AvailableWebTemplates.AddRange(webTemplates.AsEnumerable<WebTemplate>().Select(wt => new AvailableWebTemplate() { TemplateName = wt.Name, LanguageCode = (int)wt.Lcid }));
             publishing.AutoCheckRequirements = AutoCheckRequirementsOptions.MakeCompliant;
             publishing.DesignPackage = null;
             publishing.PageLayouts.AddRange(GetAvailablePageLayouts(web));
             template.Publishing = publishing;
         }
     }
     return template;
 }
Пример #24
0
        public void Update(Publishing modifyPublishing)
        {
            Publishing publishingToUpdate = context.Publishings
                                            .Include(p => p.PublishingEmployees)
                                            .Include(p => p.Topics)
                                            .FirstOrDefault(x => x.Id == modifyPublishing.Id);

            if (publishingToUpdate == null)
            {
                throw new Exception($"Publishing with Id '{modifyPublishing.Id}' not found");
            }

            publishingToUpdate.Title               = modifyPublishing.Title;
            publishingToUpdate.Type                = modifyPublishing.Type;
            publishingToUpdate.Subjects            = modifyPublishing.Subjects;
            publishingToUpdate.PublishingEmployees = modifyPublishing.PublishingEmployees;

            var topicIds = modifyPublishing.Topics.Select(t => t.Id);

            publishingToUpdate.Topics = context.Topics.Where(t => topicIds.Contains(t.Id)).ToList();
        }
Пример #25
0
 public bool Edit(Publishing publishing)
 {
     try
     {
         using (var con = new SqlConnection(config.ConnectionString))
         {
             using (var cmnd = new SqlCommand("publishing_edite", con))
             {
                 cmnd.CommandType = CommandType.StoredProcedure;
                 cmnd.Parameters.AddWithValue("@name", publishing.Name);
                 cmnd.Parameters.AddWithValue("@id", publishing.Id);
                 con.Open();
                 cmnd.ExecuteNonQuery();
                 return(true);
             }
         }
     }
     catch
     {
         return(false);
     }
 }
Пример #26
0
        public bool Add(Publishing publishing)
        {
            if (publishing == null)
            {
                throw new ArgumentNullException();
            }

            if (publishing.Name == null || publishing.Name.Length > 300)
            {
                throw new ArgumentException("Publishing Name");
            }

            try
            {
                using (var con = new SqlConnection(config.ConnectionString))
                {
                    using (var cmnd = new SqlCommand("publishing_add", con))
                    {
                        cmnd.CommandType = CommandType.StoredProcedure;
                        cmnd.Parameters.AddWithValue("@name", publishing.Name);
                        cmnd.Parameters.Add("@id", SqlDbType.Int, 4);
                        cmnd.Parameters["@id"].Direction = ParameterDirection.Output;
                        con.Open();
                        cmnd.ExecuteNonQuery();
                        int?id = cmnd.Parameters["@id"].Value as int?;
                        if (id != null)
                        {
                            publishing.Id = (int)cmnd.Parameters["@id"].Value;
                        }
                        return(true);
                    }
                }
            }
            catch
            {
                return(false);
            }
        }
Пример #27
0
        public ICollection <Publishing> GetAll()
        {
            using (var con = new SqlConnection(config.ConnectionString))
            {
                using (var cmnd = new SqlCommand("publishing_get_all", con))
                {
                    cmnd.CommandType = CommandType.StoredProcedure;
                    con.Open();

                    using (var reader = cmnd.ExecuteReader())
                    {
                        var publishings = new List <Publishing>();
                        while (reader.Read())
                        {
                            var publishing = new Publishing();
                            publishing.Id   = (int)reader["id"];
                            publishing.Name = (string)reader["name"];
                            publishings.Add(publishing);
                        }
                        return(publishings);
                    }
                }
            }
        }
Пример #28
0
        public IActionResult Index()
        {
            string projectPath = Path.Combine(UsersHelper.GetUserFolder(), UsersHelper.GetToolsFolder());
            string command     = Request.Query["command"];
            string path        = HttpUtility.UrlDecode(Request.Query["path"]);

            if (!string.IsNullOrEmpty(command) && !string.IsNullOrEmpty(path))
            {
                string[] folders = path.Split('/', '\\');

                if (command == "create")
                {
                    if (folders.Length == 1)
                    {
                        CreateCategory(folders[0], projectPath);
                    }
                    else if (folders.Length == 2)
                    {
                        CreateProduct(folders[1], Path.Combine(projectPath, folders[0]));
                    }
                    else if (folders.Length == 3)
                    {
                        CreateScenario(folders[2], Path.Combine(projectPath, folders[0], folders[1]));
                    }
                }
                else if (command == "remove")
                {
                    if (folders.Length > 0 && folders.Length <= 3)
                    {
                        RemoveFolder(Path.Combine(projectPath, folders[0]));
                    }
                    else if (folders.Length == 4)
                    {
                        RemoveTopic(Path.Combine(projectPath, folders[0], folders[1], folders[2]), folders[3]);
                    }
                }
                else if (command == "draft")
                {
                    if (folders.Length == 3)
                    {
                        Publishing.Draft(Path.Combine(projectPath, path), (res) => { Content("result: " + res); });
                    }
                }
                else if (command == "publish")
                {
                    if (folders.Length == 3)
                    {
                        Publishing.Publish(Path.Combine(projectPath, path), (res) => { });

                        return(Ok());
                    }
                }
                else if (command == "edit")
                {
                    if (folders.Length > 0 && folders.Length <= 2)
                    {
                        string newName = Request.Query["name"];
                        if (!string.IsNullOrEmpty(newName))
                        {
                            EditInfo(Path.Combine(projectPath, path), newName);
                        }
                    }
                    else if (folders.Length == 3)
                    {
                        string newName = Request.Query["name"];
                        string newDesc = Request.Query["desc"];
                        if (!string.IsNullOrEmpty(newName) || !string.IsNullOrEmpty(newDesc))
                        {
                            EditInfo(Path.Combine(projectPath, path), newName, newDesc);
                        }
                    }
                    else if (folders.Length == 4)
                    {
                        string to        = Request.Query["to"];
                        string topicPath = path.Replace(folders[3], "topics");
                        if (!string.IsNullOrEmpty(to))
                        {
                            EditTopicIndex(Path.Combine(projectPath, topicPath), folders[3], int.Parse(to));
                        }
                        else if (Request.Form.Files.Count > 0)
                        {
                            string newPathToZip = Path.Combine(projectPath,
                                                               path.Replace(folders[3],
                                                                            Path.Combine("default", "pub_in", Request.Form.Files[0].FileName)));
                            if (!IOFile.Exists(newPathToZip))
                            {
                                using (var fileStream = new FileStream(newPathToZip, FileMode.Create))
                                {
                                    Request.Form.Files[0].CopyTo(fileStream);
                                }

                                EditZipPath(Path.Combine(projectPath, topicPath, folders[3] + ".info"), newPathToZip);
                            }
                        }
                        else
                        {
                            return(Content("wrong data"));
                        }
                    }
                }
            }

            return(new StatusCodeResult(302));
        }
Пример #29
0
 public ActionResult Index()
 {
     return View(new Models.ModelWithController<IEnumerable<Models.Publisher>>
     {
         ClientController = "publisher-ctrl",
         Contents = Mapper.Map<IEnumerable<Data.Publisher>, IEnumerable<Models.Publisher>>(Publishing.GetAllPublishers())
     });
 }
Пример #30
0
        public async Task <ActionResult> EditPublishingPost([Bind(Include = "Id,Name,NameForDisplay,Image,Description")] Publishing publishing)
        {
            var result = await PublishingService.Edit(publishing);

            return(PartialView("_infoPartial", result));
        }
Пример #31
0
 public ActionResult Delete(long id)
 {
     Publishing.DeletePublisher(id);
     return Json(id);
 }
        /// <summary>
        /// Publishes a list of content items
        /// </summary>
        /// <param name="content"></param>
        /// <param name="userId"></param>
        /// <param name="includeUnpublishedDocuments">
        /// By default this is set to true which means that it will publish any content item in the list that is completely unpublished and
        /// not visible on the front-end. If set to false, this will only publish content that is live on the front-end but has new versions
        /// that have yet to be published.
        /// </param>
        /// <returns></returns>
        /// <remarks>
        ///
        /// This method becomes complex once we start to be able to cancel events or stop publishing a content item in any way because if a
        /// content item is not published then it's children shouldn't be published either. This rule will apply for the following conditions:
        /// * If a document fails to be published, do not proceed to publish it's children if:
        /// ** The document does not have a publish version
        /// ** The document does have a published version but the includeUnpublishedDocuments = false
        ///
        /// In order to do this, we will order the content by level and begin by publishing each item at that level, then proceed to the next
        /// level and so on. If we detect that the above rule applies when the document publishing is cancelled we'll add it to the list of
        /// parentsIdsCancelled so that it's children don't get published.
        ///
        /// Its important to note that all 'root' documents included in the list *will* be published regardless of the rules mentioned
        /// above (unless it is invalid)!! By 'root' documents we are referring to documents in the list with the minimum value for their 'level'.
        /// In most cases the 'root' documents will only be one document since under normal circumstance we only publish one document and
        /// its children. The reason we have to do this is because if a user is publishing a document and it's children, it is implied that
        /// the user definitely wants to publish it even if it has never been published before.
        ///
        /// </remarks>
        internal IEnumerable <Attempt <PublishStatus> > PublishWithChildrenInternal(
            IEnumerable <IContent> content, int userId, bool includeUnpublishedDocuments = true)
        {
            var statuses = new List <Attempt <PublishStatus> >();

            //a list of all document ids that had their publishing cancelled during these iterations.
            //this helps us apply the rule listed in the notes above by checking if a document's parent id
            //matches one in this list.
            var parentsIdsCancelled = new List <int>();

            //group by levels and iterate over the sorted ascending level.
            //TODO: This will cause all queries to execute, they will not be lazy but I'm not really sure being lazy actually made
            // much difference because we iterate over them all anyways?? Morten?
            // Because we're grouping I think this will execute all the queries anyways so need to fetch it all first.
            var fetchedContent = content.ToArray();

            var evtMsgs = _eventMessagesFactory.Get();

            //We're going to populate the statuses with all content that is already published because below we are only going to iterate over
            // content that is not published. We'll set the status to "AlreadyPublished"
            statuses.AddRange(fetchedContent.Where(x => x.Published)
                              .Select(x => Attempt.Succeed(new PublishStatus(x, PublishStatusType.SuccessAlreadyPublished, evtMsgs))));

            int?firstLevel = null;

            //group by level and iterate over each level (sorted ascending)
            var levelGroups = fetchedContent.GroupBy(x => x.Level);

            foreach (var level in levelGroups.OrderBy(x => x.Key))
            {
                //set the first level flag, used to ensure that all documents at the first level will
                //be published regardless of the rules mentioned in the remarks.
                if (!firstLevel.HasValue)
                {
                    firstLevel = level.Key;
                }

                /* Only update content thats not already been published - we want to loop through
                 * all unpublished content to write skipped content (expired and awaiting release) to log.
                 */
                foreach (var item in level.Where(x => x.Published == false))
                {
                    //Check if this item should be excluded because it's parent's publishing has failed/cancelled
                    if (parentsIdsCancelled.Contains(item.ParentId))
                    {
                        _logger.Info <PublishingStrategy>(
                            string.Format("Content '{0}' with Id '{1}' will not be published because it's parent's publishing action failed or was cancelled.", item.Name, item.Id));
                        //if this cannot be published, ensure that it's children can definitely not either!
                        parentsIdsCancelled.Add(item.Id);
                        continue;
                    }

                    //Check if this item has never been published (and that it is not at the root level)
                    if (item.Level != firstLevel && !includeUnpublishedDocuments && !item.HasPublishedVersion())
                    {
                        //this item does not have a published version and the flag is set to not include them
                        parentsIdsCancelled.Add(item.Id);
                        continue;
                    }

                    //Fire Publishing event
                    if (Publishing.IsRaisedEventCancelled(
                            new PublishEventArgs <IContent>(item, evtMsgs), this))
                    {
                        //the publishing has been cancelled.
                        _logger.Info <PublishingStrategy>(
                            string.Format("Content '{0}' with Id '{1}' will not be published, the event was cancelled.", item.Name, item.Id));
                        statuses.Add(Attempt.Fail(new PublishStatus(item, PublishStatusType.FailedCancelledByEvent, evtMsgs)));

                        //Does this document apply to our rule to cancel it's children being published?
                        CheckCancellingOfChildPublishing(item, parentsIdsCancelled, includeUnpublishedDocuments);

                        continue;
                    }

                    //Check if the content is valid if the flag is set to check
                    if (item.IsValid() == false)
                    {
                        _logger.Info <PublishingStrategy>(
                            string.Format("Content '{0}' with Id '{1}' will not be published because some of it's content is not passing validation rules.",
                                          item.Name, item.Id));
                        statuses.Add(Attempt.Fail(new PublishStatus(item, PublishStatusType.FailedContentInvalid, evtMsgs)));

                        //Does this document apply to our rule to cancel it's children being published?
                        CheckCancellingOfChildPublishing(item, parentsIdsCancelled, includeUnpublishedDocuments);

                        continue;
                    }

                    //Check if the Content is Expired to verify that it can in fact be published
                    if (item.Status == ContentStatus.Expired)
                    {
                        _logger.Info <PublishingStrategy>(
                            string.Format("Content '{0}' with Id '{1}' has expired and could not be published.",
                                          item.Name, item.Id));
                        statuses.Add(Attempt.Fail(new PublishStatus(item, PublishStatusType.FailedHasExpired, evtMsgs)));

                        //Does this document apply to our rule to cancel it's children being published?
                        CheckCancellingOfChildPublishing(item, parentsIdsCancelled, includeUnpublishedDocuments);

                        continue;
                    }

                    //Check if the Content is Awaiting Release to verify that it can in fact be published
                    if (item.Status == ContentStatus.AwaitingRelease)
                    {
                        _logger.Info <PublishingStrategy>(
                            string.Format("Content '{0}' with Id '{1}' is awaiting release and could not be published.",
                                          item.Name, item.Id));
                        statuses.Add(Attempt.Fail(new PublishStatus(item, PublishStatusType.FailedAwaitingRelease, evtMsgs)));

                        //Does this document apply to our rule to cancel it's children being published?
                        CheckCancellingOfChildPublishing(item, parentsIdsCancelled, includeUnpublishedDocuments);

                        continue;
                    }

                    //Check if the Content is Trashed to verify that it can in fact be published
                    if (item.Status == ContentStatus.Trashed)
                    {
                        _logger.Info <PublishingStrategy>(
                            string.Format("Content '{0}' with Id '{1}' is trashed and could not be published.",
                                          item.Name, item.Id));
                        statuses.Add(Attempt.Fail(new PublishStatus(item, PublishStatusType.FailedIsTrashed, evtMsgs)));

                        //Does this document apply to our rule to cancel it's children being published?
                        CheckCancellingOfChildPublishing(item, parentsIdsCancelled, includeUnpublishedDocuments);

                        continue;
                    }

                    item.ChangePublishedState(PublishedState.Published);

                    _logger.Info <PublishingStrategy>(
                        string.Format("Content '{0}' with Id '{1}' has been published.",
                                      item.Name, item.Id));

                    statuses.Add(Attempt.Succeed(new PublishStatus(item, evtMsgs)));
                }
            }

            return(statuses);
        }
Пример #33
0
 private void CloseHeartBeatToServer()
 {
     try
     {
         Publishing publishing = new Publishing("HeartBeat", "", false);
         ISubscription proxy = CreateProxy(publishing);
         proxy.UnSubscribe(currentMachineMac, "", "", "", "");
     }
     catch (System.ServiceModel.CommunicationException ex)
     {
         if (ex is EndpointNotFoundException)
         {
             MessageBox.Show("服务器连接不上", "服务器错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MessageBox.Show(ex.Message, "服务器错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     //currentMachineMac
 }
Пример #34
0
        private void PrintClient_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Login login = new Login();
            //login.loginEvent += new Login.loginDelegate(GetUser);
            //login.ShowDialog();
            //SconitWs.SecurityService securityService = new SconitWs.SecurityService();
            //if (!securityService.VerifyUserPassword(this.userName,this.password))
            //{
            //    return;
            //}

            //using (OleDbConnection conn = new OleDbConnection(connstr))
            //{
            //    conn.Open();
            //    OleDbCommand cmd = new OleDbCommand("select * from T_Config", conn);

            //    OleDbDataReader reader = cmd.ExecuteReader();
            //    while (reader.Read())
            //    {
            //        Publishing publishing = new Publishing(reader[5].ToString(), reader[1].ToString(), reader.GetBoolean(6));
            //        ISubscription proxy = CreateProxy(publishing);
            //        proxy.UnSubscribe(reader[6].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString());
            //    }
            //}
            foreach (var sub in noAutoPrintSubList)
            {
                //proxy.UnSubscribe(sub.GUID, sub.SubscribeType, sub.Flow, sub.Region, sub.UserName);
                Publishing publishing = new Publishing(sub.PrinterName, sub.SubscribeType, sub.IsAutoPrint);
                ISubscription proxy = CreateProxy(publishing);
                proxy.UnSubscribe(sub.GUID, sub.SubscribeType, sub.Flow, sub.Region, sub.UserName);
            }
            foreach (var sub in autoPrintSubList)
            {
                //proxy.UnSubscribe(sub.GUID, sub.SubscribeType, sub.Flow, sub.Region, sub.UserName);
                Publishing publishing = new Publishing(sub.PrinterName, sub.SubscribeType, sub.IsAutoPrint);
                ISubscription proxy = CreateProxy(publishing);
                proxy.UnSubscribe(sub.GUID, sub.SubscribeType, sub.Flow, sub.Region, sub.UserName);
            }

            this.CloseHeartBeatToServer();
        }
Пример #35
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            string subscribeType = ((KeyValuePair<string, string>)cmbSubType.SelectedItem).Key;
            string flow = tbFlow.Text.Trim();
            string region = tbRegion.Text.Trim();
            string userName = tbUserName.Text.Trim();
            string printerName = tbPrinterName.Text.Trim();
            string GUID = Guid.NewGuid() + currentMachineMac;
            Boolean isAutoPrint = ckIsAutoPrint.Checked;

            if (string.IsNullOrEmpty(flow) && string.IsNullOrEmpty(region) && string.IsNullOrEmpty(userName))
            {
                MessageBox.Show("请输入订阅条件。", "用户输入错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //try
            //{
            //    conn.Open();
            //    OleDbCommand cmd = new OleDbCommand("insert into T_Config(SubType,Flow,Region,PrinterName,Guid)values(" + subscribeType.ToString() + ",'" + flow + "','" + region + "','" + printerName + "','" + GUID + "')", conn);
            //    cmd.ExecuteNonQuery();
            //    cmd = new OleDbCommand("select max(id) from T_Config", conn);
            //    Id = (int)cmd.ExecuteScalar();
                
            //}
            //catch (Exception ex)
            //{
            //    logger = container.Resolve<ILogger>();
            //    logger.Error(ex.Message);
            //}
            if (autoPrintSubList.Any(o => o.SubscribeType == subscribeType && o.Flow == flow && o.Region == region
                && o.UserName == userName))
            {
                MessageBox.Show("该订阅条件已存在,请修改。", "用户输入错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            DataGridViewRow row = (DataGridViewRow)dgvSubscribed.Rows[0].Clone();
            row.Cells[0].Value = maxId++;
            row.Cells[1].Value = Utility.GetEnumDescription(typeof(DocumentsType), ((KeyValuePair<string, string>)cmbSubType.SelectedItem).Key); 
            row.Cells[2].Value = flow;
            row.Cells[3].Value = region;
            row.Cells[4].Value = userName;
            row.Cells[5].Value = printerName;
            row.Cells[6].Value = isAutoPrint;
            dgvSubscribed.Rows.Add(row);
            if (isAutoPrint)
            {
                autoPrintSubList.Add(new SubscriberData { SubscribeType = ((KeyValuePair<string, string>)cmbSubType.SelectedItem).Key, Flow = flow, Region = region, PrinterName = printerName, IsAutoPrint = isAutoPrint, GUID = GUID });
            }
            else
            {
                noAutoPrintSubList.Add(new SubscriberData { SubscribeType = ((KeyValuePair<string, string>)cmbSubType.SelectedItem).Key, Flow = flow, Region = region, PrinterName = printerName, IsAutoPrint = isAutoPrint, GUID = GUID });
            }
            Publishing publishing = new Publishing(printerName,((KeyValuePair<string, string>)cmbSubType.SelectedItem).Key, isAutoPrint);
            ISubscription proxy = CreateProxy(publishing);
            proxy.Subscribe(GUID, subscribeType, flow, region, userName);

            List<SubscriberData> subscriberList = new List<SubscriberData>();
            subscriberList.AddRange(autoPrintSubList);
            subscriberList.AddRange(noAutoPrintSubList);
            XmlSerializer xs = new XmlSerializer(typeof(List<SubscriberData>));

            Stream stream = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory + "SubInfo.xml", FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
            xs.Serialize(stream, subscriberList);
            stream.Close();

            this.cmbSubType.Text = "";
            this.tbFlow.Text = "";
            this.tbRegion.Text = "";
            this.tbUserName.Text = "";
            this.tbPrinterName.Text = "";
            
        }
Пример #36
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //using (OleDbConnection conn = new OleDbConnection(connstr))
            //{
            //    conn.Open();
            //    OleDbCommand cmd = new OleDbCommand("delete from T_Config where Id=" + this.dgvSubscribed.CurrentRow.Cells[0].Value, conn);
            //    int rowCount = cmd.ExecuteNonQuery();
            //}
            //this.dgvSubscribed.Rows.RemoveAt(this.dgvSubscribed.CurrentRow.Index);

            var sub = new SubscriberData();
            if ((bool)this.dgvSubscribed.CurrentRow.Cells[6].Value)
            {
                sub = autoPrintSubList.FirstOrDefault(o => o.SubscribeType == this.dgvSubscribed.CurrentRow.Cells[1].Value.ToString()
                    && o.Flow == this.dgvSubscribed.CurrentRow.Cells[2].Value.ToString()
                    && o.Region == this.dgvSubscribed.CurrentRow.Cells[3].Value.ToString());
                    //&& o.UserName == (this.dgvSubscribed.CurrentRow.Cells[4].Value == null ? string.Empty : this.dgvSubscribed.CurrentRow.Cells[4].Value.ToString()));
                autoPrintSubList.Remove(sub);
            }
            else
            {
                sub = noAutoPrintSubList.FirstOrDefault(o => o.SubscribeType == this.dgvSubscribed.CurrentRow.Cells[1].Value.ToString()
                    && o.Flow == this.dgvSubscribed.CurrentRow.Cells[2].Value.ToString()
                    && o.Region == this.dgvSubscribed.CurrentRow.Cells[3].Value.ToString());
                    //&& o.UserName == (this.dgvSubscribed.CurrentRow.Cells[4].Value == null ? string.Empty : this.dgvSubscribed.CurrentRow.Cells[4].Value.ToString()));
                noAutoPrintSubList.Remove(sub);
            }
            this.dgvSubscribed.Rows.RemoveAt(this.dgvSubscribed.CurrentRow.Index);
            Publishing publishing = new Publishing("HeartBeat", "", false);
            ISubscription proxy = CreateProxy(publishing);
            proxy.UnSubscribe(sub.GUID, sub.SubscribeType, sub.Flow, sub.Region, sub.UserName);

            List<SubscriberData> subscriberList = new List<SubscriberData>();
            subscriberList.AddRange(autoPrintSubList);
            subscriberList.AddRange(noAutoPrintSubList);
            XmlSerializer xs = new XmlSerializer(typeof(List<SubscriberData>));

            Stream stream = new FileStream(System.AppDomain.CurrentDomain.BaseDirectory + "SubInfo.xml", FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
            xs.Serialize(stream, subscriberList);
            stream.Close();

        }