コード例 #1
0
        private void DoArticleEdit(MainDataSet.ArticleRow articleRow)
        {
            ShowArticleEdit();
            TreeViewParentArticle.Nodes.Clear();
            TreeViewParentArticle.Nodes.Add(new Telerik.Web.UI.RadTreeNode("                                                                                                                                                                                                          ", string.Empty));
            TreeViewParentArticle.DataBind();

            CustomLinksDataBind(UserContext.Current.SelectedInstance.InstanceId);

            if (articleRow != null)
            {
                HtmlEditorBody.ImageManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") };
                HtmlEditorBody.ImageManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.ImageDBContentProvider).AssemblyQualifiedName;
                HtmlEditorBody.MediaManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") };
                HtmlEditorBody.MediaManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.VideoDBContentProvider).AssemblyQualifiedName;
                HtmlEditorBody.FlashManager.ViewPaths = new string[] { articleRow.ArticleGuid.ToString("N") };
                HtmlEditorBody.FlashManager.ContentProviderTypeName    = typeof(Micajah.FileService.Providers.FlashDBContentProvider).AssemblyQualifiedName;
                HtmlEditorBody.DocumentManager.ViewPaths               = new string[] { articleRow.ArticleGuid.ToString("N") };
                HtmlEditorBody.DocumentManager.ContentProviderTypeName = typeof(Micajah.FileService.Providers.FileDBContentProvider).AssemblyQualifiedName;
                HtmlEditorBody.Content = this.ArticleTableAdapter.GetBody(articleRow.ArticleGuid);

                ImageAdminListCtrl.ArticleGuid = articleRow.ArticleGuid;
                FileAdminListCtrl.ArticleGuid  = articleRow.ArticleGuid;
                ImageAdminListCtrl.DataBind();
                FileAdminListCtrl.DataBind();

                Master.CustomName             = articleRow.Subject;
                TextBoxSubject.Text           = articleRow.Subject;
                SearchDescriptionTextBox.Text = articleRow.SearchDesc;
                if (!articleRow.IsParentArticleGuidNull())
                {
                    Telerik.Web.UI.RadTreeNode node = TreeViewParentArticle.FindNodeByValue(articleRow.ParentArticleGuid.ToString());
                    if (node != null)
                    {
                        node.Selected = true;
                        node.ExpandParentNodes();
                    }
                }
                if (articleRow.Type == ArticleType.Request.ToString())
                {
                    TextBoxAlternateIds.Text = articleRow.Subject;
                }
                else
                {
                    using (MainDataSetTableAdapters.AlternateIdTableAdapter altAdapter = new MainDataSetTableAdapters.AlternateIdTableAdapter())
                    {
                        TextBoxAlternateIds.Text = string.Empty;
                        MainDataSet.AlternateIdDataTable dtAlt = altAdapter.GetDataByArticleGuid(articleRow.ArticleGuid);
                        foreach (MainDataSet.AlternateIdRow row in dtAlt)
                        {
                            TextBoxAlternateIds.Text += row.AlternateId + Environment.NewLine;
                        }
                    }
                }
            }
            else
            {
                Master.CustomName = (string)this.GetLocalResourceObject("AddNewArticle");
            }
        }
コード例 #2
0
        public override DirectoryItem ResolveRootDirectoryAsTree(string path)
        {
            MainDataSet.ArticleRow articleRow  = null;
            DirectoryItem          returnValue = null;
            Guid articleGuid = Guid.Empty;

            try { articleGuid = new Guid(path); }
            catch { }
            if (articleGuid != Guid.Empty)
            {
                MainDataSet.ArticleDataTable dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleGuid);
                if (dtArticle.Count > 0)
                {
                    articleRow = dtArticle[0];
                    string fullName = this.ArticleTableAdapter.GetAlternateId(articleGuid);
                    if (string.IsNullOrEmpty(fullName))
                    {
                        fullName = articleRow.ArticleGuid.ToString("N");
                    }
                    returnValue = new DirectoryItem(
                        articleRow.Subject, articleRow.Subject + "/", fullName, string.Empty, fullPermissions, GetChildFiles(articleRow),
                        GetChildDirectories(articleRow));
                }
            }
            if (returnValue == null)
            {
                returnValue = this.GetDefaultDirectoryItem();
            }
            return(returnValue);
        }
コード例 #3
0
 protected void LinkButtonEditArticle_Click(object sender, EventArgs e)
 {
     HtmlEditorBody.Modules.Clear();
     MainDataSet.ArticleRow articleRow = this.GetCurrentArticle();
     if (articleRow != null)
     {
         this.DoArticleEdit(this.GetCurrentArticle());
         HtmlEditorBody.Content       = this.ArticleTableAdapter.GetBody(articleRow.ArticleGuid);
         LinkButtonCancelEdit.Visible = true;
     }
 }
コード例 #4
0
 private MainDataSet.ArticleRow GetCurrentArticle()
 {
     if (!this.ArticleGuid.Equals(Guid.Empty) && m_articleRow == null)
     {
         MainDataSet.ArticleDataTable dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(this.ArticleGuid);
         if (dtArticle.Count > 0)
         {
             m_articleRow = dtArticle[0];
         }
     }
     return(m_articleRow);
 }
