Beispiel #1
0
        protected void UploadAs_Click(object sender, EventArgs e)
        {
            if (DataSetName.Text.Trim().Length != 0 && DataSetUpload.HasFile)
            {
                //move most to uploader
                //handle spaces in file name
                String uploadPath = System.IO.Path.Combine(System.IO.Path.GetTempPath().ToString(), DataSetUpload.FileName);
                DataSetUpload.SaveAs(uploadPath);
                String connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.IO.Path.GetTempPath().ToString() + ";Extended Properties='text;HDR=Yes;FMT=Delimited'";
                connection = new OleDbConnection(connectionString);
                OleDbCommand cmd = new OleDbCommand("SELECT * FROM " + DataSetUpload.FileName, connection);
                da = new OleDbDataAdapter(cmd);
                connection.Open();
                dt = new System.Data.DataTable();
                da.Fill(dt);
                System.Data.DataSet ds         = new System.Data.DataSet(DataSetName.Text.Trim());
                String[]            parameters = { "main" };
                ds.Load(dt.CreateDataReader(), System.Data.LoadOption.OverwriteChanges, parameters);

                Session.Add("table", dt);
                Session.Add("connection", connection);
                Session.Add("adapter", da);

                Registry.Registry registry = Registry.Registry.getRegistry(Session);
                registry.registerDataset(ds);
                DatasetList.Items.Add(ds.DataSetName);
            }
        }
        // UPLOAD BUTTON HANDLER -------------------------------------------------------------------------------------------------------

        protected void uploadbutton_Click(object sender, EventArgs e)
        {
            // Get button ID
            Button getbuttonID = (Button)sender;
            string id          = getbuttonID.ID.Replace("_button", "");

            // Use button ID to find similarly named upload control ID
            FileUpload uploadcontrol = (FileUpload)Form.FindControl(id);

            // Only upload if control has file selected
            if (uploadcontrol.HasFile)
            {
                // Add upload path
                String savePath = @"c:\temp\";

                // Retrieve filename from upload control
                String fileName = uploadcontrol.FileName;

                // Save data to web server
                uploadcontrol.SaveAs(savePath + fileName);

                // Fill GridView

                // Establish text driver connection
                System.Data.Odbc.OdbcConnection  csv_connection;
                System.Data.Odbc.OdbcDataAdapter csv_adapter;

                // Create temporary data table to store CSV data
                DataTable csv_data = new DataTable();

                // Create connection string and execute connection to CSV
                string csv_connectionString = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + savePath + ";";
                csv_connection = new System.Data.Odbc.OdbcConnection(csv_connectionString);

                // Fill adapter with SELECT * query from CSV
                csv_adapter = new System.Data.Odbc.OdbcDataAdapter("select * from [" + fileName + "]", csv_connection);
                csv_adapter.Fill(csv_data);

                // Close CSV connection
                csv_connection.Close();

                // Find GridView and fill
                GridView filedata = (GridView)Form.FindControl(id + "_table");
                filedata.DataSource = csv_data;
                filedata.DataBind();

                // SESSION MODIFICATION //

                DataSet session_datanew = new DataSet();
                session_datanew.Tables.Add(csv_data);
                session_datanew.DataSetName = "PCADATA";

                Registry.Registry registry = Registry.Registry.getRegistry(Session);
                registry.registerDataset(session_datanew);
                Analysis.ParameterStream stream = Analysis.ParameterStream.getStream(Session);
                stream.set("dataSetName", "PCADATA");

                //----------------------//
            }
        }
Beispiel #3
0
 protected void Page_PreInit(object sender, EventArgs e)
 {
     Debug.WriteLine("in page init");
     registry   = Registry.Registry.getRegistry(Application);
     dt         = (DataTable)Session["table"];
     da         = (OleDbDataAdapter)Session["adapter"];
     connection = (OleDbConnection)Session["connection"];
 }
 protected void Page_PreInit(object sender, EventArgs e)
 {
     Debug.WriteLine("in page init");
     registry = Registry.Registry.getRegistry(Application);
     dt = (DataTable)Session["table"];
     da = (OleDbDataAdapter)Session["adapter"];
     connection = (OleDbConnection)Session["connection"];
 }
 protected void Page_Init(object sender, EventArgs e)
 {
     //TODO: Move registration to app initialization, not page load
     registry = (Registry.Registry) Application.Get("appRegistry");
      
     //Display in dropdown
     foreach (String name in registry.GetAlgorithmNames())
         AlgDropDown.Items.Add(name);
 }
Beispiel #6
0
        protected void Page_Init(object sender, EventArgs e)
        {
            //TODO: Move registration to app initialization, not page load
            registry = (Registry.Registry)Application.Get("appRegistry");

            //Display in dropdown
            foreach (String name in registry.GetAlgorithmNames())
            {
                AlgDropDown.Items.Add(name);
            }
        }
