Пример #1
0
        /// <summary>
        /// Creates a new Correspondence record using async
        /// </summary>
        public static async Task<int> CreateAsync(CorrespondenceDO DO)
        {
            SqlParameter _CorrespondenceType = new SqlParameter("CorrespondenceType", SqlDbType.VarChar);
            SqlParameter _PermitKey = new SqlParameter("PermitKey", SqlDbType.Int);
            SqlParameter _UserToken = new SqlParameter("UserToken", SqlDbType.VarChar);
            SqlParameter _Name = new SqlParameter("Name", SqlDbType.VarChar);
            SqlParameter _FileSize = new SqlParameter("FileSize", SqlDbType.Int);
            SqlParameter _FileName = new SqlParameter("FileName", SqlDbType.VarChar);
            SqlParameter _MimeType = new SqlParameter("MimeType", SqlDbType.VarChar);
            SqlParameter _DateUploaded = new SqlParameter("DateUploaded", SqlDbType.DateTime);
            SqlParameter _Guid = new SqlParameter("Guid", SqlDbType.UniqueIdentifier);
            SqlParameter _Approved = new SqlParameter("Approved", SqlDbType.Bit);
            SqlParameter _ApprovedBy = new SqlParameter("ApprovedBy", SqlDbType.VarChar);
            SqlParameter _ApprovedDate = new SqlParameter("ApprovedDate", SqlDbType.DateTime);
            
            _CorrespondenceType.Value = DO.CorrespondenceType;
            _PermitKey.Value = DO.PermitKey;
            _UserToken.Value = DO.UserToken;
            _Name.Value = DO.Name;
            _FileSize.Value = DO.FileSize;
            _FileName.Value = DO.FileName;
            _MimeType.Value = DO.MimeType;
            _DateUploaded.Value = DO.DateUploaded;
            _Guid.Value = DO.Guid;
            _Approved.Value = DO.Approved;
            _ApprovedBy.Value = DO.ApprovedBy;
            _ApprovedDate.Value = DO.ApprovedDate;
            
            SqlParameter[] _params = new SqlParameter[] {
                _CorrespondenceType,
                _PermitKey,
                _UserToken,
                _Name,
                _FileSize,
                _FileName,
                _MimeType,
                _DateUploaded,
                _Guid,
                _Approved,
                _ApprovedBy,
                _ApprovedDate
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            return await DataCommon.ExecuteScalarAsync("[dbo].[Correspondence_Insert]", _params, pid);
            
        }
Пример #2
0
        /// <summary>
        /// Selects Correspondence records by PK
        /// </summary>
        public static async Task<CorrespondenceDO[]> GetByPKAsync(Int32 CorrespondenceId)
        {

            SqlParameter _CorrespondenceId = new SqlParameter("CorrespondenceId", SqlDbType.Int);
			
            _CorrespondenceId.Value = CorrespondenceId;
			
            SqlParameter[] _params = new SqlParameter[] {
                _CorrespondenceId
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = await DataCommon.ExecuteSafeReaderAsync("[dbo].[Correspondence_GetByPK]", _params, pid);


            List<CorrespondenceDO> objs = new List<CorrespondenceDO>();
			
            while(sr.Read())
            {
                CorrespondenceDO obj = new CorrespondenceDO();
				
                obj.CorrespondenceId = sr.GetInt32(sr.GetOrdinal("CorrespondenceId"));
                obj.CorrespondenceType = sr.GetString(sr.GetOrdinal("CorrespondenceType"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                obj.UserToken = sr.GetString(sr.GetOrdinal("UserToken"));
                obj.Name = sr.GetString(sr.GetOrdinal("Name"));
                obj.FileSize = sr.GetInt32(sr.GetOrdinal("FileSize"));
                obj.FileName = sr.GetString(sr.GetOrdinal("FileName"));
                obj.MimeType = sr.GetString(sr.GetOrdinal("MimeType"));
                obj.DateUploaded = sr.GetDateTime(sr.GetOrdinal("DateUploaded"));
                obj.Guid = sr.GetGuid(sr.GetOrdinal("Guid"));
                obj.Approved = sr.GetBoolean(sr.GetOrdinal("Approved"));
                if (sr.IsDBNull(sr.GetOrdinal("ApprovedBy"))) { obj.ApprovedBy = null; } else { obj.ApprovedBy = sr.GetString(sr.GetOrdinal("ApprovedBy")); }
                if (sr.IsDBNull(sr.GetOrdinal("ApprovedDate"))) { obj.ApprovedDate = null; } else { obj.ApprovedDate = sr.GetDateTime(sr.GetOrdinal("ApprovedDate")); }

                objs.Add(obj);
            }

            return objs.ToArray();
        }
Пример #3
0
        /// <summary>
        /// Gets all Correspondence records
        /// </summary>
        public static CorrespondenceDO[] GetAll()
        {

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            SafeReader sr = DataCommon.ExecuteSafeReader("[dbo].[Correspondence_GetAll]", new SqlParameter[] { }, pid);
            
            List<CorrespondenceDO> objs = new List<CorrespondenceDO>();
            
            while(sr.Read()){

                CorrespondenceDO obj = new CorrespondenceDO();
                
                obj.CorrespondenceId = sr.GetInt32(sr.GetOrdinal("CorrespondenceId"));
                obj.CorrespondenceType = sr.GetString(sr.GetOrdinal("CorrespondenceType"));
                obj.PermitKey = sr.GetInt32(sr.GetOrdinal("PermitKey"));
                obj.UserToken = sr.GetString(sr.GetOrdinal("UserToken"));
                obj.Name = sr.GetString(sr.GetOrdinal("Name"));
                obj.FileSize = sr.GetInt32(sr.GetOrdinal("FileSize"));
                obj.FileName = sr.GetString(sr.GetOrdinal("FileName"));
                obj.MimeType = sr.GetString(sr.GetOrdinal("MimeType"));
                obj.DateUploaded = sr.GetDateTime(sr.GetOrdinal("DateUploaded"));
                obj.Guid = sr.GetGuid(sr.GetOrdinal("Guid"));
                obj.Approved = sr.GetBoolean(sr.GetOrdinal("Approved"));
                if (sr.IsDBNull(sr.GetOrdinal("ApprovedBy"))) { obj.ApprovedBy = null; } else { obj.ApprovedBy = sr.GetString(sr.GetOrdinal("ApprovedBy")); }
                if (sr.IsDBNull(sr.GetOrdinal("ApprovedDate"))) { obj.ApprovedDate = null; } else { obj.ApprovedDate = sr.GetDateTime(sr.GetOrdinal("ApprovedDate")); }


                objs.Add(obj);
            }

            return objs.ToArray();
        }
Пример #4
0
        /// <summary>
        /// Deletes a Correspondence record
        /// </summary>
        public static async Task<int> DeleteAsync(CorrespondenceDO DO)
        {
            SqlParameter _CorrespondenceId = new SqlParameter("CorrespondenceId", SqlDbType.Int);
            
            _CorrespondenceId.Value = DO.CorrespondenceId;
            
            SqlParameter[] _params = new SqlParameter[] {
                _CorrespondenceId
            };

            string pid = ConfigurationManager.AppSettings["ePermitDAL"];

            return await DataCommon.ExecuteScalarAsync("[dbo].[Correspondence_Delete]", _params, pid);
        }
        /// <summary>
        /// Saves a correspondence letter from the posted data
        /// </summary>
        /// <param name="PermitKey"></param>
        /// <param name="CorrespondenceType"></param>
        /// <returns></returns>
        private CorrespondenceBO SaveLetterFile(int PermitKey, ENUMBLL.PDFDocuments CorrespondenceType)
        {
            // Gets the posted file from the request
            HttpPostedFileBase File = Request.Files["File"];

            // Build the letter data object
            CorrespondenceDO data = new CorrespondenceDO()
            {
                CorrespondenceId = 0,
                CorrespondenceType = CorrespondenceType.ToString(),
                DateUploaded = DateTime.Now,
                FileName = File.FileName,
                FileSize = File.ContentLength,
                MimeType = File.ContentType,
                Guid = Guid.NewGuid(),
                Name = ENUMBLL.EnumDescription(CorrespondenceType),
                PermitKey = PermitKey,
                UserToken = myCoalUser.UserToken,
                Approved = false
            };

            // read content from stream
            byte[] content = new byte[File.ContentLength];
            File.InputStream.Read(content, 0, (int)File.ContentLength);

            // post the information to create a new business object
            CorrespondenceBO letter = CorrespondenceBLL.AddCorrespondence(data, content, DirectoryMapping.CorrespondenceFolder);

            return letter;
        }
 /// <summary>
 /// A partial view used to upload and approve correspondence letters
 /// </summary>
 /// <param name="PermitKey"></param>
 /// <param name="Type"></param>
 /// <returns></returns>
 public ActionResult LetterUploader(int PermitKey, ENUMBLL.PDFDocuments Type)
 {
     CorrespondenceDO DataObject = new CorrespondenceDO() { CorrespondenceType = Type.ToString(), PermitKey = PermitKey };
     CorrespondenceBO model = new CorrespondenceBO() { DataObject = DataObject };
     return PartialView(model);
 }