コード例 #5
0
        public override DirectoryItem ResolveDirectory(string path)
        {
            DirectoryItem[] directories;
            DirectoryItem   returnValue = null;

            MainDataSet.ArticleRow       articleRow = null;
            MainDataSet.ArticleDataTable dtArticle  = null;

            Guid articleGuid = Guid.Empty;

            try { articleGuid = new Guid(path); }
            catch { }
            if (articleGuid != Guid.Empty)
            {
                dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleGuid);
            }
            else
            {
                dtArticle = this.ArticleTableAdapter.GetDataByAlternateId(path);
            }
            if (dtArticle.Count > 0)
            {
                articleRow = dtArticle[0];
            }

            //if (DisplayMode == FileBrowserDisplayMode.List)
            directories = new DirectoryItem[] { };
            //else
            //{
            //    if (articleRow != null)
            //        directories = GetChildDirectories(articleRow);
            //    else directories = new DirectoryItem[] { };
            //}
            if (articleRow != null)
            {
                returnValue = new DirectoryItem(articleRow.Subject, articleRow + "/", articleRow + "/", articleRow + "/", fullPermissions, GetChildFiles(articleRow),
                                                directories);
            }
            else
            {
                returnValue = this.GetDefaultDirectoryItem();
            }
            return(returnValue);
        }
コード例 #6
0
        protected DirectoryItem[] GetChildDirectories(MainDataSet.ArticleRow articleRow)
        {
            List <DirectoryItem> directories = new List <DirectoryItem>();

            MainDataSet.ArticleDataTable dtArticles = this.ArticleTableAdapter.GetDataByParent(articleRow.ArticleGuid);
            foreach (MainDataSet.ArticleRow row in dtArticles)
            {
                //string itemFullPath = string.Format("/{0}/{1}/", articleRow.Subject, row.Subject);
                string itemFullPath = string.Format("~/ArticleViewAdmin.aspx?id={0}", row.ArticleGuid.ToString("N"));
                directories.Add(new DirectoryItem(
                                    row.Subject,
                                    string.Empty,
                                    itemFullPath,
                                    string.Empty,
                                    fullPermissions,
                                    GetChildFiles(row),
                                    GetChildDirectories(row)));
            }
            return(directories.ToArray());
        }
コード例 #7
0
 protected void ButtonInactive_Click(object sender, EventArgs e)
 {
     MainDataSet.ArticleRow row = this.GetCurrentArticle();
     if (row != null)
     {
         if (ButtonInactive.Text == (string)this.GetLocalResourceObject("ActivateArticle"))
         {
             this.ArticleTableAdapter.Activate(this.ArticleGuid);
             ShowArticleView();
             ButtonInactive.Text          = (string)this.GetLocalResourceObject("InactivateArticle");
             ButtonInactive.OnClientClick = string.Empty;
         }
         else
         {
             ShowArticleInactive();
             litSubjectDelete.Text = row.Subject;
             int?qty = this.ArticleTableAdapter.GetRelatedArticleCount(row.ArticleGuid);
             tableInactive.Rows[2].Visible = tableInactive.Rows[3].Visible = tableInactive.Rows[4].Visible = (qty.HasValue && qty.Value > 0);
         }
     }
 }
コード例 #8
0
        public override DirectoryItem[] ResolveRootDirectoryAsList(string path)
        {
            List <DirectoryItem> directories = new List <DirectoryItem>();

            MainDataSet.ArticleRow articleRow = null;
            Guid articleGuid = Guid.Empty;

            try { articleGuid = new Guid(path); }
            catch { }
            if (articleGuid != Guid.Empty)
            {
                MainDataSet.ArticleDataTable dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(articleGuid);
                if (dtArticle.Count > 0)
                {
                    articleRow = dtArticle[0];
                    directories.Add(new DirectoryItem(
                                        articleRow.Subject,
                                        articleRow.Subject + "/",
                                        string.Empty,
                                        string.Empty,
                                        fullPermissions,
                                        GetChildFiles(articleRow),
                                        new DirectoryItem[] { }));
                    MainDataSet.ArticleDataTable dtChildArticles = this.ArticleTableAdapter.GetDataRecursiveByArticleGuid(articleGuid);
                    foreach (MainDataSet.ArticleRow row in dtChildArticles)
                    {
                        directories.Add(new DirectoryItem(
                                            row.Subject,
                                            row.Subject + "/",
                                            string.Empty,
                                            string.Empty,
                                            fullPermissions,
                                            GetChildFiles(row),
                                            new DirectoryItem[] { }));
                    }
                }
            }
            return(directories.ToArray());
        }
コード例 #9
0
        public static BreadcrumbCollection GenerateBreadCrumbs(Guid articleGuid, Guid instanceGuid, bool isAdmin)
        {
            BreadcrumbCollection breadCrumbs = new BreadcrumbCollection();

            using (MainDataSetTableAdapters.ArticleTableAdapter m_taArticle = new MainDataSetTableAdapters.ArticleTableAdapter())
            {
                if (articleGuid != Guid.Empty && instanceGuid != Guid.Empty)
                {
                    MainDataSet.ArticleDataTable dtArticle = m_taArticle.GetRecursiveAllByArticleGuid(articleGuid);
                    if (dtArticle.Count > 0)
                    {
                        for (int i = dtArticle.Count - 1; i >= 0; i--)
                        {
                            MainDataSet.ArticleRow row = dtArticle[i];
                            breadCrumbs.Add(
                                row.Subject,
                                isAdmin ? string.Format("~/ArticleViewAdmin.aspx?id={0}", row.ArticleGuid.ToString("N")) : string.Format("~/?i={0}&t={1}", instanceGuid.ToString("N"), row.ArticleGuid.ToString("N")),
                                row.Subject, false);
                        }
                    }
                }
            }
            return(breadCrumbs);
        }
