Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int plotId = 0;

            if ((Request.QueryString["plotId"] != "") && (Request.QueryString["plotId"] != null))
            {
                int.TryParse(Request.QueryString["plotId"], out plotId);
            }

            if (plotId == 0)
            {
                Response.Redirect("~/Members/ArchivedPlotList.aspx");
            }

            PlotIdHiddenField.Value = plotId.ToString();

            try
            {
                // Get the common web service instance.
                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();

                int userId = farmService.GetUserIdForPlot(plotId);
                UserIdHiddenField.Value = userId.ToString();

                if (!IsAgentRole)
                {
                    ForAgentPanel.Visible           = true;
                    ForAgentUserIdHiddenField.Value = userId.ToString();
                    ForAgentUserNameLabel.Text      = farmService.GetUserName(userId);
                }
                else
                {
                    ForAgentPanel.Visible = false;
                }

                //Getting Archived Plot Header Details
                FarmService.PlotInfo plot = farmService.GetArchivedPlotSummaryDetails(plotId);

                //Getting Parent Farm Details
                FarmService.FarmInfo farm = farmService.GetArchivedFarmSummaryDetails(plot.FarmId);

                PlotNameLabel.Text      = farm.FarmName + " / " + plot.PlotName;
                ContactCountLabel.Text  = plot.ContactCount.ToString();
                CreateDateLabel.Text    = plot.CreateDate.ToShortDateString();
                FarmIdHiddenField.Value = plot.FarmId.ToString();

                FarmService.ContactInfo[] contacts = farmService.GetArchivedContactListForPlot(plotId);
                ContactListGridView.DataSource = contacts;
                ContactListGridView.DataBind();
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR LOADING ARCHIVE CONTACT LIST:", exception);
                MessageLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
            }
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int farmId = 0;
            if ((Request.QueryString["farmId"] != "") && (Request.QueryString["farmId"] != null))
            {
                int.TryParse(Request.QueryString["farmId"], out farmId);
            }

            if (farmId == 0)
            {
                Response.Redirect("~/Members/ArchivedFarmList.aspx");
            }

            FarmIdHiddenField.Value = farmId.ToString();

            try
            {
                // Get the common web service instance.

                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();
                int userId = farmService.GetUserIdForFarm(farmId);
                UserIdHiddenField.Value = userId.ToString();
                if (!IsAgentRole)
                {
                    ForAgentPanel.Visible           = true;
                    ForAgentUserNameLabel.Text      = farmService.GetUserName(userId);
                    ForAgentUserIdHiddenField.Value = userId.ToString();
                }
                else
                {
                    ForAgentPanel.Visible = false;
                }

                FarmService.FarmInfo farm = farmService.GetArchivedFarmSummaryDetails(farmId);

                if (farm.FarmId == 0)
                {
                    Response.Redirect("~/Members/ArchivedFarmList.aspx", true);
                }
                else
                {
                    farm.UserId                = GetAgentId();
                    FarmNameLabel.Text         = farm.FarmName;
                    MailingPlanLabel.Text      = farm.MailingPlan.Title;
                    CreateDateLabel.Text       = farm.CreateDate.ToShortDateString();
                    FarmContactCountLabel.Text = farm.ContactCount.ToString();
                    PlotCountLabel.Text        = farm.PlotCount.ToString();
                    FarmService.PlotInfo[] Plots = farmService.GetArchivedPlotSummary(farmId);
                    PlotListGridView.DataSource = Plots;
                    PlotListGridView.DataBind();
                    for (int i = 0; i < PlotListGridView.Rows.Count; i++)
                    {
                        if (Plots[i].Deleted)
                        {
                            PlotListGridView.Rows[i].ForeColor = System.Drawing.Color.DarkKhaki;
                        }
                        else
                        {
                            PlotListGridView.Rows[i].ForeColor        = System.Drawing.Color.Green;
                            PlotListGridView.Rows[i].Cells[0].Enabled = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error("UNKNOWN ERROR:", ex);
                ErrorLiteral.Text = "Unknown Error Please contact Administrator:";
            }
        }
    }
Beispiel #3
0
    protected void RestoreContactButton_Click(object sender, EventArgs e)
    {
        bool jumpError = false;

        try
        {
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();
            int plotId = int.Parse(PlotIdHiddenField.Value.ToString());

            for (int i = 0; i < ContactListGridView.Rows.Count; i++)
            {
                GridViewRow row       = ContactListGridView.Rows[i];
                bool        isChecked = ((CheckBox)row.FindControl("ContactIdCheckBox")).Checked;
                if (isChecked)
                {
                    Int64 contactId = Int64.Parse(((CheckBox)row.FindControl("ContactIdCheckBox")).ToolTip);
                    farmService.RestoreContact(contactId, LoginUserId);
                }
            }

            FarmService.ContactInfo[] contacts = farmService.GetArchivedContactListForPlot(plotId);

            if (contacts.Length == 0)
            {
                Response.Redirect("~/Members/ArchivedPlotList.aspx");
            }
            else
            {
                //Getting Archived Plot Header Details
                FarmService.PlotInfo plot = farmService.GetArchivedPlotSummaryDetails(plotId);

                //Getting Parent Farm Details
                FarmService.FarmInfo farm = farmService.GetArchivedFarmSummaryDetails(plot.FarmId);

                PlotNameLabel.Text     = farm.FarmName + " / " + plot.PlotName;
                ContactCountLabel.Text = plot.ContactCount.ToString();
                CreateDateLabel.Text   = plot.CreateDate.ToShortDateString();

                ContactListGridView.DataSource = contacts;
                ContactListGridView.DataBind();
            }
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE RESTORING CONTACT:", exception);
            if (exception.Message.Contains("Parent Plot / Farm is not active. Contact cannot be restored."))
            {
                MessageLiteral.Text = "Parent Plot / Farm is not active. Contact cannot be restored.";
            }
            else
            {
                MessageLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
                jumpError           = true;
            }
        }
        if (jumpError)
        {
            Response.Redirect("~/Members/ArchivedPlotList.aspx?farmId=" + FarmIdHiddenField.Value.ToString());
        }
    }
Beispiel #4
0
    protected void RestorePlotButton_Click(object sender, EventArgs e)
    {
        bool jumpError = false;

        try
        {
            // Get the common web service instance.
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            for (int i = 0; i < PlotListGridView.Rows.Count; i++)
            {
                GridViewRow row       = PlotListGridView.Rows[i];
                bool        isChecked = ((CheckBox)row.FindControl("PlotIdCheckBox")).Checked;
                if (isChecked)
                {
                    int plotId = int.Parse(((CheckBox)row.FindControl("PlotIdCheckBox")).ToolTip);
                    farmService.RestorePlotContact(plotId, LoginUserId);
                }
            }

            int farmId = int.Parse(FarmIdHiddenField.Value.ToString());
            FarmService.FarmInfo farm = farmService.GetArchivedFarmSummaryDetails(farmId);
            FarmNameLabel.Text         = farm.FarmName;
            MailingPlanLabel.Text      = farm.MailingPlan.Title;
            CreateDateLabel.Text       = farm.CreateDate.ToShortDateString();
            FarmContactCountLabel.Text = farm.ContactCount.ToString();
            PlotCountLabel.Text        = farm.PlotCount.ToString();

            FarmService.PlotInfo[] Plots = farmService.GetArchivedPlotSummary(farmId);

            PlotListGridView.DataSource = Plots;
            PlotListGridView.DataBind();
            for (int i = 0; i < PlotListGridView.Rows.Count; i++)
            {
                if (Plots[i].Deleted)
                {
                    PlotListGridView.Rows[i].ForeColor = System.Drawing.Color.DarkKhaki;
                }
                else
                {
                    PlotListGridView.Rows[i].ForeColor        = System.Drawing.Color.Green;
                    PlotListGridView.Rows[i].Cells[0].Enabled = false;
                }
            }
        }
        catch (Exception exception)
        {
            if (exception.Message.Contains("Parent Farm is in Deleted State. Plot Cannot be restored"))
            {
                ErrorLiteral.Text = "Parent Farm is in Deleted State. Plot Cannot be restored";
            }
            else
            {
                log.Error("UNKNOWN ERROR WHILE RESTORING CONTACT:", exception);
                ErrorLiteral.Text = "Unknown Error Please contact Administrator:";
                jumpError         = true;
            }
            if (jumpError)
            {
                Response.Redirect("~/Members/ArchivedFarmList.aspx");
            }
        }
    }