Read() public method

public Read ( ) : bool
return bool
        public void Fact()
        {
            var connection = default (DbConnection);
            var reader = default(DbDataReader);

            try
            {
                connection = KandaXunitProviderFactory.Instance.CreateConnection();
                connection.Open();

                var schema = connection.GetTablesSchema();
                reader = new DataTableReader(schema);

                while (reader.Read())
                {
                    var name = reader.GetString(reader.GetOrdinal(@"TABLE_NAME"));
                    var type = reader.GetString(reader.GetOrdinal(@"TABLE_TYPE"));

                    //this.transformEntity(name, type);
                    this.transformInsertTable(name, type);
                }
            }
            finally
            {
                if (reader != null) { reader.Close(); }
                if (connection != null) { connection.Close(); }
            }
        }
        public void TransformTextFact()
        {
            var connection = default(DbConnection);
            var reader = default(DbDataReader);

            try
            {
                connection = this._factory.CreateConnection();
                connection.Open();

                var schema = connection.GetTablesSchema();
                reader = new DataTableReader(schema);

                while (reader.Read())
                {
                    var name = TextTemplateFact.GetTableName(reader);
                    var type = TextTemplateFact.GetTableType(reader);

                    var context = new InsertTableContext(name, type)
                                      {
                                          ProcedureNamePrefix = @"usp_", 
                                          ProcedureNameSuffix = @"", 
                                      };
                    var template = new InsertTableTemplate(context);
                    template.Initialize();
                    var text = template.TransformText();
                    // TODO : 
                }
            }
            finally
            {
                if (reader != null) { reader.Close(); }
                if (connection != null) { connection.Close(); }
            }
        }
Exemplo n.º 3
0
    static void Main()
    {
        var dt = new System.Data.DataTable();

        dt.Columns.Add("ID", typeof(String));
        dt.Columns.Add("Val", typeof(int));

        dt.Rows.Add("1", 10);
        dt.Rows.Add("2", 20);
        dt.Rows.Add("3", 10);
        dt.Rows.Add("4", 20);

        System.Data.DataTableReader dr = dt.CreateDataReader();

        for (int I = 0; I < dr.FieldCount; I++)
        {
            Console.Write(dr.GetName(I) + ",");
        }
        Console.WriteLine();

        while (dr.Read())
        {
            for (int I = 0; I < dr.FieldCount; I++)
            {
                Console.Write(dr[dr.GetName(I)] + ",");
            }
            Console.WriteLine();
        }
    }
