Пример #1
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                bool isDeleted = false;
                foreach (GridDataItem data in grid.SelectedItems)
                {
                    int authorID = Convert.ToInt32(data.GetDataKeyValue("AuthorID"));
                    //CheckBox cbDelete = (CheckBox)data.FindControl("cbDelete");
                    //bool isDel = Convert.ToBoolean(data.GetDataKeyValue("IsDel"));
                    KLAuthor author = new KLAuthor(authorID);

                    if (author != null && author.AuthorID != -1)
                    {
                        author.IsDel = true;
                        author.Save();
                        isDeleted = true;
                    }
                }

                if (isDeleted)
                {
                    SiteUtils.QueueIndexing();
                    grid.Rebind();

                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Пример #2
0
        void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                bool isUpdated = false;
                foreach (GridDataItem data in grid.Items)
                {
                    CheckBox cbActive = (CheckBox)data.FindControl("cbActive");
                    int      authorID = Convert.ToInt32(data.GetDataKeyValue("AuthorID"));
                    bool     active   = Convert.ToBoolean(data.GetDataKeyValue("IsActive"));
                    if (cbActive.Checked != active)
                    {
                        KLAuthor author = new KLAuthor(authorID);
                        if (author != null && author.AuthorID != -1)
                        {
                            author.IsActive = cbActive.Checked;
                            author.Save();
                            isUpdated = true;
                        }
                    }
                }

                if (isUpdated)
                {
                    grid.Rebind();

                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Пример #3
0
        void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (!NewsPermission.CanUpdate)
                {
                    SiteUtils.RedirectToEditAccessDeniedPage();
                    return;
                }

                bool isUpdated = false;
                foreach (GridDataItem data in grid.Items)
                {
                    //TextBox txtDisplayOrder = (TextBox)data.FindControl("txtDisplayOrder");
                    //TextBox txtViewed = (TextBox)data.FindControl("txtViewed");
                    CheckBox cbIsPublished = (CheckBox)data.FindControl("cbPublished");
                    int      newsId        = Convert.ToInt32(data.GetDataKeyValue("NewsID"));
                    int      number_news   = 0;
                    //int displayOrder = Convert.ToInt32(data.GetDataKeyValue("DisplayOrder"));
                    //int viewed = Convert.ToInt32(data.GetDataKeyValue("Viewed"));
                    bool isPublished = Convert.ToBoolean(data.GetDataKeyValue("IsPublished"));

                    //int displayOrderNew = displayOrder;
                    //int.TryParse(txtDisplayOrder.Text, out displayOrderNew);

                    //int viewedNew = viewed;
                    //int.TryParse(txtViewed.Text, out viewedNew);
                    //|| viewed != viewedNew
                    //displayOrder != displayOrderNew ||

                    if (cbIsPublished.Checked != isPublished)
                    {
                        News     objNews = new News(SiteId, newsId);
                        KLNews   klNews  = KLNews.GetAll().Where(n => n.NewsID == newsId).FirstOrDefault();
                        KLAuthor author  = new KLAuthor(klNews.AuthorID);
                        if (objNews != null && objNews.NewsID > -1)
                        {
                            if (cbIsPublished.Checked == true)
                            {
                                if (author != null && author.AuthorID > -1 && objNews.IsPublished == false)
                                {
                                    number_news        = author.ArticleCount = (author.ArticleCount + 1);
                                    author.LevelAuthor = UpdateLevel(number_news);
                                    author.Save();
                                    klNews.Isapproved = true;
                                    klNews.Save();
                                }
                                ApproveArticle(objNews.NewsID);
                            }
                            else
                            {
                                if (objNews.IsPublished == true)
                                {
                                    number_news        = author.ArticleCount = (author.ArticleCount - 1);
                                    author.LevelAuthor = UpdateLevel(number_news);
                                    author.Save();
                                    klNews.Isapproved = false;
                                    insertnotify(author.UserID, klNews.NewsID, objNews.Title);
                                    klNews.Save();
                                }
                            }
                            objNews.IsPublished = cbIsPublished.Checked;
                            // objNews.DisplayOrder = displayOrderNew;
                            //objNews.Viewed = viewedNew;
                            objNews.Save();

                            LogActivity.Write("Resort news", objNews.Title);

                            isUpdated = true;
                        }
                    }
                }

                if (isUpdated)
                {
                    grid.Rebind();
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "UpdateSuccessMessage");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Пример #4
0
        private int Save()
        {
            Page.Validate("Author");

            if (!Page.IsValid)
            {
                return(-1);
            }
            try
            {
                author.LinkFacebook  = txtfb.Text;
                author.LinkInstagram = txtinstagram.Text;
                author.LinkPinterest = txtpinterest.Text;
                author.LinkTwitter   = txttwinter.Text;
                author.Name          = txtFullName.Text;
                SiteUser temp = new SiteUser(siteSettings, author.UserID);
                temp.Signature = editDescription.Text;
                if (fileImage.UploadedFiles.Count > 0)
                {
                    imageFolderPath = AuthorHepper.MediaFolderPath(siteSettings.SiteId, author.UserID);


                    AuthorHepper.VerifyAuthorFolders(fileSystem, imageFolderPath);

                    foreach (UploadedFile file in fileImage.UploadedFiles)
                    {
                        string ext = file.GetExtension();
                        if (SiteUtils.IsAllowedUploadBrowseFile(ext, WebConfigSettings.ImageFileExtensions))
                        {
                            ContentMedia media = new ContentMedia();
                            media.SiteGuid = siteSettings.SiteGuid;
                            //image.Title = txtImageTitle.Text;
                            media.DisplayOrder = 0;

                            string newFileName  = file.FileName.ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);
                            string newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                            if (media.MediaFile == newFileName)
                            {
                                // an existing image delete the old one
                                fileSystem.DeleteFile(newImagePath);
                            }
                            else
                            {
                                // this is a new newsImage instance, make sure we don't use the same file name as any other instance
                                int i = 1;
                                while (fileSystem.FileExists(VirtualPathUtility.Combine(imageFolderPath, newFileName)))
                                {
                                    newFileName = i.ToInvariantString() + newFileName;
                                    i          += 1;
                                }
                            }

                            newImagePath = VirtualPathUtility.Combine(imageFolderPath, newFileName);

                            file.SaveAs(Server.MapPath(newImagePath));

                            media.MediaFile     = newFileName;
                            media.ThumbnailFile = newFileName;

                            author.Avatar = newFileName;
                            media.Save();
                            AuthorHepper.ProcessImage(media, fileSystem, imageFolderPath, file.FileName);
                        }
                    }
                }


                if (temp.Save() && author.Save())
                {
                    ImageAvatar.ImageUrl = AuthorHepper.GetAvatarAuthor(siteSettings.SiteId, author.UserID);
                    LogActivity.Write("Update Author", author.Name);
                    message.SuccessMessage = ResourceHelper.GetResourceString("CustomResources", "UpdateAuthorSuccess");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
            return(author.AuthorID);
        }