public List <DepartmentViewModel> GetDepartment_Pagination(int Skip)
        {
            var result = new List <DepartmentViewModel>();
            var obj    = new DepartmentViewModel();

            using (NpgsqlConnection connection =
                       new NpgsqlConnection(ConfigureSetting.GetConnectionString))
            {
                connection.Open();

                string sql = "sp_departmentpagination";


                using (NpgsqlCommand command =
                           new NpgsqlCommand(sql, connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", NpgsqlTypes.NpgsqlDbType.Integer, Skip);

                    using (var reader = command.ExecuteReader())
                    {
                        result = DataReaderMap.DataReaderMapToList <DepartmentViewModel>(reader);
                    }
                }
                connection.Close();
            }

            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// the command should have the connections string set,  doesnt have to be open but
        /// the string should be set.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="command"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static List <T> ToList <T>(this d.SqlClient.SqlCommand command, T parameter = null)
            where T : class, new()
        {
            List <T> ret = new List <T>();

            try
            {
                if (command.IsConnectionOpen())
                {
                    setCommandParameters(parameter, command);
                    using (var reader = command.ExecuteReader())
                    {
                        var map = DataReaderMap.GetReaderMap(reader);
                        while (reader.Read())
                        {
                            T newObj = new T();
                            DataReaderMap.Set(reader, map, newObj);
                            ret.Add(newObj);
                        }
                    }
                    setOutputParameters(parameter, command);
                }
            }
            catch
            {
                throw;
            }
            finally { command.CloseConnection(); }
            return(ret);
        }
        public List <AssetOpnameTransactionViewModel> GetAssetLatestLocationByLocationID(int LocationID, DateTime Opnamedate)
        {
            List <AssetOpnameTransactionViewModel> result = new List <AssetOpnameTransactionViewModel>();

            using (NpgsqlConnection connection =
                       new NpgsqlConnection(ConfigureSetting.GetConnectionString))
            {
                connection.Open();

                string sql = "sp_assetlocationlatest";


                using (NpgsqlCommand command =
                           new NpgsqlCommand(sql, connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@locationid", NpgsqlTypes.NpgsqlDbType.Integer, LocationID);
                    command.Parameters.AddWithValue("@opnamedate", NpgsqlTypes.NpgsqlDbType.Timestamp, Opnamedate);

                    using (var reader = command.ExecuteReader())
                    {
                        result = DataReaderMap.DataReaderMapToList <AssetOpnameTransactionViewModel>(reader);
                    }
                }
                connection.Close();
            }
            return(result);
        }
Ejemplo n.º 4
0
        public List <HistoryViewModel> AssetHistory_SP(int AssetID, int Skip)
        {
            var result = new List <HistoryViewModel>();



            using (NpgsqlConnection connection =
                       new NpgsqlConnection(ConfigureSetting.GetConnectionString))
            {
                connection.Open();

                string sql = "sp_assethistory_pagination";


                using (NpgsqlCommand command =
                           new NpgsqlCommand(sql, connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@skip", NpgsqlTypes.NpgsqlDbType.Integer, Skip);
                    command.Parameters.AddWithValue("@assetid", NpgsqlTypes.NpgsqlDbType.Integer, AssetID);

                    using (var reader = command.ExecuteReader())
                    {
                        result = DataReaderMap.DataReaderMapToList <HistoryViewModel>(reader);
                    }
                }
                connection.Close();
            }

            return(result);
        }
Ejemplo n.º 5
0
 private static void executeReaderAndFillList <T>(d.SqlClient.SqlCommand command, List <T> ret) where T : class, IBattleAxe, new()
 {
     using (var reader = command.ExecuteReader())
     {
         var map = DataReaderMap.GetReaderMap(reader);
         while (reader.Read())
         {
             T newObj = new T();
             DataReaderMap.Set(reader, map, newObj);
             ret.Add(newObj);
         }
     }
 }
Ejemplo n.º 6
0
        public List <MismatchReportViewModel> LostAssetReport_SP(int categorycode, bool?ismovable, string owner)
        {
            var result = new List <MismatchReportViewModel>();

            using (NpgsqlConnection connection =
                       new NpgsqlConnection(ConfigureSetting.GetConnectionString))
            {
                connection.Open();

                string sql = "sp_lostassetreport";


                using (NpgsqlCommand command =
                           new NpgsqlCommand(sql, connection))
                {
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@categorycd", NpgsqlTypes.NpgsqlDbType.Integer, categorycode);
                    if (ismovable == null)
                    {
                        command.Parameters.AddWithValue("@ismovable", NpgsqlTypes.NpgsqlDbType.Boolean, DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@ismovable", NpgsqlTypes.NpgsqlDbType.Boolean, ismovable);
                    }

                    if (owner == null)
                    {
                        command.Parameters.AddWithValue("@owner", NpgsqlTypes.NpgsqlDbType.Varchar, DBNull.Value);
                    }
                    else
                    {
                        command.Parameters.AddWithValue("@owner", NpgsqlTypes.NpgsqlDbType.Varchar, owner);
                    }


                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            result = DataReaderMap.DataReaderMapToList <MismatchReportViewModel>(reader);
                        }
                    }
                }
                connection.Close();
            }



            return(result);
        }
Ejemplo n.º 7
0
    void Awake()
    {
        //Make sure this is in fact the only instance (Singleton pattern)
        if (instance == null)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        //Sets this to not be destroyed when reloading scene
        DontDestroyOnLoad(gameObject);

        DictReader dictReader = new DictReader(resourceLocation);

        m_data = new Dictionary <int, BuildingInfo> ();

        foreach (var row in dictReader)
        {
            //	Debug.Log (row ["ID"] + ", " +
            //	row ["IMAGE"] + ", " +
            //	row ["ARCHITECT"] + ", " +
            //	row ["BUILDING"] + ", " +
            //	row ["HEX"] + ", " +
            //	row ["RGB"] + ", " +
            //	row ["QUOTE"] + ", " +
            //	row ["BLOCK"]
            //	);

            BuildingInfo info = new BuildingInfo();
            info.m_image        = row ["IMAGE"];
            info.m_architect    = row ["ARCHITECT"];
            info.m_buildingName = row ["BUILDING"];
            Color c = new Color();
            ColorUtility.TryParseHtmlString("#" + row ["HEX"], out c);
            info.m_color = c;
            //Debug.Log (c.ToString ());
            info.m_quote  = row ["QUOTE"];
            info.m_block  = row ["BLOCK"];
            info.m_sprite = Resources.Load <Sprite> ("BuildingSprites/" + info.m_image);

            m_data.Add(Convert.ToInt32(row ["ID"]), info);
        }


        //Debug.Log (dictReader);
    }
Ejemplo n.º 8
0
        public void Sample()
        {
            var mapper = DataReaderMap <Employee> .CreateMap();

            var list = mapper.ProjectToEnumerable(GetSomeDataTable().CreateDataReader()).ToList();
        }
Ejemplo n.º 9
0
        public static IEnumerable <T> ProjectToEnumerable <T>(this IDataReader datareader) where T : new()
        {
            var mapper = DataReaderMap <T> .CreateMap();

            return(mapper.ProjectToEnumerable(datareader));
        }
Ejemplo n.º 10
0
 public static IEnumerable <T> ProjectToEnumerable <T>(this IDataReader datareader, DataReaderMap <T> mapper) where T : new()
 {
     return(mapper.ProjectToEnumerable(datareader));
 }