Exemplo n.º 4
0
 private void FillPartyName()
 {
     DataTableReader read = new DataTableReader(this.maindataset.Pending);
     while (read.Read())
     {
         txtPartyName.Items.Add(read.GetString(3));
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Imports article from csv file to db. If article with same number exists, it will be replaced.
        /// </summary>
        /// <param name="db"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public static bool ImportArticleFromCsv(ISposDb db, string file)
        {
            // read csv file
            DataTable data = ParseCSV(file);
            if (data == null)
            {
                return false;
            }
            // convert data
            DataTableReader reader = new DataTableReader(data);
            if (reader.FieldCount != 5 && !reader.HasRows)
            {
                return false;
            }
            List<SimplePOS.Article.RegularArticle> articleList = new List<SimplePOS.Article.RegularArticle>();
            reader.Read(); // read the header
            while (reader.Read())
            {
                object[] values = new object[5];
                int result = reader.GetValues(values);
                if (result > 0)
                {
                    try
                    {
                        // Text may be empty wich results in a strange object
                        string text;
                        try { text = (string)values[2]; }
                        catch { text = ""; }
                        articleList.Add(new SimplePOS.Article.RegularArticle((string)values[0],
                            (string)values[1], text,
                            Double.Parse((string)values[3]),
                            Double.Parse((string)values[4])));
                    }
                    catch { return false; }
                }
            }

            // import to db
            db.SaveArticleList(articleList);

            return true;
        }
Exemplo n.º 6
0
 private void FillComDebitBillIdIsFalse()
 {
     this.selectlocalbillTableAdapter.Fill(this.lclsupset.selectlocalbill);
     DataTable table = this.lclsupset.Tables["selectlocalbill"];
     DataTableReader read = new DataTableReader(table);
     comboDebitBillNumber.Properties.Items.Clear();
     while (read.Read())
     {
         comboDebitBillNumber.Properties.Items.Add(read.GetInt32(1).ToString());
     }
 }
Exemplo n.º 7
0
 private void SupBillReceived_Load(object sender, EventArgs e)
 {
     // TODO: This line of code loads data into the 'maindataset.mainbill' table. You can move, or remove it, as needed.
     this.mainbillTableAdapter.Fill(this.maindataset.mainbill);
     DataTable table = this.maindataset.Tables["mainbill"];
     DataTableReader read = new DataTableReader(table);
     while (read.Read())
     {
         comboDebitBillNumber.Properties.Items.Add(read.GetInt32(3).ToString());
     }
 }
        public void GetValue_ValidColumnIdentifiers_ReturnsCorrectType()
        {
            using (var dr = new DataTableReader(_dt1)) {
                dr.Read();
                Assert.AreEqual(1, dr.GetValue<int>("id"), "ID");
                Assert.AreEqual(1L, dr.GetValue<long>("id"), "ID as long");
                Assert.AreEqual(1, dr.GetValue<ushort>("id"), "ID as short");
                Assert.AreEqual(1, dr.GetValue<byte>("id"), "ID as byte");

                Assert.AreEqual(new DateTime(2011, 03, 31, 18, 22, 13), dr.GetValue<DateTime>("time"), "Time");
                Assert.AreEqual(70.41f, dr.GetValue<decimal>("amount"), "Amount");
                Assert.AreEqual("Kaffe", dr.GetValue<string>("description"), "Description");
            }
        }
Exemplo n.º 9
0
 private static string[] GetFromDataBase()
 {
     CheckLane.lanesetTableAdapters.tariff_oceanTableAdapter tableAdapter = new CheckLane.lanesetTableAdapters.tariff_oceanTableAdapter();
     laneset.tariff_oceanDataTable table = new laneset.tariff_oceanDataTable();
     tableAdapter.Fill(table);
     DataTableReader reader = new DataTableReader(table);
     string[] laneid = new string[table.Rows.Count];
     int counter = 0;
     while (reader.Read())
     {
         laneid[counter++] = reader[0].ToString();
     }
     return laneid;
 }
        public void should_map_enums()
        {
            var value = FoobarEnum.Bar;
            using (var table = CreateTable("Enum", value, typeof(int)))
            {
                var mapper = CreateMapper(table, x => x.Value(y => y.Enum));
                using (var reader = new DataTableReader(table))
                {
                    reader.Read();
                    var person = (Foobar)mapper.Map(reader, typeof(Foobar));

                    Assert.That(person.Enum, Is.EqualTo(value));
                }
            }
        }
        public void should_map_ids()
        {
            var value = 1;
            using (var table = CreateTable("Id", value))
            {
                var mapper = CreateMapper(table, x => x.Id(y => y.Id));
                using (var reader = new DataTableReader(table))
                {
                    reader.Read();
                    var person = (Foobar)mapper.Map(reader, typeof(Foobar));

                    Assert.That(person.Id, Is.EqualTo(value));
                }
            }
        }
        public void should_map_nullable_type_with_value()
        {
            var value = 1;
            using (var table = CreateTable("NullableValueDefaultsToZero", value))
            {
                var mapper = CreateMapper(table, x => x.Value(y => y.NullableValueDefaultsToZero));
                using (var reader = new DataTableReader(table))
                {
                    reader.Read();
                    var person = (Foobar)mapper.Map(reader, typeof(Foobar));

                    Assert.That(person.NullableValueDefaultsToZero, Is.EqualTo(value));
                }
            }
        }
Exemplo n.º 13
0
        public void MapUnexistPropertyException_Test()
        {
            ObjectConverter objectConverter = new ObjectConverter();

            DataTable dt = new DataTable();
            dt.Columns.Add("Name", typeof(string));

            dt.Rows.Add("QQ");
            var reader = new DataTableReader(dt);
            reader.Read();
            MapWithoutPropertyTestObject1 obj = new MapWithoutPropertyTestObject1();
            objectConverter.MapObject(reader, obj);

            Assert.AreEqual("QQ", obj.Name);
            Assert.AreEqual(100, obj.Age);
        }
Exemplo n.º 14
0
 //对下拉列表进行数据绑定
 private void CBoxBind()
 {
     cbox_SheetName.Items.Clear();//清空下拉列表项
     //连接Excel数据库
     OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txt_Path.Text + ";Extended Properties=Excel 8.0");
     olecon.Open();//打开数据库连接
     System.Data.DataTable DTable = olecon.GetSchema("Tables");//实例化表对象
     DataTableReader DTReader = new DataTableReader(DTable);//实例化表读取对象
     while (DTReader.Read())//循环读取
     {
         cbox_SheetName.Items.Add(DTReader["Table_Name"].ToString().Replace('$',' ').Trim());//将工作表名添加到下拉列表中
     }
     DTable = null;//清空表对象
     DTReader = null;//清空表读取对象
     olecon.Close();//关闭数据库连接
     cbox_SheetName.SelectedIndex = 0;//设置下拉列表默认选项为第一项
 }
Exemplo n.º 15
0
                public void CtorTest ()
                {
                        dt.Rows [1].Delete ();
                        DataTableReader reader = new DataTableReader (dt);
                        try {
                                
                                int i = 0;
                                while (reader.Read ())
                                        i++;
                                reader.Close ();

                                Assert.AreEqual (2, i, "no. of rows iterated is wrong");
                        } finally {
                                if (reader != null && !reader.IsClosed)
                                        reader.Close ();
                        }
                }
Exemplo n.º 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            //add a reference to our SQL WS
            ws.SQLWS_endpoint SQLWS = new ws.SQLWS_endpoint();

            //Set our default credentials to our Windows one
            SQLWS.Credentials = CredentialCache.DefaultCredentials;

            //Call the sproc through the WS
            System.Data.DataSet dsReturnValue = (System.Data.DataSet)SQLWS.SQLWS("Calling stored proc").GetValue(0);

            //Get the reader associated with our Dataset
            System.Data.DataTableReader drSQL = dsReturnValue.CreateDataReader();

            //Get the result
            string strResult = "";

            while (drSQL.Read())
            {
                strResult = drSQL[0].ToString();
            }

            //Display the results
            MessageBox.Show("Return value from SQL call: " + strResult);

            ws.SqlParameter[] sqlparams = new ws.SqlParameter[0];

            //Send a batch command to SQL
            System.Data.DataSet dsReturnValue1 = (System.Data.DataSet)SQLWS.sqlbatch("SELECT * FROM sys.http_endpoints", ref sqlparams).GetValue(0);

            //Get the reader associated with our Dataset
            System.Data.DataTableReader drSQL1 = dsReturnValue1.CreateDataReader();

            //Get the result
            string strResult1 = "";

            while (drSQL1.Read())
            {
                strResult1 = drSQL1[0].ToString();
            }

            //Display the results
            MessageBox.Show("Return value from SQL call: " + strResult1);
        }
Exemplo n.º 17
0
 //获取所有工作表名称
 private List<string> GetSheetName(string P_str_Excel)
 {
     List<string> P_list_SheetName = new List<string>();//实例化泛型集合对象
     //连接Excel数据库
     OleDbConnection olecon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + P_str_Excel + ";Extended Properties=Excel 8.0");
     olecon.Open();//打开数据库连接
     System.Data.DataTable DTable = olecon.GetSchema("Tables");//实例化表对象
     DataTableReader DTReader = new DataTableReader(DTable);//实例化表读取对象
     while (DTReader.Read())//循环读取
     {
         string P_str_Name = DTReader["Table_Name"].ToString().Replace('$', ' ').Trim();//记录工作表名称
         if (!P_list_SheetName.Contains(P_str_Name))//判断泛型集合中是否已经存在该工作表名称
             P_list_SheetName.Add(P_str_Name);//将工作表名添加到泛型集合中
     }
     DTable = null;//清空表对象
     DTReader = null;//清空表读取对象
     olecon.Close();//关闭数据库连接
     return P_list_SheetName;//返回得到的泛型集合
 }
