示例#1
0
        private void createSegemnt(string SegmentType)
        {
            try
            {
                lblMainMsg.Text = string.Empty;
                ListMasterBase listMaster = new ListMasterBase(ConnectionString);
                SegmentMasterBase segmentMaster = new SegmentMasterBase(ConnectionString);
                ListContactMaster objListContactMaster = new ListContactMaster(ConnectionString);
                DataTable dtListContactMaster = new DataTable();
                dtListContactMaster.Columns.Add(new DataColumn("ListMasterID", typeof(string)));
                dtListContactMaster.Columns.Add(new DataColumn("ContactId", typeof(string)));
                dtListContactMaster.Columns.Add(new DataColumn("CreatedDate", typeof(string)));
                dtListContactMaster.Columns.Add(new DataColumn("ModifiedDate", typeof(string)));
                dtListContactMaster.Columns.Add(new DataColumn("IsSegment", typeof(bool)));
                dtListContactMaster.Columns.Add(new DataColumn("IsActive", typeof(bool)));
                List<string> contactids = new List<string>();
                contactids = (List<string>)Session["ContactId"];
                if (hdfListId.Value != "")
                {
                    bool isDeleted = objListContactMaster.DeleteAllContactsFromList(Convert.ToInt64(hdfListId.Value));
                    if (isDeleted)
                    {
                        foreach (string contactID in contactids)
                        {
                            DataRow rowListContactMaster = dtListContactMaster.NewRow();
                            rowListContactMaster["ListMasterID"] = hdfListId.Value;
                            rowListContactMaster["ContactId"] = contactID;
                            rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                            rowListContactMaster["IsActive"] = true;
                            dtListContactMaster.Rows.Add(rowListContactMaster);
                        }
                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate","IsActive"  };
                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, ConnectionString);
                        ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(hdfListId.Value));
                        ListMaster listMasterNew = ListMaster.SelectOne(pk, ConnectionString);
                        listMaster.ListMasterID = Convert.ToInt64(hdfListId.Value);
                        listMaster.ListName = txtSegmentName.Text;
                        listMaster.ListDesc = txtDescription.Text;
                        listMaster.CreatedDate = listMasterNew.CreatedDate;
                        listMaster.ModifiedDate = System.DateTime.Now;
                        listMaster.IsSegment = true;
                        listMaster.Update();
                        segmentMaster.ListMasterID = Convert.ToInt64(hdfListId.Value);
                        segmentMaster.SegmentName = txtSegmentName.Text;
                        segmentMaster.SelectCondition = SelectedIds.Value.Substring(0, SelectedIds.Value.Length);
                        if (rbSegCamRecOnly.Checked)
                            HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactFieldName\" onChange='QueryBuild(this);'");
                        else
                            HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactFieldName\" onChange='ListQueryBuild(this);'");
                        HtmlContent.Value = HtmlContent.Value.Replace("\"ddlOperatorName\"", "\"ddlOperatorName\" onChange='getSearchKeys(this);'");
                        HtmlContent.Value = HtmlContent.Value.Replace("\"ddllinkdate\"", "\"ddllinkdate\" onChange='linkDateRange(this);'");
                        segmentMaster.SegmentFilter = HtmlContent.Value;
                        segmentMaster.Type = SegmentType;
                        segmentMaster.Update();
                    }
                    Response.Redirect("~/pages/segmentation.aspx?name=" + txtSegmentName.Text + "&mode=update");
                }
                else
                {
                    if (rgdContacts.MasterTableView.Items.Count > 0)
                    {
                        listMaster.ListName = txtSegmentName.Text;
                        listMaster.ListDesc = txtDescription.Text;
                        listMaster.CreatedDate = System.DateTime.Now;
                        listMaster.IsSegment = true;
                        listMaster.InsertWithDefaultValues(true);
                        Int64 listid = Convert.ToInt64(listMaster.ListMasterID);

                        segmentMaster.ListMasterID = listid;
                        segmentMaster.SegmentName = txtSegmentName.Text;
                        segmentMaster.SelectCondition = SelectedIds.Value.Substring(0, SelectedIds.Value.Length);
                        if (rbSegCamRecOnly.Checked)
                            HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactFieldName\" onChange='QueryBuild(this);'");
                        else
                            HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactFieldName\" onChange='ListQueryBuild(this);'");
                        HtmlContent.Value = HtmlContent.Value.Replace("\"ddlOperatorName\"", "\"ddlOperatorName\" onChange='getSearchKeys(this);'");
                        HtmlContent.Value = HtmlContent.Value.Replace("\"ddllinkdate\"", "\"ddllinkdate\" onChange='linkDateRange(this);'");
                        segmentMaster.SegmentFilter = HtmlContent.Value;
                        segmentMaster.Type = SegmentType;
                        segmentMaster.Insert();

                        foreach (string contactID in contactids)
                        {
                            DataRow rowListContactMaster = dtListContactMaster.NewRow();
                            rowListContactMaster["ListMasterID"] = listid;
                            rowListContactMaster["ContactId"] = contactID;
                            rowListContactMaster["CreatedDate"] = DateTime.Now.ToString();
                            rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString();
                            rowListContactMaster["IsActive"] = true;
                            dtListContactMaster.Rows.Add(rowListContactMaster);
                        }
                        string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                        string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" };
                        ListContactMaster.BulkCopy(dtListContactMaster, "ListContactMaster", SourceColumn, DestinationColumn, ConnectionString);
                    }
                }
                Response.Redirect("~/pages/segmentation.aspx?name=" + txtSegmentName.Text + "&mode=create");
            }
            catch (Exception ex)
            {
                lblMainMsg.Text = "Error: " + ex.Message;
                rtsAddSegment.SelectedIndex = 0;
                rtsAddSegment.MultiPage.SelectedIndex = 0;
            }
        }