コード例 #10
0
        protected void ButtonPostComment_Click(object sender, EventArgs e)
        {
            // check the Honeypot
            if (TextBoxPhone.Text == string.Empty && this.InstanceGuid != Guid.Empty)
            {
                int indexUrl = Request.Url.AbsoluteUri.IndexOf(":" + Request.Url.Port.ToString());
                if (indexUrl <= 0)
                {
                    indexUrl = Request.Url.AbsoluteUri.IndexOf(Request.Url.AbsolutePath);
                }
                string siteUrl = Request.Url.AbsoluteUri.Substring(0, indexUrl) + Request.ApplicationPath + "/";
                using (MainDataSetTableAdapters.CommentTableAdapter taComment = new MainDataSetTableAdapters.CommentTableAdapter())
                {
                    Organization currOrganization           = null;
                    MainDataSet.Mc_InstanceRow currInstance = null;
                    using (MainDataSetTableAdapters.Mc_InstanceTableAdapter taInstance = new MainDataSetTableAdapters.Mc_InstanceTableAdapter())
                    {
                        MainDataSet.Mc_InstanceDataTable instances = taInstance.GetDataByInstanceId(this.InstanceGuid);
                        if (instances.Count > 0)
                        {
                            currInstance     = instances[0];
                            currOrganization = Micajah.Common.Bll.Providers.OrganizationProvider.GetOrganization(currInstance.OrganizationId);
                        }
                    }
                    DateTime dtNow = DateTime.Now;
                    if (this.ArticleGuid == Guid.Empty)
                    {
                        // create a reqest
                        Guid newId = Guid.NewGuid();
                        // create a request
                        if (this.ArticleTableAdapter.Insert(newId,
                                                            this.InstanceGuid,
                                                            new Guid?(),
                                                            ArticleType.Request.ToString(),
                                                            (this.AlternateId != string.Empty) ? this.AlternateId : HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50)),
                                                            (string)this.GetLocalResourceObject("BodyNotArticle"),
                                                            string.Empty,
                                                            0,
                                                            0,
                                                            0,
                                                            false,
                                                            new DateTime?(),
                                                            new DateTime?(),
                                                            new DateTime?(),
                                                            new Guid?(),
                                                            new Guid?(),
                                                            new Guid?()) > 0)
                        {
                            MainDataSet.CommentDataTable commentDataTable = taComment.InsertComment(newId,
                                                                                                    TextBoxName.Text,
                                                                                                    TextBoxEmail.Text,
                                                                                                    string.Format("{0} ({1})", Request.UserHostName, Request.UserHostAddress),
                                                                                                    HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50)),
                                                                                                    HttpUtility.HtmlEncode(TextBoxComment.Text),
                                                                                                    false,
                                                                                                    true,
                                                                                                    DateTime.Now, true);
                            if (commentDataTable != null && commentDataTable.Rows.Count > 0)
                            {
                                if (CommentPosted != null)
                                {
                                    CommentPosted(this, new ArticleEventArgs(newId, true));
                                }
                                if (currOrganization != null && currInstance != null)
                                {
                                    string subj;
                                    Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers(
                                        currOrganization.OrganizationId,
                                        this.InstanceGuid,
                                        new string[] { "InstAdmin" });

                                    ArrayList admins = new ArrayList();
                                    ArrayList SendTo = new ArrayList();

                                    admins.AddRange(this.InputListAdmin);

                                    foreach (Micajah.Common.Dal.OrganizationDataSet.UserRow row in users)
                                    {
                                        admins.Add(row.Email);
                                    }

                                    SendTo.AddRange(admins);

                                    MainDataSetTableAdapters.EmailsTableAdapter emailsTableAdapter = new MainDataSetTableAdapters.EmailsTableAdapter();
                                    foreach (DataRow row in emailsTableAdapter.GetArticleEmails(ArticleGuid).Rows)
                                    {
                                        if (!SendTo.Contains(row["UserEmail"].ToString()))
                                        {
                                            SendTo.Add(row["UserEmail"].ToString());
                                        }
                                    }

                                    foreach (DataRow row in emailsTableAdapter.GetUnsubscribedEmails(ArticleGuid, this.InstanceGuid).Rows)
                                    {
                                        SendTo.Remove(row["UserEmail"].ToString());
                                    }

                                    string SendToList = string.Empty;
                                    bool   separated  = false;
                                    for (int i = 0; i < SendTo.Count; i++)
                                    {
                                        if (!separated && !admins.Contains(SendTo[i].ToString()))
                                        {
                                            SendToList += "<br><br>Commentors:<br>" + SendTo[i].ToString();
                                            separated   = true;
                                        }
                                        else
                                        {
                                            SendToList += ", " + SendTo[i].ToString();
                                        }
                                    }
                                    SendToList = SendToList.Remove(0, 1);

                                    if (SendTo.Count > 0)
                                    {
                                        for (int i = 0; i < SendTo.Count; i++)
                                        {
                                            subj = (this.AlternateId != string.Empty) ? this.AlternateId : HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50));
                                            StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_Request"));
                                            body.Replace("{OrgName}", currOrganization.Name);
                                            body.Replace("{InstName}", currInstance.Name);
                                            body.Replace("{ArticleName}", subj);
                                            body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", this.InstanceGuid.ToString("N"), newId.ToString("N")));
                                            body.Replace("{ArticleText}", HttpUtility.HtmlEncode(TextBoxComment.Text));
                                            body.Replace("{AuthorName}", TextBoxName.Text);
                                            body.Replace("{AuthorEmail}", string.IsNullOrEmpty(TextBoxEmail.Text) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", TextBoxEmail.Text));
                                            body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl);
                                            if (body.Length > 0)
                                            {
                                                string encrypted = Utils.Encrypt(String.Format("{0}&{1}&{2}&{3}&{4}", SendTo[i].ToString(), 1, commentDataTable[0].CommentId.ToString(CultureInfo.InvariantCulture), InstanceGuid.ToString(), UserContext.SelectedOrganizationId.ToString()), "Dshd*&^*@dsdss", "237w&@2d", "SHA1", 2, "&s2hfyDjuf372*73", 256);
                                                string url       = siteUrl + String.Format("Unsubscribe.aspx?token={0}", encrypted);
                                                body.Replace("{UnsubscribeFromArticleUrl}", url);
                                                encrypted = Utils.Encrypt(String.Format("{0}&{1}&{2}&{3}&{4}", SendTo[i].ToString(), 2, commentDataTable[0].CommentId.ToString(CultureInfo.InvariantCulture), InstanceGuid.ToString(), UserContext.SelectedOrganizationId.ToString()), "Dshd*&^*@dsdss", "237w&@2d", "SHA1", 2, "&s2hfyDjuf372*73", 256);
                                                url       = siteUrl + String.Format("Unsubscribe.aspx?token={0}", encrypted);
                                                body.Replace("{UnsubscribeFromAllUrl}", url);
                                                if (admins.Contains(SendTo[i]))
                                                {
                                                    body.Replace("{SendToList}", "This message was also sent to:<br>" + SendToList);
                                                }
                                                else
                                                {
                                                    body.Replace("{SendToList}", string.Empty);
                                                }
                                                Utils.SendEmail("*****@*****.**", SendTo[i].ToString(), string.Format((string)this.GetLocalResourceObject("EmailSubjectRequest"), subj), body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true);
                                            }
                                        }
                                    }
                                }
                                ResetData();
                            }
                        }
                    }
                    else
                    {
                        // post to article
                        MainDataSet.CommentDataTable commentDataTable = taComment.InsertComment(this.ArticleGuid,
                                                                                                TextBoxName.Text,
                                                                                                TextBoxEmail.Text,
                                                                                                string.Format("{0} ({1})", Request.UserHostName, Request.UserHostAddress),
                                                                                                HttpUtility.HtmlEncode(Utils.ShortCommentText(TextBoxComment.Text, 50)),
                                                                                                HttpUtility.HtmlEncode(TextBoxComment.Text),
                                                                                                false,
                                                                                                true,
                                                                                                dtNow, true);
                        if (commentDataTable != null && commentDataTable.Rows.Count > 0)
                        {
                            if (CommentPosted != null)
                            {
                                CommentPosted(this, new ArticleEventArgs(this.ArticleGuid, false));
                            }
                            MainDataSet.ArticleRow articleRow = this.GetCurrentArticle();
                            if (currOrganization != null && articleRow != null && !articleRow.IsUpdatedByNull() && currInstance != null)
                            {
                                string author = string.Empty, subj;
                                subj = string.Format((string)this.GetLocalResourceObject("EmailSubjectComment"), articleRow.Subject);

                                System.Data.DataRow mcuser = Micajah.Common.Bll.Providers.UserProvider.GetUserRow(articleRow.UpdatedBy, currOrganization.OrganizationId);
                                if (mcuser != null)
                                {
                                    author = (string)mcuser["Email"];
                                }

                                Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers(
                                    currOrganization.OrganizationId,
                                    this.InstanceGuid,
                                    new string[] { "InstAdmin" });

                                ArrayList admins           = new ArrayList();
                                ArrayList SendTo           = new ArrayList();

                                admins.AddRange(this.InputListAdmin);
                                foreach (Micajah.Common.Dal.OrganizationDataSet.UserRow row in users)
                                {
                                    admins.Add(row.Email);
                                }
                                SendTo.AddRange(admins);

                                if (!string.IsNullOrEmpty(author) && !SendTo.Contains(author))
                                {
                                    SendTo.Add(author);
                                }

                                MainDataSetTableAdapters.EmailsTableAdapter emailsTableAdapter = new MainDataSetTableAdapters.EmailsTableAdapter();
                                foreach (DataRow row in emailsTableAdapter.GetArticleEmails(ArticleGuid).Rows)
                                {
                                    if (!SendTo.Contains(row["UserEmail"].ToString()))
                                    {
                                        SendTo.Add(row["UserEmail"].ToString());
                                    }
                                }

                                foreach (DataRow row in emailsTableAdapter.GetUnsubscribedEmails(ArticleGuid, this.InstanceGuid).Rows)
                                {
                                    SendTo.Remove(row["UserEmail"].ToString());
                                }

                                string SendToList = string.Empty;
                                bool   separated  = false;
                                for (int i = 0; i < SendTo.Count; i++)
                                {
                                    if (!separated && !admins.Contains(SendTo[i].ToString()))
                                    {
                                        SendToList += "<br><br>Commentors:<br>" + SendTo[i].ToString();
                                        separated   = true;
                                    }
                                    else
                                    {
                                        SendToList += ", " + SendTo[i].ToString();
                                    }
                                }
                                SendToList = SendToList.Remove(0, 1);

                                if (SendTo.Count > 0)
                                {
                                    for (int i = 0; i < SendTo.Count; i++)
                                    {
                                        StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_PostToArticle"));
                                        body.Replace("{OrgName}", currOrganization.Name);
                                        body.Replace("{InstName}", currInstance.Name);
                                        body.Replace("{ArticleName}", articleRow.Subject);
                                        body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", this.InstanceGuid.ToString("N"), this.ArticleGuid.ToString("N")));
                                        body.Replace("{ArticleText}", HttpUtility.HtmlEncode(TextBoxComment.Text));
                                        body.Replace("{AuthorName}", TextBoxName.Text);
                                        body.Replace("{AuthorEmail}", string.IsNullOrEmpty(TextBoxEmail.Text) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", TextBoxEmail.Text));
                                        body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl);
                                        if (admins.Contains(SendTo[i]))
                                        {
                                            body.Replace("{SendToList}", "This message was also sent to:<br>" + SendToList);
                                        }
                                        else
                                        {
                                            body.Replace("{SendToList}", string.Empty);
                                        }

                                        if (body.Length > 0)
                                        {
                                            string encrypted = Utils.Encrypt(String.Format("{0}&{1}&{2}&{3}&{4}", SendTo[i].ToString(), 1, commentDataTable[0].CommentId.ToString(CultureInfo.InvariantCulture), InstanceGuid.ToString(), UserContext.SelectedOrganizationId.ToString()), "Dshd*&^*@dsdss", "237w&@2d", "SHA1", 2, "&s2hfyDjuf372*73", 256);
                                            string url       = siteUrl + String.Format("Unsubscribe.aspx?token={0}", encrypted);
                                            body.Replace("{UnsubscribeFromArticleUrl}", url);
                                            encrypted = Utils.Encrypt(String.Format("{0}&{1}&{2}&{3}&{4}", SendTo[i].ToString(), 2, commentDataTable[0].CommentId.ToString(CultureInfo.InvariantCulture), InstanceGuid.ToString(), UserContext.SelectedOrganizationId.ToString()), "Dshd*&^*@dsdss", "237w&@2d", "SHA1", 2, "&s2hfyDjuf372*73", 256);
                                            url       = siteUrl + String.Format("Unsubscribe.aspx?token={0}", encrypted);
                                            body.Replace("{UnsubscribeFromAllUrl}", url);
                                            Utils.SendEmail("*****@*****.**", SendTo[i].ToString(), subj, body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true);
                                        }
                                    }
                                }
                            }
                            ResetData();
                        }
                    }
                }
            }
        }
