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);
        }
Esempio n. 2
0
        public static void MultiSelection_FileUploadComplete(object sender, FileUploadCompleteEventArgs args)
        {
            try
            {
                _uploadError = "";
                var rowID = _rowID;

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

                string partVendorQuoteNumber = "PVQ_" + rowID.ToString();
                string attachmentCategory    = "VendorQuote";

                // Save uploaded file to the file server
                using (var context = new MONITOREntities4())
                {
                    context.usp_PVQ_FileManagement_Save(partVendorQuoteNumber, attachmentCategory, args.UploadedFile.FileName, args.UploadedFile.FileBytes, tranDT, result);
                }
            }
            catch (EntityCommandExecutionException e)
            {
                _uploadError = "SQL Error:  " + e.Message + " " + e.InnerException?.Message;
                //throw new Exception("SQL Error:  " + e.Message + " " + e.InnerException?.Message);
            }
            catch (Exception e)
            {
                _uploadError = "SQL Error:  " + e.Message + " " + e.InnerException?.Message;
                //throw new Exception("NON-SQL Error:" + e.Message + e.InnerException?.Message);
            }
        }