Пример #1
0
        public virtual bool UploadAssetFile(HttpPostedFile postedFile, int RequestID, string FileCategory, string AssetID)
        {
            byte[] fileContents = new byte[postedFile.ContentLength];
            postedFile.InputStream.Read(fileContents, 0, fileContents.Length);

            string SavedPath = "/AssetSystem/AssetFile/";

            if (FileCategory == "Certification")
            {
                SavedPath += "Certification/";
            }
            else if (FileCategory == "Manual")
            {
                SavedPath += "Manual/";
            }
            else if (FileCategory == "Image")
            {
                SavedPath += "Image/";
            }

            string SavedName = RequestID + "_" + postedFile.FileName;

            if (Common.FtpRepository.UploadFile(fileContents, SavedPath, SavedName) == true)
            {
                AssetFile file = new AssetFile();

                file.Date       = DateTime.Now;
                file.FK_AssetID = AssetID;
                file.Category   = FileCategory;
                file.Path       = "http://192.168.9.3:8888" + SavedPath + SavedName;
                file.Add();
            }
            return(true);
        }