コード例 #11
0
 private MainDataSet.ArticleRow GetCurrentArticle()
 {
     if (!this.ArticleGuid.Equals(Guid.Empty) && m_articleRow == null)
     {
         MainDataSet.ArticleDataTable dtArticle = this.ArticleTableAdapter.GetDataByArticleGuid(this.ArticleGuid);
         if (dtArticle.Count > 0)
             m_articleRow = dtArticle[0];
     }
     return m_articleRow;
 }
コード例 #12
0
        protected FileItem[] GetChildFiles(MainDataSet.ArticleRow articleRow)
        {
            if (articleRow != null && articleRow.DepartmentGuid != Guid.Empty)
            {
                MetaDataSet.FileDataTable dtFiles = (new Micajah.FileService.Client.Dal.MetaDataSetTableAdapters.FileTableAdapter()).GetFiles(
                    Micajah.Common.Bll.Providers.InstanceProvider.GetInstance(articleRow.DepartmentGuid).OrganizationId,
                    articleRow.DepartmentGuid,
                    "Article",
                    articleRow.ArticleGuid.ToString("N"), false);
                ArrayList files = new ArrayList();
                foreach (MetaDataSet.FileRow frow in dtFiles)
                {
                    string path     = string.Empty;
                    string ext      = Path.GetExtension(frow.Name);
                    string mimeType = MimeType.GetMimeType(ext);
                    switch (FileType)
                    {
                    case "Image":
                        path = Access.GetThumbnailUrl(frow.FileUniqueId, frow.OrganizationId, frow.DepartmentId, 640, 0, 0);
                        if (MimeType.IsImageType(mimeType))
                        {
                            files.Add(
                                new FileItem(
                                    frow.Name,
                                    ext,
                                    frow.SizeInBytes,
                                    string.Empty,
                                    path,
                                    string.Format("{0}/{1}/", articleRow.Subject, frow.Name),
                                    fullPermissions));
                        }
                        break;

                    case "Video":
                        path = Access.GetFileUrl(frow.FileUniqueId, frow.OrganizationId, frow.DepartmentId);
                        if (MimeType.IsVideoType(mimeType))
                        {
                            files.Add(new FileItem(
                                          frow.Name,
                                          ext,
                                          frow.SizeInBytes,
                                          string.Empty,
                                          path,
                                          string.Format("{0}/{1}/", articleRow.Subject, frow.Name),
                                          fullPermissions));
                        }
                        break;

                    case "Flash":
                        path = Access.GetFlashUrl(frow.FileUniqueId, frow.OrganizationId, frow.DepartmentId);
                        if (MimeType.IsFlash(mimeType))
                        {
                            files.Add(new FileItem(
                                          frow.Name,
                                          ext,
                                          frow.SizeInBytes,
                                          string.Empty,
                                          path,
                                          string.Format("{0}/{1}/", articleRow.Subject, frow.Name),
                                          fullPermissions));
                        }
                        break;

                    default:
                        path = Access.GetFileUrl(frow.FileUniqueId, frow.OrganizationId, frow.DepartmentId);
                        files.Add(new FileItem(
                                      frow.Name,
                                      ext,
                                      frow.SizeInBytes,
                                      string.Empty,
                                      path,
                                      string.Format("{0}/{1}/", articleRow.Subject, frow.Name),
                                      fullPermissions));
                        break;
                    }
                }
                return((FileItem[])files.ToArray(typeof(FileItem)));
            }
            return(new FileItem[] { });
        }