Exemplo n.º 18
0
 public Entity.User LoadUserMapData(System.Data.DataSet dataSet)
 {
     //Map the entity data...
     System.Data.DataTableReader reader = dataSet.Tables[(Int32)UserMap.DataSets.entitydata].CreateDataReader();
     Entity.User user = null;
     //Single record...
     if (reader.Read())
     {
         List <Entity.SQLEnumeration> roleTypes = EnumerationMapData(dataSet.Tables[(Int32)UserMap.DataSets.enumeration]);
         user = new User(
             Int32.Parse(reader[UserMap.Names.id].ToString()),
             reader[UserMap.Names.sqlSession].ToString(),
             new UserRole(
                 Int32.Parse(reader[UserMap.Names.roleId].ToString()),
                 reader[UserMap.Names.roleName].ToString(),
                 reader[UserMap.Names.roleDescription].ToString()
                 ),
             new UserIdentity(
                 reader[UserMap.Names.email].ToString(),
                 reader[UserMap.Names.userGreeting].ToString(),
                 reader[UserMap.Names.userName].ToString(),
                 reader[UserMap.Names.firstName].ToString(),
                 reader[UserMap.Names.lastName].ToString(),
                 reader[UserMap.Names.lastLoginText].ToString(),
                 reader[UserMap.Names.createdText].ToString(),
                 reader[UserMap.Names.editedText].ToString(),
                 DateTime.Parse(reader[UserMap.Names.lastLogin].ToString()),
                 DateTime.Parse(reader[UserMap.Names.created].ToString()),
                 DateTime.Parse(reader[UserMap.Names.edited].ToString()),
                 reader[UserMap.Names.editor].ToString(),
                 Boolean.Parse(reader[UserMap.Names.active].ToString())
                 ),
             new UserCredential(),
             roleTypes
             );
     }
     if (reader != null)
     {
         reader.Dispose();
     }
     return(user);
 }
Exemplo n.º 19
0
        public string platsnamn(string platsID)
        {
            conn.Open();
            string namn = "";
            string query = "select nummer from platser where id = ";
            query += platsID.ToString();
            DataTable dt = new DataTable();
            NpgsqlDataAdapter da = new NpgsqlDataAdapter(query, conn);

            da.Fill(dt);

            DataTableReader dtr = new DataTableReader(dt);

            while (dtr.Read())
            {
                namn = dtr[0].ToString();
            }
            conn.Close();
            return namn;
        }
Exemplo n.º 20
0
 private void RellenaEtiquetasPlaceHolder()
 {
     if (this.idindicator.HasValue)
     {
         try
         {
             using (Clases.cKPI_INDICATOR_ETIQUETAS objEtiquetas = new Clases.cKPI_INDICATOR_ETIQUETAS())
             {
                 objEtiquetas.indicatorid = this.idindicator.Value;
                 System.Data.DataTableReader dtrValores = objEtiquetas.ObtenerDatos().CreateDataReader();
                 while (dtrValores.Read())
                 {
                     HyperLink NuevoEnlace = new HyperLink();
                     NuevoEnlace.Text        = dtrValores.GetValue(2).ToString();
                     NuevoEnlace.NavigateUrl = "~/search.aspx?tagstring=" + dtrValores.GetValue(2).ToString();
                     NuevoEnlace.CssClass    = "tag";
                     PlaceHolderEtiquetas.Controls.Add(NuevoEnlace);
                 }
             }
         }
         catch (Exception excp)
         {
             ExceptionUtility.LogException(excp, "Error en la función << RellenaEtiquetasPlaceHolder() >>");
         }
         finally
         {
             if (PlaceHolderEtiquetas.Controls.Count > 0)
             {
                 lbNumEtiquetasNoEditable.Text = PlaceHolderEtiquetas.Controls.Count.ToString();
             }
             else
             {
                 PanelEtiquetasNoEditable.Visible = false;
             }
         }
     }
     else
     {
         Response.Redirect("~/errors/notfound.aspx");
     }
 }
Exemplo n.º 21
0
        public List <Entity.User> LoadListMapData(System.Data.DataTable data)
        {
            //Map the entity data...
            System.Data.DataTableReader reader = data.CreateDataReader();
            List <Entity.User>          list   = new List <User>(data.Rows.Count);

            //Record set...
            while (reader.Read())
            {
                list.Add(
                    new User(
                        Int32.Parse(reader[UserMap.Names.id].ToString()),
                        reader[UserMap.Names.sqlSession].ToString(),
                        new UserRole(
                            Int32.Parse(reader[UserMap.Names.roleId].ToString()),
                            reader[UserMap.Names.roleName].ToString(),
                            reader[UserMap.Names.roleDescription].ToString()
                            ),
                        new UserIdentity(
                            reader[UserMap.Names.email].ToString(),
                            reader[UserMap.Names.userGreeting].ToString(),
                            reader[UserMap.Names.userName].ToString(),
                            reader[UserMap.Names.firstName].ToString(),
                            reader[UserMap.Names.lastName].ToString(),
                            reader[UserMap.Names.lastLoginText].ToString(),
                            reader[UserMap.Names.createdText].ToString(),
                            reader[UserMap.Names.editedText].ToString(),
                            DateTime.Parse(reader[UserMap.Names.lastLogin].ToString()),
                            DateTime.Parse(reader[UserMap.Names.created].ToString()),
                            DateTime.Parse(reader[UserMap.Names.edited].ToString()),
                            reader[UserMap.Names.editor].ToString(),
                            Boolean.Parse(reader[UserMap.Names.active].ToString())
                            )));
            }

            if (reader != null)
            {
                reader.Dispose();
            }
            return(list);
        }
