Esempio n. 1
0
        public string GetFile(int rowID, out string fileName, out byte[] fileContents)
        {
            string error = "";
            string partVendorQuoteNumber = "PVQ_" + rowID.ToString();
            string attachmentCategory    = "VendorQuote";

            fileName     = "";
            fileContents = null;

            ObjectParameter tranDT = new ObjectParameter("TranDT", typeof(DateTime?));
            ObjectParameter result = new ObjectParameter("Result", typeof(Int32?));

            try
            {
                using (var context = new MONITOREntities4())
                {
                    var collection = context.usp_PVQ_FileManagement_Get(partVendorQuoteNumber, attachmentCategory, tranDT, result);
                    var item       = collection.ToList().First();
                    fileName     = item.FileName;
                    fileContents = item.FileContents;
                }
            }
            catch (EntityCommandExecutionException e)
            {
                error = (e.InnerException != null) ? e.InnerException.Message : e.Message;
            }
            catch (Exception e)
            {
                error = (e.InnerException != null) ? e.InnerException.Message : e.Message;
            }
            return(error);
        }