Ejemplo n.º 1
0
        /// <summary>
        /// Export committed project file for given NetworkID and SimulationID
        /// </summary>
        /// <param name="strNetworkID"></param>
        /// <param name="strSimulationID"></param>
        public static void ExportCommitted(string strNetworkID, string strSimulationID)
        {
            List <CommittedExport> listCommitExport = new List <CommittedExport>();
            String          strCommitID             = "";
            string          strSelect = "SELECT COMMITTED_.SECTIONID,FACILITY,SECTION,BEGIN_STATION,END_STATION,DIRECTION,YEARS,BUDGET,COST_,AREA,YEARSAME,YEARANY,COMMIT_CONSEQUENCES.COMMITID, ATTRIBUTE_,CHANGE_,TREATMENTNAME FROM COMMITTED_ INNER JOIN COMMIT_CONSEQUENCES ON COMMITTED_.COMMITID = COMMIT_CONSEQUENCES.COMMITID INNER JOIN SECTION_" + strNetworkID + " ON SECTION_" + strNetworkID + ".SECTIONID=COMMITTED_.SECTIONID WHERE SIMULATIONID=" + strSimulationID;
            DataSet         ds        = DBMgr.ExecuteQuery(strSelect);
            CommittedExport commit    = null;

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                string strNewCommitID = row[0].ToString();
                if (strCommitID != strNewCommitID)
                {
                    if (commit != null)
                    {
                        listCommitExport.Add(commit);
                    }
                    commit               = new CommittedExport();
                    commit.Facility      = row[1].ToString();
                    commit.Section       = row[2].ToString();
                    commit.BeginStation  = row[3].ToString();
                    commit.EndStation    = row[4].ToString();
                    commit.Direction     = row[5].ToString();
                    commit.Year          = row[6].ToString();
                    commit.Budget        = row[7].ToString();
                    commit.Cost          = row[8].ToString();
                    commit.Area          = row[9].ToString();
                    commit.Same          = row[10].ToString();
                    commit.Any           = row[11].ToString();
                    commit.ConsequenceID = row[12].ToString();
                    commit.Treatment     = row[15].ToString();
                }
                ConsequenceExport consequenceExport = new ConsequenceExport();
                consequenceExport.Attribute = row[13].ToString();
                consequenceExport.Change    = row[14].ToString();
            }
            // Get header information
            List <String> listAttribute = new List <string>();

            strSelect = "SELECT DISTINCT COMMITTED_.SIMULATIONID,ATTRIBUTE_ FROM COMMIT_CONSEQUENCES,COMMITTED_ WHERE COMMITTED_.SIMULATIONID=" + strSimulationID + " ORDER BY ATTRIBUTE_";
            ds        = DBMgr.ExecuteQuery(strSelect);
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listAttribute.Add(row[1].ToString());
            }
            //Create Header
            String strHeader = "FACILITY\tSECTION\tSECTION_BEGIN\tSECTION_END\tDIRECTION\tYEARS\tTREATMENT\tBUDGET\tCOST\tAREA\tYEAR_SAME\tYEAR_ANY";

            foreach (String strAttribute in listAttribute)
            {
                strHeader += "\t";
                strHeader += strAttribute;
            }

            foreach (CommittedExport committedExport in listCommitExport)
            {
                WriteCommittedExportLine(listAttribute, committedExport);
            }
        }
Ejemplo n.º 2
0
        //Write single line of Committed project export.
        public static string WriteCommittedExportLine(List <String> listAttribute, CommittedExport commit)
        {
            string strReturn = "";

            strReturn = commit.Facility + "\t" + commit.Section + "\t" + commit.BeginStation + "\t" + commit.EndStation + "\t" + commit.Direction + "\t" + commit.Year +
                        "\t" + commit.Treatment + "\t" + commit.Budget + "\t" + commit.Cost + "\t" + commit.Area + "\t" + commit.Same + "\t" + commit.Any;
            foreach (string strAttribute in listAttribute)
            {
                ConsequenceExport consequenceExport = commit.Consequence.Find(delegate(ConsequenceExport ce) { return(ce.Attribute == strAttribute); });
                strReturn += "\t";
                if (consequenceExport != null)
                {
                    strReturn += consequenceExport.Change;
                }
            }
            return(strReturn);
        }