Exemplo n.º 22
0
        public List <Entity.SQLEnumeration> EnumerationMapData(System.Data.DataTable data)
        {
            System.Data.DataTableReader  reader = data.CreateDataReader();
            List <Entity.SQLEnumeration> list   = new List <SQLEnumeration>(data.Rows.Count);

            while (reader.Read())
            {
                list.Add(new SQLEnumeration(
                             Int16.Parse(reader[UserMap.Names.enumValue].ToString()),
                             reader[UserMap.Names.enumName].ToString(),
                             reader[UserMap.Names.enumDescription].ToString(),
                             Int16.Parse(reader[UserMap.Names.enumSort].ToString())
                             ));
            }

            if (reader != null)
            {
                reader.Dispose();
            }
            return(list);
        }
        public void getStudentData()
        {
            DataTable dt = DataAccessLayer.getAllStudentData();
            List<StudentDetails> sd_List = new List<StudentDetails>();
            DataTableReader dtr = new DataTableReader(dt);
            while (dtr.Read())
            {
                StudentDetails sd = new StudentDetails();
                sd.fname = dtr[0].ToString()+" "+dtr[1].ToString();
                sd.mname = dtr[2].ToString();
                sd.lname = dtr[3].ToString();
                sd.email = dtr[4].ToString();
                sd.gender = dtr[5].ToString();
                sd.maritial = dtr[6].ToString();
                sd.mobile = dtr[7].ToString();
                sd.dob = dtr[8].ToString();

                sd.branch = dtr[9].ToString();
                sd.division = dtr[10].ToString();
                sd.rollno = dtr[11].ToString();
                sd.backlogs = dtr[12].ToString();
                sd.totalAvg = dtr[13].ToString();

                sd.hsc_board_name = dtr[14].ToString();
                sd.hsc_specialization = dtr[15].ToString();
                sd.hsc_courseType = dtr[16].ToString();
                sd.hsc_percentage = dtr[17].ToString();

                sd.ssc_board_name = dtr[18].ToString();
                sd.ssc_courseType = dtr[19].ToString();
                sd.ssc_percentage = dtr[20].ToString();

                sd.break_years = dtr[21].ToString().ToString();

                sd_List.Add(sd);
            }
            JavaScriptSerializer jss = new JavaScriptSerializer();
            Context.Response.Write(jss.Serialize(sd_List));
        }
Exemplo n.º 24
0
        public Entity.User SaveUserMapData(System.Data.DataTable data)
        {
            //Map the entity data...
            System.Data.DataTableReader reader = data.CreateDataReader();
            Entity.User user = null;
            //Single record...
            if (reader.Read())
            {
                user = new User(
                    Int32.Parse(reader[UserMap.Names.id].ToString()),
                    reader[UserMap.Names.sqlSession].ToString(),
                    new UserRole(
                        Int32.Parse(reader[UserMap.Names.roleId].ToString()),
                        reader[UserMap.Names.roleName].ToString(),
                        reader[UserMap.Names.roleDescription].ToString()
                        ),
                    new UserIdentity(
                        reader[UserMap.Names.email].ToString(),
                        reader[UserMap.Names.userGreeting].ToString(),
                        reader[UserMap.Names.userName].ToString(),
                        reader[UserMap.Names.firstName].ToString(),
                        reader[UserMap.Names.lastName].ToString(),
                        reader[UserMap.Names.lastLoginText].ToString(),
                        reader[UserMap.Names.createdText].ToString(),
                        reader[UserMap.Names.editedText].ToString(),
                        DateTime.Parse(reader[UserMap.Names.lastLogin].ToString()),
                        DateTime.Parse(reader[UserMap.Names.created].ToString()),
                        DateTime.Parse(reader[UserMap.Names.edited].ToString()),
                        reader[UserMap.Names.editor].ToString(),
                        Boolean.Parse(reader[UserMap.Names.active].ToString())
                        ));
            }

            if (reader != null)
            {
                reader.Dispose();
            }
            return(user);
        }
Exemplo n.º 25
0
    private void RellenaEtiquetasEditables()
    {
        if (this.idindicator.HasValue)
        {
            string sComa        = string.Empty;
            string sKeywords    = string.Empty;
            int    NumEtiquetas = 0;

            try
            {
                using (Clases.cKPI_INDICATOR_ETIQUETAS objEtiquetas = new Clases.cKPI_INDICATOR_ETIQUETAS())
                {
                    objEtiquetas.indicatorid = this.idindicator.Value;
                    System.Data.DataTableReader dtrValores = objEtiquetas.ObtenerDatos().CreateDataReader();
                    while (dtrValores.Read())
                    {
                        sKeywords += sComa + dtrValores.GetValue(2).ToString();
                        sComa      = ", ";
                        NumEtiquetas++;
                    }
                }
            }
            catch (Exception excp)
            {
                ExceptionUtility.LogException(excp, "Error en la función << RellenaEtiquetasEditables() >>");
            }
            finally
            {
                txtEtiquetasEditable.Text   = sKeywords;
                Page.MetaKeywords           = sKeywords;
                lbNumEtiquetasEditable.Text = NumEtiquetas.ToString();
            }
        }
        else
        {
            Response.Redirect("~/errors/notfound.aspx");
        }
    }
Exemplo n.º 26
0
        public Entity.Session <NullT> InitializeMapData(System.Data.DataTable data)
        {
            //Map the entity data...
            System.Data.DataTableReader reader = data.CreateDataReader();
            Entity.Session <NullT>      init   = new Session <NullT>();
            //Single record...
            if (reader.Read())
            {
                init.SessionOk        = false;
                init.ClientMessage    = String.Empty;
                init.ServerMessage    = String.Empty;
                init.SqlKey           = reader[UserMap.Names.privateKey].ToString();
                init.AppOnline        = Boolean.Parse(reader[UserMap.Names.appOnline].ToString());
                init.SqlAuthorization = Boolean.Parse(reader[UserMap.Names.sqlAuthorization].ToString());
                init.WinAuthorization = Boolean.Parse(reader[UserMap.Names.winAuthorization].ToString());
            }

            if (reader != null)
            {
                reader.Dispose();
            }
            return(init);
        }
