protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int idx = DataList1.SelectedIndex;

            Label lbl = (Label)DataList1.Items[idx].FindControl("Label2");

            System.Data.OracleClient.OracleConnection conn      = new System.Data.OracleClient.OracleConnection(ConfigurationManager.ConnectionStrings["CGConnectionString"].ToString());
            System.Data.OracleClient.OracleCommand    myCommand = new System.Data.OracleClient.OracleCommand("SELECT * FROM wf_cm_images WHERE ID = '" + lbl.Text + "'", conn);
            conn.Open();
            System.Data.OracleClient.OracleDataReader myReader = myCommand.ExecuteReader(System.Data.CommandBehavior.Default);
            try
            {
                while (myReader.Read())
                {
                    System.Data.OracleClient.OracleLob myLob = myReader.GetOracleLob(myReader.GetOrdinal("IMAGE"));
                    if (!myLob.IsNull)
                    {
                        string FN = myReader.GetString(myReader.GetOrdinal("IMAGE_NAME"));


                        //Use buffer to transfer data
                        byte[] b = new byte[myLob.Length];
                        //Read data from database
                        myLob.Read(b, 0, (int)myLob.Length);


                        Response.AddHeader("content-disposition", "attachment;filename=" + FN);
                        Response.ContentType = "application/octectstream";
                        Response.BinaryWrite(b);
                        Response.End();
                    }
                }
            }
            finally
            {
                myReader.Close();
                conn.Close();
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                lblidddl.Visible = false;
                txtCorreo.Text   = Session["Value"].ToString();


                Array enumList1 = Enum.GetValues(typeof(tiposTarea));
                foreach (tiposTarea getTipoTarea in enumList1)
                {
                    ddlTipoTarea.Items.Add(new ListItem(getTipoTarea.ToString(), ((int)getTipoTarea).ToString()));
                }

                try
                {
                    ora2.Open();
                    System.Data.OracleClient.OracleCommand comando3 = new System.Data.OracleClient.OracleCommand("listar_tareas_devueltas");
                    comando3.Connection  = ora2;
                    comando3.CommandType = System.Data.CommandType.StoredProcedure;

                    comando3.Parameters.Add("p_recordset", OracleType.Cursor).Direction = ParameterDirection.Output;
                    System.Data.OracleClient.OracleDataAdapter adaptador = new System.Data.OracleClient.OracleDataAdapter();

                    adaptador.SelectCommand = comando3;
                    DataTable dt = new DataTable();
                    adaptador.Fill(dt);

                    tablasTareasDevueltas.DataSource = dt;
                    tablasTareasDevueltas.DataBind();

                    if (tablasTareasDevueltas.Rows.Count == 0)
                    {
                        // Response.Write("<script>('No hay tareas pendientes')</script>");
                    }
                    ora2.Close();
                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Ha ocurrido un error actualizando');</script>");
                }

                try
                {
                    ora2.Open();
                    System.Data.OracleClient.OracleCommand comando = new System.Data.OracleClient.OracleCommand("listar_flujo_aprobado");
                    comando.Connection  = ora2;
                    comando.CommandType = System.Data.CommandType.StoredProcedure;
                    comando.Parameters.Add("p_recordset", OracleType.Cursor).Direction = ParameterDirection.Output;
                    System.Data.OracleClient.OracleDataAdapter adaptador = new System.Data.OracleClient.OracleDataAdapter();

                    System.Data.OracleClient.OracleDataReader rdr = comando.ExecuteReader();

                    while (rdr.Read())
                    {
                        ddlFlujo.Items.Add(rdr.GetString(0).ToString());
                    }
                    ora2.Close();
                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Ha ocurrido un error' " + ex.ToString() + "');</script>");
                }
            }
        }