コード例 #13
0
        private void DoArticleView(MainDataSet.ArticleRow articleRow)
        {
            PanelArticle.Visible = true;
            if (articleRow != null)
            {
                if (!IsPopup)
                {
                    UserContext.Breadcrumbs.AddRange(Utils.GenerateBreadCrumbs(articleRow.ArticleGuid, this.Master.InstanceGuid, false));
                }
                //Master.CustomName = articleRow.Subject;
                Master.Title    = articleRow.Subject;
                litSubject.Text = articleRow.Subject;
                HtmlMeta metaKeywords = new HtmlMeta();
                metaKeywords.Name    = "keywords";
                metaKeywords.Content = Master.Title;
                Page.Header.Controls.Add(metaKeywords);
                HtmlMeta metaDescription = new HtmlMeta();
                metaDescription.Name    = "Description";
                metaDescription.Content = articleRow.SearchDesc;
                Page.Header.Controls.Add(metaDescription);

                if (articleRow.Type == ArticleType.Request.ToString())
                {
                    divBody.InnerHtml = (string)this.GetLocalResourceObject("ArticleDoesNotExist");
                }
                else
                {
                    this.ArticleTableAdapter.IncReview(articleRow.ArticleGuid);
                    string body = this.ArticleTableAdapter.GetBody(articleRow.ArticleGuid);
                    if (!string.IsNullOrEmpty(body))
                    {
                        divBody.InnerHtml = body;
                    }
                }
                //divType.InnerText = articleRow.Type;
                Guid userId = Guid.Empty;
                if (!articleRow.IsCreatedByNull())
                {
                    userId = articleRow.CreatedBy;
                }
                if (!articleRow.IsUpdatedByNull())
                {
                    userId = articleRow.UpdatedBy;
                }
                //if (userId == Guid.Empty)
                //    PostCommentCtrl.ReceiverName = Utils.GetInstanceUserName(this.Master.InstanceGuid);
                //else
                //{
                //    using (MainDataSetTableAdapters.Mc_UserTableAdapter userAdapter = new MainDataSetTableAdapters.Mc_UserTableAdapter())
                //    {
                //        MainDataSet.Mc_UserDataTable dtUser = userAdapter.GetDataByUserId(userId);
                //        if (dtUser != null && dtUser.Count > 0)
                //            PostCommentCtrl.ReceiverName = dtUser[0].FirstName + " " + dtUser[0].LastName;
                //    }
                //}
                ArticlesListCtrl.ArticleGuid = articleRow.ArticleGuid;
                PostCommentCtrl.InstanceGuid = this.Master.InstanceGuid;
                PostCommentCtrl.ArticleGuid  = articleRow.ArticleGuid;
                CommentsListCtrl.ArticleGuid = articleRow.ArticleGuid;
                CommentsListCtrl.DataBind();
            }
        }