示例#2
0
        private void updateSegmentDetails()
        {
            ListMasterBase listMaster = new ListMasterBase(ConnectionString);
                SegmentMasterBase segmentMaster = new SegmentMasterBase(ConnectionString);
                ListMasterPrimaryKey pk = new ListMasterPrimaryKey(Convert.ToInt64(hdfListId.Value));//hiddenEditID.Value));
                ListMaster listMasterNew = ListMaster.SelectOne(pk, ConnectionString);

                listMaster.ListMasterID = Convert.ToInt64(hdfListId.Value);
                listMaster.ListName = txtSegmentName.Text;
                listMaster.ListDesc = txtDescription.Text;
                listMaster.ModifiedDate = System.DateTime.Now;
                listMaster.CreatedDate = listMasterNew.CreatedDate;
                listMaster.IsSegment = true;
                listMaster.Update();

                segmentInfo = (DataTable)ViewState["SegementDetails"];
                segmentMaster.ListMasterID = Convert.ToInt64(hdfListId.Value);
                segmentMaster.SegmentName = txtSegmentName.Text;
                segmentMaster.SelectCondition = segmentInfo.Rows[0]["SelectCondition"].ToString();
                segmentMaster.SegmentFilter = segmentInfo.Rows[0]["SegmentFilter"].ToString();
                segmentMaster.Type = segmentInfo.Rows[0]["Type"].ToString();
                segmentMaster.Update();
                Response.Redirect("~/pages/segmentation.aspx?name=" + txtSegmentName.Text + "&mode=update");
        }
示例#3
0
        /// <summary>
        /// Populates the fields of a single objects from the columns found in an open reader.
        /// </summary>
        /// <param name="obj" type="SegmentMaster">Object of SegmentMaster to populate</param>
        /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			4/21/2012 4:48:41 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        internal static void PopulateObjectFromReader(SegmentMasterBase obj,IDataReader rdr)
        {
            obj.ListMasterID = rdr.GetInt64(rdr.GetOrdinal(SegmentMasterFields.ListMasterID));
            if (!rdr.IsDBNull(rdr.GetOrdinal(SegmentMasterFields.SegmentName)))
            {
                obj.SegmentName = rdr.GetString(rdr.GetOrdinal(SegmentMasterFields.SegmentName));
            }

            if (!rdr.IsDBNull(rdr.GetOrdinal(SegmentMasterFields.SelectCondition)))
            {
                obj.SelectCondition = rdr.GetString(rdr.GetOrdinal(SegmentMasterFields.SelectCondition));
            }

            if (!rdr.IsDBNull(rdr.GetOrdinal(SegmentMasterFields.SegmentFilter)))
            {
                obj.SegmentFilter = rdr.GetString(rdr.GetOrdinal(SegmentMasterFields.SegmentFilter));
            }

            if (!rdr.IsDBNull(rdr.GetOrdinal(SegmentMasterFields.Type)))
            {
                obj.Type = rdr.GetString(rdr.GetOrdinal(SegmentMasterFields.Type));
            }
        }