コード例 #1
0
        protected void lbtnYes_Click(object sender, EventArgs e)
        {
            try
            {
                hdnSearchValue.Value = txtsearch.Text;
                if (grdContacts.Rows.Count > 0)
                {
                    lblMsg.Text = string.Empty;
                    //Get contact Selection
                    rememberContactSelection("chkSelect", "lblId", grdContacts, "chkHdr");

                    if (Session["SASelectedContacts"] != null)
                    {
                        StringBuilder strbDeletedContacts = new StringBuilder();
                        //adding selected contatIds to stringbuilder
                        for (int i = 0; i < contactsSelected.Count; i++)
                        {
                            strbDeletedContacts.Append(contactsSelected[i] + ", ");
                        }
                        strbDeletedContacts.Remove(strbDeletedContacts.Length - 2, 1);

                        SuppressContactsBase SupContact = new SuppressContactsBase(ConnectionString);
                        SupContact.RemoveMultipleContacts(strbDeletedContacts.ToString());

                        Session["SASelectedContacts"] = null;
                        hdrchkselected.Clear();
                        hdContacts.Value = "";
                        if (RBGlobal.Checked == true)
                        {
                            lstBoxListNames.Style.Add("display", "none");
                            lbtnLookup.Style.Add("display", "none");
                            lbllists.Style.Add("display", "none");
                        }
                        else
                        {
                            lstBoxListNames.Style.Add("display", "Block");
                            lbtnLookup.Style.Add("display", "Block");
                            lbllists.Style.Add("display", "Block");
                        }

                        searchselect();
                        UpdatePanel1.Update();
                        lblGrdMsg.Text = "Contact(s) removed successfully from suppression with ids: " + strbDeletedContacts.ToString();
                        Session["SASelectedContacts"] = null;
                        txtsearch.Text = hdnSearchValue.Value;
                    }
                }
            }
            catch (Exception ex)
            {
                lblGrdMsg.Style.Add("color", "red");
                lblGrdMsg.Text = ex.Message;
                throw ex;
            }
        }
コード例 #2
0
        protected void lbtnSuppress_Click(object sender, EventArgs e)
        {
            try
            {
                lblGrdMsg.Text = string.Empty;
                string listids = null;
                bool statusLocal = false, statusGlobal = false;

                if (lstBoxListNames.Items.Count > 0)
                {
                    foreach (ListItem item in lstBoxListNames.Items)
                        listids = listids + item.Value + ',';
                    listids = listids.Substring(0, listids.Length - 1);
                }
                if (RBLocal.Checked == true)
                {
                    ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                    statusLocal = objListContactMaster.UpdateStatusByEmail(txtEmailAddress.Text.ToString(), listids.ToString());
                }
                else
                {
                    SuppressContactsBase objSupAdd = new SuppressContactsBase(ConnectionString);
                    objSupAdd.ChannelType = ddlChannelType.SelectedItem.Value;
                    objSupAdd.CreatedBy = User.Identity.Name;
                    objSupAdd.EmailAddress = txtEmailAddress.Text;
                    objSupAdd.LastActionType = "manual";
                    //By Anwar on 11Aug12
                    statusGlobal = objSupAdd.SuppressEmailIDBYGlobalOrLocal(listids);
                    bindgrid();
                    UdpnlGridRecipients.Update();
                }
                if (statusLocal == true || statusGlobal == true)
                {
                    lblMsg.Style.Add("color", "Green");
                    lblMsg.Text = txtEmailAddress.Text + "  Suppressed successfully";
                    txtEmailAddress.Text = string.Empty;
                    if (RBLocal.Checked != true)
                    {
                        lbtnLookup.Style.Add("display", "none");
                        lstBoxListNames.Style.Add("display", "none");
                        lbllists.Style.Add("display", "none");
                    }
                }
                else if (statusLocal == false)
                {
                    lblMsg.Style.Add("color", "Red");
                    lblMsg.Text = txtEmailAddress.Text + "not Suppressed, Email Address not Contain for Selected List(s)";
                }
                else if (statusGlobal == false)
                {
                    lblMsg.Style.Add("color", "Red");
                    lblMsg.Text = txtEmailAddress.Text + " not Suppressed please try again";
                }
            }
            catch (Exception ex)
            {
                lblMsg.Style.Add("color", "Red");
                lblMsg.Text = ex.Message;
            }
        }