コード例 #14
0
        protected void ButtonUpload_Click(object sender, EventArgs e)
        {
            using (MainDataSetTableAdapters.AlternateIdTableAdapter altAdapter = new MainDataSetTableAdapters.AlternateIdTableAdapter())
            {
                articleGuid = this.ArticleGuid;
                foreach (string str in TextBoxAlternateIds.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                {
                    if ((int)altAdapter.CheckAlternateId(UserContext.Current.SelectedInstance.InstanceId, articleGuid, str) == 1)
                    {
                        Master.ErrorMessage = string.Format((string)this.GetLocalResourceObject("ErrorMsg_AlternateId"), str);
                        return;
                    }
                }
                //string htmlBody = HtmlEditorBody.Content;
                if (!HtmlEditorBody.Content.EndsWith("<p></p>\r\n") &&
                    !HtmlEditorBody.Content.EndsWith("<p>nbsp;</p>\r\n") &&
                    !HtmlEditorBody.Content.EndsWith("<p> </p>\r\n") &&
                    !HtmlEditorBody.Content.EndsWith("<p></p>") &&
                    !HtmlEditorBody.Content.EndsWith("<p> </p>") &&
                    !HtmlEditorBody.Content.EndsWith("<p>nbsp;</p>"))
                {
                    HtmlEditorBody.Content += "<p></p>\r\n";
                }
                if (articleGuid.Equals(Guid.Empty))
                {
                    articleGuid = Guid.NewGuid();
                    this.ArticleTableAdapter.Insert(
                        articleGuid,
                        UserContext.Current.SelectedInstance.InstanceId,
                        ((this.ParntArticleGuid != Guid.Empty) ? this.ParntArticleGuid : new Guid?()),
                        ArticleType.Article.ToString(),
                        TextBoxSubject.Text,
                        HtmlEditorBody.Content,
                        SearchDescriptionTextBox.Text,
                        0,
                        0,
                        0,
                        false,
                        new DateTime?(DateTime.Now),
                        new DateTime?(),
                        new DateTime?(),
                        new Guid?(UserContext.Current.UserId),
                        new Guid?(),
                        new Guid?());

                    if (!articleGuid.Equals(Guid.Empty))
                    {
                        DoUploadFile(articleGuid);
                        if (this.ArticleGuid.Equals(Guid.Empty))
                        {
                            Response.Redirect("~/ArticleViewAdmin.aspx?mode=edit&id=" + articleGuid.ToString("N"), false);
                        }
                    }
                }
                else
                {
                    MainDataSet.ArticleRow articleRow = this.GetCurrentArticle();
                    string oldType = articleRow.Type;
                    articleRow.Type       = ArticleType.Article.ToString();
                    articleRow.Body       = HtmlEditorBody.Content;//HttpUtility.HtmlEncode(htmlBody);
                    articleRow.Subject    = TextBoxSubject.Text;
                    articleRow.SearchDesc = SearchDescriptionTextBox.Text;
                    if (this.ParntArticleGuid != Guid.Empty)
                    {
                        articleRow.ParentArticleGuid = this.ParntArticleGuid;
                    }
                    else
                    {
                        articleRow.SetParentArticleGuidNull();
                    }
                    articleRow.UpdatedBy   = UserContext.Current.UserId;
                    articleRow.UpdatedTime = DateTime.Now;
                    this.ArticleTableAdapter.Update(articleRow);

                    if (oldType == ArticleType.Request.ToString())
                    {
                        string siteUrl = Request.Url.AbsoluteUri.Substring(0, Request.Url.AbsoluteUri.IndexOf(Request.Url.AbsolutePath)) + Request.ApplicationPath + "/";

                        Micajah.Common.Dal.OrganizationDataSet.UserDataTable users = Micajah.Common.Bll.Providers.UserProvider.GetUsers(
                            UserContext.Current.SelectedOrganization.OrganizationId,
                            UserContext.Current.SelectedInstance.InstanceId,
                            new string[] { "InstAdmin" });

                        ArrayList admins = new ArrayList();
                        ArrayList SendTo = new ArrayList();

                        foreach (Micajah.Common.Dal.OrganizationDataSet.UserRow row in users)
                        {
                            admins.Add(row.Email);
                        }

                        SendTo.AddRange(admins);

                        MainDataSetTableAdapters.EmailsTableAdapter emailsTableAdapter = new MainDataSetTableAdapters.EmailsTableAdapter();
                        foreach (DataRow row in emailsTableAdapter.GetArticleEmails(ArticleGuid).Rows)
                        {
                            if (!SendTo.Contains(row["UserEmail"].ToString()))
                            {
                                SendTo.Add(row["UserEmail"].ToString());
                            }
                        }

                        foreach (DataRow row in emailsTableAdapter.GetUnsubscribedEmails(articleRow.ArticleGuid, UserContext.Current.SelectedInstance.InstanceId).Rows)
                        {
                            SendTo.Remove(row["UserEmail"].ToString());
                        }

                        string SendToList = string.Empty;
                        bool   separated  = false;
                        for (int i = 0; i < SendTo.Count; i++)
                        {
                            if (!separated && !admins.Contains(SendTo[i].ToString()))
                            {
                                SendToList += "<br><br>Commentors:<br>" + SendTo[i].ToString();
                                separated   = true;
                            }
                            else
                            {
                                SendToList += ", " + SendTo[i].ToString();
                            }
                        }
                        SendToList = SendToList.Remove(0, 1);

                        if (SendTo.Count > 0)
                        {
                            for (int i = 0; i < SendTo.Count; i++)
                            {
                                StringBuilder body = new StringBuilder((string)this.GetLocalResourceObject("EmailBody_ArticleCreated"));
                                body.Replace("{OrgName}", UserContext.Current.SelectedOrganization.Name);
                                body.Replace("{InstName}", UserContext.Current.SelectedInstance.Name);
                                body.Replace("{ArticleName}", articleRow.Subject);
                                body.Replace("{ArticleUrl}", siteUrl + string.Format(CultureInfo.CurrentCulture, "?i={0}&t={1}", articleRow.DepartmentGuid.ToString("N"), articleRow.ArticleGuid.ToString("N")));
                                body.Replace("{ArticleText}", HtmlEditorBody.Content);
                                body.Replace("{AuthorName}", UserContext.Current.FirstName + " " + UserContext.Current.LastName);
                                body.Replace("{AuthorEmail}", string.IsNullOrEmpty(UserContext.Current.Email) ? string.Empty : string.Format(CultureInfo.CurrentCulture, "<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>", UserContext.Current.Email));
                                body.Replace("{ImageUrl}", siteUrl + Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl);
                                if (admins.Contains(SendTo[i]))
                                {
                                    body.Replace("{SendToList}", "This message was also sent to:<br>" + SendToList);
                                }
                                else
                                {
                                    body.Replace("{SendToList}", string.Empty);
                                }
                                Utils.SendEmail("*****@*****.**", SendTo[i].ToString(), new string[] { }, string.Format((string)this.GetLocalResourceObject("EmailSubjectNewArticle"), articleRow.Subject), body.ToString(), true, Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.Email.SmtpServer, true);
                            }
                        }
                    }
                    altAdapter.DeleteByArticleGuid(articleGuid);
                    foreach (string str in TextBoxAlternateIds.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        altAdapter.InsertAlt(UserContext.Current.SelectedInstance.InstanceId, articleGuid, str);
                    }
                    if (!articleGuid.Equals(Guid.Empty))
                    {
                        DoUploadFile(articleGuid);
                        if (this.ArticleGuid.Equals(Guid.Empty))
                        {
                            Response.Redirect("~/ArticleViewAdmin.aspx?mode=edit&id=" + articleGuid.ToString("N"), false);
                        }
                    }
                }
            }
        }
コード例 #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MagicFormRequest.ColorScheme = Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.DefaultColorScheme;
            if (!this.ClientScript.IsClientScriptBlockRegistered("TreeViewValidator"))
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "TreeViewValidator", string.Format(@"function StartActionValidate(source, arguments) {{ var _treeView = $find('{0}'); if (_treeView) arguments.IsValid = (_treeView.get_selectedNode() != null); }}", TreeViewParentArticleToDelete.ClientID), true);
            }

            UploadControl.OrganizationId   = UserContext.Current.SelectedOrganization.OrganizationId;
            UploadControl.OrganizationName = UserContext.Current.SelectedOrganization.Name;
            UploadControl.DepartmentName   = UserContext.Current.SelectedInstance.Name;
            UploadControl.DepartmentId     = UserContext.Current.SelectedInstance.InstanceId;

            if (!IsPostBack)
            {
                //                FileAdminListCtrl.UploadControlsUniqueId = ButtonUpdate.UniqueID;
                Master.AutoGenerateBreadcrumbs = false;
                UserContext.Breadcrumbs.Add((string)this.GetLocalResourceObject("Home"), UserContext.Current.StartPageUrl, string.Empty, false);
                //SearchArticleCtrl.InstanceGuid = UserContext.Current.SelectedInstance.InstanceId;

                if (!this.ArticleGuid.Equals(Guid.Empty))
                {
                    MainDataSet.ArticleRow articleRow = this.GetCurrentArticle();
                    if (articleRow != null)
                    {
                        using (MainDataSetTableAdapters.CommentTableAdapter taComment = new MainDataSetTableAdapters.CommentTableAdapter())
                        {
                            taComment.MarkAsRead(articleRow.ArticleGuid);
                        }
                        //Master.AutoGenerateBreadcrumbs = false;
                        ArticlesTreeCtrl.ArticleGuid = articleRow.ArticleGuid;

                        if (this.Mode == "edit")
                        {
                            DoArticleEdit(articleRow);
                            return;
                        }
                        if (articleRow.Type == ArticleType.Request.ToString())
                        {
                            UserContext.Breadcrumbs.Add((string)this.GetLocalResourceObject("TheRequestsList"), "RequestList.aspx", string.Empty, false);
                            UserContext.Breadcrumbs.AddRange(Utils.GenerateBreadCrumbs(articleRow.ArticleGuid, UserContext.Current.SelectedInstance.InstanceId, true));
                            ShowRequestView();
                            MagicFormRequest.DataBind();
                            ImageListCtrl.Visible = FileListCtrl.Visible = false;
                            return;
                        }
                        else if (articleRow.Type == ArticleType.Article.ToString())
                        {
                            if (Request.QueryString["UC"] != null)
                            {
                                UserContext.Breadcrumbs.Add((string)this.GetLocalResourceObject("TheUnreadCommentsList"), "UnreadComments.aspx", string.Empty, false);
                            }
                            else
                            {
                                UserContext.Breadcrumbs.Add((string)this.GetLocalResourceObject("TheInstanceHome"), "InstanceHomeAdmin.aspx", string.Empty, false);
                            }
                            UserContext.Breadcrumbs.AddRange(Utils.GenerateBreadCrumbs(articleRow.ArticleGuid, UserContext.Current.SelectedInstance.InstanceId, true));
                            DoAricleView(articleRow);

                            return;
                        }
                    }
                    Master.AutoGenerateBreadcrumbs = false;
                    Master.ErrorMessage            = (string)this.GetLocalResourceObject("ArticleNotFound");
                }
                else
                {
                    UserContext.Breadcrumbs.Add((string)this.GetLocalResourceObject("TheInstanceHome"), "InstanceHomeAdmin.aspx", string.Empty, false);
                    UserContext.Breadcrumbs.Add((string)this.GetLocalResourceObject("AddNewArticle"), string.Empty, string.Empty, false);
                    DoArticleEdit(null);
                }
            }
        }
