Beispiel #1
0
        public static List <List <Customers> > list(String path)
        {
            #region creating connection

            HBaseConnection con = new HBaseConnection("localhost", 10003);
            con.Open();

            #endregion creating connection

            #region parsing csv input file

            csv csvObj = new csv();
            object[,] cells;
            cells = null;

            cells = csvObj.Table(path, false, ',');

            #endregion parsing csv input file

            #region creating table
            String        tableName      = "AdventureWorks_Person_Contact";
            List <string> columnFamilies = new List <string>();
            columnFamilies.Add("info");
            columnFamilies.Add("contact");
            columnFamilies.Add("others");
            if (!HBaseOperation.IsTableExists(tableName, con))
            {
                if (columnFamilies.Count > 0)
                {
                    HBaseOperation.CreateTable(tableName, columnFamilies, con);
                }
                else
                {
                    throw new HBaseException("ERROR: Table must have at least one column family");
                }
            }

            # endregion
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ViewModel"/> class.
        /// </summary>
        public ViewModel()
        {
            TableName = "AdventureWorks_Person_Contact";

            try
            {
                #region Creating connection

                //Initialize hbase thrift server connection
                Connection = new HBaseConnection("localhost", 10003);
                Connection.Open();

                #endregion Creating connection

                #region Creating table

                string        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, Connection))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, Connection);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values

                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                path = path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv";

                #region Parsing csv input file

                csv csvObj = new csv();
                object[,] cells = csvObj.Table(path, false, ',');

                #endregion Parsing csv input file

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;

                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }

                HBaseOperation.InsertRows(tableName, rowCollection, Connection);

                #endregion Inserting Values
            }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                cells = csvObj.Table(path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;

                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }

                HBaseOperation.InsertRows(tableName, rowCollection, con);

                #endregion Inserting Values

                #region Fetch result

                HBaseOperation.FetchSize = 100;
                HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);

                #endregion Fetch result

                //Binding the fetched result to the grid
                gridGroupingControl1.DataSource = table;
                gridGroupingControl1.TableDescriptor.Columns["rowKey"].Width              = 85;
                gridGroupingControl1.TableDescriptor.Columns["info:FULLNAME"].Width       = 170;
                gridGroupingControl1.TableDescriptor.Columns["info:AGE"].Width            = 90;
                gridGroupingControl1.TableDescriptor.Columns["contact:EMAILID"].Width     = 230;
                gridGroupingControl1.TableDescriptor.Columns["contact:PHONE"].Width       = 170;
                gridGroupingControl1.TableDescriptor.Columns["others:MODIFIEDDATE"].Width = 170;

                #region closing connection
                //closing the hive connection
                con.Close();
                #endregion closing connection
            }
Beispiel #4
0
        public MainWindow()
        {
            InitializeComponent();

            try
            {
                #region Creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion Creating connection

                #region Creating table

                string        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values

                #region Parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                cells = csvObj.Table(path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", false, ',');

                #endregion Parsing csv input file

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;

                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }

                HBaseOperation.InsertRows(tableName, rowCollection, con);

                #endregion Inserting Values

                #region Fetch result

                HBaseOperation.FetchSize = 100;
                HBaseResultSet result = HBaseOperation.ScanTable(tableName, con);

                #endregion Fetch result

                //Binding the fetched result to the grid
                gridData1.ItemsSource = result;

                //closing the HBase connection
                con.Close();
            }
Beispiel #5
0
        private void BindDataSource()
        {
            ErrorMessage.InnerText = "";
            string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));

            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;

                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }
                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                #region scan values

                HBaseOperation.FetchSize = 100;
                HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);

                //Initialize the list to add elements in each row
                BindingList <Customers> resultList = new BindingList <Customers>();

                //Read each row from the fetched result
                foreach (HBaseRecord rows in table)
                {
                    //Adding element of each row to the list
                    resultList = new BindingList <Customers>(table.Select(row => new Customers
                    {
                        ContactId    = row["rowKey"] != null?row["rowKey"].ToString():"",
                        FullName     = row["info:FULLNAME"] != null ? row["info:FULLNAME"].ToString() : "",
                        Age          = row["info:AGE"] != null ? row["info:AGE"].ToString() : "",
                        EmailId      = row["contact:EMAILID"] != null ? row["contact:EMAILID"].ToString() : "",
                        PhoneNumber  = row["contact:PHONE"] != null ? row["contact:PHONE"].ToString() : "",
                        ModifiedDate = row["others:MODIFIEDDATE"] != null ? row["others:MODIFIEDDATE"].ToString() : "",
                    }).ToList());
                }
                //Binding the result to the grid
                this.FlatGrid.DataSource = resultList;
                this.FlatGrid.DataBind();
                #endregion scan values

                #region close connection
                //Closing the hbase connection
                con.Close();
                #endregion close connection
            }