Exemplo n.º 27
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'MyDataBaseDataSet1.mainbilll' table. You can move, or remove it, as needed.
            this.mainbilllTableAdapter.Fill(this.MyDataBaseDataSet1.mainbilll);
            DataTable table = this.MyDataBaseDataSet1.Tables[1];

            DataTableReader read = new DataTableReader(table);
            while (read.Read())
            {
                comboBox1.Items.Add(read.GetInt32(0));
            }
            read.Close();
            this.reportViewer1.RefreshReport();

            //Microsoft.Reporting.WinForms.ReportPageSettings settings = this.reportViewer1.LocalReport.GetDefaultPageSettings();
            //settings.Margins.Bottom = 25;
            //settings.Margins.Top = 25;
            //settings.Margins.Left = 25;
            //settings.Margins.Right = 25;
            //Microsoft.Reporting.WinForms.
           

        }
 public void getStudentLoginData()
 {
     string error;
     DataTable dt = DataAccessLayer.showAllStudent(out error);
     if (error == null)
     {
         List<StudentLoginDetails> sld_List = new List<StudentLoginDetails>();
         DataTableReader dtr = new DataTableReader(dt);
         while (dtr.Read())
         {
             StudentLoginDetails sld = new StudentLoginDetails();
             sld.fname = dtr[1].ToString();
             sld.lname = dtr[2].ToString();
             sld.branch = dtr[3].ToString();
             sld.gender = dtr[4].ToString();
             sld.username = dtr[5].ToString();
             sld.verified = dtr[6].ToString();
             sld_List.Add(sld);
         }
         JavaScriptSerializer jss = new JavaScriptSerializer();
         Context.Response.Write(jss.Serialize(sld_List));
     }
 }
Exemplo n.º 29
0
 public void loadTableName(ComboBox cb)
 {
     System.Data.DataTable dt = ocon.GetSchema("Tables");
     DataTableReader dtr = new DataTableReader(dt);
     cb.Items.Clear();
     cb.Text = "";
     while (dtr.Read())
     {
         cb.Items.Add(dtr["Table_Name"]);
     }
     dtr.Close();
 }
Exemplo n.º 30
0
        /// <summary>
        /// Returns an individual entry entity
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public WebLogEntry GetEntry(int id)
        {
            XElement doc = XElement.Load(LogFilename);
            XElement match = doc.Descendants("LogEntry")
                                .Where( el => (int) el.Element("Id") == id )
                                .FirstOrDefault();

            DataTable dt = CreateEntryDataTable();
            DataRow dr = dt.NewRow();
            UpdateDataRowFromElement(match, dr);
            dt.Rows.Add(dr);
            DataTableReader reader = new DataTableReader(dt);
            reader.Read();

            WebLogEntry entry = new WebLogEntry();
            DataUtils.DataReaderToObject(reader, entry, null);

            return entry;
        }
        //list the log-in sessions according to the selected criterion
        private void BuildListBox(int userID, int groupID, DateTime time1, DateTime time2, bool cvs)
        {
            string pad = "  ";
            try
            {
                DataSet sessionData = InternalAdminDB.SelectSessionHistory(userID, groupID, time1, time2);
                DataTable sessionHistory = sessionData.Tables[0];

                if (sessionHistory.Rows.Count == 0)
                {
                    lblResponse.Text = Utilities.FormatWarningMessage(" No sessions found for your criteria.");
                    lblResponse.Visible = true;
                }
                else
                {
                    StringBuilder buf = new StringBuilder();
                    buf.AppendLine(String.Format("{0,-14}{1,-18}{2,-10}{3,-10}{4,-26}{5,-24}",
                        "User Name", "Create Time", "End Time","Modify","Group","Client"));

                    DataTableReader dtr = new DataTableReader(sessionHistory);
                    while(dtr.Read())
                    {
                        //buf.Append(dtr.GetInt64(0) + pad);
                        buf.Append(String.Format("{0,-12:12}", dtr.GetString(1)) + pad);
                        if(!dtr.IsDBNull(2))
                            buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(2),
                                CultureInfo.InvariantCulture,userTZ,"g") +pad);
                        else
                            buf.Append(String.Format("{0,-9:9}", "Not Set") + pad);
                        if (!dtr.IsDBNull(3))
                            buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(3), CultureInfo.InvariantCulture, userTZ, "T") + pad);
                        else
                            buf.Append(String.Format("{0,-8}", "Not Set") + pad);
                        if (!dtr.IsDBNull(4))
                            buf.Append(DateUtil.ToUserTime(dtr.GetDateTime(4), CultureInfo.InvariantCulture, userTZ, "T") + pad);
                        else
                            buf.Append(String.Format("{0,-8}", "Not Set") + pad);
                        string tmp = dtr.GetString(5);
                        if (tmp != null && tmp.Length > 24)
                            tmp = tmp.Substring(0, 24);
                        buf.Append(String.Format("{0,-24}",tmp) + pad);
                        tmp = dtr.GetString(6);
                        if (tmp != null && tmp.Length > 24)
                            tmp = tmp.Substring(0, 24);
                        buf.Append(String.Format("{0,-24}",tmp));

                        buf.AppendLine();
                    }
                    txtLoginDisplay.Text = buf.ToString();
                }
            }
            catch (Exception ex)
            {
                lblResponse.Text = Utilities.FormatErrorMessage(" Cannot retrieve UserSessions. " + ex.GetBaseException());
                lblResponse.Visible = true;
            }
        }
