|
Hola amigos tengo ya en una dll lo que quiero
correr desde un stored procedureutilizando la integracion clr. ya cree el
assemblie tambien. ¿como hago para crear el stored procedure?. el problema esta
en que hay que pasarle un parametro pero no se es que parte del stored procedure
se lo paso al assemblie. ejemplo:
el assemblie se llama compactar y tiene la funcion
GZipcompress y tengo que pasarle el string para compactar, pero no se donde y
como se lo pongo. gracias nos leemos
CREATE PROCEDURE compacta
@filename nvarchar(4000) AS EXTERNAL NAME compactar.compactar.GZipCompress
esta es la clase que hice se que no esta bien por completo, pero solo estoy probando despues la depuro mejor: namespace compactar{ class compactar{ public bool GZipCompress(string filename){ FileStream infile; bool bien = false; try{ // Open the file as a FileStream object.infile = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); byte[] buffer = new byte[infile.Length]; // Read the file to ensure it is readable. int count = infile.Read(buffer, 0, buffer.Length); if (count != buffer.Length){ infile.Close(); throw new ApplicationException("Unable to read data from file"); return bien = false;} infile.Close(); FileStream ms = new FileStream(filename + ".gz", FileMode.CreateNew); // Use the newly created memory stream for the compressed data. GZipStream compressedzipStream = new GZipStream(ms, CompressionMode.Compress, true);compressedzipStream.Write(buffer, 0, buffer.Length); // Close the stream.compressedzipStream.Close(); ms.Close(); ms.Dispose(); File.Delete(filename); return bien = true;} // end try catch (InvalidDataException){ //Console.WriteLine("Error: The file being read contains invalid data."); return bien = false;} catch (FileNotFoundException){ //Console.WriteLine("Error:The file specified was not found."); return bien = false;} catch (ArgumentException){ //Console.WriteLine("Error: path is a zero-length string, contains only white space, or contains one or more invalid characters"); return bien = false;} catch (PathTooLongException){ //Console.WriteLine("Error: The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters."); return bien = false;} catch (DirectoryNotFoundException){ //Console.WriteLine("Error: The specified path is invalid, such as being on an unmapped drive."); return bien = false;} catch (IOException){ //Console.WriteLine("Error: An I/O error occurred while opening the file."); return bien = false;} catch (UnauthorizedAccessException){ //Console.WriteLine("Error: path specified a file that is read-only, the path is a directory, or caller does not have the required permissions."); return bien = false;} catch (IndexOutOfRangeException){ //Console.WriteLine("Error: You must provide parameters for MyGZIP."); return bien = false;} } } } |
