Ejemplo n.º 1
0
        private FileDTO FillDTO2(SqlDataReader reader)
        {
            var dto = new FileDTO();

            dto.ID             = reader.GetInt32(0);
            dto.FileUniqueName = reader.GetString(1);

            return(dto);
        }
Ejemplo n.º 2
0
        private FileDTO FillDTO1(SqlDataReader reader)
        {
            var dto = new FileDTO();

            dto.ID             = reader.GetInt32(0);
            dto.FileUniqueName = reader.GetString(1);
            dto.ParentFolderid = reader.GetInt32(2);
            dto.FileExt        = reader.GetString(3);
            dto.Size           = reader.GetInt32(4);
            dto.CreatedBy      = reader.GetInt32(5);
            dto.UploadedOn     = reader.GetDateTime(6);

            return(dto);
        }
Ejemplo n.º 3
0
        /* public  FileDTO GetFileByUniqueID(string uniqueName)
         * {
         *
         *
         * }*/
        public int SaveFile(FileDTO dto)
        {
            int    uid        = 0;
            string connString = @"Data Source=AZAZ-PC\SQLEXPRESS2012 ;Initial Catalog=Assignment8 ; User Id=sa;Password=1234";

            using (SqlConnection conn = new SqlConnection(connString))
            {
                conn.Open();
                String sqlQuery = "";
                {
                    sqlQuery = String.Format("INSERT INTO dbo.Files(Name,parentFolderId,FileExt,FileSizeInKB,CreatedBy,UploadedOn,IsActive,ContentTpye,Actualname) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}');",
                                             dto.FileUniqueName, dto.ParentFolderid, dto.FileExt, dto.Size, dto.CreatedBy, dto.UploadedOn, dto.IsActive, dto.ContentTpye, dto.fileActualName);
                }
                SqlCommand    command = new SqlCommand(sqlQuery, conn);
                SqlDataReader reader  = command.ExecuteReader();
                if (reader.Read())
                {
                    uid = reader.GetInt32(reader.GetOrdinal("ID"));
                }
            }

            return(uid);
        }
Ejemplo n.º 4
0
        public FileDTO GetFileByUniqueID(string UniqueName)
        {
            FileDTO dto        = new FileDTO();
            string  connString = @"Data Source=AZAZ-PC\SQLEXPRESS2012 ;Initial Catalog=Assignment8 ; User Id=sa;Password=1234";

            using (SqlConnection conn = new SqlConnection(connString))
            {
                conn.Open();
                var query = String.Format("Select f.ID ,f.Name,f.parentFolderId,f.FileExt,f.FileSizeInKB ,f.CreatedBy,f.UploadedOn,f.ContentTpye  from Users u , Files f where u.UserID = f.CreatedBy and  f.Name = '{0}';", UniqueName);

                SqlCommand    command = new SqlCommand(query, conn);
                SqlDataReader reader  = command.ExecuteReader();
                if (reader.Read())
                {
                    dto.ID             = reader.GetInt32(reader.GetOrdinal("ID"));
                    dto.FileExt        = reader.GetString(reader.GetOrdinal("FileExt"));
                    dto.Size           = reader.GetInt32(reader.GetOrdinal("FileSizeInKB"));
                    dto.FileUniqueName = reader.GetString(reader.GetOrdinal("Name"));
                    dto.ContentTpye    = reader.GetString(reader.GetOrdinal("ContentTpye"));
                }
            }

            return(dto);
        }