public static void Run() { // ExStart:1 StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH); string Path = "testfile.txt"; string dest = "new-testfile.txt"; string versionId = null; string storage = null; string destStorage = null; byte[] file = System.IO.File.ReadAllBytes(Common.GetDataDir() + Path); try { // Invoke Aspose.Storage Cloud SDK API to upload and move file storageApi.PutCreate(Path, versionId, storage, file); MoveFileResponse apiResponse = storageApi.PostMoveFile(Path, dest, versionId, storage, destStorage); if (apiResponse != null && apiResponse.Status.Equals("OK")) { Console.WriteLine("File moved successfully."); Console.ReadKey(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace); } // ExEnd:1 }
protected void UploadAttachFiles() { try { using (FileService.FileTransferServiceClient svc = new FileService.FileTransferServiceClient()) { MoveFileResponse response = new MoveFileResponse(); foreach (AttachFilesIAS.AttachFile attatch in this.AttachFiles) { String container = String.Format(@"{0}\{1}", AttachFileContainer, this.ID_CARD_NO); String newFileName = this.ID_CARD_NO + "_" + Convert.ToInt32(attatch.ATTACH_FILE_TYPE).ToString("00") + "." + attatch.EXTENSION; //response = svc.MoveFile(new MoveFileRequest() { // CurrentContainer = "", // CurrentFileName = attatch.ATTACH_FILE_PATH, // TargetContainer = container, // TargetFileName = newFileName }); if (response.Code != "0000") { throw new RegistrationException(response.Message); } } } } catch (Exception ex) { throw new RegistrationException(ex.Message); } }
private static void AddLicenseRequest(IAS.DAL.Interfaces.IIASPersonEntities ctx, String _netDrive, DirectoryInfo zipFolder, AG_IAS_SUBPAYMENT_H_T SubPaymentHT, AG_IAS_SUBPAYMENT_D_T subPaymentDT, AG_IAS_LICENSE_D licenD, AG_IAS_LICENSE_H licenH, AG_IAS_LICENSE_TYPE_R licenType, AG_IAS_ATTACH_FILE_LICENSE attach) { String filePath = String.Format(@"{0}\{1}\{2}\{3}", zipFolder.FullName, ((String.IsNullOrEmpty(licenH.COMP_CODE))?"0000": licenH.COMP_CODE), SubPaymentHT.PETITION_TYPE_CODE, licenType.LICENSE_TYPE_CODE); DirectoryInfo dirInfo = new DirectoryInfo(Path.Combine(_netDrive, filePath)); if (!dirInfo.Exists) { dirInfo.Create(); } FileInfo fileInfo = new FileInfo(Path.Combine(dirInfo.FullName, "1.txt")); if (!fileInfo.Exists) { using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileInfo.FullName, true, Encoding.GetEncoding(874))) { file.WriteLine("ชื่อรูป,เลขที่ใบอนุญาต,เลขบัตรประชาชน,ชื่อ,สกุล,วันที่ออกใบอนุญาต,วันที่หมดอายุ,บริษัท,ประเภทใบอนุญาต,"); } } using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileInfo.FullName, true, Encoding.GetEncoding(874))) { file.WriteLine(String.Format("{0},{1},{2},{3},{4},\"{5}\",\"{6}\",{7},{8},", subPaymentDT.ID_CARD_NO, WordSpacing(subPaymentDT.LICENSE_NO), WordSpacing(subPaymentDT.ID_CARD_NO), String.Format("{0} {1}", licenD.TITLE_NAME, licenD.NAMES), licenD.LASTNAME, ((DateTime)licenD.LICENSE_DATE).ToString("dd/MM/yyy", CultureInfo.CreateSpecificCulture("th-TH")), ((DateTime)licenD.LICENSE_EXPIRE_DATE).ToString("dd/MM/yyy", CultureInfo.CreateSpecificCulture("th-TH")), licenH.COMP_NAME, licenType.LICENSE_TYPE_NAME)); } Int32 start = attach.ATTACH_FILE_PATH.LastIndexOf('.'); Int32 len = attach.ATTACH_FILE_PATH.Length; String extension = attach.ATTACH_FILE_PATH.Substring(attach.ATTACH_FILE_PATH.LastIndexOf('.'), len - start); MoveFileResponse response = FileManagerService.RemoteFileCommand(new MoveFileRequest() { CurrentContainer = "", CurrentFileName = attach.ATTACH_FILE_PATH, TargetContainer = String.Format(@"{0}\{1}", dirInfo.FullName.Replace(_netDrive, ""), "images"), TargetFileName = String.Format("{0}{1}", licenD.ID_CARD_NO, extension) }).Action(); if (response.Code != "0000") { throw new ApplicationException(response.Message); } }
public MoveFileResponse MoveFile(MoveFileRequest request) { MoveFileResponse response = new MoveFileResponse(); try { response = FileManagerService.RemoteFileCommand(request).Action(); } catch (Exception ex) { response.Code = "0001"; response.Code = ex.Message; } return(response); }
private bool MoveFile(int nFileId, int nFolderId, out string err) { string strResultInfo = string.Empty; err = string.Empty; string sProspectStatus = LoansManager.GetProspectStatusInfo(nFileId); string sFileName = LoansManager.GetProspectFileNameInfo(nFileId); //bug 878 if (sFileName == "") { err = "The selected lead does not have a Point file."; return(false); } ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { MoveFileRequest req = new MoveFileRequest(); req.FileId = nFileId; req.NewFolderId = nFolderId; req.hdr = new ReqHdr(); req.hdr.UserId = CurrUser.iUserID; MoveFileResponse response = client.MoveFile(req); if (response.hdr.Successful) { return(true); } // LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo)); //PageCommon.WriteJsEnd(this, response.hdr.StatusInfo); err = response.hdr.StatusInfo; return(false); } }
public MoveFileResponse Action() { MoveFileResponse response = new MoveFileResponse(); try { FileInfo fileInfoTarget = new FileInfo(Path.Combine(DefaultNetDrive, _targetPath)); FileInfo fileInfoCurrent = new FileInfo(Path.Combine(DefaultNetDrive, _currentPath)); if (!fileInfoCurrent.Exists) { throw new FileNotFoundException(String.Format("ไม่พบไฟล์ {0} ในระบบ", _currentFileName), _currentFileName); } //if (fileInfoTarget.Exists) throw new FileNotFoundException("File is dupicate", _targetfileName); if (fileInfoTarget.Exists) { File.Delete(fileInfoTarget.FullName); } File.Copy(fileInfoCurrent.FullName, fileInfoTarget.FullName); response.Code = "0000"; response.Message = Resources.infoAmendFile_Success; response.TargetFullName = _targetPath; } catch (FileNotFoundException fex) { response.Code = "0002"; response.Message = fex.Message; } catch (Exception ex) { response.Code = "0001"; response.Message = Resources.errorMoveFile_001; } return(response); }
protected void btnSave_Click(object sender, EventArgs e) { MoveFileResponse response = new MoveFileResponse(); try { using (svc = new FileService.FileTransferServiceClient()) { IList <DTO.AttachFile> attachFiles = ((IList <DTO.AttachFile>)Session["AttachFiles"]); foreach (DTO.AttachFile item in attachFiles) { String target = AttachFileContainer + @"\" + item.ID; response = svc.MoveFile(new MoveFileRequest() { CurrentContainer = "", CurrentFileName = CryptoBase64.Decryption(item.TargetFullName), TargetContainer = target, TargetFileName = item.TargetFileName }); if (response.Code != "0000") { throw new ApplicationException(response.Message); } item.TargetFullName = response.TargetFullName; } gv.DataSource = attachFiles; gv.DataBind(); } } catch (Exception ex) { response.Message = ex.Message; response.Code = "0001"; } //IList<DTO.AttachFile> attachFiles = ((IList<DTO.AttachFile>)Session["AttechFiles"]).ToList(); //foreach (DTO.AttachFile item in AttachFiles) //{ ////svc = new FileService.FileTransferServiceClient(); //svc = new FileService.FileTransferServiceClient(); //UploadFileResponse response = new UploadFileResponse(); //string res = svc.UploadFile(item.TargetFolder, item.ID, item.DataStream, out response.Code, out response.Message, out response.Certificate); //BLL.FileBiz biz = new BLL.FileBiz(); //string targetFolder = IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId(); ////biz.UploadToTemp(fUpload.PostedFile.InputStream, fUpload.FileName, targetFolder, fUpload.FileName); //biz.UploadToTemp(item.DataStream, item.FileName, item.TargetFolder, item.FileName); //Response.Write("Success"); //IAS.FileService.FileUploadMessage fileUploadMessage = new IAS.FileService.FileUploadMessage(); //var res = new DTO.ResponseService<string>(); //var resMsg = new FileService.FileUploadMessage(); //try //{ // resMsg.FileByteStream = item.DataStream; // resMsg.Metadata = new FileMetaData // { // localFilename = item.FileName, // remoteFilename = item.ID, // targetFolder = string.Format(item.FileName + @"\{0}\", item.ID), // }; // svc.UploadFile(ref resMsg.Metadata, ref resMsg.FileByteStream); // res.DataResponse = resMsg.Metadata.resMsg; //} //catch (Exception ex) //{ // res.ErrorMsg = "กรุณาติดต่อผู้ดูแลระบบ"; // +resMsg.Metadata.resMsg; //} //} }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDispose_Click(object sender, EventArgs e) { bool bmove = false; int nFileId = -1; if (!int.TryParse(this.hiSelectedLoan.Value, out nFileId)) { nFileId = -1; } if (nFileId == -1) { LPLog.LogMessage(LogType.Logerror, "Invalid file Id: " + this.hiSelectedLoan.Value); return; } int nFolderId = -1; if (!int.TryParse(this.hiSelectedFolderId.Value, out nFolderId)) { nFolderId = -1; } if (nFolderId == -1) { LPLog.LogMessage(LogType.Logerror, "Invalid folder Id: " + this.hiSelectedFolderId.Value); return; } try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { if (!bmove) { DisposeLoanRequest req = new DisposeLoanRequest(); req.FileId = nFileId; req.LoanStatus = hiSelectedDisposal.Value; req.NewFolderId = nFolderId; req.hdr = new ReqHdr(); req.hdr.UserId = CurrUser.iUserID; req.StatusDate = DateTime.Now; DisposeLoanResponse response = client.DisposeLoan(req); if (response.hdr.Successful) { if (WorkflowManager.UpdateLoanStatus(nFileId, hiSelectedDisposal.Value, CurrUser.iUserID)) { BindLoanGrid(); LPLog.LogMessage(LogType.Loginfo, string.Format("Successfully update loan status, LoanId:{0}, to Status:{1}. ", nFileId, this.hiSelectedDisposal.Value)); } else { PageCommon.AlertMsg(this, "Failed to update loan status."); LPLog.LogMessage(LogType.Logerror, string.Format("Failed to update loan status, LoanId:{0}, to Status:{1}.", nFileId, this.hiSelectedDisposal.Value)); } } else { LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo)); PageCommon.AlertMsg(this, response.hdr.StatusInfo); } } else { MoveFileRequest req = new MoveFileRequest(); req.FileId = nFileId; req.NewFolderId = nFolderId; req.hdr = new ReqHdr(); req.hdr.UserId = CurrUser.iUserID; MoveFileResponse response = client.MoveFile(req); if (response.hdr.Successful) { } else { LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo)); PageCommon.AlertMsg(this, response.hdr.StatusInfo); } } } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ee.Message)); PageCommon.AlertMsg(this, "Failed to move the Point file, reason: Point Manager is not running."); } catch (Exception ex) { LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ex.Message)); PageCommon.AlertMsg(this, ex.Message); } }
protected void btnSel_Click(object sender, EventArgs e) { string sFolderID = "0"; // return selected record as XML foreach (GridViewRow row in gvFolder.Rows) { CheckBox ckbSelected = row.FindControl("ckbSelected") as CheckBox; if (ckbSelected.Checked) { if (!string.IsNullOrEmpty(_strPstatus) && _strPstatus == "1") { //ClientFun("callback", string.Format("callBack('{0}','{1}');", gvFolder.DataKeys[row.RowIndex].Value, _strPstatus)); sFolderID = gvFolder.DataKeys[row.RowIndex].Value.ToString(); //return; } //ClientFun("callback", string.Format("callBack('{0}');", gvFolder.DataKeys[row.RowIndex].Value.ToString())); sFolderID = gvFolder.DataKeys[row.RowIndex].Value.ToString(); //return; } } BLL.Loans LoansManager = new BLL.Loans(); string sProspectStatus = ""; try { sProspectStatus = LoansManager.GetProspectStatusInfo(Convert.ToInt32(this.strFileId)); string sFileName = LoansManager.GetProspectFileNameInfo(Convert.ToInt32(this.strFileId)); //bug 878 if (sFileName == "") { //PageCommon.AlertMsg(this, string.Format("The selected loan does not have a Point file. Please export the loan to a Point file using the Lead Detail page and try again.")); PageCommon.WriteJsEnd(this, "The selected loan does not have a Point file. Please export the loan to a Point file using the Lead Detail page and try again.", "window.parent.CloseGlobalPopup();"); return; } } catch { LPLog.LogMessage(LogType.Logerror, "Invalid loan status: " + sProspectStatus); return; } try { ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { MoveFileRequest req = new MoveFileRequest(); req.FileId = Convert.ToInt32(this.strFileId); // req.LoanStatus = lse; req.NewFolderId = Convert.ToInt32(sFolderID); req.hdr = new ReqHdr(); req.hdr.UserId = CurrUser.iUserID; // req.StatusDate = DateTime.Now; MoveFileResponse response = client.MoveFile(req); if (response.hdr.Successful) { PageCommon.WriteJsEnd(this, "", "window.parent.CloseGlobalPopup();"); } else { LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo)); //PageCommon.AlertMsg(this, response.hdr.StatusInfo); //ClientFun("callback", ""); PageCommon.WriteJsEnd(this, response.hdr.StatusInfo, "window.parent.CloseGlobalPopup();"); } } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ee.Message)); //PageCommon.AlertMsg(this, "Failed to move the Point file, reason: Point Manager is not running."); //ClientFun("callback", ""); PageCommon.WriteJsEnd(this, "Failed to move the Point file, reason: Point Manager is not running.", "window.parent.CloseGlobalPopup();"); } catch (Exception ex) { LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ex.Message)); PageCommon.WriteJsEnd(this, ex.Message, "window.parent.CloseGlobalPopup();"); } }