Exemplo n.º 1
0
        private string ConstructUrlForInfoLibItemFile(int InfoLibItemId, InfoLibFileServerTypes type)
        {
            NameValueCollection nvColl = new NameValueCollection();

            nvColl.Add(QueryStringHelper.QueryStringParamNames.INFOLIB_ITEMID_INT.Description(), InfoLibItemId.ToString());
            nvColl.Add(QueryStringHelper.QueryStringParamNames.INFOLIB_REQ_FILE_IDEN_INT.Description(), type.EnumValue <int>().ToString());
            return(InfoLibUtil.ConstructInfoLibFileServerUrl(nvColl));
            //return string.Format(InfoLib_File_Server_Url + "?" + InfoLib_File_Server_Url_QS_Params_Fmt, InfoLibItemId, type.EnumValue<int>());
        }
Exemplo n.º 2
0
        public InfoLibItemFile GetInfoLibFile(int InfoLibItemId, InfoLibFileServerTypes type)
        {
            using (var command = database.GetStoredProcCommand(StoredProcNames.InfoLib.GetInfoLibItemFile.Description()))
            {
                InfoLibItemFile itemFile = null;

                database.AddInParameter(command, "@InfoLibItemId", DbType.Int32, InfoLibItemId);
                database.AddInParameter(command, "@FileTypeIdentifier", DbType.Int32, type.EnumValue <int>());

                using (IDataReader reader = database.ExecuteReader(command))
                {
                    if (reader.Read())
                    {
                        //Get file size
                        int?fileSizeinBytes = !reader.IsDBNull(2) ? reader.GetInt32(2) : (int?)null;

                        //Get file into the buffer
                        byte[] fileBuffer = null;
                        if (fileSizeinBytes.HasValue && fileSizeinBytes.Value > 0)
                        {
                            fileBuffer = new byte[fileSizeinBytes.Value];
                            int actualFileOrdinal = 3;
                            reader.GetBytes(actualFileOrdinal, 0, fileBuffer, 0, fileSizeinBytes.Value);
                        }
                        itemFile = new InfoLibItemFile()
                        {
                            ItemFileMimeType    = !reader.IsDBNull(0) ? reader.GetString(0) : string.Empty,
                            ItemFileExtension   = !reader.IsDBNull(1) ? reader.GetString(1) : string.Empty,
                            ItemFileSizeInBytes = fileSizeinBytes,
                            ItemFile            = fileBuffer,
                            ItemFileName        = !reader.IsDBNull(4) ? reader.GetString(4) : string.Empty,
                        };
                    }
                }

                return(itemFile);
            }
        }
Exemplo n.º 3
0
        public static InfoLibItemFile GetInfoLibFile(int InfoLibItemId, InfoLibFileServerTypes type)
        {
            InfoLibDAL dal = new InfoLibDAL();

            return(dal.GetInfoLibFile(InfoLibItemId, type));
        }