示例#3
0
 public override string GetString(int ordinal)
 {
     return(rdr.GetString(ordinal));
 }
        /// <summary>
        /// Create a MembershipUser object from a data reader.
        /// </summary>
        /// <param name="sqlDataReader">Data reader.</param>
        /// <returns>MembershipUser object.</returns>
        private MembershipUser GetUserFromReader(
      OracleDataReader oracleDataReader
        )
        {
            object idPersonne = oracleDataReader.GetValue(0);
            string courriel = oracleDataReader.GetString(1);
            string motDePasse = oracleDataReader.GetString(2);
            string username = String.Empty;

            string passwordQuestion = String.Empty;
            if (oracleDataReader.GetValue(3) != DBNull.Value)
            {
                passwordQuestion = oracleDataReader.GetString(3);
            }

            string comment = String.Empty;
            if (oracleDataReader.GetValue(4) != DBNull.Value)
            {
                comment = oracleDataReader.GetString(4);
            }

            bool isApproved = true;
            if (oracleDataReader.GetBoolean(5) != null)
            {
                isApproved = oracleDataReader.GetBoolean(5);
            }
            bool isLockedOut = oracleDataReader.GetBoolean(6);
            if (oracleDataReader.GetBoolean(6) != null)
            {
                isLockedOut = oracleDataReader.GetBoolean(6);
            }
            DateTime creationDate = new DateTime();
            if (oracleDataReader.GetValue(7) != DBNull.Value)
            {
                creationDate = oracleDataReader.GetDateTime(7);
            }

            DateTime lastLoginDate = new DateTime();
            if (oracleDataReader.GetValue(8) != DBNull.Value)
            {
                lastLoginDate = oracleDataReader.GetDateTime(8);
            }

            DateTime lastActivityDate = new DateTime();
            if (oracleDataReader.GetValue(9) != DBNull.Value)
            {
                lastActivityDate = oracleDataReader.GetDateTime(9);
            }
            DateTime lastPasswordChangedDate = new DateTime();
            if (oracleDataReader.GetValue(10) != DBNull.Value)
            {
                lastPasswordChangedDate = oracleDataReader.GetDateTime(10);
            }

            DateTime lastLockedOutDate = new DateTime();
            if (oracleDataReader.GetValue(11) != DBNull.Value)
            {
                lastLockedOutDate = oracleDataReader.GetDateTime(11);
            }

            MembershipUser membershipUser = new MembershipUser(
              this.Name,
             username,
             idPersonne,
             courriel,
             passwordQuestion,
             comment,
             isApproved,
             isLockedOut,
             creationDate,
             lastLoginDate,
             lastActivityDate,
             lastPasswordChangedDate,
             lastLockedOutDate
              );

            return membershipUser;
        }