Beispiel #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                #region creating connection
                con = new HBaseConnection("localhost", 10003);
                con.Open();
                #endregion creating connection

                #region parsing csv input file
                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                cells = csvObj.Table(path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", false, ',');

                #endregion parsing csv input file

                #region creating table
                tableName = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values


                ////Executes the Hql query
                //HqlDataReader reader = command.ExecuteReader();

                //Assigning number of records to be fetched from HBase
                HBaseOperation.FetchSize = 5000;


                //#endregion

                // Paging enabled in grid
                var pager = new Pager();
                pager.Wire(_gridGroupingControl2, tableName, con, commonLoaderPicPanel);

                _gridGroupingControl2.TopLevelGroupOptions.ShowFilterBar = false;
                foreach (var col in _gridGroupingControl2.TableDescriptor.Columns)
                {
                    col.AllowFilter = false;
                }

                int topRow = this._gridGroupingControl2.TableControl.TopRowIndex;
                this._gridGroupingControl2.TableControl.CurrentCell.Activate(topRow, 1);
            }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ErrorMessage.InnerText = "";
            string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));

            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;

                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }
                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                #region scan values

                HBaseOperation.FetchSize = 100;
                HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);


                StringWriter stringWriter = new StringWriter();
                //Htmlwriter for creating table to append the HiveResults
                using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Border, "1");
                    writer.AddStyleAttribute(HtmlTextWriterStyle.BorderCollapse, "collapse");
                    writer.RenderBeginTag(HtmlTextWriterTag.Table);

                    writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("ContactId");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("contact:EmailId");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("contact:PhoneNo");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("info:Age");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("info:FullName");
                    writer.RenderEndTag();

                    writer.RenderBeginTag(HtmlTextWriterTag.Th);
                    writer.Write("others:ModifiedDate");
                    writer.RenderEndTag();

                    writer.RenderEndTag();
                    int count = table.Count();
                    for (int i = 0; i < count; i++)
                    {
                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        HBaseRecord records = table[i];

                        for (int j = 0; j < records.Count; j++)
                        {
                            Object fields = records[j];
                            writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            writer.Write(fields);
                            writer.RenderEndTag();
                        }
                        writer.RenderEndTag();
                    }
                    writer.RenderEndTag();
                }
                //Binding the result to the RTE control
                string results = stringWriter.ToString();
                rteControl.RTEContent.InnerHtml = results;
                #endregion scan values

                #region close connection
                //Closing the hive connection
                con.Close();
                #endregion close connection
            }
