public static void InitWindows() { AppWindow = new AppWindow(); FileCreate = new FileCreate(); SettingsDialog = new ServiceSettings(); }
public GoodsType() { filedirectory = Properties.Settings.Default.Goods; FileCreate.FileAndDirCreate(FileType.directory, filedirectory); FileCreate.FileAndDirCreate(FileType.File, filedirectory + @"/" + FILENAME); filefullname = filedirectory + @"/" + FILENAME; lgoods = new List <Goods>(); }
public GoodsType(string name, int price) { goods.GoodName = name; goods.GoodPrice = price; filedirectory = Properties.Settings.Default.Goods; FileCreate.FileAndDirCreate(FileType.directory, filedirectory); FileCreate.FileAndDirCreate(FileType.File, filedirectory + @"/" + FILENAME); filefullname = filedirectory + @"/" + FILENAME; lgoods = new List <Goods>(); }
/// <summary> /// Create metadata information and get upload link for one file. The uploadUrl link which is returned in the /// response is a Google Cloud Storage(GCS) resumable upload URL.It should be used in a separate request to /// upload the file, as documented in /// https://cloud.google.com/storage/docs/json_api/v1/how-tos/resumable-upload. The uploadUrl expires after one /// week.Any file info entry that do not have the actual file uploaded within one week will be automatically /// deleted. The 'Origin' header parameter is forwarded as a 'Origin' header to the GCS initiate upload session /// request. Also, the 'mimeType' query parameter is forwarded as a 'X-Upload-Content-Type' heade /// </summary> /// <param name="file">The file to upload.</param> /// <param name="overwrite"> /// If 'overwrite' is set to true, and the POST body content specifies a 'externalId' field, fields for the file /// found for externalId can be overwritten. The default setting is false. If metadata is included in the /// request body, all of the original metadata will be overwritten.The actual file will be overwritten after a /// successful upload with the uploadUrl from the response.If there is no successful upload, the current file /// contents will be kept. File-Asset mappings only change if explicitly stated in the assetIds field of the /// POST json body. Do not set assetIds in request body if you want to keep the current file-asset mappings. /// </param> /// <param name="token">Optional cancellation token.</param> /// <returns>The Updated file.</returns> public async Task <FileUploadRead> UploadAsync(FileCreate file, bool overwrite = false, CancellationToken token = default) { if (file is null) { throw new ArgumentNullException(nameof(file)); } var req = Oryx.Cognite.Files.upload <FileUploadRead>(file, overwrite); return(await RunAsync(req, token).ConfigureAwait(false)); }
public void FileCreate_ToDLModelShouldMapToFile() { var newFile = new FileCreate { FileDescription = "asdf", PilotID = 1, UserID = 1, FileName = "file.txt", ParsedID = "parsedid" }; var result = newFile.ToDLModel(); Assert.Equal(newFile.FileDescription, result.FileDescription); Assert.Equal(newFile.PilotID, result.PilotID); Assert.Equal(newFile.UserID, result.UploaderID); Assert.Equal(newFile.FileName, result.FileName); Assert.Equal(newFile.ParsedID, result.ParsedID); }
public IActionResult Create([FromForm] FileCreate apiModel) { BlobContainerClient containerClient = _blobSC.GetBlobContainerClient($"pilot{apiModel.PilotID}"); if (!containerClient.Exists()) { containerClient = _blobSC.CreateBlobContainer($"pilot{apiModel.PilotID}", Azure.Storage.Blobs.Models.PublicAccessType.BlobContainer); } BlobClient blobClient = containerClient.GetBlobClient(apiModel.FileName); if (blobClient.Exists()) { return(BadRequest(new { error = "File name already taken for this pilot" })); } blobClient.Upload(apiModel.File.OpenReadStream()); apiModel.FileURL = blobClient.Uri.AbsoluteUri; return(Ok(FileMinimal.FromDLModel(_aviBL.AddFile(apiModel.ToDLModel())))); }
/// <summary> /// Helper method creates a file. /// </summary> /// <param name="file"></param> /// <param name="fileCreate"></param> /// <returns>"true" if the file was created.</returns> private bool CreateFile ( string file, FileCreate fileCreate ) { try { using (FileStream fs = fileCreate(file)) { } } catch (Exception e) when(ExceptionHandling.IsIoRelatedException(e)) { Log.LogErrorWithCodeFromResources("Touch.CannotCreateFile", file, e.Message); return(false); } return(true); }
public async Task <IActionResult> Upload(FileCreate model) { if (ModelState.IsValid) { string uniqueFileName = null; if (model.FileToUpload != null) { string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "files"); uniqueFileName = Guid.NewGuid().ToString() + "_" + model.FileToUpload.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); using (var stream = new FileStream(filePath, FileMode.Create)) { await model.FileToUpload.CopyToAsync(stream); } } if (signInManager.IsSignedIn(User)) { this.email = User.Identity.Name; Console.WriteLine(User.Identity.Name); } Uploadfile obj = new Uploadfile { Email = this.email, filepath = uniqueFileName }; _context.Add(obj); await _context.SaveChangesAsync(); return(View("index")); } return(View()); }
//结算 public void Settlement(DataTable dt, int TotalPrice) { //删除库存 Banlance bl = new Banlance(vinfo); vinfo.Balance -= TotalPrice; bl.ExecAdd(TotalPrice, BanlanceType.消费); vinfo.EditVipUser(vinfo); //写入文件 RecordsConsumption ls = new RecordsConsumption(); ls.VipCard = vinfo.VipCard; ls.Vtype = vinfo.VipType; ls.UserName = vinfo.UserName; ls.PhoneNumber = vinfo.PhoneNumber; ls.Banlance = vinfo.PhoneNumber; ls.ls = new List <ConsumptionInfo>(); ConsumptionInfo cinfo; for (int i = 0; i < dt.Rows.Count; i++) { cinfo = new ConsumptionInfo(); cinfo.Goods = dt.Rows[i]["Goods"].ToString(); cinfo.GoodsNumber = dt.Rows[i]["GoodsNumber"].ToString(); cinfo.TotalPrice = dt.Rows[i]["TotalPrice"].ToString(); cinfo.UnitPrice = dt.Rows[i]["UnitPrice"].ToString(); ls.ls.Add(cinfo); } ls.ConsumptionTime = DateTime.Now.ToLocalTime().ToString(); string filediry = filedir + @"/" + ls.VipCard; string fileurl = filediry + $"/{DateTime.Now.ToString("yyyyMMddhhmmss")}.txt"; FileCreate.FileAndDirCreate(FileType.directory, filediry); //FileCreate.FileAndDirCreate(FileType.File, fileurl); File.WriteAllText(fileurl, JsonConvert.SerializeObject(ls)); }
/// <summary> /// Helper method creates a file. /// </summary> /// <param name="file"></param> /// <param name="fileCreate"></param> /// <returns>"true" if the file was created.</returns> private bool CreateFile ( string file, FileCreate fileCreate ) { try { using (System.IO.FileStream fs = fileCreate(file)) { } } catch (Exception e) // Catching Exception, but rethrowing unless it's a well-known exception. { if (ExceptionHandling.NotExpectedException(e)) { throw; } Log.LogErrorWithCodeFromResources("Touch.CannotCreateFile", file, e.Message); return(false); } return(true); }
/// <summary> /// Implementation of the execute method. /// </summary> /// <returns></returns> internal bool ExecuteImpl ( FileExists fileExists, FileCreate fileCreate, GetAttributes fileGetAttributes, SetAttributes fileSetAttributes, SetLastAccessTime fileSetLastAccessTime, SetLastWriteTime fileSetLastWriteTime ) { // See what time we are touching all files to DateTime touchDateTime; try { touchDateTime = GetTouchDateTime(); } catch (FormatException e) { Log.LogErrorWithCodeFromResources("Touch.TimeSyntaxIncorrect", e.Message); return(false); } // Go through all files and touch 'em bool retVal = true; var touchedItems = new ArrayList(); var touchedFilesSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (ITaskItem file in Files) { string path = FileUtilities.FixFilePath(file.ItemSpec); // For speed, eliminate duplicates caused by poor targets authoring if (touchedFilesSet.Contains(path)) { continue; } // Touch the file. If the file was touched successfully then add it to our array of // touched items. if ( TouchFile ( path, touchDateTime, fileExists, fileCreate, fileGetAttributes, fileSetAttributes, fileSetLastAccessTime, fileSetLastWriteTime ) ) { touchedItems.Add(file); } else { retVal = false; } // Add even on failure to avoid reattempting touchedFilesSet.Add(path); } // Now, set the property that indicates which items we touched. Note that we // touch all the items TouchedFiles = (ITaskItem[])touchedItems.ToArray(typeof(ITaskItem)); return(retVal); }
public void UploadFile(FileCreate fileCreate) { var paramArray = new List <OracleParameter> { new OracleParameter("V_ID", OracleDbType.Int64) { Value = fileCreate.ID }, new OracleParameter("V_TitleCn", OracleDbType.NVarchar2) { Value = fileCreate.TitleCn }, new OracleParameter("V_TitleEn", OracleDbType.NVarchar2) { Value = fileCreate.TitleEn }, new OracleParameter("V_TopicID", OracleDbType.Int32) { Value = fileCreate.TopicID }, new OracleParameter("V_Status", OracleDbType.Int32, ParameterDirection.InputOutput) { Value = fileCreate.Status }, new OracleParameter("V_SubmitDate", OracleDbType.TimeStamp) { Value = (OracleTimeStamp)fileCreate.SubmitDate }, new OracleParameter("V_ReportDate", OracleDbType.TimeStamp) { Value = (OracleTimeStamp)fileCreate.ReportDate }, new OracleParameter("V_FileType", OracleDbType.NVarchar2) { Value = fileCreate.FileType }, //new OracleParameter("V_Doc", OracleDbType.VarBinary) {Value = fileCreate.Doc}, new OracleParameter("V_RIC", OracleDbType.NVarchar2) { Value = fileCreate.RIC }, new OracleParameter("V_DescrCn", OracleDbType.NVarchar2) { Value = fileCreate.DescrCn }, new OracleParameter("V_DescrEn", OracleDbType.NVarchar2) { Value = fileCreate.DescrEn }, new OracleParameter("V_AuthorRM", OracleDbType.NVarchar2) { Value = fileCreate.AuthorRM }, new OracleParameter("V_AuthorEmail", OracleDbType.NVarchar2) { Value = fileCreate.AuthorEmail }, new OracleParameter("V_Author", OracleDbType.NVarchar2) { Value = fileCreate.Author }, new OracleParameter("V_Tag", OracleDbType.NVarchar2) { Value = fileCreate.Tag }, new OracleParameter("V_UploadType", OracleDbType.NVarchar2) { Value = fileCreate.UploadType }, new OracleParameter("V_Source", OracleDbType.NVarchar2) { Value = fileCreate.Source }, new OracleParameter("V_FileName", OracleDbType.NVarchar2) { Value = fileCreate.FileName }, new OracleParameter("V_SubmitterID", OracleDbType.NVarchar2) { Value = fileCreate.SubmitterID }, new OracleParameter("V_DisplayOrder", OracleDbType.NVarchar2) { Value = fileCreate.DisplayOrder }, }; OracleParameter outPar = new OracleParameter(); outPar.ParameterName = "V_Result"; outPar.DbType = DbType.Int32; outPar.Size = 400; outPar.Direction = ParameterDirection.Output; paramArray.Add(outPar); string fileId = ""; ExecNonQuerySpWithResult("UploadFile", paramArray.ToArray(), out fileId); if (!string.IsNullOrEmpty(fileId)) { string path = ""; using (var db = new IPPEntities()) { var id = Convert.ToInt32(fileId); var subPath = (from f in db.FILEINFOs join t in db.TOPICs on f.TOPICID equals t.ID join m in db.MODULEINFOs on t.MODULEID equals m.ID where f.ID == id select new { m.NAMEEN, t.ID }).ToList().FirstOrDefault(); path = "/IPP/" + subPath.NAMEEN + "/" + subPath.ID; } FileService.UploadFile(path, fileId + "." + fileCreate.FileType, fileCreate.Doc); } }
/// <summary> /// Helper method touches a file. /// </summary> /// <returns>"True" if the file was touched.</returns> private bool TouchFile ( string file, DateTime dt, FileExists fileExists, FileCreate fileCreate, GetAttributes fileGetAttributes, SetAttributes fileSetAttributes, SetLastAccessTime fileSetLastAccessTime, SetLastWriteTime fileSetLastWriteTime ) { if (!fileExists(file)) { // If the file does not exist then we check if we need to create it. if (AlwaysCreate) { Log.LogMessageFromResources(MessageImportance.Normal, "Touch.CreatingFile", file, "AlwaysCreate"); if (!CreateFile(file, fileCreate)) { return(false); } } else { Log.LogErrorWithCodeFromResources("Touch.FileDoesNotExist", file); return(false); } } else { Log.LogMessageFromResources(MessageImportance.Normal, "Touch.Touching", file); } // If the file is read only then we must either issue an error, or, if the user so // specified, make the file temporarily not read only. bool needToRestoreAttributes = false; FileAttributes faOriginal = fileGetAttributes(file); if ((faOriginal & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { if (ForceTouch) { try { FileAttributes faNew = (faOriginal & ~FileAttributes.ReadOnly); fileSetAttributes(file, faNew); needToRestoreAttributes = true; } catch (Exception e) when(ExceptionHandling.IsIoRelatedException(e)) { Log.LogErrorWithCodeFromResources("Touch.CannotMakeFileWritable", file, e.Message); return(false); } } } // Do the actual touch operation bool retVal = true; try { fileSetLastAccessTime(file, dt); fileSetLastWriteTime(file, dt); } catch (Exception e) when(ExceptionHandling.IsIoRelatedException(e)) { Log.LogErrorWithCodeFromResources("Touch.CannotTouch", file, e.Message); return(false); } finally { if (needToRestoreAttributes) { // Attempt to restore the attributes. If we fail here, then there is // not much we can do. try { fileSetAttributes(file, faOriginal); } catch (Exception e) when(ExceptionHandling.IsIoRelatedException(e)) { Log.LogErrorWithCodeFromResources("Touch.CannotRestoreAttributes", file, e.Message); retVal = false; } } } return(retVal); }
/// <summary> /// Helper method creates a file. /// </summary> /// <param name="file"></param> /// <param name="fileCreate"></param> /// <returns>"true" if the file was created.</returns> private bool CreateFile ( string file, FileCreate fileCreate ) { try { using (System.IO.FileStream fs = fileCreate(file)) { } } catch (Exception e) when (ExceptionHandling.IsIoRelatedException(e)) { Log.LogErrorWithCodeFromResources("Touch.CannotCreateFile", file, e.Message); return false; } return true; }
public async Task <NodeEntry> Create(FileCreate fileCreate) { return(await _fileService.Create(fileCreate.DocumentId)); }
/// <summary> /// Implementation of the execute method. /// </summary> /// <returns></returns> internal bool ExecuteImpl ( FileExists fileExists, FileCreate fileCreate, GetAttributes fileGetAttributes, SetAttributes fileSetAttributes, SetLastAccessTime fileSetLastAccessTime, SetLastWriteTime fileSetLastWriteTime ) { // See what time we are touching all files to DateTime touchDateTime; try { touchDateTime = GetTouchDateTime(); } catch (FormatException e) { Log.LogErrorWithCodeFromResources("Touch.TimeSyntaxIncorrect", e.Message); return false; } // Go through all files and touch 'em bool retVal = true; ArrayList touchedItems = new ArrayList(); HashSet<string> touchedFilesSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (ITaskItem file in Files) { // For speed, eliminate duplicates caused by poor targets authoring if (touchedFilesSet.Contains(file.ItemSpec)) { continue; } // Touch the file. If the file was touched successfully then add it to our array of // touched items. if ( TouchFile ( file.ItemSpec, touchDateTime, fileExists, fileCreate, fileGetAttributes, fileSetAttributes, fileSetLastAccessTime, fileSetLastWriteTime ) ) { touchedItems.Add(file); } else { retVal = false; } // Add even on failure to avoid reattempting touchedFilesSet.Add(file.ItemSpec); } // Now, set the property that indicates which items we touched. Note that we // touch all the items TouchedFiles = (ITaskItem[])touchedItems.ToArray(typeof(ITaskItem)); return retVal; }
/// <summary> /// Helper method touches a file. /// </summary> /// <param name="file"></param> /// <param name="dt"></param> /// <param name="fileExists"></param> /// <param name="fileCreate"></param> /// <param name="fileGetAttributes"></param> /// <param name="fileSetAttributes"></param> /// <param name="fileSetLastAccessTime"></param> /// <param name="fileSetLastWriteTime"></param> /// <returns>"True" if the file was touched.</returns> private bool TouchFile ( string file, DateTime dt, FileExists fileExists, FileCreate fileCreate, GetAttributes fileGetAttributes, SetAttributes fileSetAttributes, SetLastAccessTime fileSetLastAccessTime, SetLastWriteTime fileSetLastWriteTime ) { if (!fileExists(file)) { // If the file does not exist then we check if we need to create it. if (AlwaysCreate) { Log.LogMessageFromResources(MessageImportance.Normal, "Touch.CreatingFile", file, "AlwaysCreate"); if (!CreateFile(file, fileCreate)) { return false; } } else { Log.LogErrorWithCodeFromResources("Touch.FileDoesNotExist", file); return false; } } else { Log.LogMessageFromResources(MessageImportance.Normal, "Touch.Touching", file); } // If the file is read only then we must either issue an error, or, if the user so // specified, make the file temporarily not read only. bool needToRestoreAttributes = false; System.IO.FileAttributes faOriginal = fileGetAttributes(file); if ((faOriginal & System.IO.FileAttributes.ReadOnly) == System.IO.FileAttributes.ReadOnly) { if (ForceTouch) { try { System.IO.FileAttributes faNew = (faOriginal & ~System.IO.FileAttributes.ReadOnly); fileSetAttributes(file, faNew); needToRestoreAttributes = true; } catch (Exception e) // Catching Exception, but rethrowing unless it's a well-known exception. { if (ExceptionHandling.NotExpectedException(e)) throw; Log.LogErrorWithCodeFromResources("Touch.CannotMakeFileWritable", file, e.Message); return false; } } } // Do the actual touch operation bool retVal = true; try { fileSetLastAccessTime(file, dt); fileSetLastWriteTime(file, dt); } catch (Exception e) // Catching Exception, but rethrowing unless it's a well-known exception. { if (ExceptionHandling.NotExpectedException(e)) throw; Log.LogErrorWithCodeFromResources("Touch.CannotTouch", file, e.Message); return false; } finally { if (needToRestoreAttributes) { // Attempt to restore the attributes. If we fail here, then there is // not much we can do. try { fileSetAttributes(file, faOriginal); } catch (Exception e) // Catching Exception, but rethrowing unless it's a well-known exception. { if (ExceptionHandling.NotExpectedException(e)) throw; Log.LogErrorWithCodeFromResources("Touch.CannotRestoreAttributes", file, e.Message); retVal = false; } } } return retVal; }
public ActionResult FileEditor(long?id, int?topicid, string previousRequest) { FileCreate fileCreate = null; if (id == null) { fileCreate = new FileCreate(); var eikonUserId = UserSettingHelper.GetEikonUserID(Request); var submitter = IPPRepository.GeSubmitterById(eikonUserId); fileCreate.SubmitterID = submitter.ID; fileCreate.SubmiterName = submitter.Name; fileCreate.Submiter = submitter.Email; } else { fileCreate = IPPRepository.GetFileByFileID((long)id); } IPPFile ippFile; fileCreate = fileCreate ?? new FileCreate(); var moduleItems = new List <SelectListItem>(); var topicItems = new List <SelectListItem>(); var ricTypeItems = new List <SelectListItem>(); var uploadTypeItems = HtmlUtil.CookSelectOptions("Ipp_UploadType"); if (id != null) { topicid = IPPRepository.GetTopicIdByFileId(id); } IEnumerable <MODULEINFO> modules = IPPRepository.GetModuleList(); var moduleId = (topicid == null || topicid == 0)? modules.FirstOrDefault().ID : (int)IPPRepository.GetModuleIdByTopicId((int)topicid); var topics = IPPRepository.GetTopicListByModuleId(moduleId); foreach (var m in modules) { moduleItems.Add(new SelectListItem { Selected = m.ID == moduleId ? true : false, Value = m.ID.ToString(), Text = CultureHelper.IsEnglishCulture() ? m.NAMEEN : m.NAMECN }); } var selectedTopicId = topicid == null?topics.FirstOrDefault().ID : topicid; foreach (var m in topics) { topicItems.Add(new SelectListItem { Selected = m.ID == selectedTopicId ? true : false, Value = m.ID.ToString(), Text = CultureHelper.IsEnglishCulture() ? m.NAMEEN : m.NAMECN }); } ricTypeItems.Add(new SelectListItem { Value = "Graph", Text = "Chart" }); ricTypeItems.Add(new SelectListItem { Value = "Quote Object", Text = "Quote" }); ricTypeItems.Add(new SelectListItem { Value = "News", Text = "News" }); var userAttibuteMap = UserSettingHelper.GetUserAttributeMap(Request); var author = userAttibuteMap == null ? "" : userAttibuteMap.First(x => x.name.ToLower() == "FullName".ToLower()).value; var source = userAttibuteMap == null ? "" : userAttibuteMap.First(x => x.name.ToLower() == "AccountName".ToLower()).value; if (UserSettingHelper.IsInternalUser(Request)) { source = "Thomson Reuters"; } ippFile = new IPPFile { Id = fileCreate.ID, Author = string.IsNullOrEmpty(fileCreate.Author) ? author : fileCreate.Author, AuthorRM = fileCreate.AuthorRM, AuthorEmail = fileCreate.AuthorEmail, DescriptionCn = fileCreate.DescrCn, DescriptionEn = fileCreate.DescrEn, UploadType = fileCreate.UploadType, FileType = fileCreate.FileType, WebsiteRic = fileCreate.UploadType == "Upload_Website" ? fileCreate.RIC : "", EikonRic = fileCreate.UploadType == "Upload_Ric" ? fileCreate.RIC : "", ReportDate = fileCreate.ReportDate.ToString("yyyy-MM-dd"), SubmitterID = fileCreate.SubmitterID, SubmiterName = fileCreate.SubmiterName, Submiter = fileCreate.Submiter, Tag = fileCreate.Tag != null?fileCreate.Tag.Replace('|', ';') : fileCreate.Tag, TitleCn = fileCreate.TitleCn, TitleEn = fileCreate.TitleEn, ModuleItems = moduleItems, Topic = selectedTopicId.ToString(), TopicItems = topicItems, UploadTypeItems = uploadTypeItems, RicTypeItems = ricTypeItems, Source = string.IsNullOrEmpty(fileCreate.Source) ? source : fileCreate.Source, PreviousRequest = previousRequest, Status = fileCreate.Status, FileName = fileCreate.FileName, DisplayOrder = fileCreate.DisplayOrder }; return(View(ippFile)); }
/// <summary> /// Helper method creates a file. /// </summary> /// <param name="file"></param> /// <param name="fileCreate"></param> /// <returns>"true" if the file was created.</returns> private bool CreateFile ( string file, FileCreate fileCreate ) { try { using (System.IO.FileStream fs = fileCreate(file)) { } } catch (Exception e) // Catching Exception, but rethrowing unless it's a well-known exception. { if (ExceptionHandling.NotExpectedException(e)) throw; Log.LogErrorWithCodeFromResources("Touch.CannotCreateFile", file, e.Message); return false; } return true; }
public ActionResult Upload(IPPFile ippFile, HttpPostedFileBase file, string submit) { string fileType = ""; string ric = ""; if (ippFile.UploadType == "Upload_File") { if (file != null) { var index = file.FileName.LastIndexOf("."); fileType = file.FileName.Substring(index + 1); } else { var index = ippFile.FileName.LastIndexOf("."); fileType = ippFile.FileName.Substring(index + 1); } } else { fileType = ippFile.FileType; } if (ippFile.UploadType == "Upload_Website") { if (!ippFile.WebsiteRic.Contains("cpurl://")) { if (!ippFile.WebsiteRic.Contains("http")) { ippFile.WebsiteRic = "http://" + ippFile.WebsiteRic; } } ric = ippFile.WebsiteRic; } else if (ippFile.UploadType == "Upload_Ric") { ric = ippFile.EikonRic; } var fileCreate = new FileCreate { ID = ippFile.Id ?? 0, /*0 to indicated 'insert'*/ Author = ippFile.Author, AuthorRM = ippFile.AuthorRM, AuthorEmail = ippFile.AuthorEmail, DescrCn = ippFile.DescriptionCn, DescrEn = ippFile.DescriptionEn, UploadType = ippFile.UploadType, FileType = fileType, RIC = ric, SubmitDate = DateTime.Now, ReportDate = DateTime.Parse(ippFile.ReportDate), SubmitterID = ippFile.SubmitterID, Tag = ippFile.Tag == null ? "" : ippFile.Tag.Replace(';', '|').Replace(';', '|'), TitleCn = ippFile.TitleCn, TitleEn = ippFile.TitleEn, TopicID = Convert.ToInt32(ippFile.Topic), Source = ippFile.Source, FileName = ippFile.FileName, DisplayOrder = ippFile.DisplayOrder }; if (file != null && file.ContentLength > 0) { fileCreate.Doc = new byte[file.ContentLength]; file.InputStream.Read(fileCreate.Doc, 0, file.ContentLength); } fileCreate.Status = submit == Resources.IPP.IPP_Save ? 0 : -1; //-1: publish IPPRepository.UploadFile(fileCreate); switch (ippFile.PreviousRequest) { case "fileBrowser": return(RedirectToAction("FileBrowser", new { id = fileCreate.TopicID })); case "prePublish": return(Redirect("~/ipp/MyDocument/prePublish")); case "published": return(Redirect("~/ipp/MyDocument/published")); case "approved": return(Redirect("~/ipp/MyDocument/approved")); default: return(RedirectToAction("FileBrowser", new { id = fileCreate.TopicID })); } }