예제 #1
0
        /// <summary>
        /// Method itry to drop and create table
        /// </summary>
        /// <param name="prefix">Project prefix</param>
        /// <param name="tableName">Table name</param>
        /// <param name="tableType">New columns types</param>
        /// <param name="columns">New table columns</param>
        /// <param name="drop">If true table with the same name will be drop</param>
        private static string tryCreateTable(string prefix, string tableName, string tableType, string columns, bool drop)
        {
            if (tableName != "" && tableType != "" && columns != "")
            {
                Result result;

                if (tableType == "DIMENSION")
                {
                    if (drop == true)
                    {
                        DimensionHandler.dropDimension(prefix, tableName);
                    }
                    result = DimensionHandler.addDimension(tableName, columns, prefix);
                    if (result.errormsg != "OK")
                    {
                        return("Import status: Cannot create table. Please check if old table contains foreign keys or if all required inforamtion are correct.");
                    }
                    return("OK");
                }
                else
                {
                    if (drop == true)
                    {
                        FactHandler.dropFact(prefix, tableName);
                    }
                    result = FactHandler.addFact(tableName, columns, prefix);
                    if (result.errormsg != "OK")
                    {
                        return("Import status: Cannot create table. Please check if old table exists or contains foreign keys or if all required inforamtion are correct.");
                    }
                    return("OK");
                }
                if (tableType == "FUNCTION")
                {
                    if (drop == true)
                    {
                        FunctionHandler.dropFunction(prefix + "_" + tableType + "_" + tableName);
                    }
                    result = FunctionHandler.addFunction(tableName, columns, prefix);
                    if (result.errormsg != "OK")
                    {
                        return("Import status: Cannot create table. Please check if old table exists or contains foreign keys or if all required inforamtion are correct.");
                    }
                    return("OK");
                }
            }
            return("Import status: Please check if csv contains all required information - table type, table name and columns name with types");
        }
예제 #2
0
        private bool CreateNewDimension()
        {
            if (updating)
            {
                DimensionHandler.dropDimension(Application.Current.Resources["ProjectPrefix"].ToString(), TxtTableName.Text.ToString().ToUpper());
            }


            string tmpStr  = "";
            bool   allFill = true;

            foreach (ColumnBar2 tmp in ColumnList)
            {
                if (tmp.TxtColumnName.Text.ToString() == "" || tmp.TxtColumnType.Text.ToString() == "")
                {
                    allFill = false;
                }
                tmpStr = tmpStr + tmp.TxtColumnName.Text.ToString() + " " + tmp.TxtColumnType.Text.ToString() + " " + tmp.TxtColumnCons.Text.ToString() + ",";
            }
            tmpStr = tmpStr.Remove(tmpStr.Length - 1);

            if (TxtTableName.Text.ToString() == "")
            {
                allFill = false;
            }
            if (allFill)
            {
                Result wynik = new Result();
                wynik = DimensionHandler.addDimension(TxtTableName.Text, tmpStr, Application.Current.Resources["ProjectPrefix"].ToString());
                if (wynik.errormsg != "OK")
                {
                    textBlockError.Text = wynik.errormsg;
                }
                else
                {
                    Console.WriteLine(tmpStr);
                    DataSet testowy = DimensionHandler.getDimensions(Application.Current.Resources["ProjectPrefix"].ToString());
                    Console.WriteLine(testowy.Tables["result"].ToString());
                    return(true);
                }
            }
            else
            {
                MessageBox.Show("Fill all Textbox!!!");
            }

            return(false);
        }