Exemplo n.º 32
0
    public void Process()
    {
        // use the following method to update the status on the AsyncProcessorDetail
        // in the AsyncProcessManager
        AsyncProcessManager.GetProcessorDetail(ProcessorDetail.ID).UpdateStatusText("Processing has started");

        try
        {
            int datasets   = 0;
            int errorCount = 0;
            int processed  = 0;
            int total      = 0;

            //PRIMER PASO
            //Nos aseguramos que el usuario que va a subir la información tiene una sesión abierta
            System.Web.Security.MembershipUser usr = System.Web.Security.Membership.GetUser();
            if (usr == null)
            {
                AsyncProcessManager.FinalizeProcess(ProcessorDetail.ID);
            }

            //SEGUNDO PASO
            //Comprobamos que en los parámetros de importación están definidos el campo Fecha e Indicador así como
            //evaluar los atributos definidos para la importación
            int?colFecha = null;
            int?colValor = null;
            List <importColumns>   jsonDimensions = (List <importColumns>)Newtonsoft.Json.JsonConvert.DeserializeObject <List <importColumns> >(ProcessorDetail.Info);
            List <DimensionPrompt> vDimensions    = new List <DimensionPrompt>();
            foreach (importColumns elem in jsonDimensions)
            {
                switch (elem.attrid)
                {
                case -3:
                    colValor = elem.column;
                    break;

                case -2:
                    colFecha = elem.column;
                    break;

                case -1:
                    break;

                default:
                    DimensionPrompt NuevaDimension = new DimensionPrompt();
                    NuevaDimension.tablecolumn = elem.column;
                    NuevaDimension.dimensionid = elem.attrid;
                    NuevaDimension.tablename   = elem.name;
                    NuevaDimension.importmode  = 0;
                    vDimensions.Add(NuevaDimension);
                    break;
                }
            }
            List <importAttributes> jsonAttributes = (List <importAttributes>)Newtonsoft.Json.JsonConvert.DeserializeObject <List <importAttributes> >(ProcessorDetail.Atributtes);
            foreach (importAttributes elem in jsonAttributes)
            {
                DimensionPrompt NuevaDimension = new DimensionPrompt();
                NuevaDimension.dimensionid = elem.id;
                NuevaDimension.valor       = elem.name;
                NuevaDimension.importmode  = 1;
                vDimensions.Add(NuevaDimension);
            }

            //Nos aseguramos que existe el campo Fecha y el campo valor
            if ((!colValor.HasValue) || (!colFecha.HasValue))
            {
                AsyncProcessManager.FinalizeProcess(ProcessorDetail.ID);
            }

            //TERCER PASO
            //Comprobamos que el fichero se subió correctamente y que por lo tanto existe en el disco
            //duro para leer
            string path = System.Web.Hosting.HostingEnvironment.MapPath("~/uploads/imports/" + usr.ProviderUserKey.ToString() + "/" + ProcessorDetail.FileName);
            if (!System.IO.File.Exists(path))
            {
                AsyncProcessManager.FinalizeProcess(ProcessorDetail.ID);
            }

            System.Data.DataSet TablaOriginal = new System.Data.DataSet();
            TablaOriginal.ReadXml(path);
            System.Data.DataTableReader dtrDatos = TablaOriginal.Tables[0].CreateDataReader();

            DateTime?dFechaActual = null;
            decimal? dValorActual = null;
            string   sSelectA, sSelectB, sComa, sNombre;

            while (dtrDatos.Read())
            {
                //Nueva fila a procesar
                total++;

                //Inicializamos la búsqueda
                sSelectA = string.Empty;
                sSelectB = string.Empty;
                sNombre  = string.Empty;
                sComa    = string.Empty;

                //Para cada dimension especificada buscamos aquellos datasets en las que coinciden todas sus dimensiones
                using (Clases.cKPI_DATASETS objDataset = new Clases.cKPI_DATASETS())
                {
                    foreach (DimensionPrompt DimensionActual in vDimensions)
                    {
                        if (DimensionActual.importmode == 0)
                        {
                            DimensionActual.valor = dtrDatos[DimensionActual.tablecolumn].ToString().Replace("'", "");
                            sNombre = sNombre + sComa + DimensionActual.tablename + " = " + dtrDatos[DimensionActual.tablecolumn].ToString().Replace("'", "");
                        }
                        else if (DimensionActual.importmode == 1)
                        {
                            sNombre = sNombre + sComa + DimensionActual.valor;
                        }
                        sSelectA = sSelectA + DimensionActual.DimensionSelect();
                        sSelectB = sSelectB + sComa + DimensionActual.dimensionid.ToString();
                        sComa    = ", ";
                    }

                    objDataset.indicatorid = ProcessorDetail.IndicatorId;
                    objDataset.userid      = Convert.ToInt32(usr.ProviderUserKey);
                    if (!objDataset.bExiste(sSelectA, sSelectB))
                    {
                        datasets++;
                        objDataset.indicatorid = ProcessorDetail.IndicatorId;
                        objDataset.userid      = Convert.ToInt32(usr.ProviderUserKey);
                        objDataset.nombre      = sNombre;
                        objDataset.dimension   = "L";
                        objDataset.importid    = ProcessorDetail.ID;
                        if (objDataset.bInsertar())
                        {
                            foreach (DimensionPrompt DimensionActual in vDimensions)
                            {
                                using (Clases.cKPI_DIMENSION_VALUES objDimensionValues = new Clases.cKPI_DIMENSION_VALUES())
                                {
                                    objDimensionValues.datasetid   = objDataset.datasetid;
                                    objDimensionValues.dimensionid = DimensionActual.dimensionid;
                                    objDimensionValues.codigo      = DimensionActual.valor;
                                    objDimensionValues.bInsertarFromImport();
                                }
                            }
                        }
                    }
                    using (Clases.cKPI_DATASET_VALUES objValor = new Clases.cKPI_DATASET_VALUES())
                    {
                        objValor.indicatorid = ProcessorDetail.IndicatorId;
                        objValor.datasetid   = objDataset.datasetid.Value;
                        objValor.userid      = Convert.ToInt32(usr.ProviderUserKey);
                        objValor.importid    = ProcessorDetail.ID;
                        dFechaActual         = ConvertirStringToFecha(dtrDatos[colFecha.Value].ToString());
                        dValorActual         = ConvertirStringToDecimal(dtrDatos[colValor.Value].ToString());
                        if ((dFechaActual.HasValue) && (dValorActual.HasValue))
                        {
                            switch (objDataset.dimension)
                            {
                            case "D":
                                objValor.fecha = dFechaActual;
                                objValor.valor = dValorActual;
                                if (objValor.bGuardarLibre(ProcessorDetail.Modo))
                                {
                                    processed++;
                                }
                                else
                                {
                                    errorCount++;
                                }
                                break;

                            case "s":
                                objValor.ejercicio = dFechaActual.Value.Year;
                                objValor.mes       = dFechaActual.Value.Month;
                                if (dFechaActual.Value.Day < 8)
                                {
                                    objValor.semana = 1;
                                }
                                else if (dFechaActual.Value.Day < 15)
                                {
                                    objValor.semana = 2;
                                }
                                else if (dFechaActual.Value.Day < 22)
                                {
                                    objValor.semana = 3;
                                }
                                else
                                {
                                    objValor.semana = 4;
                                }
                                objValor.valor = dValorActual;
                                if (objValor.bGuardarSemana(ProcessorDetail.Modo))
                                {
                                    processed++;
                                }
                                else
                                {
                                    errorCount++;
                                }
                                break;

                            case "Q":
                                objValor.ejercicio = dFechaActual.Value.Year;
                                objValor.mes       = dFechaActual.Value.Month;
                                objValor.quincena  = dFechaActual.Value.Day < 16 ? 1 : 2;
                                objValor.valor     = dValorActual;
                                if (objValor.bGuardarQuincena(ProcessorDetail.Modo))
                                {
                                    processed++;
                                }
                                else
                                {
                                    errorCount++;
                                }
                                break;

                            case "M":
                                objValor.ejercicio = dFechaActual.Value.Year;
                                objValor.mes       = dFechaActual.Value.Month;
                                objValor.valor     = dValorActual;
                                if (objValor.bGuardarMes(ProcessorDetail.Modo))
                                {
                                    processed++;
                                }
                                else
                                {
                                    errorCount++;
                                }
                                break;

                            case "T":
                                objValor.ejercicio = dFechaActual.Value.Year;
                                if (dFechaActual.Value.Month < 4)
                                {
                                    objValor.trimestre = 1;
                                }
                                else if (dFechaActual.Value.Month < 7)
                                {
                                    objValor.trimestre = 2;
                                }
                                else if (dFechaActual.Value.Month < 10)
                                {
                                    objValor.trimestre = 3;
                                }
                                else
                                {
                                    objValor.trimestre = 4;
                                }
                                objValor.valor = dValorActual;
                                if (objValor.bGuardarTrimestre(ProcessorDetail.Modo))
                                {
                                    processed++;
                                }
                                else
                                {
                                    errorCount++;
                                }
                                break;

                            case "S":
                                objValor.ejercicio = dFechaActual.Value.Year;
                                objValor.semestre  = dFechaActual.Value.Month < 7 ? 1 : 2;
                                objValor.valor     = dValorActual;
                                if (objValor.bGuardarSemestre(ProcessorDetail.Modo))
                                {
                                    processed++;
                                }
                                else
                                {
                                    errorCount++;
                                }
                                break;

                            case "A":
                                objValor.ejercicio = dFechaActual.Value.Year;
                                objValor.valor     = dValorActual;
                                if (objValor.bGuardarEjercicio(ProcessorDetail.Modo))
                                {
                                    processed++;
                                }
                                else
                                {
                                    errorCount++;
                                }
                                break;

                            case "L":
                                objValor.fecha = dFechaActual;
                                objValor.valor = dValorActual;
                                if (objValor.bGuardarLibre(ProcessorDetail.Modo))
                                {
                                    processed++;
                                }
                                else
                                {
                                    errorCount++;
                                }
                                break;
                            }
                        }
                        else
                        {
                            errorCount++;
                            if (!dFechaActual.HasValue)
                            {
                                InsertaDetalleError(total, dtrDatos[colFecha.Value].ToString(), "El valor especificado no es un campo de FECHA válido");
                            }
                            if (!dValorActual.HasValue)
                            {
                                InsertaDetalleError(total, dtrDatos[colValor.Value].ToString(), "El valor especificado no es un campo de NÚMERO válido");
                            }
                        }
                    }
                }
                // in loops, call the UpdateStatus method to determine if you should update the counts
                // on the current iteration. This will save processing time so your not updating the
                // counts on every iteration
                if (UpdateStatus(processed, total))
                {
                    // use the following method to update the counts on the AsyncProcessorDetail
                    // in the AsyncProcessManager. This should be included inside any worker loops
                    // you may have or between code blocks to update the user
                    AsyncProcessManager.GetProcessorDetail(ProcessorDetail.ID).UpdateCounts(processed, errorCount, 0, total);
                }
            }
            using (Clases.cKPI_IMPORTS objImport = new Clases.cKPI_IMPORTS())
            {
                objImport.importid       = ProcessorDetail.ID;
                objImport.num_datasets   = datasets;
                objImport.num_data_ok    = processed;
                objImport.num_data_error = errorCount;
                objImport.finalizado     = true;
                objImport.bModificar();
            }

            // check to see if the process has been cancelled by calling AsyncProcessManager.Continue
            // this method should be called within an UpdateStatus condition within any loops you have
            // and should be followed by a break;
            if (!AsyncProcessManager.Continue(ProcessorDetail.ID))
            {
                AsyncProcessManager.GetProcessorDetail(ProcessorDetail.ID).UpdateStatusText("Processing cancelled");
            }

            AsyncProcessManager.GetProcessorDetail(ProcessorDetail.ID).UpdateStatusText("Processing is complete");
        }
        catch (Exception ex)
        {
            string error = ex.Message + ex.StackTrace;
        }

        AsyncProcessManager.FinalizeProcess(ProcessorDetail.ID);
    }
            public void ExecuteReader(string command, Action<DbDataReader> action)
            {
                var table = new DataTable();
                var sqlSplit = new Regex(@"\W+").Split(command);

                if (sqlSplit.Contains("AppliedConcept"))
                {
                    // SELECT ID, InfoType, SerializedInfo, ConceptInfoKey, ImplementationType, ConceptImplementationVersion, CreateQuery, RemoveQuery, ModificationOrder
                    table.Columns.Add(new DataColumn("ID", typeof(Guid)));
                    table.Columns.Add();
                    table.Columns.Add();
                    table.Columns.Add();
                    table.Columns.Add();
                    table.Columns.Add();
                    table.Columns.Add(new DataColumn("ModificationOrder", typeof(Int32)));

                    foreach (var ca in Expected)
                        AddRow(table, ca);
                }
                else if (sqlSplit.Contains("AppliedConceptDependsOn"))
                {
                    //"SELECT DependentID, DependsOnID FROM Rhetos.AppliedConceptDependsOn"
                    table.Columns.Add(new DataColumn("DependentID", typeof(Guid)));
                    table.Columns.Add(new DataColumn("DependsOnID", typeof(Guid)));

                    foreach (var ca in Expected)
                        foreach (var dependsOn in ca.DependsOn)
                            table.Rows.Add(ca.Id, dependsOn.Id);
                }
                else
                    throw new NotImplementedException();

                var reader = new DataTableReader(table);
                while (reader.Read())
                    action(reader);
            }
