Beispiel #1
0
 public DataTable ConvertReaderToTable(DbDataReader reader)
 {
     DataReaderAdapter dra = new DataReaderAdapter();
     DataTable dt = new DataTable();
     dra.FillFromReader(dt, reader);
     return dt;
 }
Beispiel #2
0
        public DataTable ConvertReaderToTable(DbDataReader reader)
        {
            DataReaderAdapter dra = new DataReaderAdapter();
            DataTable         dt  = new DataTable();

            dra.FillFromReader(dt, reader);
            return(dt);
        }
Beispiel #3
0
        DataTable GetTrailersComingIn()
        {
            try
            {
                string connectionString = WebConfigurationManager.ConnectionStrings["Orchestrator"].ConnectionString;
                using (SqlConnection conTrailersCominIn = new SqlConnection(connectionString))
                {
                    conTrailersCominIn.Open();

                    SqlCommand cmdTrailersComingIn = new SqlCommand("spTrailer_GetLastPosition");

                    cmdTrailersComingIn.CommandType = CommandType.StoredProcedure;
                    cmdTrailersComingIn.Connection  = conTrailersCominIn;
                    cmdTrailersComingIn.Parameters.Add(new SqlParameter("@TrafficAreas", TrafficAreaIds));

                    SqlDataReader dr = cmdTrailersComingIn.ExecuteReader();

                    if (dr != null)
                    {
                        DataReaderAdapter dar = new DataReaderAdapter();
                        DataTable         dt  = new DataTable();
                        dar.FillFromReader(dt, dr);
                        if (dt != null && dt.Columns.Count > 0)
                        {
                            conTrailersCominIn.Close();

                            return(dt);
                        }
                    }
                }
            }
            catch (SqlException sqle)
            {
                if (Utilities.MapSqlException(sqle) && getTrailersComingInErrorCount < 5)
                {
                    getTrailersComingInErrorCount++;
                    return(GetTrailersComingIn());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(null);
        }
        /// <summary>
        ///     Converts <paramref name="dataReader" /> value to DataTable instance.
        /// </summary>
        public static DataTable ToDataTable(this IDataReader dataReader)
        {
            if (dataReader == null)
            {
                throw new ArgumentNullException("dataReader");
            }

            var outputTable = new DataTable
            {
                Locale = CultureInfo.InvariantCulture
            };
            var adapter = new DataReaderAdapter();

            adapter.FillFromReader(outputTable, dataReader);

            dataReader.Close();

            return(outputTable);
        }
Beispiel #5
0
        DataTable GetMyTrailers()
        {
            try
            {
                string connectionString = WebConfigurationManager.ConnectionStrings["Orchestrator"].ConnectionString;

                using (SqlConnection conMyResource = new SqlConnection(connectionString))
                {
                    conMyResource.Open();

                    SqlCommand cmdMyResource = new SqlCommand("spResource_GetDepotCodeResources");

                    cmdMyResource.Parameters.Add(new SqlParameter("@ControlAreaId", _filter.ControlAreaId));
                    cmdMyResource.Parameters.Add(new SqlParameter("@TrafficAreaIds", TrafficAreaIds));
                    cmdMyResource.Parameters.Add(new SqlParameter("@StartDate", _filter.FilterStartDate));
                    cmdMyResource.Parameters.Add(new SqlParameter("@EndDate", _filter.FilterEnddate));
                    cmdMyResource.Parameters.Add(new SqlParameter("@OnlyShowAvailable", false));
                    cmdMyResource.Parameters.Add(new SqlParameter("@ResourceTypeId", 2));
                    cmdMyResource.Parameters.Add(new SqlParameter("@HomeDepotId", _filter.DepotId));
                    cmdMyResource.Parameters.Add(new SqlParameter("@DriverRequestsHoursAhead", Orchestrator.Globals.Configuration.DriverRequestHoursAhead));
                    cmdMyResource.Parameters.Add(new SqlParameter("@OnlyShowIfNoFuture", _filter.OnlyShowEmptyTrailers));

                    cmdMyResource.CommandType = CommandType.StoredProcedure;
                    cmdMyResource.Connection  = conMyResource;

                    DataReaderAdapter dar = new DataReaderAdapter();
                    SqlDataReader     dr  = cmdMyResource.ExecuteReader();

                    if (dr != null)
                    {
                        DataTable dtMyTrailers = new DataTable();
                        dar.FillFromReader(dtMyTrailers, dr);

                        if (dtMyTrailers != null && dtMyTrailers.Columns.Count > 0)
                        {
                            using (SqlConnection conMyResourceFuture = new SqlConnection(connectionString))
                            {
                                conMyResourceFuture.Open();

                                SqlCommand cmdMyResourceFuture = new SqlCommand("spResource_GetAllResourceFutures");

                                cmdMyResourceFuture.CommandType = CommandType.StoredProcedure;
                                cmdMyResourceFuture.Parameters.Add(new SqlParameter("@ResourceTypeId", 2));
                                cmdMyResourceFuture.Connection = conMyResourceFuture;

                                _rdrMyResourceFuture = cmdMyResourceFuture.ExecuteReader();

                                if (_rdrMyResourceFuture != null)
                                {
                                    DataTable dtMyResourceFuture = new DataTable();
                                    dar.FillFromReader(dtMyResourceFuture, _rdrMyResourceFuture);
                                    if (dtMyResourceFuture != null)
                                    {
                                        DataView dv = null;
                                        dv = dtMyResourceFuture.DefaultView;


                                        DataView trailersWithFuture = dtMyTrailers.DefaultView;
                                        trailersWithFuture.RowFilter = "HasFuture = 1";
                                        PopulateTrailerFutures(trailersWithFuture, dv);
                                        dtMyTrailers.DefaultView.RowFilter = "";
                                        conMyResource.Close();

                                        return(dtMyTrailers);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (SqlException sqle)
            {
                if (Utilities.MapSqlException(sqle) && getMyTrailersErrorCount < 5)
                {
                    getMyTrailersErrorCount++;
                    return(GetMyTrailers());
                }
                else
                {
                    throw;
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(null);
        }
Beispiel #6
0
        void Traffic_TrafficSheet4_PreRenderComplete(object sender, EventArgs e)
        {
            DataReaderAdapter dar = new DataReaderAdapter();

            #region My Resource
            DataTable dtMyDrivers                 = new DataTable();
            DataTable dtMyTrailers                = new DataTable();
            DataTable dtMyVehicles                = new DataTable();
            DataTable dtMyResourceFuture          = new DataTable();
            CheckBox  chkShowDriversWithoutReload = ((CheckBox)RadPanelbar1.FindControl("chkShowDriversWithoutReloads"));

            try
            {
                if (_rdrMyResource != null)
                {
                    dar.FillFromReader(dtMyDrivers, _rdrMyResource);

                    if (_rdrMyResourceFuture != null)
                    {
                        dar.FillFromReader(dtMyResourceFuture, _rdrMyResourceFuture);
                        if (dtMyResourceFuture != null)
                        {
                            DataView dv = null;
                            dv = dtMyResourceFuture.DefaultView;


                            //Fill My Drivers Grid
                            if (dtMyDrivers != null && dtMyDrivers.Columns.Count > 0)
                            {
                                DataView driversWithFuture = dtMyDrivers.DefaultView;
                                //if (_filter.OnlyShowDriversWithoutReloads == false)
                                //{
                                // BUG: t.lunken this will restrict to only people who have got a future booking (Doh!)
                                //driversWithFuture.RowFilter = "HasFuture = 1";

                                PopulateDriverFutures(driversWithFuture, dv);
                                //}

                                ((ComponentArt.Web.UI.Grid)RadPanelbar1.Items[0].Items[0].FindControl("grdMyDrivers")).ItemContentCreated += new ComponentArt.Web.UI.Grid.ItemContentCreatedEventHandler(TSResource_ItemContentCreated);
                                ((ComponentArt.Web.UI.Grid)RadPanelbar1.Items[0].Items[0].FindControl("grdMyDrivers")).DataSource          = driversWithFuture;
                                ((ComponentArt.Web.UI.Grid)RadPanelbar1.Items[0].Items[0].FindControl("grdMyDrivers")).DataBind();
                            }
                        }
                    }
                }
            }
            finally
            {
                if (_rdrMyResource != null)
                {
                    _rdrMyResource.Dispose();
                }

                if (_rdrMyResourceFuture != null)
                {
                    _rdrMyResourceFuture.Dispose();
                }
            }

            #endregion
        }