예제 #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["ContactID"] != null && Request.QueryString["CampaignID"] != null && Request.QueryString["Username"] != null)
            {

                if (Request.QueryString["direct"] == null || Request.QueryString["direct"] == "no")
                {
                    ContactMasters contemail = ContactMaster.SelectByField("EmailAddress", txtEmailAddress.Text, connectionString);
                    contMasters = ContactMaster.SelectByField("ContactId", Convert.ToInt64(Request.QueryString["ContactID"]), connectionString);

                    contactBase = new ContactMaster(connectionString);
                    contactBase.FirstName = txtFirstName.Text;
                    contactBase.LastName = txtLastName.Text;
                    contactBase.EmailAddress = txtEmailAddress.Text;
                    contactBase.City = txtCity.Text;
                    contactBase.Country = txtCountry.Text;
                    contactBase.MobilePhone = txtMobilePhone.Text;
                    contactBase.PostalCode = txtZipCode.Text;
                    contactBase.State = txtState.Text;
                    contactBase.Address1 = txtAddress1.Text;
                    contactBase.Address2 = txtAddress2.Text;
                    contactBase.ModifiedDate = DateTime.Now;

                    if (contMasters.Count > 0)
                    {
                        List<ContactMaster> cm1 = contemail.ToList().FindAll(delegate(ContactMaster contact) { return (contact.IsDeleted == false || contact.IsDeleted == null); });
                        if (cm1.Count == 0)
                        {
                            update();
                        }
                        else
                        {
                            List<ContactMaster> cm2 = cm1.FindAll(delegate(ContactMaster contact) { return (contact.ContactId == contMasters[0].ContactId); });
                            if (cm2.Count > 0)
                            {
                                update();
                            }
                            else
                            {
                                statusmessage.Append(string.Format("Contact already exists with EmailAddress - {0}", txtEmailAddress.Text));
                                lbMsg.Text = statusmessage.ToString();
                                lbMsg.ForeColor = System.Drawing.Color.Red;
                            }
                        }
                    }
                }
                else if (Request.QueryString["direct"] != null || Request.QueryString["direct"] == "yes")
                {

                    objRecipientMasters = RecipientMaster.SelectByField("ContactId", Convert.ToInt64(Request.QueryString["ContactID"]), connectionString);
                    RecipientBase =new RecipientMaster(connectionString);
                    RecipientBase.Firstname= txtFirstName.Text;
                    RecipientBase.Lastname = txtLastName.Text;
                    RecipientBase.EmailAddress = txtEmailAddress.Text;
                    RecipientBase.City = txtCity.Text;
                    RecipientBase.Country = txtCountry.Text;
                    RecipientBase.CellPhone = txtMobilePhone.Text;
                    RecipientBase.Postal_Code = txtZipCode.Text;
                    RecipientBase.State = txtState.Text;
                    RecipientBase.Address1 = txtAddress1.Text;
                    RecipientBase.Address2 = txtAddress2.Text;
                    RecipientBase.Major1_Intended_College_Major_Description = ddlMajor.SelectedValue;
                    RecipientBase.Sports1 = ddlSports.SelectedValue;
                    RecipientBase.Parent1eml = txtParentEmail.Text;
                    updateContactInDirectMail();
                }
            }
        }
        public DataTable ImportRecordsToRecipientMaster(DataTable dtContacts, DataTable dtFieldMap, DataRow dr)
        {
            try
            {
                Logger.logdata(logforimportrecipients, "************** in ImportRecordsToRecipientMaster(..) method **************");
                Logger.logdata(logforimportrecipients, string.Format("ImportRecordsToRecipientMaster(..) has been started at {0}", DateTime.Now.ToString()));

                RecipientMaster objRecipientMaster = new RecipientMaster(connectionString);
                //convert csv datatable to xml.
                string contactmasterXMLString = buildXmlFromDatatable(dtContacts, "RecipientMaster");
                //Logger.logdata(logforimportrecipients, string.Format("contactmaster xml string {0}", contactmasterXMLString));

                //Batch insert and update contacts to RecipientMaster table and
                //save the return values in a datatable which contains contactIds of inserted and updated rows in RecipientMaster table.
                DataTable dtContactMasterData = objRecipientMaster.InsertOrUpdateRecipientMaster(Convert.ToInt64(dr["ID"].ToString()), contactmasterXMLString, Convert.ToInt32(dr["ListID"]));

                string listcontactmasterXMLString = buildXmlFromDatatable(dtContactMasterData, "AdvanceListContactMaster");
                Logger.logdata(logforimportrecipients, string.Format("listcontactmaster xml string {0}", listcontactmasterXMLString));
                //Batch insert and update contacts to listcontactmaster table.
                DataTable dtListContactMasterResult = objRecipientMaster.InsertOrUpdateListContactMaster(listcontactmasterXMLString);

                return dtListContactMasterResult;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
        private void DisplayCustomControlValuesForDirectMail(RecipientMaster contact)
        {
            //alCustonFields
            DataTable dt = ManageFieldsBase.SelectCustomFields(connectionString);
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                alCustonFields.Add(dt.Rows[i]["ContactFieldName"].ToString());

                if (dt.Rows[i]["FieldType"].ToString().ToLower() == "drop down list")
                {
                    switch (dt.Rows[i]["FieldName"].ToString().ToLower())
                    {
                        case "intended major":
                            dtFieldsProps = ManageFieldsPropertyBase.SelectByFields(connectionString, "FieldId", Convert.ToInt32(dt.Rows[i]["FieldId"]));
                            for (int j = 0; j < dtFieldsProps.Rows.Count; j++)
                            {
                                ListItem item = new ListItem(dtFieldsProps.Rows[j]["Item"].ToString(), dtFieldsProps.Rows[j]["value"].ToString());
                                ddlMajor.Items.Add(item);
                            }
                           //ddlMajor.Items.Contains(contact.in
                            try
                            {
                                ListItem li = ddlMajor.Items.FindByValue(value);
                                if (li != null)
                                {
                                    li.Selected = true;
                                    hddIntendedMajor.Value = value.ToString();
                                }
                                else
                                {
                                    //ddlMajor.SelectedItem.Text = "--Select--";
                                    hddIntendedMajor.Value = "--Select--";
                                }
                                ddlMajor.Items.Insert(0, litem);
                            }
                            catch { }
                            break;

                        case "sport":
                            dtFieldsProps = ManageFieldsPropertyBase.SelectByFields(connectionString, "FieldId", Convert.ToInt32(dt.Rows[i]["FieldId"]));
                            for (int j = 0; j < dtFieldsProps.Rows.Count; j++)
                            {
                                ListItem item = new ListItem(dtFieldsProps.Rows[j]["Item"].ToString(), dtFieldsProps.Rows[j]["value"].ToString());
                                ddlSports.Items.Add(item);
                            }
                            //displayingCustomControlValues(dt.Rows[i]["ContactFieldName"].ToString(), contact, ref value);
                            try
                            {
                                ListItem li = ddlSports.Items.FindByValue(value);
                                if (li != null)
                                {
                                    li.Selected = true;
                                    hddSports.Value = value.ToString();
                                }
                                else
                                {
                                    //ddlSports.SelectedItem.Text = "--Select--";
                                    hddSports.Value = "--Select--";
                                }
                                ddlSports.Items.Insert(0, litem);
                            }
                            catch { }
                            break;
                    }
                }
                if (dt.Rows[i]["FieldType"].ToString().ToLower() == "radio button list")
                {
                    switch (dt.Rows[i]["FieldName"].ToString().ToLower())
                    {
                        case "can we contact you by text message?":
                            dtFieldsProps = ManageFieldsPropertyBase.SelectByFields(connectionString, "FieldId", Convert.ToInt32(dt.Rows[i]["FieldId"]));
                            //for (int j = 0; j < dtFieldsProps.Rows.Count; j++)
                            //{
                            //    ListItem item = new ListItem(dtFieldsProps.Rows[j]["Item"].ToString(), dtFieldsProps.Rows[j]["value"].ToString());
                            //    ddlMajor.Items.Add(item);
                            //}
                            //displayingCustomControlValues(dt.Rows[i]["ContactFieldName"].ToString(), contact, ref value);
                            try
                            {
                                ListItem li = RBLtextmsg.Items.FindByText(value);
                                if (li != null)
                                {
                                    li.Selected = true;
                                    hdRBLtextmsg.Value = value.ToString();
                                }
                            }
                            catch { }
                            break;

                    }
                }

            }
        }
예제 #4
0
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="RecipientMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class RecipientMaster</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			9/19/2012 10:48:08 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static RecipientMaster SelectOne(RecipientMasterPrimaryKey pk,string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr=oDatabaseHelper.ExecuteReader("sp_RecipientMaster_SelectbyPrimaryKey", ref ExecutionState);
            if (dr.Read())
            {
                RecipientMaster obj = new RecipientMaster(ConnectionString);
                PopulateObjectFromReader(obj,dr);
                dr.Close();
                oDatabaseHelper.Dispose();
                return obj;
            }
            else
            {
                dr.Close();
                oDatabaseHelper.Dispose();
                return null;
            }
        }