Exemplo n.º 34
0
                public void DeletePreviousAndAcceptChangesTest ()
                {
                        DataTableReader reader = new DataTableReader (dt);
                        try {
                                reader.Read (); // first row
                                reader.Read (); // second row
                                dt.Rows [0].Delete ();
                                dt.AcceptChanges ();
                                Assert.AreEqual (2, (int) reader [0], "#1 should not affect the current position");
                        } finally {
                                if (reader != null && !reader.IsClosed)
                                        reader.Close ();
                        }

                }
Exemplo n.º 35
0
 public void AddAtPointTest ()
 {
         DataTableReader reader = new DataTableReader (dt);
         try {
                 reader.Read (); // first row
                 reader.Read (); // second row
                 DataRow r = dt.NewRow ();
                 r [0] = 0;
                 r [1] = "same point";
                 dt.Rows.InsertAt (r, 1);
                 dt.Rows.Add (new object [] { 4, "mono 4"}); // should not affect the counter
                 Assert.AreEqual (2, (int) reader [0], "#1 should not affect the current position");
         } finally {
                 if (reader != null && !reader.IsClosed)
                         reader.Close ();
         }
 }
Exemplo n.º 36
0
 public void DeleteLastAndAcceptChangesTest2 ()
 {
         DataTableReader reader = new DataTableReader (dt);
         try {
                 reader.Read (); // first row
                 reader.Read (); // second row
                 reader.Read (); // third row
                 dt.Rows [2].Delete (); // delete row, where reader points to
                 dt.AcceptChanges (); // accept the action
                 Assert.AreEqual (2, (int) reader [0], "#1 should point to the first row");
         } finally {
                 if (reader != null && !reader.IsClosed)
                         reader.Close ();
         }
 }