コード例 #16
0
        private void DoAricleView(MainDataSet.ArticleRow articleRow)
        {
            if (articleRow != null)
            {
                this.ArticleTableAdapter.IncReview(articleRow.ArticleGuid);
                ImageListCtrl.ArticleGuid = articleRow.ArticleGuid;
                FileListCtrl.ArticleGuid  = articleRow.ArticleGuid;
                ShowArticleView();

                HyperLinkPreview.Attributes["onclick"] = string.Format(CultureInfo.InvariantCulture, "javascript:window.open('default.aspx?i={0}&t={1}&popup=true', '_blank', 'location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,top=' + Mp_GetPopupPositionY(event) + ',left=' + Mp_GetPopupPositionX({2})  + ',width={2},height={3}');",
                                                                       UserContext.Current.SelectedInstance.InstanceId.ToString("N"),
                                                                       articleRow.ArticleGuid.ToString("N"),
                                                                       Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.MasterPage.HelpLink.WindowWidth,
                                                                       Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.MasterPage.HelpLink.WindowHeight);
                if (articleRow.Deleted)
                {
                    ButtonInactive.Text          = (string)this.GetLocalResourceObject("ActivateArticle");
                    ButtonInactive.OnClientClick = (string)this.GetLocalResourceObject("ConfirmActivate");
                }
                else
                {
                    ButtonInactive.Text          = (string)this.GetLocalResourceObject("InactivateArticle");
                    ButtonInactive.OnClientClick = string.Empty;
                }
                Master.CustomName = articleRow.Subject;
                //Master.Title = string.Format("{0} {1} KB - {2}", this.ArticleTableAdapter.GetOrganizationName(this.Master.InstanceGuid), this.ArticleTableAdapter.GetInstanceName(this.Master.InstanceGuid), articleRow.Subject);
                Master.Title = articleRow.Subject;

                //Master.VisiblePageTitle = false;
                litSubject.Text = articleRow.Subject;
                string body = this.ArticleTableAdapter.GetBody(articleRow.ArticleGuid);
                if (!string.IsNullOrEmpty(body))
                {
                    body = body.Replace("<h2>", "<h2><span>");
                    body = body.Replace("<H2>", "<H2><span>");
                    body = body.Replace("</h2>", "</span></h2>");
                    body = body.Replace("</H2>", "</span></H2>");
                    divBody.InnerHtml = body;//HttpUtility.HtmlDecode(body);
                }
                HtmlMeta metaDescription = new HtmlMeta();
                metaDescription.Name    = "Description";
                metaDescription.Content = articleRow.SearchDesc;
                Page.Header.Controls.Add(metaDescription);
                Guid userId = Guid.Empty;
                if (!articleRow.IsCreatedByNull())
                {
                    userId = articleRow.CreatedBy;
                }
                if (!articleRow.IsUpdatedByNull())
                {
                    userId = articleRow.UpdatedBy;
                }
                //if (userId == Guid.Empty)
                //    PostCommentCtrl.ReceiverName = Utils.GetInstanceUserName(UserContext.Current.SelectedInstance.InstanceId);
                //else
                //{
                //    Micajah.Common.Dal.OrganizationDataSet.UserRow userRow = Micajah.Common.Bll.Providers.UserProvider.GetUserRow(userId);
                //    if (userRow != null)
                //        PostCommentCtrl.ReceiverName = userRow.FirstName + " " + userRow.LastName;
                //}
                PostCommentCtrl.InstanceGuid = UserContext.Current.SelectedInstance.InstanceId;
                PostCommentCtrl.ArticleGuid  = articleRow.ArticleGuid;
                CommentsListCtrl.ArticleGuid = articleRow.ArticleGuid;
                CommentsListCtrl.DataBind();
            }
        }