コード例 #3
0
 protected void lbtnYesAll_Click(object sender, EventArgs e)
 {
     if (grdContacts.Rows.Count > 0)
     {
         StringBuilder strbDeletedContacts = new StringBuilder();
         DataTable dtsuppressContacts = SuppressContactsBase.SelectAll(ConnectionString);
         //adding selected contatIds to stringbuilder
         for (int i = 0; i < dtsuppressContacts.Rows.Count; i++)
         {
             strbDeletedContacts.Append(dtsuppressContacts.Rows[i][0] + ", ");
         }
         strbDeletedContacts.Remove(strbDeletedContacts.Length - 2, 1);
         SuppressContactsBase SupContact = new SuppressContactsBase(ConnectionString);
         SupContact.RemoveMultipleContacts(strbDeletedContacts.ToString());
         Session["SASelectedContacts"] = null;
         hdrchkselected.Clear();
         hdContacts.Value = "";
         if (RBGlobal.Checked == true)
         {
             lstBoxListNames.Style.Add("display", "none");
             lbtnLookup.Style.Add("display", "none");
             lbllists.Style.Add("display", "none");
         }
         else
         {
             lstBoxListNames.Style.Add("display", "Block");
             lbtnLookup.Style.Add("display", "Block");
             lbllists.Style.Add("display", "Block");
         }
         searchselect();
         UpdatePanel1.Update();
         txtsearch.Text = "";
         lblGrdMsg.Text = "All Contacts removed successfully from suppression";
         Session["SASelectedContacts"] = null;
         txtsearch.Text = hdnSearchValue.Value;
     }
 }
コード例 #4
0
 protected void lbtnImport_Click(object sender, EventArgs e)
 {
     try
     {
         lblGrdMsg.Text = string.Empty;
         Stream stream = null;
         string[] strFileData = null;
         bool isFirstRowHeadder = false;
         DataTable dtFileData = null;
         //save import file data in session as byte format.
         HttpPostedFile myFile = fileUploadCSV.PostedFile;
         stream = myFile.InputStream;
         int nFileLen = myFile.ContentLength;
         byte[] myData = new Byte[nFileLen];
         fileUploadCSV.FileContent.Read(myData, 0, nFileLen);
         isFirstRowHeadder = false;
         if (ddlFileType.SelectedItem.Text.Equals("Excel(.xls, .xlsx)"))
         {
             dtFileData = getDataTableOfExcel(stream, fileUploadCSV.FileName, false);
         }
         else
         {
             UTF8Encoding encoding = new UTF8Encoding();
             string str = encoding.GetString(myData, 0, myData.Length);
             strFileData = str.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
             dtFileData = convertFileToDatatable(strFileData, isFirstRowHeadder);
         }
         dtFileData = checkInValidEmailAddresses(dtFileData);
         dtFileData = RemoveDuplicateRows(dtFileData, "EmailAddress");
         string XMLData = buildXmlFromDatatable(dtFileData, "SuppressContacts");
         if (dtFileData.Columns.Count > 5)
         {
             throw new Exception("Please upload one column text file(.txt or .csv).");
         }
         if (isFirstRowHeadder == true)
         {
             dtFileData.Rows.RemoveAt(0);
         }
         SuppressContactsBase objSuppressContacts = new SuppressContactsBase(ConnectionString);
         objSuppressContacts.InsertUpdate(ConnectionString, XMLData);
         lblMsg.Visible = true;
         lblMsg.ForeColor = System.Drawing.Color.Green;
         lblMsg.Text = "Successfully imported file: " + fileUploadCSV.FileName;
         ddlFileType.SelectedIndex = 0;
         bindgrid();
         UdpnlGridRecipients.Update();
     }
     catch (Exception ex)
     {
         lblMsg.ForeColor = System.Drawing.Color.Red;
         lblMsg.Text = ex.Message;
     }
 }