示例#1
0
    protected void RestoreFarmButton_Click(object sender, EventArgs e)
    {
        try
        {
            // Get the common web service instance.
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            for (int i = 0; i < FarmGridView.Rows.Count; i++)
            {
                GridViewRow row       = FarmGridView.Rows[i];
                bool        isChecked = ((CheckBox)row.FindControl("FarmIdCheckBox")).Checked;
                if (isChecked)
                {
                    int farmId = int.Parse(((CheckBox)row.FindControl("FarmIdCheckBox")).ToolTip);
                    farmService.RestoreFarmPlot(farmId, LoginUserId);
                }
            }

            FarmService.FarmInfo[] farmList;
            farmList = farmService.GetArchivedFarmSummary(GetAgentId());
            FarmGridView.DataSource = farmList;
            FarmGridView.DataBind();
            if (farmList.Length == 0)
            {
                NoFarmDataPanel.Visible = true;
            }
            else
            {
                NoFarmDataPanel.Visible = false;
                for (int i = 0; i < FarmGridView.Rows.Count; i++)
                {
                    if (farmList[i].Deleted == true)
                    {
                        FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Red;
                    }
                    else if (farmList[i].PlotCount == 0)
                    {
                        FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        FarmGridView.Rows[i].ForeColor = System.Drawing.Color.DarkKhaki;
                    }
                }
            }
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE RESTORE FARM:", exception);
            MessageLiteral.Text = "Error: Unable to Restore Farm";
        }
    }
示例#2
0
 protected void SelectedAgentButton_Click(object sender, EventArgs e)
 {
     try
     {
         // Get the common web service instance.
         ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
         FarmService.FarmService farmService   = serviceLoader.GetFarm();
         FarmService.FarmInfo[]  farmList;
         farmList = farmService.GetArchivedFarmSummary(GetAgentId());
         FarmGridView.DataSource = farmList;
         FarmGridView.DataBind();
         if (farmList.Length == 0)
         {
             NoFarmDataPanel.Visible = true;
         }
         else
         {
             NoFarmDataPanel.Visible = false;
             for (int i = 0; i < FarmGridView.Rows.Count; i++)
             {
                 if (farmList[i].Deleted == true)
                 {
                     FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Red;
                 }
                 else if (farmList[i].PlotCount == 0)
                 {
                     FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Green;
                 }
                 else
                 {
                     FarmGridView.Rows[i].ForeColor = System.Drawing.Color.DarkKhaki;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         log.Error("UNKNOWN ERROR:", exception);
         ErrorLiteral.Text = "UNKNOWN ERROR. Contact Administrator";
     }
 }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        IsArchived = true;
        if (!Page.IsPostBack)
        {
            try
            {
                // Get the common web service instance.

                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();
                if (IsAgentRole)
                {
                    AgentListPanel.Visible = false;
                    FarmService.FarmInfo[] farmList;
                    farmList = farmService.GetArchivedFarmSummary(GetAgentId());
                    FarmGridView.DataSource = farmList;
                    FarmGridView.DataBind();
                    if (farmList.Length == 0)
                    {
                        NoFarmDataPanel.Visible = true;
                    }
                    else
                    {
                        NoFarmDataPanel.Visible = false;
                        for (int i = 0; i < FarmGridView.Rows.Count; i++)
                        {
                            if (farmList[i].Deleted == true)
                            {
                                FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Red;
                            }
                            else if (farmList[i].PlotCount == 0)
                            {
                                FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Green;
                            }
                            else
                            {
                                FarmGridView.Rows[i].ForeColor = System.Drawing.Color.DarkKhaki;
                            }
                            if (farmList[i].Deleted == false)
                            {
                                FarmGridView.Rows[i].Cells[0].Enabled = false;
                            }
                        }
                    }
                }
                else
                {
                    AgentListPanel.Visible = true;
                    CommonService commonService = serviceLoader.GetCommon();
                    AgentListDropDownList.DataSource     = commonService.GetAgentsList();
                    AgentListDropDownList.DataValueField = "UserId";
                    AgentListDropDownList.DataTextField  = "UserName";
                    AgentListDropDownList.DataBind();
                    AgentListDropDownList.Items.Insert(0, "Select an Agent");
                }
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR:", exception);
                ErrorLiteral.Text = "UNKNOWN ERROR. Contact Administrator";
            }
        }
    }