public ActionResult ASPOPTrack(QueryReplyDocumentViewModel vm, int?PageIndex) { vm.Customers = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID) .Select(c => new SelectListItem() { Value = c.CustomerID.ToString(), Text = c.CustomerName }); StringBuilder sb = new StringBuilder(); foreach (var i in vm.Customers) { sb.Append("'" + i.Text + "',"); } var response = new AMSUploadService().QueryAMSUpload(new QueryAMSUploadRequests() { PageIndex = PageIndex ?? 0, PageSize = UtilConstants.PAGESIZE, SearchCondition = vm.SearchCondition, Customers = sb.ToString().Substring(0, sb.Length - 1).ToString() }); if (response.IsSuccess) { vm.AMSUploadCollection = response.Result.AMSUploadCollection; vm.PageCount = response.Result.PageCount; vm.PageIndex = response.Result.PageIndex; } return(View(vm)); }
public ActionResult Line(GenBoxNumberViewModel vm, int?PageIndex) { vm.Customers = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID) .Select(c => new SelectListItem { Value = c.CustomerID.ToString(), Text = c.CustomerName }); //var CustomerText = Json(vm.Customers.Select(p => new { p.Text})).ToJsonString(); StringBuilder sb = new StringBuilder(); foreach (var i in vm.Customers) { sb.Append("'" + i.Text + "',"); } var response = new AMSUploadService().QueryGenBoxNumber(new GenBoxNumberRequest() { PageIndex = PageIndex ?? 0, PageSize = UtilConstants.PAGESIZE, SearchCondition = vm.SearchCondition, Customers = sb.ToString().Substring(0, sb.Length - 1).ToString(), }); if (response.IsSuccess) { vm.AMSUploadCollection = response.Result.AMSUploadCollection; } return(View(vm)); }
/// <summary> /// 点击查看图片 /// </summary> public ActionResult GetAttachment(long?id) { if (id.HasValue) { AMSUploadService service = new AMSUploadService(); Response <AMSUpload> resp = service.GetAttachmentByID(new GetAMSUPLOADByIDRequest() { ID = id.Value }); if (resp.IsSuccess) { string encode = string.Empty; if (resp.Result.ServerName.EndsWith("xlsx", StringComparison.OrdinalIgnoreCase) || resp.Result.FileType.EndsWith("xls", StringComparison.OrdinalIgnoreCase)) { encode = "application/vnd.ms-excel"; } else if (resp.Result.ServerName.EndsWith("bmp", StringComparison.OrdinalIgnoreCase)) { encode = "image/x-ms-bmp"; } else if (resp.Result.ServerName.EndsWith("jpeg", StringComparison.OrdinalIgnoreCase) || resp.Result.ServerName.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) || resp.Result.ServerName.EndsWith("jpe", StringComparison.OrdinalIgnoreCase)) { encode = "image/jpeg"; } else { encode = "application"; } return(File(resp.Result.FilePath, encode, resp.Result.ServerName.ToUtf8String())); } } return(new EmptyResult()); }
public JsonResult GenBoxNumbers(string sql) { GenBoxNumberViewModel gb = new GenBoxNumberViewModel(); var response = new AMSUploadService().AddGenBoxNumber(new GenBoxNumberRequest() { Check = sql, }); if (response.IsSuccess) { return(Json(response.Result.AMSUploadCollection.Select(p => new{ p.ID, p.OrderNo }))); } throw response.Exception; }
private string GetImportReplyDocument() { StringBuilder result = new StringBuilder(); AMSUploadService service = new AMSUploadService(); Response <IEnumerable <AMSUpload> > respose = service.GetAMSUploadOrPODInfo(); string amsTime = DateTime.Now.AddMonths(-2).ToString("yyyy-MM") + "-01"; result.Append("(以下为" + amsTime + "至今天所有运单的回单明细,如果AMS当前同步数不等于TMS已上传附件数,请点击 [手动导入] 按钮)<br />"); if (respose.IsSuccess) { foreach (AMSUpload ams in respose.Result) { result.Append(ams.ProjectName + "全部运单总数:" + ams.ProjectID); result.Append(",TMS中已上传附件数:" + ams.ID); result.Append(",AMS中当前同步数:" + ams.FileType + "<br />"); } } return(result.ToString()); }
public string SetImportReplyDocument() { string uploadFolderPath = Runbow.TWS.Common.Constants.UPLOAD_AMS_PATH;//新路径 AMSUploadService service = new AMSUploadService(); Response <IEnumerable <Attachment> > response = service.GetAttachmentOrAMS(); if (response.IsSuccess) { string destFileName = string.Empty; try { foreach (Attachment at in response.Result) { destFileName = Path.Combine(uploadFolderPath, at.Creator, DateTime.Now.ToString("yyyy-MM")); if (!Directory.Exists(destFileName)) { Directory.CreateDirectory(destFileName); } destFileName = Path.Combine(destFileName, at.ActualNameInServer); if (MyFile.Exists(at.Url)) { MyFile.Copy(at.Url, destFileName, true); } } service.InsertAMSUpload(); return(new { result = "导入成功", IsSuccess = true }.ToJsonString()); } catch { return(new { result = "导入失败", IsSuccess = false }.ToJsonString()); } } return(new { result = "手动导入完成", IsSuccess = true }.ToJsonString()); }
public ActionResult ExpressTrack() { QueryReplyDocumentViewModel vm = new QueryReplyDocumentViewModel(); vm.packageSearch = new WMS_Package(); vm.Type = 0; vm.PageIndex = 0; vm.PageCount = 0; vm.Customers = ApplicationConfigHelper.GetProjectUserCustomers(base.UserInfo.ProjectID, base.UserInfo.ID) .Select(c => new SelectListItem() { Value = c.CustomerID.ToString(), Text = c.CustomerName }); #region 顺丰下单 //RequestSFModel sFModel = new RequestSFModel() //{ // OID = 3, // orderid = "OR1082021030000003", // j_company = "玫琳凯(中国)", // j_province = "四川", // j_city = "成都", // //j_county = "成都", // j_contact = "玫琳凯(中国)", // j_tel = "4008201655", // j_address = "成都仓", // d_company = "黄玉玲", // d_province = "重庆", // d_city = "重庆市", // d_county = "北碚区", // d_contact = "黄玉玲", // d_tel = "13224008664", // d_address = "龙凤桥香洲心城11栋1单元62", // cargo_total_weight = "1", // parcel_quantity = "1", // pay_method = "1", // custid = "", // customs_batchs = "", // cargo = "服装", // Creator = base.UserInfo.Name, //}; //var res = SFDetailHelper.CreateSFOrder(sFModel); #endregion var response = new AMSUploadService().GetWMS_PackageByCondition(new QueryAMSUploadRequests() { PageIndex = 0, PageSize = UtilConstants.PAGESIZE, WMS_PackageSearch = vm.packageSearch, // Customers = sb.ToString().Substring(0, sb.Length - 1).ToString() }); if (response.IsSuccess) { vm.packageList = response.Result.WMS_PackageCollection; vm.PageCount = response.Result.PageCount; vm.PageIndex = response.Result.PageIndex; } return(View(vm)); }
public string ReplyDocument_Upload(long customer, string customerName) { //新路径 string uploadFolderPath = Runbow.TWS.Common.Constants.UPLOAD_AMS_PATH; string targetPath = Path.Combine(uploadFolderPath, customerName, DateTime.Now.ToString("yyyy-MM")); DateTime createDate; string url = string.Empty, actualNameInServer = string.Empty, displayName = string.Empty, ext = string.Empty; IList <AMSUpload> amsUpload = new List <AMSUpload>(); if (string.IsNullOrEmpty(targetPath) || !Path.IsPathRooted(targetPath)) { return(new { msg = "程序出错!" }.ToJsonString()); } if (Request.Files.Count > 0) { HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase; if (hpf.ContentLength > 0) { if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } displayName = Path.GetFileName(hpf.FileName); ext = Path.GetExtension(hpf.FileName); if (!ext.ToLower().Equals(".zip")) { return(new { msg = "批量上传,请用zip格式压缩" }.ToJsonString()); } actualNameInServer = UserInfo.ProjectName + DateTime.Now.ToString("yyyyMMddHHmmss") + ext; url = Path.Combine(targetPath, actualNameInServer); hpf.SaveAs(url); hpf.InputStream.Close(); if (ext.ToLower().Equals(".zip")) { IList <string> unZipedFileName = new List <string>(); ZipHelper.UnZip(url, targetPath, unZipedFileName); MyFile.Delete(url); unZipedFileName.Each((k, fileName) => { actualNameInServer = Path.GetFileName(fileName); ext = Path.GetExtension(fileName); displayName = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(actualNameInServer)); createDate = DateTime.Now; amsUpload.Add(new AMSUpload() { FileName = displayName, FileType = ext, ServerName = actualNameInServer, FilePath = fileName, ProjectID = customer, ProjectName = customerName, OrderNo = "", Creator = UserInfo.Name, CreateTime = createDate, Updator = "", UpdateTime = createDate, Status = false }); }); } else { amsUpload.Add(new AMSUpload() { FileName = displayName, FileType = ext, ServerName = actualNameInServer, FilePath = url, ProjectID = UserInfo.ProjectID, ProjectName = UserInfo.ProjectName, OrderNo = "", Creator = UserInfo.Name, CreateTime = DateTime.Now, Updator = "", UpdateTime = DateTime.Now, Status = false }); } AMSUploadService service = new AMSUploadService(); //查询已存在的记录 Response <IEnumerable <AMSUpload> > resams = service.GetAMSUpload(new AddAMSUploadRequest() { amsUpload = amsUpload }); //执行新增修改操作 Response <IEnumerable <AMSUpload> > response = service.AddAMSUpload(new AddAMSUploadRequest() { amsUpload = amsUpload }); if (response.IsSuccess) { #region 除已存在记录的图片 if (resams.IsSuccess) { if (resams.Result != null) { foreach (AMSUpload a in resams.Result) { if (MyFile.Exists(a.FilePath)) { MyFile.Delete(a.FilePath); } } } } #endregion return(new { result = "批量上传文件成功!", IsSuccess = true }.ToJsonString()); } } return(new { result = "文件内容为空", IsSuccess = false }.ToJsonString()); } return(new { result = "请选择文件", IsSuccess = false }.ToJsonString()); }
public string ExcelCheck(string customer) { string uploadFolderPath = Runbow.TWS.Common.Constants.UPLOAD_FOLDER_PATH; string targetPath = Path.Combine(uploadFolderPath, "AMSTempFile"); string url = string.Empty, actualNameInServer = string.Empty, ext = string.Empty; DateTime amsDate = new DateTime(); if (string.IsNullOrEmpty(targetPath) || !Path.IsPathRooted(targetPath)) { return(new { msg = "程序出错!" }.ToJsonString()); } if (Request.Files.Count > 0) { HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase; if (hpf.ContentLength > 0) { if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } ext = Path.GetExtension(hpf.FileName); if (!ext.ToLower().Equals(".xls") && !ext.ToLower().Equals(".xlsx")) { return(new { msg = "请选择Excel格式的文件" }.ToJsonString()); } actualNameInServer = DateTime.Now.ToString("yyyyMMddHHmmss") + ext; url = Path.Combine(targetPath, actualNameInServer); hpf.SaveAs(url); hpf.InputStream.Close(); Runbow.TWS.Common.ExcelHelper excelHelper = new Runbow.TWS.Common.ExcelHelper(url); DataSet ds = excelHelper.GetAllDataFromAllSheets(); excelHelper.Dispose(); MyFile.Delete(url); AMSUploadService service = new AMSUploadService(); Response <IEnumerable <AMSUpload> > response = service.GetAMSUpload(new AddAMSUploadRequest() { amsUpload = null }); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0 && response.Result.Count() > 0) { StringBuilder results = new StringBuilder(); StringBuilder ids = new StringBuilder(); string projectName, fileName; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow row = ds.Tables[0].Rows[i]; projectName = row[0].ToString().Trim().ToUpper(); fileName = row[1].ToString().Trim().ToUpper(); if (projectName == "AMS_永兴东润") { amsDate = Convert.ToDateTime(row[2].ToString()); fileName = amsDate.ToString("yyyy-MM-") + fileName; } bool isExist = false; foreach (AMSUpload ams in response.Result) { if (projectName == ams.ProjectName.Trim().ToUpper() && fileName == ams.FileName.Trim().ToUpper()) { ids.Append("'" + ams.ID.ToString() + "',"); isExist = true; //if (projectName != "AMS_永兴东润") //AMS_永兴东润 //{ // break; //} } } if (!isExist) { results.Append("[" + row[0].ToString() + "]客户中[" + row[1].ToString() + "]运单号 未上传回单图片<br />"); } } if (ids.Length > 0) { service.UpdateAMSUploadStatus(new AddAMSUploadRequest() { Ids = ids.ToString() }); } if (results.Length <= 0) { results.Append("回单图片都已上传."); } return(new { result = results.ToString(), IsSuccess = true }.ToJsonString()); } } return(new { result = "文件内容为空", IsSuccess = false }.ToJsonString()); } return(new { result = "请选择文件", IsSuccess = false }.ToJsonString()); }
public string AjaxUpload2(string gid, bool isMultiple, bool isCoverOld) {//, long customerID, string customerName string uploadFolderPath = Runbow.TWS.Common.Constants.UPLOAD_FOLDER_PATH; string targetPath = Path.Combine(uploadFolderPath, base.UserInfo.ProjectName, DateTime.Now.ToString("yyyy-MM")); DateTime createDate; string attachmentGroupID = gid, url = string.Empty, actualNameInServer = string.Empty, displayName = string.Empty, ext = string.Empty; IList <AMSUpload> amsUpload = new List <AMSUpload>(); // amsUpload.Add(new AMSUpload() { FileName = displayName, FileType = ext, ServerName = actualNameInServer, FilePath = fileName, ProjectID = customer, ProjectName = customerName, OrderNo = "", Creator = UserInfo.Name, CreateTime = createDate, Updator = "", UpdateTime = createDate, Status = false }); if (string.IsNullOrEmpty(targetPath) || !Path.IsPathRooted(targetPath)) { return(new { msg = "程序出错!" }.ToJsonString()); } try { if (Request.Files.Count > 0) { HttpPostedFileBase hpf = Request.Files[0] as HttpPostedFileBase; if (hpf.ContentLength > 0) { if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } displayName = Path.GetFileName(hpf.FileName); ext = Path.GetExtension(hpf.FileName); if (isMultiple && !ext.ToLower().Equals(".zip")) { return(new { msg = "批量上传,请用zip格式压缩" }.ToJsonString()); } //actualNameInServer = displayName.Substring(0, displayName.Length - ext.Length + 1) + DateTime.Now.ToString("yyyyMMddHHmmss") + ext; actualNameInServer = UserInfo.ProjectName + DateTime.Now.ToString("yyyyMMddHHmmss") + ext; url = Path.Combine(targetPath, actualNameInServer); hpf.SaveAs(url); hpf.InputStream.Close(); if (ext.ToLower().Equals(".zip") && isMultiple) { IList <string> unZipedFileName = new List <string>(); ZipHelper.UnZip(url, targetPath, unZipedFileName); MyFile.Delete(url); unZipedFileName.Each((k, fileName) => { actualNameInServer = Path.GetFileName(fileName); ext = Path.GetExtension(fileName); //string groupID = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(actualNameInServer)); displayName = Path.GetFileNameWithoutExtension(Path.GetFileNameWithoutExtension(actualNameInServer)); createDate = DateTime.Now; amsUpload.Add(new AMSUpload() { FileName = displayName, FileType = ext, ServerName = actualNameInServer, FilePath = fileName, ProjectID = UserInfo.ProjectID, ProjectName = UserInfo.ProjectName, OrderNo = "", Creator = UserInfo.Name, CreateTime = createDate, Updator = "", UpdateTime = createDate, Status = false }); }); } else { amsUpload.Add(new AMSUpload() { FileName = displayName, FileType = ext, ServerName = actualNameInServer, FilePath = url, ProjectID = UserInfo.ProjectID, ProjectName = UserInfo.ProjectName, OrderNo = "", Creator = UserInfo.Name, CreateTime = DateTime.Now, Updator = "", UpdateTime = DateTime.Now, Status = false }); } AMSUploadService service = new AMSUploadService(); Response <IEnumerable <AMSUpload> > response = service.AddAMSUpload(new AddAMSUploadRequest() { amsUpload = amsUpload, IsCoverOld = isCoverOld }); if (response.IsSuccess) { if (isMultiple) { return(new { msg = "批量上传文件成功", aids = response.Result.Select(a => a.ID), anms = response.Result.Select(a => a.ServerName), times = response.Result.Select(a => a.CreateTime), creators = response.Result.Select(a => a.Creator) }.ToJsonString()); } else { return(new { msg = "上传文件成功", gid = response.Result.First().ID, aid = response.Result.First().ID, anm = response.Result.First().ServerName, time = response.Result.First().CreateTime, creator = response.Result.First().Creator }.ToJsonString()); } } else { return(new { msg = "上传文件失败!" }.ToJsonString()); } } } return(new { msg = "文件无内容" }.ToJsonString()); } catch (Exception ex) { return(new { msg = ex.Message }.ToJsonString()); } }