Beispiel #7
0
        void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started
            // Session data
            //Selected analysis
            Session.Add("analysis", null);
            Analysis.ParameterStream stream = new Analysis.ParameterStream(Session);
            sessionRegistry = new Registry.Registry(Session);
            Session.Add("stepid", stepid);
            stepid = 0;


            //Add pre-existing user data sets
            //Add pre-existing user-defined scripts
        }
        void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started
            // Session data
            //Selected analysis
            Session.Add("analysis", null);
            Analysis.ParameterStream stream = new Analysis.ParameterStream(Session);
            sessionRegistry = new Registry.Registry(Session);
            Session.Add("stepid", stepid);
            stepid = 0;


            //Add pre-existing user data sets
            //Add pre-existing user-defined scripts
        }
Beispiel #9
0
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            appRegistry = new Registry.Registry(Application);

            //Add algorithms

            Analysis.Analysis myPCA0 = new Analysis.PCA.PCADynamicNIPALS("Principal Component Analysis - NIPALs (Dynamic)");
            appRegistry.registerAlgorithm(myPCA0);

            Analysis.Analysis myPCA1 = new Analysis.PCA.NipalsPCA("Principal Component Analysis - NIPALs");
            appRegistry.registerAlgorithm(myPCA1);

            Analysis.Analysis myPCA2 = new Analysis.PCA.svdPCA("Principal Component Analysis - SVD");
            appRegistry.registerAlgorithm(myPCA2);

            //Add existing data sets
        }
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            appRegistry = new Registry.Registry(Application);

            //Add algorithms

            Analysis.Analysis myPCA0 = new Analysis.PCA.PCADynamicNIPALS("Principal Component Analysis - NIPALs (Dynamic)");
            appRegistry.registerAlgorithm(myPCA0);
            
            Analysis.Analysis myPCA1 = new Analysis.PCA.NipalsPCA("Principal Component Analysis - NIPALs");
            appRegistry.registerAlgorithm(myPCA1);
   
            Analysis.Analysis myPCA2 = new Analysis.PCA.svdPCA("Principal Component Analysis - SVD");
            appRegistry.registerAlgorithm(myPCA2);

            //Add existing data sets 
        }
        // CONTROL DATA FILL ------------------------------------------------------------------------------------------------------------

        void fillcontrol(Control fillcontrol, string[,,] controlarray, int col_traverse, int row_traverse, int jobid, int algorithmid, int stepid, SqlDataReader reader, SqlConnection connection)
        {
            // Fill data

            // Get the data name from controlarray
            string dataname = controlarray[col_traverse, row_traverse, 1];
            // String to store SQL query
            string control_query;

            // Check if fill query is specified
            if (dataname != "NONE" && dataname != "")
            {
                // Add Job ID
                if (dataname != "CONST")
                {
                    control_query = "WEBAPP_READ " + " " + jobid + ",'" + dataname + "'";
                }
                else
                {
                    control_query = "WEBAPP_SELECTCONST " + algorithmid + "," + stepid + "," + col_traverse + "," + row_traverse;
                }

                // Initialize reader and get data
                reader = openconnection(control_query, connection);

                // Fill details are specific to control type
                switch (fillcontrol.GetType().ToString())
                {
                // Label control type
                case "System.Web.UI.WebControls.Label":
                {
                    string datavalue;

                    // Load label text into string and set control value
                    reader.Read();

                    if (reader.HasRows)
                    {
                        datavalue = reader["value"].ToString();
                    }
                    else
                    {
                        datavalue = null;
                    }
                    // Create label control that points to fillcontrol object
                    Label labelcontrol = (Label)fillcontrol;

                    // Add label text
                    labelcontrol.Text = datavalue;

                    break;
                }

                case "System.Web.UI.WebControls.Image":
                {
                    // Load image into string and set control value
                    reader.Read();
                    string imagepath = reader["value"].ToString();

                    // Create image control that points to fillcontrol object
                    Image imagecontrol = (Image)fillcontrol;

                    // Add image path
                    imagecontrol.ImageUrl = imagepath;

                    break;
                }

                case "System.Web.UI.WebControls.Panel":
                {
                    // Convert reader data to dataset
                    //DataTable retrieveddataset;
                    //retrieveddataset = db_dataretrieve(reader);

                    // Create GridView control that points to fillcontrol object
                    Panel    tablecontainer  = (Panel)fillcontrol;
                    GridView gridviewcontrol = (GridView)tablecontainer.Controls[0];

                    //gridviewcontrol.DataSource = retrieveddataset;
                    //gridviewcontrol.DataBind();

                    // SESSION MODIFICATIONS //

                    DataMiningApp.Analysis.ParameterStream stream = DataMiningApp.Analysis.ParameterStream.getStream(Session);

                    Matrix   PCmatrix = (Matrix)stream.get("PCmatrix");
                    Vector   Weights  = (Vector)stream.get("Weights");
                    String[] features = (String[])stream.get("selectedFeatures");

                    //for (int i = 0; i < Weights.Length; i++)
                    //    VariancePlot.Series[0].Points.InsertY(i, Weights[i]);

                    DataSet   ds = new DataSet("temp");
                    DataTable dt = new DataTable();
                    // Declare your Columns

                    //PC Weight
                    DataColumn dc = new DataColumn("Weight", Type.GetType("System.Double"));
                    dt.Columns.Add(dc);

                    //PC Coefficients
                    foreach (String feature in features)
                    {
                        dc = new DataColumn(feature, Type.GetType("System.Double"));
                        dt.Columns.Add(dc);
                    }

                    // Add the DataTable to your DataSet
                    ds.Tables.Add(dt);

                    DataRow dr;
                    for (int i = 0; i < PCmatrix.ColumnCount; i++)
                    {
                        dr = ds.Tables[0].NewRow();
                        dt.Rows.Add(dr);
                        dt.Rows[i][0] = Math.Round(Weights[i], 3);
                        for (int j = 0; j < PCmatrix.RowCount; j++)
                        {
                            dt.Rows[i][j + 1] = Math.Round(PCmatrix[j, i], 3);
                        }
                    }

                    /*
                     * dr = ds.Tables[0].NewRow();
                     * dt.Rows.Add(dr);
                     * double[] dataArray = new double[Weights.Length];
                     * dataArray[0] = 1232.21321;
                     * dr[0] = 321.12321;
                     *
                     * //dt.Rows[0].ItemArray[1] = 333.32;
                     */
                    gridviewcontrol.DataSource = dt;
                    gridviewcontrol.DataBind();

                    //-------------------------------//

                    break;
                }

                case "System.Web.UI.DataVisualization.Charting.Chart":
                {
                    // Convert reader data to dataset

                    /*
                     * DataTable retrieveddataset;
                     * retrieveddataset = db_dataretrieve(reader);
                     *
                     * // Set data plotted by returned column names
                     * chartcontrol.Series["Series"].XValueMember = retrieveddataset.Columns[0].ColumnName;
                     * chartcontrol.Series["Series"].YValueMembers = retrieveddataset.Columns[1].ColumnName;
                     *
                     * chartcontrol.ChartAreas[0].AxisX.Title = chartcontrol.Series["Series"].XValueMember;
                     * chartcontrol.ChartAreas[0].AxisY.Title = chartcontrol.Series["Series"].YValueMembers;
                     *
                     * chartcontrol.DataSource = retrieveddataset;
                     * chartcontrol.DataBind();
                     */

                    break;
                }

                case "System.Web.UI.WebControls.FileUpload":
                {
                    FileUpload uploadcontrol = (FileUpload)fillcontrol;
                    string     id            = uploadcontrol.ID;
                    string     datavalue;

                    // Fill label
                    reader.Read();
                    if (reader.HasRows)
                    {
                        datavalue = reader["value"].ToString();
                    }
                    else
                    {
                        datavalue = null;
                    }
                    Label uploadlabel = (Label)Form.FindControl(id + "_label");
                    uploadlabel.Text = datavalue;

                    break;
                }

                case "System.Web.UI.WebControls.ListBox":
                {
                    ListBox listboxcontrol = (ListBox)fillcontrol;

                    string id = listboxcontrol.ID;
                    string datavalue;

                    // Fill label
                    reader.Read();
                    if (reader.HasRows)
                    {
                        datavalue = reader["value"].ToString();
                    }
                    else
                    {
                        datavalue = null;
                    }
                    Label uploadlabel = (Label)Form.FindControl(id + "_label");
                    uploadlabel.Text = datavalue;

                    String dataSetParameterName = "dataSetName";
                    DataMiningApp.Analysis.ParameterStream stream = DataMiningApp.Analysis.ParameterStream.getStream(Session);
                    if (stream.contains(dataSetParameterName))
                    {
                        Registry.Registry appRegistry = Registry.Registry.getRegistry(Session);
                        DataSet           ds          = appRegistry.GetDataset((String)stream.get(dataSetParameterName));

                        foreach (DataColumn dc in ds.Tables[0].Columns)
                        {
                            listboxcontrol.Items.Add(dc.ColumnName);
                        }
                    }

                    break;
                }
                }

                // Close reader and connection
                closeconnection(reader, connection);
            }
        }