Exemplo n.º 1
0
    protected void btn4_clearAll_Click(object sender, EventArgs e)
    {
        manageDict_class manageDict = new manageDict_class();

        // remove all future check box elements with removeItems class. Pass in collection of check box items, dictionary, and current year
        manageDict.clearAllHistory(cbList_management.Items, (SortedList <string, ArrayList>)Session["managementDict"], Convert.ToInt16(Page.Session["currentYear"].ToString()));
    }
Exemplo n.º 2
0
    protected void btn4_removeElements_Click(object sender, EventArgs e)
    {
        manageDict_class manageDict = new manageDict_class();

        // remove selected check box elements with removeItems class. Pass in collection of check box items and dictionary
        manageDict.removeItems(cbList_management.Items, (SortedList <string, ArrayList>)Session["managementDict"]);

        displayDictionary((SortedList <string, ArrayList>)Session["managementDict"]);
    }
    protected void setSessionFromFile(string xmlParamFile)
    {
        manageDict_class manageDict = new manageDict_class();
        SortedList <string, ArrayList> managementDict = new SortedList <string, ArrayList>();
        SortedList <string, ArrayList> natDisturbDict = new SortedList <string, ArrayList>();

        managementDict = (SortedList <string, ArrayList>)Session["managementDict"];
        natDisturbDict = (SortedList <string, ArrayList>)Session["natDisturbDict"];

        XmlDocument   oXmlDoc        = new XmlDocument();
        XmlTextReader xmlParamReader = new XmlTextReader(xmlParamFile);

        xmlParamReader.Read();
        oXmlDoc.Load(xmlParamReader);
        XmlNode oNode = oXmlDoc.DocumentElement;

        Page.Session["region"]    = oNode.SelectSingleNode("/RunParameters/SiteRegion").InnerText;
        Page.Session["ownership"] = oNode.SelectSingleNode("/RunParameters/SiteOwner").InnerText;
        Page.Session["elevClass"] = oNode.SelectSingleNode("/RunParameters/SiteElevationClass").InnerText;
        //       Page.Session["siteIndx"] = oNode.SelectSingleNode("/RunParameters/SiteSiteIndex").InnerText;

        Page.Session["currentYear"] = oNode.SelectSingleNode("/RunParameters/RunCurrentYear").InnerText;
        Page.Session["numSimYears"] = oNode.SelectSingleNode("/RunParameters/RunSimYears").InnerText;
        Page.Session["randomSeed"]  = oNode.SelectSingleNode("/RunParameters/RunRandomSeed").InnerText;
        Page.Session["runName"]     = oNode.SelectSingleNode("/RunParameters/RunName").InnerText;
        Page.Session["cellAreaHa"]  = oNode.SelectSingleNode("/RunParameters/RunCellAreaHa").InnerText;

        Page.Session["mfgExBiofuel"] = oNode.SelectSingleNode("/RunParameters/UseMfgExBioFuel").InnerText;
        Page.Session["mfgStrWood"]   = oNode.SelectSingleNode("/RunParameters/UseMfgStrWood").InnerText;
        Page.Session["mfgPulp"]      = oNode.SelectSingleNode("/RunParameters/UseMfgPulp").InnerText;

        Page.Session["recycleLT"]    = oNode.SelectSingleNode("/RunParameters/UseRecycleLT").InnerText;
        Page.Session["recycleST"]    = oNode.SelectSingleNode("/RunParameters/UseRecycleST").InnerText;
        Page.Session["recyclePaper"] = oNode.SelectSingleNode("/RunParameters/UseRecyclePaper").InnerText;

        Page.Session["productLTStr"] = oNode.SelectSingleNode("/RunParameters/UseProductLTStr").InnerText;

        Page.Session["disposalDump"]           = oNode.SelectSingleNode("/RunParameters/UseDisposalDump").InnerText;
        Page.Session["disposalLandfill"]       = oNode.SelectSingleNode("/RunParameters/UseDisposalLandfill").InnerText;
        Page.Session["disposalIncinVol"]       = oNode.SelectSingleNode("/RunParameters/UseDisposalIncinVol").InnerText;
        Page.Session["disposalIncinBioenergy"] = oNode.SelectSingleNode("/RunParameters/UseDisposalIncinBioenergy").InnerText;

        Page.Session["substitutionProd"]   = oNode.SelectSingleNode("/RunParameters/SubstitutionProductDefault").InnerText;
        Page.Session["substitutionEnergy"] = oNode.SelectSingleNode("/RunParameters/SubstitutionBioenergyDefault").InnerText;
        Page.Session["subDisplacement"]    = oNode.SelectSingleNode("/RunParameters/SubstitutionDisplacement").InnerText;
        Page.Session["subBuilding"]        = oNode.SelectSingleNode("/RunParameters/SubstitutionBuildings").InnerText;
        Page.Session["subBioenergyFactor"] = oNode.SelectSingleNode("/RunParameters/SubstitutionBioenergyFactor").InnerText;
        Page.Session["subLeakage"]         = oNode.SelectSingleNode("/RunParameters/SubstitutionLeakage").InnerText;

        manageDict.loadDictFromXML(managementDict, oNode.SelectNodes("/RunParameters/ManagementRegime"));
        manageDict.loadDictFromXML(natDisturbDict, oNode.SelectNodes("/RunParameters/NaturalDisturbanceRegime"));
    }
    protected void btn3_clearAll_Click(object sender, EventArgs e)
    {
        manageDict_class  manageDict  = new manageDict_class();
        displayDict_class displayDict = new displayDict_class();

        // remove all future check box elements with removeItems class. Pass in collection of check box items, dictionary, and current year
        manageDict.clearAllHistory(cbList_management.Items, (SortedList <string, ArrayList>)Session["managementDict"], Convert.ToInt16(Page.Session["currentYear"].ToString()));
        manageDict.clearAllHistory(cbList_natDisturb.Items, (SortedList <string, ArrayList>)Session["natDisturbDict"], Convert.ToInt16(Page.Session["currentYear"].ToString()));

        ddl_secondary.Enabled   = false;
        lbl_secondary.ForeColor = Color.Gray;

        displayDictionary((SortedList <string, ArrayList>)Session["managementDict"], (SortedList <string, ArrayList>)Session["natDisturbDict"]);
    }
    protected void btn3_setDefault_Click(object sender, EventArgs e)
    {
        manageDict_class manageDict = new manageDict_class();
        SortedList <string, ArrayList> managementDict = new SortedList <string, ArrayList>();
        SortedList <string, ArrayList> natDisturbDict = new SortedList <string, ArrayList>();

        managementDict = (SortedList <string, ArrayList>)Session["managementDict"];
        natDisturbDict = (SortedList <string, ArrayList>)Session["natDisturbDict"];

        string appPath      = Request.PhysicalApplicationPath; // requires System.Diagnostics
        string xmlParamFile = appPath + "LandCarbData31\\Base\\ManagementHistory\\";

        xmlParamFile += Page.Session["region"].ToString() + "_" + Page.Session["ownership"].ToString() + "_defaultHist.xml";

        XmlDocument   oXmlDoc        = new XmlDocument();
        XmlTextReader xmlParamReader = new XmlTextReader(xmlParamFile);

        xmlParamReader.Read();
        oXmlDoc.Load(xmlParamReader);
        XmlNode oNode = oXmlDoc.DocumentElement;

        manageDict.loadDictFromXML(managementDict, oNode.SelectNodes("/RunParameters/ManagementRegime"));
        manageDict.loadDictFromXML(natDisturbDict, oNode.SelectNodes("/RunParameters/NaturalDisturbanceRegime"));

        // adjust default management history for custom current run year
        if (Page.Session["currentYear"].ToString() != "2012")
        {
            ArrayList modKeyList   = new ArrayList();
            string    newStartYear = Page.Session["simStartYear"].ToString();
            string    newEndYear   = (Convert.ToInt16(Page.Session["currentYear"].ToString()) - 1).ToString();

            manageDict.modDictKey(managementDict, newStartYear, newEndYear);
            manageDict.modDictKey(natDisturbDict, newStartYear, newEndYear);
        }

        displayDictionary(managementDict, natDisturbDict);
    }
    protected void btn_addPrimary_Click(object sender, EventArgs e)
    {
        manageDict_class manageDict = new manageDict_class();

        SortedList <string, ArrayList> managementDict = new SortedList <string, ArrayList>();
        SortedList <string, ArrayList> natDisturbDict = new SortedList <string, ArrayList>();

        managementDict = (SortedList <string, ArrayList>)Session["managementDict"];
        natDisturbDict = (SortedList <string, ArrayList>)Session["natDisturbDict"];
        // int currentYearInt = Convert.ToInt16(Page.Session["currentYear"].ToString());
        string dictKey;

        //Regex reNum = new Regex(@"^\d+$");
        //if (!reNum.Match(TextBox_Year.Text).Success | TextBox_Year.Text == "" | Convert.ToInt16(TextBox_Year.Text) >= currentYearInt)
        //    TextBox1.Text = "*** Incomplete Event Input ***\nPlease enter a year prior to the current year for the disturbance.";

        ArrayList dictData = new ArrayList();

        dictData.Add(ddl_primary.SelectedValue);

        if (ddl_primary.SelectedItem.Text.StartsWith("Harvest") | ddl_primary.SelectedItem.Text.StartsWith("Salvage"))
        {
            dictData.Add(txt_priInterval.Text);
            dictData.Add(txt_priDisturb.Text);
            dictData.Add(ddl_priUtilization.SelectedValue);
        }
        else if (ddl_primary.SelectedItem.Text.StartsWith("Prescribed"))
        {
            dictData.Add(txt_priInterval.Text);
            dictData.Add(txt_priDisturb.Text);
            dictData.Add(ddl_priSeverity.SelectedValue);
        }
        else if (ddl_primary.SelectedItem.Text.StartsWith("Wildfire default"))
        {
            dictData.Add("null");
            dictData.Add("null");
            dictData.Add(ddl_priSuppression.SelectedValue);
        }
        else if (ddl_primary.SelectedItem.Text.StartsWith("Wildfire custom"))
        {
            dictData.Add(txt_priInterval.Text);
            dictData.Add(ddl_priFireSize.SelectedValue);
            dictData.Add(ddl_priSeverity.SelectedValue);
        }

        dictKey = "p" + txt_priStartYear.Text + "to" + txt_priEndYear.Text;

        if (ddl_primary.SelectedItem.Text.StartsWith("Wildfire"))
        {
            manageDict.insertRegime(natDisturbDict, dictKey, dictData, Convert.ToInt16(txt_priStartYear.Text), Convert.ToInt16(txt_priEndYear.Text));
        }
        else
        {
            manageDict.insertRegime(managementDict, dictKey, dictData, Convert.ToInt16(txt_priStartYear.Text), Convert.ToInt16(txt_priEndYear.Text));
        }

        displayDictionary(managementDict, natDisturbDict);

        // reset secondary range validation to keep secondary offset from being larger than primary interval in management disturbances
        if (ddl_primary.Text.StartsWith("Wildfire"))
        {
            valRange_secOffset.MaximumValue = Page.Session["numSimYears"].ToString();
        }
        else
        {
            valRange_secOffset.MaximumValue = (Convert.ToInt16(txt_priInterval.Text) - 1).ToString();
        }

        valRange_secOffset.ErrorMessage = "Select secondary treatment offset between " + valRange_secOffset.MinimumValue + " and " + valRange_secOffset.MaximumValue;

        //  enable secondary regime controls
        ddl_secondary.Enabled   = true;
        lbl_secondary.ForeColor = Color.Black;
    }
    protected void btn_addPrimary_Click(object sender, EventArgs e)
    {
        manageDict_class manageDict = new manageDict_class();
        SortedList <string, ArrayList> managementDict = new SortedList <string, ArrayList>();
        SortedList <string, ArrayList> natDisturbDict = new SortedList <string, ArrayList>();

        managementDict = (SortedList <string, ArrayList>)Session["managementDict"];
        natDisturbDict = (SortedList <string, ArrayList>)Session["natDisturbDict"];
        int    currentYear = Convert.ToInt16(Page.Session["currentYear"].ToString());
        int    endYear     = Convert.ToInt16(Page.Session["currentYear"].ToString()) + Convert.ToInt16(Page.Session["numSimYears"].ToString());
        string dictKey;
        //object junkObject = new object();
        //EventArgs junkEvent = new EventArgs();
        //btn4_clearAll_Click(junkObject, junkEvent);

        ArrayList dictData = new ArrayList();

        dictData.Add(ddl_primary.SelectedValue);

        if (ddl_primary.SelectedItem.Text.StartsWith("Harvest") | ddl_primary.SelectedItem.Text.StartsWith("Salvage"))
        {
            dictData.Add(txt_priInterval.Text);
            dictData.Add(txt_priDisturb.Text);
            dictData.Add(ddl_priUtilization.SelectedValue);
        }
        else if (ddl_primary.SelectedItem.Text.StartsWith("Prescribed"))
        {
            dictData.Add(txt_priInterval.Text);
            dictData.Add(txt_priDisturb.Text);
            dictData.Add(ddl_priSeverity.SelectedValue);
        }
        else if (ddl_primary.SelectedItem.Text.StartsWith("Wildfire default"))
        {
            dictData.Add("null");
            dictData.Add("null");
            dictData.Add(ddl_priSuppression.SelectedValue);
        }
        else if (ddl_primary.SelectedItem.Text.StartsWith("Wildfire custom"))
        {
            dictData.Add(txt_priInterval.Text);
            dictData.Add(ddl_priFireSize.SelectedValue);
            dictData.Add(ddl_priSeverity.SelectedValue);
        }

        if (ddl_primary.SelectedItem.Text.StartsWith("Wildfire"))
        {
            manageDict.clearAllFuture(cbList_natDisturb.Items, natDisturbDict, currentYear);
            dictKey = "p" + currentYear.ToString() + "to" + endYear.ToString();
            natDisturbDict.Add(dictKey, dictData);
        }
        else
        {
            manageDict.clearAllFuture(cbList_management.Items, managementDict, currentYear);

            for (int year = currentYear; year < endYear; year += Convert.ToInt16(txt_priInterval.Text))
            {
                dictKey = "p" + year.ToString() + "xx0000";
                managementDict.Add(dictKey, dictData);
            }
        }

        displayDictionary(managementDict, natDisturbDict);

        // reset secondary range validation to keep secondary offset from being larger than primary interval in management disturbances
        if (ddl_primary.Text.StartsWith("Wildfire"))
        {
            valRange_secOffset.MaximumValue = Page.Session["numSimYears"].ToString();
        }
        else
        {
            valRange_secOffset.MaximumValue = (Convert.ToInt16(txt_priInterval.Text) - 1).ToString();
        }

        valRange_secOffset.ErrorMessage = "Select secondary treatment offset between " + valRange_secOffset.MinimumValue + " and " + valRange_secOffset.MaximumValue;

        //  enable secondary regime controls
        ddl_secondary.Enabled   = true;
        lbl_secondary.ForeColor = Color.Black;
    }