Example #1
0
        private List <csv> readData()
        {
            List <csv> myList = new List <csv>();
            string     path   = @"C:\Users\danie\source\repos\csvreader\data.csv";

            if (!System.IO.File.Exists(path))
            {
                csv temp = new csv();
                temp.AccountNumber = "Null";
                myList.Add(temp);
                return(myList);
            }
            else
            {
                using (StreamReader sr = System.IO.File.OpenText(path))
                {
                    string s = "";
                    while ((s = sr.ReadLine()) != null)
                    {
                        Console.WriteLine(s);
                        csv temp = parseLine(s);
                        myList.Add(temp);
                    }
                }
                return(myList);
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            List <DataTable> tables = new List <DataTable>();

            foreach (KeyValuePair <string, string> entry in workspacesSheets)
            {
                String    workSpace       = entry.Key;
                DataTable statistikaTable = (DataTable)this.Session["statistikaTable" + workSpace];
                tables.Add(statistikaTable);
            }
            csv    csvFile    = new csv();
            String fileName   = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss") + ".csv";
            String thisDayDir = Server.MapPath("~") + "\\csvFiles\\" + DateTime.Now.ToString("yyyy_MM_dd");

            if (!Directory.Exists(thisDayDir))
            {
                Directory.CreateDirectory(thisDayDir);
            }
            String excellFilePath = thisDayDir + "\\" + fileName;

            csvFile.writeToCsvFile(excellFilePath, tables);
            Response.Write("<script>");
            Response.Write("window.open('downloadFile.aspx?fileName=" + fileName + "&excellFilePath=" + excellFilePath.Replace('\\', '*') + "' ,'_blank')");
            Response.Write("</script>");
        }
Example #3
0
        private csv parseLine(string s)
        {
            csv Account   = new csv();
            int nextIndex = 0;

            nextIndex = s.IndexOf(',');

            Account.AccountNumber = s.Substring(0, nextIndex);
            s                  = s.Substring(nextIndex + 1);
            nextIndex          = s.IndexOf(',');
            Account.LastName   = s.Substring(0, nextIndex);
            s                  = s.Substring(nextIndex + 1);
            nextIndex          = s.IndexOf(',');
            Account.FirstName  = s.Substring(0, nextIndex);
            s                  = s.Substring(nextIndex + 1);
            nextIndex          = s.IndexOf(',');
            Account.MiddleName = s.Substring(0, nextIndex);
            s                  = s.Substring(nextIndex + 1);
            nextIndex          = s.IndexOf(',');

            //get the adress city and state
            Account.Address = s.Substring(0, nextIndex);
            s                = s.Substring(nextIndex + 1);
            nextIndex        = s.IndexOf(',');
            Account.Address += s.Substring(0, nextIndex);
            s                = s.Substring(nextIndex + 1);
            nextIndex        = s.IndexOf(',');
            Account.Address += s.Substring(0, nextIndex);
            s                = s.Substring(nextIndex + 1);
            nextIndex        = s.IndexOf(',');
            Account.Address += s.Substring(0, nextIndex);
            s                = s.Substring(nextIndex + 1);
            nextIndex        = s.IndexOf(',');
            Account.Address += s.Substring(0, nextIndex);
            s                = s.Substring(nextIndex + 1);
            nextIndex        = s.IndexOf(',');


            Account.PhoneNumber = s.Substring(0, nextIndex);
            s                    = s.Substring(nextIndex + 1);
            nextIndex            = s.IndexOf(',');
            Account.SPhoneNumber = s.Substring(0, nextIndex);
            s                    = s.Substring(nextIndex + 1);
            nextIndex            = s.IndexOf(',');
            Account.OpendedDate  = s.Substring(0, nextIndex);
            s                    = s.Substring(nextIndex + 1);
            nextIndex            = s.IndexOf(',');
            Account.Balance      = s.Substring(0, nextIndex);
            s                    = s.Substring(nextIndex + 1);
            Account.Type         = s;

            return(Account);
        }
Example #4
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
Example #5
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();
            }
Example #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);
            }
Example #7
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
            }
        public void UploadRecord(DataRow Dr)
        {
            string folder = "";

            StringBuilder sb = new StringBuilder();

            csv item = new csv();

            folder        = Path.Combine(Dr["doc_comp_code"].ToString(), Dr["doc_table_name"].ToString(), Dr["doc_slno"].ToString());
            item.company  = comp_code;
            item.orderno  = Dr["doc_slno"].ToString();
            item.rowcount = "1";
            item.slno     = "1";

            item.orderid = comp_code + Dr["doc_slno"].ToString() + "-" + item.slno;
            if (Dr["size"].ToString().Length > 0)
            {
                item.orderid = comp_code + Dr["doc_slno"].ToString() + "-" + item.slno + "-" + Dr["size"].ToString();
            }

            item.customer_store = Dr["store"].ToString();
            item.approver       = Dr["approver"].ToString();
            item.receiver       = Dr["receiver"].ToString();


            if (item.approver != "")
            {
                item.email = item.orderid + "!" + item.approver + "#" + item.receiver;
            }
            else
            {
                item.email = item.orderid + "#" + item.receiver;
            }

            item.output = Dr["output"].ToString() + "\\" + item.email;

            item.project = Dr["aep"].ToString();

            if (Dr["size"].ToString().Length > 0)
            {
                item.product_name = Dr["size"].ToString();
            }
            else
            {
                item.product_name = Dr["product"].ToString();
            }

            item.upload_logo_location2 = Dr["logo"].ToString();
            if (Dr["logo"].ToString().Trim().Length > 0)
            {
                item.upload_logo_location2 = folder + "\\" + Dr["logo"].ToString();
            }

            item.upload_image1_location2 = Dr["image1"].ToString();
            if (Dr["image1"].ToString().Trim().Length > 0)
            {
                item.upload_image1_location2 = folder + "\\" + Dr["image1"].ToString();
            }

            item.upload_image2_location2 = Dr["image2"].ToString();
            if (Dr["image2"].ToString().Trim().Length > 0)
            {
                item.upload_image2_location2 = folder + "\\" + Dr["image2"].ToString();
            }

            item.upload_image3_location2 = Dr["image3"].ToString();
            if (Dr["image3"].ToString().Trim().Length > 0)
            {
                item.upload_image3_location2 = folder + "\\" + Dr["image3"].ToString();
            }

            item.upload_image4_location2 = Dr["image4"].ToString();
            if (Dr["image4"].ToString().Trim().Length > 0)
            {
                item.upload_image4_location2 = folder + "\\" + Dr["image4"].ToString();
            }

            item.upload_image5_location2 = Dr["image5"].ToString();
            if (Dr["image5"].ToString().Trim().Length > 0)
            {
                item.upload_image5_location2 = folder + "\\" + Dr["image5"].ToString();
            }

            item.text1 = Dr["text1"].ToString();
            item.text2 = Dr["text2"].ToString();
            item.text3 = Dr["text3"].ToString();
            item.text4 = Dr["text4"].ToString();
            item.text5 = Dr["text5"].ToString();


            string json = System.Text.Json.JsonSerializer.Serialize(item);

            postdata(json, Dr["doc_slno"].ToString(), "1");
        }
Example #9
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
                }
Example #10
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>();
            }
Example #11
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
            }
Example #12
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   = "";
            }
Example #13
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
            }
Example #14
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
            }
Example #15
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
            }
Example #16
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
            }
Example #17
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
            }