예제 #5
0
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of RecipientMasters</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			9/19/2012 10:48:08 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static RecipientMasters PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper, string ConnectionString)
        {
            RecipientMasters list = new RecipientMasters();

            if (rdr.Read())
            {
                RecipientMaster obj = new RecipientMaster(ConnectionString);
                PopulateObjectFromReader(obj, rdr);
                list.Add(obj);
                while (rdr.Read())
                {
                    obj = new RecipientMaster(ConnectionString);
                    PopulateObjectFromReader(obj, rdr);
                    list.Add(obj);
                }
                oDatabaseHelper.Dispose();
                return list;
            }
            else
            {
                oDatabaseHelper.Dispose();
                return null;
            }
        }
예제 #6
0
        /// <summary>
        /// Populates the fields for multiple objects from the columns found in an open reader.
        /// </summary>
        ///
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <returns>Object of RecipientMasters</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			9/19/2012 10:48:08 AM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static RecipientMasters PopulateObjectsFromReader(IDataReader rdr, string ConnectionString)
        {
            RecipientMasters list = new RecipientMasters();

            while (rdr.Read())
            {
                RecipientMaster obj = new RecipientMaster(ConnectionString);
                PopulateObjectFromReader(obj,rdr);
                list.Add(obj);
            }
            return list;
        }