示例#5
0
        public CWarehouseTask GetTask2(int channel)
        {
            if (channel == 4) channel = 0;
            bool sucess = false;
            CWarehouseTask newTask = null;
            if (Connection.State != ConnectionState.Open) { return null; }
            try
            {
                using (OracleCommand cmd = new OracleCommand())
                {
                    cmd.Connection = Connection;
                    //MessageBox.Show(GetTaskSQLCommand2);
                    cmd.CommandText = string.Format(GetTaskSQLCommand2, channel);
                    cmd.CommandType = CommandType.Text;
                    using (dataReader = cmd.ExecuteReader())
                    {
                        if (dataReader.Read())
                        {//如果有任务
                            OprationState = "正在读取任务";
                            #region 读取
                            //#region task_id,task_type,status,from_addr,to_addr,create_time,product_id,pack_unit,pack_num,pallet_id
                            CWarehouseTask tmpTask = new CWarehouseTask();
                            tmpTask.TaskID = dataReader.GetInt32(0);
                            tmpTask.TaskType = (CWarehouseTask.ETaskType)int.Parse(dataReader.GetString(1));
                            tmpTask.State = int.Parse(dataReader.GetString(2));
                            
                            //调整地址格式
                            string tmp = dataReader.GetString(3);
                            tmp = tmp.Replace("LF00", "WH01");
                            tmpTask.SourceAddress = tmp;
                            tmp = dataReader.GetString(4);
                            tmp = tmp.Replace("LF00", "WH01");
                            tmp = tmp.Replace("CR0115", "CR0105");
                            tmpTask.DestinationAddress = tmp;
                            
                            //调整空托盘直出任务类型
                            if ((tmpTask.TaskType == CWarehouseTask.ETaskType.空托盘返库) && (tmpTask.DestinationAddress == "CR0105"))
                            { tmpTask.TaskType = CWarehouseTask.ETaskType.空托盘直出; }

                            tmpTask.CreateTime = dataReader.GetDateTime(5);
                            tmpTask.ProductID = dataReader.GetString(6);
                            tmpTask.PackingUnit = dataReader.GetString(7);
                            tmpTask.PackingNumber = dataReader.GetInt32(8);
                            tmpTask.PalletID = dataReader.GetString(9);
                            tmpTask.ProductName = dataReader.GetString(10);
                            if (dataReader[11] != null)
                            {
                                int ch = dataReader.GetInt32(11);
                                tmpTask.ChannelID = (ch == 0) ? (4) : (ch);
                            }
                            else
                            { tmpTask.ChannelID = 4; }
                            tmpTask.Priority = dataReader.GetInt32(12);
                            //tmpTask.RunningState = CWarehouseTask.EState.创建;
                            #endregion
                            #region 创建
                            try
                            {
                                newTask = new CWarehouseTask(tmpTask.TaskID,
                                                            tmpTask.Req_ID,
                                                            (int)tmpTask.TaskType,
                                                            tmpTask.State,
                                                            tmpTask.SourceAddress,
                                                            tmpTask.DestinationAddress,
                                                            tmpTask.CreateTime,
                                                            tmpTask.ProductID,
                                                            tmpTask.PackingUnit,
                                                            tmpTask.PackingNumber,
                                                            tmpTask.Num,
                                                            tmpTask.Priority,
                                                            tmpTask.PalletID,
                                                            tmpTask.ProductName,
                                                            tmpTask.ChannelID);
                                sucess = true;
                            }
                            catch (Exception ex1)
                            {
                                sucess = false;
                                Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.Programer, new Exception("生成任务实例出现异常,此异常并不会影响程序执行结果。", ex1)));
                            }
                            #endregion
                        }
                        else
                        {//无任务
                            sucess = false;
                        }
                    }

                }
            }
            catch (Exception ex) // catches any other error
            {
                sucess = false;
                OprationState = "读取任务过程中出现数据库相关的操作错误";
                Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.Programer, ex));

            }
            //如果无错误,返回newTask,否则返回null
            return ((sucess) && newTask != null) ? (newTask) : (null);

        }
		public void run()
		{
			Exception exp = null;
		
			OracleCommand cmd = new OracleCommand();
			try
			{
				BeginCase("CommandType - default");
				Assert.AreEqual(cmd.CommandType , CommandType.Text );
			} 
			catch(Exception ex){exp = ex;}
			finally{EndCase(exp); exp = null;}
#if NotWorking
			try
			{
				BeginCase("CommandType - TableDirect");
				cmd.CommandType = CommandType.TableDirect; 
				Assert.AreEqual(cmd.CommandType , CommandType.TableDirect);
			} 
			catch(Exception ex){exp = ex;}
			finally{EndCase(exp); exp = null;}
#endif

			try
			{
				BeginCase("CommandType - Text");
				cmd.CommandType = CommandType.Text  ; 
				Assert.AreEqual(cmd.CommandType , CommandType.Text);
			} 
			catch(Exception ex){exp = ex;}
			finally{EndCase(exp); exp = null;}


			#region		---- CommandType.Text using Parameters.Add ---- 
			try
			{
				BeginCase("CommandType.Text using Parameters.Add");

				cmd = new OracleCommand();
				cmd.Connection = con;
				cmd.Transaction = tr;
				cmd.CommandType = CommandType.Text;
				cmd.CommandText = "call GH_REFCURSOR3(:IN_LASTNAME, :RCT_Employees)";

				OracleParameter param1 = cmd.Parameters.Add("IN_LASTNAME", OracleType.VarChar,20);
				param1.Direction = ParameterDirection.Input;
				param1.Value = "Yavine"; 
				cmd.Parameters.Add("RCT_Employees", OracleType.Cursor).Direction = ParameterDirection.Output;
#if DAAB
#if !JAVA
				if ((dbServerType == DataBaseServer.PostgreSQL))
				{
					dr = PostgresOracleHelper.OLEDB4ODBCExecuteReader(cmd,true);
				}
				else
#endif
#endif
				{
					dr = cmd.ExecuteReader();
				}

				if (dr.HasRows)
				{
					dr.Read();
					Assert.AreEqual(dr.GetValue(0).ToString(),"1");
					Assert.AreEqual(dr.GetString(1),"Yavine");
				}
				else
					Assert.AreEqual("error","HasRows=0");

			} 
			catch(Exception ex)
			{
				exp = ex;
			}
			finally
			{
				if (dr != null)dr.Close();
				if (con != null)
				{if (con.State == ConnectionState.Open) con.Close();}

				EndCase(exp);
				exp = null;
			}
			#endregion

			CommandTypeSP_Manual_InOutParameters();

			#region		---- ORACLE CommandType.StoredProcedure using DeriveParameters ---- 
			if (ConnectedDataProvider.GetDbType(con) == MonoTests.System.Data.Utils.DataBaseServer.Oracle)
			{
				try
				{
					BeginCase("ORACLE CommandType.StoredProcedure using DeriveParameters");

					con.Open();
					cmd = new OracleCommand();
					cmd.Connection = con;
					cmd.Transaction = tr;
					cmd.CommandType = CommandType.StoredProcedure;
					cmd.CommandText = "GH_REFCURSOR3";

					OracleCommandBuilder.DeriveParameters(cmd);
					cmd.Parameters[0].Value = "Yavine"; 
					//cmd.Parameters.RemoveAt(1); // the ORACLE DAAB trick is to remove the out parameter

					dr = cmd.ExecuteReader();
					if (dr.HasRows)
					{
						dr.Read();
						Assert.AreEqual(dr.GetValue(0).ToString(),"1");
						Assert.AreEqual(dr.GetString(1),"Yavine");
					}
					else
						Assert.AreEqual("error","HasRows=0");

				} 
				catch(Exception ex)
				{
					exp = ex;
				}
				finally
				{
					if (dr != null)dr.Close();
					if (con != null)
					{if (con.State == ConnectionState.Open) con.Close();}

					EndCase(exp);
					exp = null;
				}
			}		
			#endregion

			#region CommandType.StoredProcedure in order to repreduce bug 4003
			if (ConnectedDataProvider.GetDbType(con) == MonoTests.System.Data.Utils.DataBaseServer.SQLServer)
			{
				exp = null;
				try
				{
					if (con.State == ConnectionState.Closed) con.Open();
					BeginCase("Bug 4003");
					OracleCommand cmd4003 = new OracleCommand("[mainsoft].[GH_DUMMY]",con);
					cmd4003.CommandType = CommandType.StoredProcedure;
					cmd4003.Parameters.Add("@EmployeeIDPrm","1");
					cmd4003.ExecuteReader();
					
				}
				catch (Exception ex)
				{
					exp=ex;
				}
				finally
				{
					if (con.State == ConnectionState.Open) con.Close();
					EndCase(exp);
				}

			}

			#endregion
		}
        protected override void GatherKeyColumns(
            DBSqlParserTable table
            )
        {
            //  Called after the table and column information is completed to
            //  identify which columns in the select-list are key columns for
            //  their table.

            OracleCommand    cmd = null;
            OracleDataReader rdr = null;

            try {
                try {
                    cmd = _connection.CreateCommand();

                    cmd.Transaction = _connection.Transaction; // must set the transaction context to be the same as the command, or we'll throw when we execute.

                    string schemaName = CatalogCase(table.SchemaName);
                    string tableName  = CatalogCase(table.TableName);

                    string synonymSchemaName = schemaName;
                    string synonymTableName  = tableName;

                    // First, we have to "dereference" a synonym, if it was specified, because
                    // synonyms don't have catalog items stored for them, they're for the table
                    // or view that the synonym references.

                    cmd.CommandText = GetSynonymQueryStatement(schemaName, tableName);
                    rdr             = cmd.ExecuteReader();

                    if (rdr.Read())
                    {
                        synonymSchemaName = rdr.GetString(0);
                        synonymTableName  = rdr.GetString(1);
                    }

                    rdr.Dispose();

                    // Now we have the real schema name and table name, go and derive the key
                    // columns

                    cmd.CommandText = GetConstraintQueryStatement(synonymSchemaName, synonymTableName);
                    rdr             = cmd.ExecuteReader();

                    ArrayList constraintColumnNames = new ArrayList();
                    bool      isUniqueConstraint;

                    if (true == (_moreConstraints = rdr.Read()))
                    {
                        while (GetConstraint(rdr, out isUniqueConstraint, constraintColumnNames))
                        {
                            bool foundAllColumns       = true;
                            int  constraintColumnCount = constraintColumnNames.Count;

                            DBSqlParserColumn[] constraintColumn = new DBSqlParserColumn[constraintColumnCount];

                            for (int j = 0; j < constraintColumnCount; ++j)
                            {
                                DBSqlParserColumn column = FindConstraintColumn(
                                    schemaName,
                                    tableName,
                                    (string)constraintColumnNames[j]
                                    );

                                if (null == column)
                                {
                                    foundAllColumns = false;
                                    break;
                                }

                                constraintColumn[j] = column;
                            }

                            if (foundAllColumns)
                            {
                                for (int j = 0; j < constraintColumnCount; ++j)
                                {
                                    constraintColumn[j].SetAsKey(isUniqueConstraint);
                                }

                                break;
                            }
                        }
                    }
                }
                finally
                {
                    if (null != cmd)
                    {
                        cmd.Dispose();
                        cmd = null;
                    }

                    if (null != rdr)
                    {
                        rdr.Dispose();
                        rdr = null;
                    }
                }
            }
            catch { // Prevent exception filters from running in our space
                throw;
            }
        }
 // Check for reader for null
 private static string GetNullableString(OracleDataReader reader, int col)
 {
     if(reader.IsDBNull(col) == false)
         return reader.GetString(col);
     return null;
 }
 protected override void GatherKeyColumns(DbSqlParserTable table)
 {
     using (OracleCommand command = this._connection.CreateCommand())
     {
         command.Transaction = this._connection.Transaction;
         string schemaName = CatalogCase(table.SchemaName);
         string tableName  = CatalogCase(table.TableName);
         string str        = schemaName;
         string str4       = tableName;
         command.CommandText = this.GetSynonymQueryStatement(schemaName, tableName);
         using (OracleDataReader reader2 = command.ExecuteReader())
         {
             if (reader2.Read())
             {
                 str  = reader2.GetString(0);
                 str4 = reader2.GetString(1);
             }
         }
         StringBuilder builder2 = new StringBuilder(ConstraintQuery1a);
         StringBuilder builder  = new StringBuilder(ConstraintQuery2a);
         if (System.Data.Common.ADP.IsEmpty(str))
         {
             builder2.Append(ConstraintQuery1b_ownerDefault);
             builder.Append(ConstraintQuery2b_ownerDefault);
         }
         else
         {
             command.Parameters.Add(new OracleParameter(ConstraintOwnerParameterName, DbType.String)).Value = str;
             builder2.Append(ConstraintQuery1b_ownerIsKnown);
             builder.Append(ConstraintQuery2b_ownerIsKnown);
         }
         command.Parameters.Add(new OracleParameter(ConstraintTableParameterName, DbType.String)).Value = str4;
         builder2.Append(ConstraintQuery1c);
         builder.Append(ConstraintQuery2c);
         string[] strArray3 = new string[] { builder2.ToString(), builder.ToString() };
         foreach (string str6 in strArray3)
         {
             command.CommandText = str6;
             using (OracleDataReader reader = command.ExecuteReader())
             {
                 ArrayList list  = new ArrayList();
                 bool      flag2 = reader.Read();
                 bool      flag  = false;
                 while (flag2)
                 {
                     ConstraintColumn column;
                     list.Clear();
                     string str5 = reader.GetString(0);
                     do
                     {
                         column = new ConstraintColumn {
                             columnName     = reader.GetString(1),
                             constraintType = (DbSqlParserColumn.ConstraintType)((int)reader.GetDecimal(2)),
                             parsedColumn   = null
                         };
                         list.Add(column);
                         flag2 = reader.Read();
                     }while (flag2 && (str5 == reader.GetString(0)));
                     flag = true;
                     for (int i = 0; i < list.Count; i++)
                     {
                         column = (ConstraintColumn)list[i];
                         column.parsedColumn = this.FindConstraintColumn(schemaName, tableName, column.columnName);
                         if (column.parsedColumn == null)
                         {
                             flag = false;
                             break;
                         }
                     }
                     if (flag)
                     {
                         for (int j = 0; j < list.Count; j++)
                         {
                             column = (ConstraintColumn)list[j];
                             column.parsedColumn.SetConstraint(column.constraintType);
                         }
                         break;
                     }
                 }
                 if (flag)
                 {
                     return;
                 }
             }
         }
     }
 }