Beispiel #8
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            ErrorMessage.InnerText = "";
            if (hdnGroup.Value == "Word")
            {
                string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));
                try
                {
                    //Create a new document
                    WordDocument document = new WordDocument();

                    //Adding new table to the document
                    WTable doctable = new WTable(document);

                    //Adding a new section to the document.
                    WSection section = document.AddSection() as WSection;

                    //Set Margin of the section
                    section.PageSetup.Margins.All = 72;

                    //Set page size of the section
                    section.PageSetup.PageSize = new SizeF(800, 792);

                    //Create Paragraph styles
                    WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle;
                    style.CharacterFormat.FontName = "Calibri";
                    style.CharacterFormat.FontSize = 11f;

                    //Create a character format for declaring font color and style for the text inside the cell
                    WCharacterFormat charFormat = new WCharacterFormat(document);
                    charFormat.TextColor = System.Drawing.Color.White;
                    charFormat.Bold      = true;

                    #region creating connection
                    HBaseConnection con = new HBaseConnection("localhost", 10003);
                    con.Open();

                    #endregion creating connection

                    #region parsing csv input file

                    csv csvObj = new csv();
                    object[,] cells;
                    cells = null;

                    cells = csvObj.Table(path, false, ',');

                    #endregion parsing csv input file

                    #region creating table
                    String        tableName      = "AdventureWorks_Person_Contact";
                    List <string> columnFamilies = new List <string>();
                    columnFamilies.Add("info");
                    columnFamilies.Add("contact");
                    columnFamilies.Add("others");
                    if (!HBaseOperation.IsTableExists(tableName, con))
                    {
                        if (columnFamilies.Count > 0)
                        {
                            HBaseOperation.CreateTable(tableName, columnFamilies, con);
                        }
                        else
                        {
                            throw new HBaseException("ERROR: Table must have at least one column family");
                        }
                    }
                    # endregion

                    #region Inserting Values
                    string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                    Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                    string rowKey;
                    for (int i = 0; i < cells.GetLength(0); i++)
                    {
                        List <HMutation> mutations = new List <HMutation>();
                        rowKey = cells[i, 0].ToString();
                        for (int j = 1; j < column.Length; j++)
                        {
                            HMutation mutation = new HMutation();
                            mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                            mutation.ColumnName   = column[j];
                            mutation.Value        = cells[i, j].ToString();
                            mutations.Add(mutation);
                        }
                        rowCollection[rowKey] = mutations;
                    }
                    HBaseOperation.InsertRows(tableName, rowCollection, con);
                    #endregion Inserting Values

                    #region scan values

                    HBaseOperation.FetchSize = 100;
                    HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);

                    //Adding headertext for the table
                    doctable.AddRow(true, false);
                    //Creating new cell
                    WTableCell cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("ContactId").ApplyCharacterFormat(charFormat);
                    cell.Width = 100;
                    //Adding cell to the row
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("contact:EmailId").ApplyCharacterFormat(charFormat);
                    cell.Width = 200;
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("contact:PhoneNo").ApplyCharacterFormat(charFormat);
                    cell.Width = 150;
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("info:Age").ApplyCharacterFormat(charFormat);
                    cell.Width = 100;
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("info:FullName").ApplyCharacterFormat(charFormat);
                    cell.Width = 150;
                    doctable.Rows[0].Cells.Add(cell);
                    cell = new WTableCell(document);
                    cell.AddParagraph().AppendText("others:ModifiedDate").ApplyCharacterFormat(charFormat);
                    cell.Width = 200;
                    doctable.Rows[0].Cells.Add(cell);


                    //Reading each row from the fetched result
                    for (int i = 0; i < table.Count(); i++)
                    {
                        HBaseRecord records = table[i];
                        doctable.AddRow(true, false);

                        //Reading each data from the row
                        for (int j = 0; j < records.Count; j++)
                        {
                            Object fields = records[j];

                            //Adding new cell to the document
                            cell = new WTableCell(document);

                            //Adding each data to the cell
                            cell.AddParagraph().AppendText(fields.ToString());
                            if (j != 1 && j != 2 && j != 4 && j != 5)
                            {
                                cell.Width = 100;
                            }
                            else if (j == 2 || j == 4)
                            {
                                cell.Width = 150;
                            }
                            else
                            {
                                cell.Width = 200;
                            }

                            //Adding cell to the table
                            doctable.Rows[i + 1].Cells.Add(cell);
                            doctable.Rows[0].Cells[j].CellFormat.BackColor = Color.FromArgb(51, 153, 51);
                        }
                    }
                    //Adding table to the section
                    section.Tables.Add(doctable);
                    //Save as word 2007 format
                    if (rBtnWord2003.Checked == true)
                    {
                        document.Save("Sample.doc", FormatType.Doc, Response, HttpContentDisposition.Attachment);
                    }
                    else if (rBtnWord2007.Checked == true)
                    {
                        document.Save("Sample.docx", FormatType.Word2007, Response, HttpContentDisposition.Attachment);
                    }
                    //Save as word 2010 format
                    else if (rbtnWord2010.Checked == true)
                    {
                        document.Save("Sample.docx", FormatType.Word2010, Response, HttpContentDisposition.Attachment);
                    }
                    //Save as word 2013 format
                    else if (rbtnWord2013.Checked == true)
                    {
                        document.Save("Sample.docx", FormatType.Word2013, Response, HttpContentDisposition.Attachment);
                    }
                    #endregion scan values

                    #region close connection
                    //Closing the hive connection
                    con.Close();
                    #endregion close connection
                }
Beispiel #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ErrorMessage.InnerText = "";
            string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));

            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;

                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }
                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                #region scan values
                HBaseOperation.FetchSize = 100;
                String rowFilter = new FilterString().RowFilter(CompareOperator.Equal, Comparator.BinaryPrefix("1002")).Query();

                RowFilter = HBaseOperation.ScanTable(tableName, rowFilter, con);

                HBaseOperation.FetchSize = 100;
                String singleColumnValueFilter = new FilterString().SingleColumnValueFilter("info", "FULLNAME", CompareOperator.Equal, Comparator.BinaryPrefix("Katherine")).Query();
                SingleColumnValueFilter   = HBaseOperation.ScanTable(tableName, singleColumnValueFilter, con);
                this.FlatGrid1.DataSource = RowFilter;
                this.FlatGrid1.DataBind();
                this.FlatGrid2.DataSource = SingleColumnValueFilter;
                this.FlatGrid2.DataBind();
                #endregion scan values

                #region close connection
                //Closing the hive connection
                con.Close();
                #endregion close connection
            }