Exemplo n.º 37
0
 public void FillDebitBillComboBox()
 {
     comboDebitBillNumber.Properties.Items.Clear();
     DataTable table = this.zmaindataset.Tables["billRcv"];
     DataTableReader read = new DataTableReader(table);
     while (read.Read())
     {
         comboDebitBillNumber.Properties.Items.Add(read.GetInt32(2).ToString());
     }
 }
Exemplo n.º 38
0
                public void ClearTest ()
                {
                        DataTableReader reader = null;
                        try {
                                reader = new DataTableReader (dt);
                                reader.Read (); // first row
                                reader.Read (); // second row
                                dt.Clear ();
                                try {
                                        int i = (int) reader [0];
                                        i++; // supress warning
                                        Assert.Fail("#1 should have thrown RowNotInTableException");
                                } catch (RowNotInTableException) {}

                                // clear and add test
                                reader.Close ();
                                reader = new DataTableReader (dt);
                                reader.Read (); // first row
                                reader.Read (); // second row
                                dt.Clear ();
                                dt.Rows.Add (new object [] {8, "mono 8"});
                                dt.AcceptChanges ();
                                bool success = reader.Read ();
                                Assert.IsFalse (success, "#2 is always invalid");

                                // clear when reader is not read yet
                                reader.Close ();
                                reader = new DataTableReader (dt);
                                dt.Clear ();
                                dt.Rows.Add (new object [] {8, "mono 8"});
                                dt.AcceptChanges ();
                                success = reader.Read ();
                                Assert.IsTrue (success, "#3 should add");
                        } finally {
                                if (reader != null && !reader.IsClosed)
                                        reader.Close ();
                        }
                        
                }
Exemplo n.º 39
0
                public void RowInAccessibleTest ()
                {

                        DataTableReader reader = new DataTableReader (dt);
                        try {
                                reader.Read ();
                                reader.Read (); // 2nd row
                                dt.Rows [1].Delete ();
                                string value = reader [1].ToString ();
                        } finally {
                                if (reader != null && !reader.IsClosed)
                                        reader.Close ();
                        }
                }
Exemplo n.º 40
0
                public void MultipleDeleteTest ()
                {
                        dt.Rows.Add (new object [] {4, "mono 4"});
                        dt.Rows.Add (new object [] {5, "mono 5"});
                        dt.Rows.Add (new object [] {6, "mono 6"});
                        dt.Rows.Add (new object [] {7, "mono 7"});
                        dt.Rows.Add (new object [] {8, "mono 8"});
                        dt.AcceptChanges ();
                        
                        DataTableReader reader = new DataTableReader (dt);
                        try {
                                reader.Read (); // first row
                                reader.Read ();
                                reader.Read ();
                                reader.Read ();
                                reader.Read ();

                                dt.Rows [3].Delete ();
                                dt.Rows [1].Delete ();
                                dt.Rows [2].Delete ();
                                dt.Rows [0].Delete ();
                                dt.Rows [6].Delete ();
                                dt.AcceptChanges ();

                                Assert.AreEqual (5, (int) reader [0], "#1 should keep pointing to 5");
                        } finally {
                                if (reader != null && !reader.IsClosed)
                                        reader.Close ();
                        }
                }