Exemple #1
0
    // Event in Row.
    protected void RadGrid1_ItemCommand(object sender, TreeListCommandEventArgs e)
    {
        int    lKeyID = 0;
        string lEvent = e.CommandName;
        string page   = "";

        switch (lEvent)
        {
        case ActRow.Delete:
            lKeyID = int.Parse(e.CommandArgument.ToString());
            int lRowDeleted = DeleteByID(lKeyID);              // Delete Row
            ShowSuccessMes(lRowDeleted + " dòng đã được xoá"); // show Mes.
            LoadData();
            break;

        case ActRow.Edit:
            lKeyID = int.Parse(e.CommandArgument.ToString());
            page   = Page.Request.QueryString["module"];
            TNavigation.EditPage(page, lKeyID);
            break;

        case ActRow.Clone:
            lKeyID = int.Parse(e.CommandArgument.ToString());
            page   = Page.Request.QueryString["module"];
            TNavigation.ClonePage(page, lKeyID);
            break;
        }
    }
 protected void DebateList_ItemCommand(object source, TreeListCommandEventArgs e)
 {
     if (e.CommandName == "replyMessage")
     {
         if (e.Item is TreeListDetailTemplateItem)
         {
             TreeListDetailTemplateItem itm = e.Item as TreeListDetailTemplateItem;
             if (!Request.IsAuthenticated)
             {
                 needLoginLblTop.Visible    = true;
                 needLoginLblBottom.Visible = true;
                 needLoginLblTop.Text       = "<div class='dnnFormMessage dnnFormWarning'>" +
                                              Localization.GetString("LoggedIn", LocalResourceFile) +
                                              "  <a href='" + ConfigurationManager.AppSettings["DomainName"] + /*"/" +
                                                                                                                * System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/
                                              "/login.aspx?returnurl=" + HttpUtility.UrlEncode(Request.Url.PathAndQuery) + "'>" +
                                              Localization.GetString("Login", LocalResourceFile) + "</a></div>";
                 needLoginLblBottom.Text = needLoginLblTop.Text;
             }
             else
             {
                 itm.CssClass = "whiteBack";
                 LinkButton newPostBtn = (LinkButton)itm.FindControl("newPostBtn");
                 newPostBtn.CssClass = "newPostActive";
                 TreeListDataItem parentPost = itm.ParentItem;
                 parentPost.IsChildInserted = true;
                 DebateList.Rebind();
             }
         }
     }
 }
        protected void rTLSkills_ItemCommand(object sender, TreeListCommandEventArgs e)
        {
            //if (e.CommandName == "Update")
            //{

            //    if (e.Item is TreeListEditFormItem)
            //    {

            //        TreeListEditFormItem editForm = e.Item as TreeListEditFormItem;

            //        var rTBSkill = (editForm.FindControl("rTBSkillName") as RadTextBox).Text.ToString();
            //        var SkillID = DataBinder.Eval(editForm.DataItem, "SkillID").ToString();

            //    }
            //}

            if (e.CommandName == "Delete")
            {
                if (e.Item is TreeListDataItem)
                {
                    TreeListDataItem item = e.Item as TreeListDataItem;
                    var SkillID = DataBinder.Eval(item.DataItem, "SkillID").ToString();
                }

            }

            if (e.CommandName == "PerformInsert")
            {

                Hashtable insertValues = new Hashtable();
                TreeListEditableItem editedItem = e.Item as TreeListEditableItem;
                e.Item.OwnerTreeList.ExtractValuesFromItem(insertValues, editedItem, true);

                if (e.Item is TreeListDataInsertItem )
                {
                    TreeListDataInsertItem insertForm = e.Item as TreeListDataInsertItem;
                    var SkillID = DataBinder.Eval(insertForm.DataItem, "MstrSkillID").ToString();
                    var rTBSkill = (insertForm.FindControl("rTBSkillNameIns") as RadTextBox).Text.ToString();

                }
            }

            if (e.CommandName == "CustomItemsDropped")
            {
                TreeListDataItem item = e.Item as TreeListDataItem;
                string ParentSkillID = e.CommandArgument.ToString();

                rTLSkills.Rebind();

            }
        }
Exemple #4
0
        protected void RadTreeList1_DeleteCommand(object sender, TreeListCommandEventArgs e)
        {
            TreeListDataItem item = e.Item as TreeListDataItem;

            if (item.CanExpand)
            {
                RadAjaxPanel1.Alert("Cần xóa hết các đơn vị con trong đơn vị này trước");
                e.Canceled = true;
                return;
            }
            var         iD  = Convert.ToInt32(item.GetDataKeyValue("IDCoCauToChuc"));
            CoCauToChuc obj = _entities.CoCauToChucs.Where(o => o.IDCoCauToChuc == iD).First();

            _entities.CoCauToChucs.DeleteObject(obj);
            _entities.SaveChanges();
        }
Exemple #5
0
        protected void RadTreeList1_InsertCommand(object sender, TreeListCommandEventArgs e)
        {
            Hashtable            table = new Hashtable();
            TreeListEditableItem item  = e.Item as TreeListEditableItem;

            item.ExtractValues(table);
            CoCauToChuc obj          = new CoCauToChuc();
            RadComboBox cbocaptochuc = (RadComboBox)item.FindControl("cboCapToChuc");

            obj.IDCapToChuc = Convert.ToInt32(cbocaptochuc.SelectedValue);
            obj.NgayTao     = obj.NgayCapNhat = DateTime.Now;
            obj.NguoiTao    = obj.NguoiCapNhat = idUser;
            item.UpdateValues(obj);
            _entities.AddToCoCauToChucs(obj);
            _entities.SaveChanges();
        }
Exemple #6
0
        protected void RadTreeList1_UpdateCommand(object sender, TreeListCommandEventArgs e)
        {
            Hashtable            table = new Hashtable();
            TreeListEditableItem item  = e.Item as TreeListEditableItem;

            item.ExtractValues(table);
            TreeListEditFormItem editedItem = (e.Item as TreeListEditFormItem);
            string      dataKeyValue        = editedItem.ParentItem.GetDataKeyValue("IDCoCauToChuc").ToString();
            int         iD           = Convert.ToInt32(dataKeyValue);
            CoCauToChuc obj          = _entities.CoCauToChucs.Where(o => o.IDCoCauToChuc == iD).FirstOrDefault();
            RadComboBox cbocaptochuc = (RadComboBox)item.FindControl("cboCapToChuc");

            obj.IDCapToChuc  = Convert.ToInt32(cbocaptochuc.SelectedValue);
            obj.NgayCapNhat  = DateTime.Now;
            obj.NguoiCapNhat = idUser;
            item.UpdateValues(obj);
            _entities.SaveChanges();
        }
Exemple #7
0
        protected void RadTreeList1_DeleteCommand(object sender, TreeListCommandEventArgs e)
        {
            TreeListDataItem item = (TreeListDataItem)e.Item;

            foreach (var child in item.ChildItems)
            {
                var index = IncluirItens.IndexOf(IncluirItens.Single(i => i.id == int.Parse(child["id"].Text) && i.id_proteina == int.Parse(child["id_proteina"].Text)));
                IncluirItens.RemoveAt(index);
            }

            IncluirItens.RemoveAt(item.DataItemIndex);

            //soma e apresenta total na treeList
            SomaTotal();

            RadTreeList1.Rebind();

            //btnOk.OnClientClicking = "windowConfirmacao";
        }
        protected void rtlPricingModulePermissionsForEditing_UpdateCommand(Object source, TreeListCommandEventArgs e)
        {
            var editedItem = e.Item as TreeListDataItem;
            if (editedItem == null) return;

            int newPricingModuleID = DataIntegrity.ConvertToInt(lblHeaderItemID.Text);
            if (newPricingModuleID == default(int)) return;

            ThinkgatePricingModule pricingModule = new ThinkgatePricingModule(newPricingModuleID);
            if (String.IsNullOrEmpty(pricingModule.Name)) return;

            //Get the new values:
            var newValues = new Hashtable();
            e.Item.OwnerTreeList.ExtractValuesFromItem(newValues, editedItem, true);
            Guid permissionID = new Guid();
            Guid.TryParse(newValues["ID"].ToString(), out permissionID);
            if (permissionID == default(Guid)) return;

            string permissionName = newValues["Name"] == null ? string.Empty : newValues["Name"].ToString();
            bool hasPermission = newValues["Member"] != null && DataIntegrity.ConvertToBool(newValues["Member"]);

            //ThinkgatePermission permission = new ThinkgatePermission(permissionID);       // WSH : Not sure what point of this was

            SessionObject sessionObject = (SessionObject)Session["SessionObject"];
            ThinkgateUser user = sessionObject.LoggedInUser;
            if (hasPermission)
            {
                //pricingModule.Permissions.Add(permission);        // Not sure what point of this was
                pricingModule.UpdatePricingModulePermissions(permissionID, 0, user.UserName);
                lblResultMessage.Text = string.Format("Permission {0} was added to Pricing Module {1}.", permissionName,
                                                      pricingModule.Name);

                // WSH: Going to loop through the children and deal with them. In theory, you could devise a strategy that involved fewer calls to the DB and did a mass update. However you have to do a uniqueness check on each child insert or do a complete delete of all children recs to then do a mass insert. Since this will be a vary rare update, I decided performance was not important.
                foreach (TreeListDataItem item in editedItem.ChildItems)
                {
                    permissionID = new Guid();
                    Guid.TryParse(item.GetDataKeyValue("ID").ToString(), out permissionID);
                    if (permissionID == default(Guid)) return;

                    pricingModule.UpdatePricingModulePermissions(permissionID, 0, user.UserName);
                }
            }
            else
            {
                //pricingModule.Permissions.Remove(permission);   // WSH : Not sure what point of this was
                pricingModule.DeletePricingModulePermissions(permissionID);
                lblResultMessage.Text = string.Format("Permission {0} was revoked from Pricing Module {1}.", permissionName, pricingModule.Name);

                // WSH: Going to loop through the children and deal with them. In theory, you could devise a strategy that involved fewer calls to the DB and did a mass update. However you have to do a uniqueness check on each child insert or do a complete delete of all children recs to then do a mass insert. Since this will be a vary rare update, I decided performance was not important.
                foreach (TreeListDataItem item in editedItem.ChildItems)
                {
                    permissionID = new Guid();
                    Guid.TryParse(item.GetDataKeyValue("ID").ToString(), out permissionID);
                    if (permissionID == default(Guid)) return;

                    pricingModule.DeletePricingModulePermissions(permissionID);
                }
            }
        }
        protected void DebateList_ItemCommand(object source, TreeListCommandEventArgs e)
        {
            if (e.CommandName == "replyMessage")
            {
                if (e.Item is TreeListDetailTemplateItem)
                {
                    TreeListDetailTemplateItem itm = e.Item as TreeListDetailTemplateItem;
                    if (!Request.IsAuthenticated)
                    {
                        needLoginLblTop.Visible = true;
                        needLoginLblBottom.Visible = true;
                        needLoginLblTop.Text = "<div class='dnnFormMessage dnnFormWarning'>" +
                            Localization.GetString("LoggedIn", LocalResourceFile) +
                         "  <a href='" + ConfigurationManager.AppSettings["DomainName"] + /*"/" +
                         System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/
                         "/login.aspx?returnurl=" + HttpUtility.UrlEncode(Request.Url.PathAndQuery) + "'>" +
                         Localization.GetString("Login", LocalResourceFile) + "</a></div>";
                        needLoginLblBottom.Text = needLoginLblTop.Text;
                    }
                    else
                    {
                        itm.CssClass = "whiteBack";
                        LinkButton newPostBtn = (LinkButton)itm.FindControl("newPostBtn");
                        newPostBtn.CssClass = "newPostActive";
                        TreeListDataItem parentPost = itm.ParentItem;
                        parentPost.IsChildInserted = true;
                        DebateList.Rebind();
                    }

                }
            }
        }
        protected void DebateList_InsertCommand(object sender, TreeListCommandEventArgs e)
        {
            string ConnString = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
            string commandText = @"INSERT INTO uDebate_Forum_Posts (ThreadID, ParentID, UserID, PostLevel, SortOrder, Subject,
                                   Message, PostDate, IsPublished, PostType, Active, Published_Date, Complaint_Count, ModuleID)
                                   VALUES (@ThreadID, @ParentID, " + UserInfo.UserID + @", 1, 1, @Subject, @Message, getDate(), 1,
                                           @PostType,1,getDate(),0," + ModuleId + ")";

            SqlConnection conn = new SqlConnection(ConnString);
            SqlCommand command = new SqlCommand(commandText, conn);
            Hashtable table = new Hashtable();
            TreeListEditFormInsertItem item = e.Item as TreeListEditFormInsertItem;
            table["Subject"] = (item.FindControl("txtSubjectPost") as TextBox).Text;
            table["Message"] = (item.FindControl("txtReply") as DotNetNuke.Web.UI.WebControls.DnnEditor).GetHtml(EditorStripHtmlOptions.None).Replace("'", "\"");

            RadioButton Issue = (item.FindControl("IssueRadio") as RadioButton);
            RadioButton Alter = (item.FindControl("AlterRadio") as RadioButton);
            RadioButton Pro = (item.FindControl("ProRadio") as RadioButton);
            RadioButton Con = (item.FindControl("ConRadio") as RadioButton);
            RadioButton Comment = (item.FindControl("CommentRadio") as RadioButton);

            String selection = String.Empty;

            if (Issue.Checked)
            {
                selection = "1";
            }
            else if (Alter.Checked)
            {
                selection = "2";
            }
            else if (Pro.Checked)
            {
                selection = "3";
            }
            else if (Con.Checked)
            {
                selection = "4";
            }
            else if (Comment.Checked)
            {
                selection = "8";
            }

            table["PostType"] = selection;
            command.Parameters.AddWithValue("ThreadID", Thread_ID);
            command.Parameters.AddWithValue("Subject", table["Subject"]);
            command.Parameters.AddWithValue("Message", table["Message"]);
            command.Parameters.AddWithValue("PostType", table["PostType"]);

            object parentValue;
            if (item.ParentItem != null)
            {
                parentValue = item.ParentItem.GetDataKeyValue("ID");
            }
            else
            {
                parentValue = "0";
            }

            command.Parameters.AddWithValue("ParentID", parentValue);

            conn.Open();
            try
            {
                command.ExecuteNonQuery();
                /*if the new post is a reply we have to disable edit mode of parent and expand it */
                if (item.ParentItem != null)
                {
                    item.ParentItem.Expanded = true;
                    item.ParentItem.IsChildInserted = false;
                }
                DebateList.IsItemInserted = false;

                DebateList.Rebind();
                DataRow lastPost = getLatestPostOfThread(Thread_ID);
                if (lastPost != null)
                    FindAndSelectItem(Convert.ToInt32(lastPost["ID"]));

            }
            finally
            {
                conn.Close();
            }

            /* If a user posts to a thread we add him to the notification list*/
            AddUserToNotified(Thread_ID);
            notifyCheck.Checked = true;

            string fromAddress = "*****@*****.**";
            string subject = "OGP Ireland - New Post";
            string body = "Hi, <br /><br/>A new post has been submitted to the OGP Ireland thread \"<b>" +
                         getDescription(Thread_ID) + "\"</b>.<br /> To see this post, visit " +
                        ConfigurationManager.AppSettings["DomainName"] +/* "/" +
                        System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/
                        "/udebatediscussion.aspx?Thread=" + Thread_ID + "<br /><br/>Kind Regards,<br /><br/>"+
                        PortalSettings.PortalName + "<br /><a href='" + PortalSettings.DefaultPortalAlias +
                        "'>" + PortalSettings.DefaultPortalAlias + "</a>" + "<br /><br />" +
                        "<img src='http://" + PortalSettings.DefaultPortalAlias + "/Portals/0/pbp_logo270.jpg'/>";

            SendTokenizedBulkEmail mailer = new SendTokenizedBulkEmail();

            /* Notify moderators of the new post*/
            switch (getPostLanguageByThread(Thread_ID).ToLower())
            {
                case "el-gr":
                     Entities.Users.UserInfo user = new Entities.Users.UserInfo();
                     user.Email = "*****@*****.**";
                     mailer.AddAddressedUser(user);

                    break;
               /* case "es-es":
                    Entities.Users.UserInfo user3 = new Entities.Users.UserInfo();
                    user3.Email = "*****@*****.**";
                     mailer.AddAddressedUser(user3);
                     Entities.Users.UserInfo user4 = new Entities.Users.UserInfo();
                    user4.Email = "*****@*****.**";
                     mailer.AddAddressedUser(user4);
                     Entities.Users.UserInfo user5 = new Entities.Users.UserInfo();
                     user5.Email = "*****@*****.**";
                     mailer.AddAddressedUser(user5);
                    break;
                case "it-it":
                    Entities.Users.UserInfo user7 = new Entities.Users.UserInfo();
                    user7.Email = "*****@*****.**";
                     mailer.AddAddressedUser(user7);
                    break;
                case "hu-hu":
                    Entities.Users.UserInfo user9 = new Entities.Users.UserInfo();
                    user9.Email = "*****@*****.**";
                     mailer.AddAddressedUser(user9);
                    break;
                case "en-gb":
                    Entities.Users.UserInfo user11 = new Entities.Users.UserInfo();
                    user11.Email = "*****@*****.**";
                     mailer.AddAddressedUser(user11);
                     Entities.Users.UserInfo user12 = new Entities.Users.UserInfo();
                     user12.Email = "*****@*****.**";
                     mailer.AddAddressedUser(user12);
                    break;*/
                default:   break;
            }

            Entities.Users.UserInfo user14 = new Entities.Users.UserInfo();
            user14.Email = "*****@*****.**";
            mailer.AddAddressedUser(user14);

            mailer.Priority = DotNetNuke.Services.Mail.MailPriority.Normal;

            mailer.AddressMethod = DotNetNuke.Services.Mail.SendTokenizedBulkEmail.AddressMethods.Send_TO;

            Entities.Users.UserInfo senderUser = new Entities.Users.UserInfo();
            senderUser.Email = "*****@*****.**";

            mailer.SendingUser = senderUser;

            mailer.ReportRecipients = false;

            mailer.Subject = subject;

            mailer.Body = body;

            mailer.BodyFormat = DotNetNuke.Services.Mail.MailFormat.Html;

            Thread objThread = new Thread(mailer.Send);

            objThread.Start();

            /* Send an email to all the subscribed users of this thread*/
            string subjectNotify = "OGP Ireland - There is a new post in the thread you are following";
            string bodyNotify = "Hi, <br /><br/>A new post has been submitted to the OGP Ireland thread \"<b>" +
                         getDescription(Thread_ID) + "\"</b>.<br /> To see this post, visit " +
                        ConfigurationManager.AppSettings["DomainName"] + /*"/" +
                        System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/
                        "/udebatediscussion.aspx?Thread=" + Thread_ID + "<br /><br/>Kind Regards,<br /><br/>"+
                        PortalSettings.PortalName + "<br /><a href='" + PortalSettings.DefaultPortalAlias +
                        "'>" + PortalSettings.DefaultPortalAlias + "</a>" + "<br /><br />" +
                        "<img src='http://" + PortalSettings.DefaultPortalAlias + "/Portals/0/pbp_logo270.jpg'/>";

            string SQL_notified = "SELECT userID,userEmail FROM uDebate_Forum_Notifications where threadID=" + Thread_ID;
            try
            {
                DataSet ds = ATC.Database.sqlExecuteDataSet(SQL_notified);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    SendTokenizedBulkEmail notificationMailer = new SendTokenizedBulkEmail();

                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        // Only send email to users different than the current one (the post writer)
                        if (UserId != Int32.Parse(row["userID"].ToString()))
                        {
                            int numRecs = 100;
                            ArrayList findEmailinRegistered = Entities.Users.UserController.GetUsersByEmail(PortalId, row["userEmail"].ToString(), 0, 10, ref numRecs,false,false);

                            //Check that the user is still registered
                            if (findEmailinRegistered.Count > 0)
                            {
                                Entities.Users.UserInfo newUser = new Entities.Users.UserInfo();
                                newUser.Email = row["userEmail"].ToString();
                                notificationMailer.AddAddressedUser(newUser);
                            }
                            //if no, remove him from the list of notified users
                            else
                            {
                                RemoveUserFromNotified(row["userEmail"].ToString());

                            }
                        }
                    }

                    notificationMailer.Priority = DotNetNuke.Services.Mail.MailPriority.Normal;

                    notificationMailer.AddressMethod = DotNetNuke.Services.Mail.SendTokenizedBulkEmail.AddressMethods.Send_TO;

                    Entities.Users.UserInfo sendingUser = new Entities.Users.UserInfo();
                    sendingUser.Email = "*****@*****.**";

                    notificationMailer.SendingUser = sendingUser;

                    notificationMailer.ReportRecipients = true;

                    notificationMailer.Subject = subjectNotify;

                    notificationMailer.Body = bodyNotify;

                    notificationMailer.BodyFormat = DotNetNuke.Services.Mail.MailFormat.Html;

                    Thread objThread1 = new Thread(notificationMailer.Send);

                    objThread1.Start();
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
 protected void radTreeResults_ItemCommand(object sender, TreeListCommandEventArgs e)
 {
     if (e.CommandName == RadTreeList.ExpandCollapseCommandName)
     {
         if ((e.Item as TreeListDataItem).HierarchyIndex.NestedLevel == 0 && e.CommandArgument.ToString() == "ExpandAll")
         {
             e.Canceled = true;
             if (!(e.Item as TreeListDataItem).Expanded)
             {
                 radTreeResults.ExpandItemToLevel((e.Item as TreeListDataItem), 10);
             }
             else
             {
                 radTreeResults.CollapseAllItems();
             }
         }
     }
 }
        protected void DebateList_InsertCommand(object sender, TreeListCommandEventArgs e)
        {
            string ConnString  = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
            string commandText = @"INSERT INTO uDebate_Forum_Posts (ThreadID, ParentID, UserID, PostLevel, SortOrder, Subject,
                                   Message, PostDate, IsPublished, PostType, Active, Published_Date, Complaint_Count, ModuleID)
                                   VALUES (@ThreadID, @ParentID, " + UserInfo.UserID + @", 1, 1, @Subject, @Message, getDate(), 1,
                                           @PostType,1,getDate(),0," + ModuleId + ")";

            SqlConnection conn              = new SqlConnection(ConnString);
            SqlCommand    command           = new SqlCommand(commandText, conn);
            Hashtable     table             = new Hashtable();
            TreeListEditFormInsertItem item = e.Item as TreeListEditFormInsertItem;

            table["Subject"] = (item.FindControl("txtSubjectPost") as TextBox).Text;
            table["Message"] = (item.FindControl("txtReply") as DotNetNuke.Web.UI.WebControls.DnnEditor).GetHtml(EditorStripHtmlOptions.None).Replace("'", "\"");

            RadioButton Issue   = (item.FindControl("IssueRadio") as RadioButton);
            RadioButton Alter   = (item.FindControl("AlterRadio") as RadioButton);
            RadioButton Pro     = (item.FindControl("ProRadio") as RadioButton);
            RadioButton Con     = (item.FindControl("ConRadio") as RadioButton);
            RadioButton Comment = (item.FindControl("CommentRadio") as RadioButton);

            String selection = String.Empty;

            if (Issue.Checked)
            {
                selection = "1";
            }
            else if (Alter.Checked)
            {
                selection = "2";
            }
            else if (Pro.Checked)
            {
                selection = "3";
            }
            else if (Con.Checked)
            {
                selection = "4";
            }
            else if (Comment.Checked)
            {
                selection = "8";
            }

            table["PostType"] = selection;
            command.Parameters.AddWithValue("ThreadID", Thread_ID);
            command.Parameters.AddWithValue("Subject", table["Subject"]);
            command.Parameters.AddWithValue("Message", table["Message"]);
            command.Parameters.AddWithValue("PostType", table["PostType"]);

            object parentValue;

            if (item.ParentItem != null)
            {
                parentValue = item.ParentItem.GetDataKeyValue("ID");
            }
            else
            {
                parentValue = "0";
            }

            command.Parameters.AddWithValue("ParentID", parentValue);

            conn.Open();
            try
            {
                command.ExecuteNonQuery();
                /*if the new post is a reply we have to disable edit mode of parent and expand it */
                if (item.ParentItem != null)
                {
                    item.ParentItem.Expanded        = true;
                    item.ParentItem.IsChildInserted = false;
                }
                DebateList.IsItemInserted = false;

                DebateList.Rebind();
                DataRow lastPost = getLatestPostOfThread(Thread_ID);
                if (lastPost != null)
                {
                    FindAndSelectItem(Convert.ToInt32(lastPost["ID"]));
                }
            }
            finally
            {
                conn.Close();
            }

            /* If a user posts to a thread we add him to the notification list*/
            AddUserToNotified(Thread_ID);
            notifyCheck.Checked = true;

            string fromAddress = "*****@*****.**";
            string subject     = "OGP Ireland - New Post";
            string body        = "Hi, <br /><br/>A new post has been submitted to the OGP Ireland thread \"<b>" +
                                 getDescription(Thread_ID) + "\"</b>.<br /> To see this post, visit " +
                                 ConfigurationManager.AppSettings["DomainName"] +/* "/" +
                                                                                  * System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/
                                 "/udebatediscussion.aspx?Thread=" + Thread_ID + "<br /><br/>Kind Regards,<br /><br/>" +
                                 PortalSettings.PortalName + "<br /><a href='" + PortalSettings.DefaultPortalAlias +
                                 "'>" + PortalSettings.DefaultPortalAlias + "</a>" + "<br /><br />" +
                                 "<img src='http://" + PortalSettings.DefaultPortalAlias + "/Portals/0/pbp_logo270.jpg'/>";

            SendTokenizedBulkEmail mailer = new SendTokenizedBulkEmail();

            /* Notify moderators of the new post*/
            switch (getPostLanguageByThread(Thread_ID).ToLower())
            {
            case "el-gr":
                Entities.Users.UserInfo user = new Entities.Users.UserInfo();
                user.Email = "*****@*****.**";
                mailer.AddAddressedUser(user);

                break;

            /* case "es-es":
             *   Entities.Users.UserInfo user3 = new Entities.Users.UserInfo();
             *   user3.Email = "*****@*****.**";
             *    mailer.AddAddressedUser(user3);
             *    Entities.Users.UserInfo user4 = new Entities.Users.UserInfo();
             *   user4.Email = "*****@*****.**";
             *    mailer.AddAddressedUser(user4);
             *    Entities.Users.UserInfo user5 = new Entities.Users.UserInfo();
             *    user5.Email = "*****@*****.**";
             *    mailer.AddAddressedUser(user5);
             *   break;
             * case "it-it":
             *   Entities.Users.UserInfo user7 = new Entities.Users.UserInfo();
             *   user7.Email = "*****@*****.**";
             *    mailer.AddAddressedUser(user7);
             *   break;
             * case "hu-hu":
             *   Entities.Users.UserInfo user9 = new Entities.Users.UserInfo();
             *   user9.Email = "*****@*****.**";
             *    mailer.AddAddressedUser(user9);
             *   break;
             * case "en-gb":
             *   Entities.Users.UserInfo user11 = new Entities.Users.UserInfo();
             *   user11.Email = "*****@*****.**";
             *    mailer.AddAddressedUser(user11);
             *    Entities.Users.UserInfo user12 = new Entities.Users.UserInfo();
             *    user12.Email = "*****@*****.**";
             *    mailer.AddAddressedUser(user12);
             *   break;*/
            default:   break;
            }

            Entities.Users.UserInfo user14 = new Entities.Users.UserInfo();
            user14.Email = "*****@*****.**";
            mailer.AddAddressedUser(user14);

            mailer.Priority = DotNetNuke.Services.Mail.MailPriority.Normal;

            mailer.AddressMethod = DotNetNuke.Services.Mail.SendTokenizedBulkEmail.AddressMethods.Send_TO;

            Entities.Users.UserInfo senderUser = new Entities.Users.UserInfo();
            senderUser.Email = "*****@*****.**";

            mailer.SendingUser = senderUser;

            mailer.ReportRecipients = false;

            mailer.Subject = subject;

            mailer.Body = body;

            mailer.BodyFormat = DotNetNuke.Services.Mail.MailFormat.Html;

            Thread objThread = new Thread(mailer.Send);

            objThread.Start();

            /* Send an email to all the subscribed users of this thread*/
            string subjectNotify = "OGP Ireland - There is a new post in the thread you are following";
            string bodyNotify    = "Hi, <br /><br/>A new post has been submitted to the OGP Ireland thread \"<b>" +
                                   getDescription(Thread_ID) + "\"</b>.<br /> To see this post, visit " +
                                   ConfigurationManager.AppSettings["DomainName"] + /*"/" +
                                                                                     * System.Threading.Thread.CurrentThread.CurrentCulture.Name +*/
                                   "/udebatediscussion.aspx?Thread=" + Thread_ID + "<br /><br/>Kind Regards,<br /><br/>" +
                                   PortalSettings.PortalName + "<br /><a href='" + PortalSettings.DefaultPortalAlias +
                                   "'>" + PortalSettings.DefaultPortalAlias + "</a>" + "<br /><br />" +
                                   "<img src='http://" + PortalSettings.DefaultPortalAlias + "/Portals/0/pbp_logo270.jpg'/>";


            string SQL_notified = "SELECT userID,userEmail FROM uDebate_Forum_Notifications where threadID=" + Thread_ID;

            try
            {
                DataSet ds = ATC.Database.sqlExecuteDataSet(SQL_notified);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    SendTokenizedBulkEmail notificationMailer = new SendTokenizedBulkEmail();

                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        // Only send email to users different than the current one (the post writer)
                        if (UserId != Int32.Parse(row["userID"].ToString()))
                        {
                            int       numRecs = 100;
                            ArrayList findEmailinRegistered = Entities.Users.UserController.GetUsersByEmail(PortalId, row["userEmail"].ToString(), 0, 10, ref numRecs, false, false);

                            //Check that the user is still registered
                            if (findEmailinRegistered.Count > 0)
                            {
                                Entities.Users.UserInfo newUser = new Entities.Users.UserInfo();
                                newUser.Email = row["userEmail"].ToString();
                                notificationMailer.AddAddressedUser(newUser);
                            }
                            //if no, remove him from the list of notified users
                            else
                            {
                                RemoveUserFromNotified(row["userEmail"].ToString());
                            }
                        }
                    }

                    notificationMailer.Priority = DotNetNuke.Services.Mail.MailPriority.Normal;

                    notificationMailer.AddressMethod = DotNetNuke.Services.Mail.SendTokenizedBulkEmail.AddressMethods.Send_TO;

                    Entities.Users.UserInfo sendingUser = new Entities.Users.UserInfo();
                    sendingUser.Email = "*****@*****.**";

                    notificationMailer.SendingUser = sendingUser;

                    notificationMailer.ReportRecipients = true;

                    notificationMailer.Subject = subjectNotify;

                    notificationMailer.Body = bodyNotify;

                    notificationMailer.BodyFormat = DotNetNuke.Services.Mail.MailFormat.Html;

                    Thread objThread1 = new Thread(notificationMailer.Send);

                    objThread1.Start();
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Exemple #13
0
 protected void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
 {
 }
        protected void rtlUserPermissionsForEditing_UpdateCommand(Object source, TreeListCommandEventArgs e)
        {
            SessionObject sessionObject = (SessionObject)Session["SessionObject"];
            _user = sessionObject.SelectedUser;
            if (_user == null) return;

            var editedItem = e.Item as TreeListDataItem;
            if (editedItem == null) return;

            //Get the new values:
            var newValues = new Hashtable();
            e.Item.OwnerTreeList.ExtractValuesFromItem(newValues, editedItem, true);
            Guid permissionID = new Guid();
            Guid.TryParse(newValues["PermissionId"].ToString(), out permissionID);
            if (permissionID == default(Guid)) return;

            string permissionName = newValues["PermissionName"] == null ? string.Empty : newValues["PermissionName"].ToString();
            int permissionLevel = newValues["PermissionLevelValue"] == null ? 0 : DataIntegrity.ConvertToInt(newValues["PermissionLevelValue"].ToString());
            bool hasPermission = newValues["HasPermission"] != null && DataIntegrity.ConvertToBool(newValues["HasPermission"]);

            ThinkgatePermission permission = new ThinkgatePermission(permissionID);

            if (hasPermission)
            {
                permission.PermissionLevel = (ThinkgatePermission.PermissionLevelValues)Enum.ToObject(typeof(ThinkgatePermission.PermissionLevelValues), permissionLevel);
                _user.addPermission(permission);
                lblResultMessage.Text = string.Format("Permission {0} was added to user {1}.", permissionName, _user.UserName);
                foreach (TreeListDataItem item in editedItem.ChildItems)
                {
                    Guid.TryParse(item.GetDataKeyValue("PermissionId").ToString(), out permissionID);
                    if (permissionID == default(Guid)) return;
                    permission = new ThinkgatePermission(permissionID);
                    permission.PermissionLevel = (ThinkgatePermission.PermissionLevelValues)Enum.ToObject(typeof(ThinkgatePermission.PermissionLevelValues), permissionLevel);

                    _user.addPermission(permission);
                }
            }
            else
            {
                _user.removePermission(permission);
                lblResultMessage.Text = string.Format("Permission {0} was revoked from user {1}.", permissionName, _user.UserName);
                foreach (TreeListDataItem item in editedItem.ChildItems)
                {
                    Guid.TryParse(item.GetDataKeyValue("PermissionId").ToString(), out permissionID);
                    if (permissionID == default(Guid)) return;
                    permission = new ThinkgatePermission(permissionID);

                    _user.removePermission(permission);
                }
            }
            sessionObject.UpdateUserObject(_user);
        }
        protected void rTLSkills_UpdateCommand(object sender, TreeListCommandEventArgs e)
        {
            TreeListEditableItem editItem = (TreeListEditableItem)e.Item;
            Hashtable values = new Hashtable();
            editItem.ExtractValues(values);

            if (values["SkillName"] == null)
            {
                e.Canceled = true;
            }
        }