Beispiel #10
0
        public ActionResult AsynchronousDefault()
        {
            ErrorMessage = "";
            string path = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv").FullName;

            try
            {
                #region creating connection
                con = new HBaseConnection("localhost", 10003);
                con.Open();
                #endregion creating connection

                #region parsing csv input file
                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                tableName = "adventureworks_person_contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                page           = 0;
                skip           = -1;
                DataCollection = new Dictionary <int, DataResult>();
                ErrorMessage   = "";
            }
Beispiel #11
0
        public void Form1_Load(object sender, EventArgs e)
        {
            rdbExcel.Checked  = true;
            groupBox1.Visible = true;
            groupBox2.Visible = false;
            button1.Visible   = true;
            try
            {
                //Initializing the HBase server connection

                #region creating connection

                con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                string path = System.AppDomain.CurrentDomain.BaseDirectory;
                cells = csvObj.Table(path + "..\\..\\..\\..\\..\\..\\..\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");

                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }

                # endregion

                #region Inserting Values

                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();

                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }

                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);

                #endregion Inserting Values

                #region scan values

                HBaseOperation.FetchSize = 100;
                table = HBaseOperation.ScanTable(tableName, con);

                #endregion scan values

                #region closing connection

                //closing the HBase connection
                con.Close();

                #endregion closing connection
            }
Beispiel #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string path = string.Format("{0}\\..\\Data\\AdventureWorks\\AdventureWorks_Person_Contact.csv", Request.PhysicalPath.ToLower().Split(new string[] { "\\c# hbase samples" }, StringSplitOptions.None));

            try
            {
                #region creating connection
                con = new HBaseConnection("localhost", 10003);
                con.Open();
                #endregion creating connection

                #region parsing csv input file
                csv csvObj = new csv();
                object[,] cells;
                cells = null;
                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                tableName = "asyncHbaseCustomer3";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        error = "ERROR: Table must have at least one column family";
                        throw new HBaseException(error);
                    }
                }

                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values

                page = 0;
                Skip = -1;

                DataCollection = new Dictionary <int, DataResult>();
            }
Beispiel #13
0
        private void BindDataSource()
        {
            ErrorMessage.InnerText = "";

            try
            {
                #region creating connection

                HBaseConnection con = new HBaseConnection("localhost", 10003);
                con.Open();

                #endregion creating connection

                #region parsing csv input file

                csv csvObj = new csv();
                object[,] cells;
                cells = null;

                cells = csvObj.Table(path, false, ',');

                #endregion parsing csv input file

                #region creating table
                String        tableName      = "AdventureWorks_Person_Contact";
                List <string> columnFamilies = new List <string>();
                columnFamilies.Add("info");
                columnFamilies.Add("contact");
                columnFamilies.Add("others");
                if (!HBaseOperation.IsTableExists(tableName, con))
                {
                    if (columnFamilies.Count > 0)
                    {
                        HBaseOperation.CreateTable(tableName, columnFamilies, con);
                    }
                    else
                    {
                        throw new HBaseException("ERROR: Table must have at least one column family");
                    }
                }
                # endregion

                #region Inserting Values
                string[] column = new string[] { "CONTACTID", "FULLNAME", "AGE", "EMAILID", "PHONE", "MODIFIEDDATE" };
                Dictionary <string, IList <HMutation> > rowCollection = new Dictionary <string, IList <HMutation> >();
                string rowKey;
                for (int i = 0; i < cells.GetLength(0); i++)
                {
                    List <HMutation> mutations = new List <HMutation>();
                    rowKey = cells[i, 0].ToString();
                    for (int j = 1; j < column.Length; j++)
                    {
                        HMutation mutation = new HMutation();
                        mutation.ColumnFamily = j < 3 ? "info" : j < 5 ? "contact" : "others";
                        mutation.ColumnName   = column[j];
                        mutation.Value        = cells[i, j].ToString();
                        mutations.Add(mutation);
                    }
                    rowCollection[rowKey] = mutations;
                }
                HBaseOperation.InsertRows(tableName, rowCollection, con);
                #endregion Inserting Values


                #region scan values

                HBaseOperation.FetchSize = 100;
                HBaseResultSet table = HBaseOperation.ScanTable(tableName, con);
                this.FlatGrid.DataSource = table;
                this.FlatGrid.DataBind();
                #endregion scan values

                #region close connection
                //Closing the hbase connection
                con.Close();
                #endregion close connection
            }