예제 #7
0
        protected void lbtnImport_Click(object sender, EventArgs e)
        {
            try
            {
                if (lstBoxListNames.Items.Count > 0 && Session["IEImportFileByteData"] != null)
                {
                    DataTable dtFieldMap = buildDatatableFromGrid();
                    if (dtFieldMap.Rows.Count > 0)
                    {
                        //to check whether Purl field mapped to one field or more
                        for (int i = 0; i < GridFieldmap.Rows.Count; i++)
                        {
                            DropDownList ddlContactMasterFields = (DropDownList)this.GridFieldmap.Rows[i].FindControl("ddlContactMasterFields");
                            if (ddlContactMasterFields.SelectedItem.Value == "Purl")
                                count++;
                        }
                        if (count > 1)
                            throw new Exception("Cannot map two fields to Purl");
                        int EmailaddressColumnNo = Convert.ToInt32(Session["IEPurlColumnNo"]);
                        DropDownList ddlContactMaster = (DropDownList)this.GridFieldmap.Rows[EmailaddressColumnNo].FindControl("ddlContactMasterFields");
                        if (ddlContactMaster.Items.Count == 0)
                        {
                            if (ddlContactMaster.SelectedItem.Text != "Purl")
                                throw new Exception("Please select Purl fieldmap correctly");
                        }

                        RecipientMaster objRecipientMaster = new RecipientMaster(ConnectionString);
                        FileInfo fileInfo = new FileInfo(hidFilename.Value);

                        string filenameWithGUID = System.Guid.NewGuid().ToString() + fileInfo.Extension;

                        for (int i = 0; i < lstBoxListNames.Items.Count; i++)
                        {
                            //insert importjob
                            Int64 ImportJobID = objRecipientMaster.InsertImportJob(hidFilename.Value, ddlFileType.SelectedItem.Text, string.Empty, chkSendNotification.Checked, lstBoxListNames.Items[i].Value, txtEmailAddress.Text, Common.ImportStatus.Pending.ToString(), filenameWithGUID, chkHasColumnNames.Checked);
                            //convert fieldmap datatable to xml.
                            string fieldmapXMLString = buildXmlFromDatatable(dtFieldMap, "AdvancedFieldMap");
                            //insert Fieldmap
                            objRecipientMaster.InsertFieldmap(ImportJobID, fieldmapXMLString);
                        }

                        // get import path.
                        string importFilePath = ConfigurationManager.AppSettings["AdvacedImportFilePath"].ToString();
                        DirectoryInfo dirlogInfo = new DirectoryInfo(importFilePath);
                        if (!dirlogInfo.Exists)
                            dirlogInfo.Create();

                        //create and save file in import path by reading it from stream saved in session variable.
                        using (FileStream writeStream = new FileStream(Path.Combine(importFilePath, filenameWithGUID), FileMode.Create, FileAccess.Write))
                        {
                            byte[] byteData = (byte[])Session["IEImportFileByteData"];
                            writeStream.Write(byteData, 0, byteData.Length);
                            writeStream.Close();
                            Session["IEImportFileByteData"] = null;
                        }
                        lblMsg.Visible = true;
                        lblMsg.ForeColor = System.Drawing.Color.Green;
                        lblMsg.Text = "Successfully imported file: " + hidFilename.Value;
                        ModalPopupExtenderShowImportInfo.Show();
                        pnlFieldMap.Visible = false;
                        fileUploadCSV.Style.Add("display", "block");
                        trShowSelectedFile.Style.Add("display", "none");
                        lstBoxListNames.Items.Clear();
                        ddlFileType.SelectedIndex = 0;
                        ddlFileType.Enabled = true;
                        chkHasColumnNames.Checked = false;
                        ViewState["IESelectedAll"] = null;

                    }
                }
                else
                {
                    lblMsg.Visible = true;
                    lblMsg.ForeColor = System.Drawing.Color.Red;
                    lblMsg.Text = "Please select Get field map and try";
                    trShowSelectedFile.Style.Add("display", "none");
                    fileUploadCSV.Style.Add("display", "block");
                }

            }
            catch (Exception ex)
            {
                lblMsg.Visible = true;
                if (lblMsg.Text == string.Empty)
                    lblMsg.Text = "Please map Purl field since it is mandatory";
                else
                    lblMsg.Text = "Error: " + ex.Message;
            }
            finally
            {
                Session["IESelectedFileDataTable"] = null;
            }
        }