예제 #1
0
        /// <summary>
        /// Hard delete file
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public bool RemoveFile(File_VM Model, string filePath)
        {
            File_VM model = new File_VM();

            using (var db = new WebPortalEntities())
            {
                try
                {
                    model = GetFileInfo(Model);
                    db.RemoveFile(model.FileID, model.TxnTimestamp);
                    db.SaveChanges();

                    DeleteFilePhysical(filePath + model.FileRelativePath + "." + model.FileType);

                    return(true);
                }
                catch (Exception ex)
                {
                    logger.Error("FileSystem_RemoveFile Error: ", ex);
                    throw;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Get File Info
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public File_VM GetFileInfo(File_VM Model)
        {
            using (var db = new WebPortalEntities())
            {
                try
                {
                    ObjectParameter pFileRelativePath   = new ObjectParameter("pFileRelativePath", DBNull.Value);
                    ObjectParameter pFileName           = new ObjectParameter("pFileName", DBNull.Value);
                    ObjectParameter pFileType           = new ObjectParameter("pFileType", DBNull.Value);
                    ObjectParameter pFileRemarks        = new ObjectParameter("pFileRemarks", DBNull.Value);
                    ObjectParameter pCreatedDateTime    = new ObjectParameter("pCreatedDateTime", DBNull.Value);
                    ObjectParameter pLastAccessDateTime = new ObjectParameter("pLastAccessDateTime", DBNull.Value);
                    ObjectParameter pAccessCount        = new ObjectParameter("pAccessCount", 0);
                    ObjectParameter pTxnTimestamp       = new ObjectParameter("pTxnTimestamp", DBNull.Value);

                    db.GetFileInfo(Model.FileID, pFileRelativePath, pFileName, pFileType, pFileRemarks, pCreatedDateTime, pLastAccessDateTime, pAccessCount, pTxnTimestamp);
                    db.SaveChanges();

                    if (pFileRelativePath.Value != DBNull.Value)
                    {
                        Model.FileRelativePath = pFileRelativePath.Value.ToString();
                    }

                    if (pFileName.Value != DBNull.Value)
                    {
                        Model.FileName = pFileName.Value.ToString();
                    }

                    if (pFileType.Value != DBNull.Value)
                    {
                        Model.FileType = pFileType.Value.ToString();
                    }

                    if (pFileRemarks.Value != DBNull.Value)
                    {
                        Model.FileRemarks = pFileRemarks.Value.ToString();
                    }

                    if (pCreatedDateTime.Value != DBNull.Value)
                    {
                        Model.CreatedDateTime = Convert.ToDateTime(pCreatedDateTime.Value);
                    }

                    if (pLastAccessDateTime.Value != DBNull.Value)
                    {
                        Model.LastAccessDateTime = Convert.ToDateTime(pLastAccessDateTime.Value);
                    }

                    if (pAccessCount.Value != DBNull.Value)
                    {
                        Model.AccessCount = Convert.ToInt32(pAccessCount.Value);
                    }

                    if (pTxnTimestamp.Value != DBNull.Value)
                    {
                        Model.TxnTimestamp = (byte[])pTxnTimestamp.Value;
                    }

                    return(Model);
                }
                catch (Exception ex)
                {
                    logger.Error("FileSystem_GetFileInfo Error: ", ex);
                    throw;
                }
            }
        }