public IHttpActionResult UploadAttachement(string projectId) { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; if (FileCollect.Count > 0) //如果集合的数量大于0 { var entity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectId && e.IsHistory == false); if (entity == null) { entity = new ClosureExecutiveSummary(); entity.Id = Guid.NewGuid(); entity.CreateTime = DateTime.Now; entity.CreatorAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.ProjectId = projectId; ClosureExecutiveSummary.Add(entity); } for (int i = 0; i < FileCollect.Count; i++) { var fileSave = FileCollect[i]; //用key获取单个文件对象HttpPostedFile string fileName = Path.GetFileName(fileSave.FileName); string fileExtension = Path.GetExtension(fileSave.FileName); var current = System.Web.HttpContext.Current; string internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; fileSave.SaveAs(absolutePath); Attachment att = new Attachment(); att.InternalName = internalName; att.RefTableName = "ClosureExecutiveSummary"; att.RefTableID = entity.Id.ToString(); att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; att.CreateTime = DateTime.Now; att.ID = Guid.NewGuid(); att.TypeCode = "Attachment"; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; Attachment.Add(att); } } return(Ok()); }
private async Task AddAttachment() { //IsBusy = true; var alertMessage = "File Loaded!"; var alertTitle = "Message"; var okButtonLabel = "OK"; //bool tasklogs = true; FileData myResult = null; try { var crossFilePicker = Plugin.FilePicker.CrossFilePicker.Current; myResult = await crossFilePicker.PickFile(); if (myResult != null) { if (!string.IsNullOrEmpty(myResult.FileName)) //Just the file name, it doesn't has the path { //foreach (byte b in myResult.DataArray) //Empty array // b.ToString(); var _Attachment = new Attachment() { name = myResult.FileName, dataArray = myResult.DataArray, path = myResult.FilePath }; Attachment.Add(_Attachment); } } } catch (Exception ex) { alertTitle = "Something went wrong!"; alertMessage = "Contact the system administrator."; ErrorMessage = ex.Message; ErrorVisible = true; } finally { //IsBusy = false; } if (myResult != null) { await App.Current.MainPage.DisplayAlert(alertTitle, alertMessage, okButtonLabel); } ////await App.Navigator.PopAsync(); //if (tasklogs == false) //{ // await App.Navigator.PopAsync(); //} }
public void SaveRenewalLegalApprovalPDF(string refTableName, string projectId, Guid requirementId, string filePath) { using (TransactionScope sope = new TransactionScope()) { var refTableId = Attachment.GetRefTableId(refTableName, projectId); string fileName = Path.GetFileName(filePath); string internalName = Guid.NewGuid() + ".pdf"; var current = HttpContext.Current; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; File.Copy(filePath, absolutePath, true); Attachment att = Attachment.Get(refTableId, requirementId); if (att == null) { att = new Attachment(); att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = ".pdf"; att.Length = null; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; att.ID = Guid.NewGuid(); att.RequirementId = requirementId; att.TypeCode = ""; Attachment.Add(att); } else { att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = ".pdf"; att.Length = null; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; Attachment.Update(att); } sope.Complete(); } }
public IHttpActionResult UploadRecordAttachment(Guid recordId) { using (TransactionScope tranScope = new TransactionScope()) { var files = HttpContext.Current.Request.Files; List <Attachment> attachments = new List <Attachment>(); for (int i = 0; i < files.Count; i++) { var file = files[i]; string fileName = Path.GetFileName(file.FileName); string fileExtension = Path.GetExtension(file.FileName); var current = System.Web.HttpContext.Current; string internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; file.SaveAs(absolutePath); Attachment att = new Attachment(); att.InternalName = internalName; att.RefTableName = "RenewalLLNegotiationRecord"; att.RefTableID = recordId.ToString(); att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = file.ContentLength; att.CreateTime = DateTime.Now; att.UpdateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; att.ID = Guid.NewGuid(); att.TypeCode = ""; attachments.Add(att); Attachment.Add(attachments.ToArray()); } tranScope.Complete(); } return(Ok()); }
private void AddAttachment() { try { if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } string fileName = openFileDialog.FileName; var fi = new FileInfo(fileName); Attachment attachment = mTicket.NewAttachment(); attachment.Name = fi.Name.Substring(0, Math.Min(255, fi.Name.Length)); // Max 255 characters. attachment.SetContents(File.ReadAllBytes(fileName)); attachment.Add(mContext); // Flush. mContext.Flush(); ShowAttachments(); FormUtil.SelectNew(attachmentsListView, attachment); } catch (Exception exception) { MessageBox.Show( exception.Message, Resources.String_Error, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, FormUtil.GetMessageBoxOptions(this)); ShowAttachments(); } }
public Get(string filePath) { var file = Path.Combine(Path.GetTempPath(), $"nemu_{new Random().Next(0, 999999999):D9}.xml"); var ec = new Run().Execute($"\"{FFmpeg.Probe}\" -hide_banner -print_format xml -show_format -show_streams \"{filePath}\" > \"{file}\"", Path.GetTempPath()); try { var xml = XDocument.Load(file); var format = from a in xml.Descendants("format") select new { fmtcode = a.Attribute("format_name").Value, fmtlong = a.Attribute("format_long_name").Value, size = a.Attribute("size").Value, bitrate = a.Attribute("bit_rate")?.Value, duration = a.Attribute("duration")?.Value, }; var video = from a in xml.Descendants("stream") where string.Equals("video", (string)a.Attribute("codec_type"), IC) select new { id = (int)a.Attribute("index"), lang = a.Elements("tag").SingleOrDefault(x => string.Equals(x.Attribute("key").Value, "language", IC))?.Attribute("value")?.Value, codec = a.Attribute("codec_name").Value, pixfmt = a.Attribute("pix_fmt")?.Value, bpc = a.Attribute("bits_per_raw_sample")?.Value, width = a.Attribute("width").Value, height = a.Attribute("height").Value, fps = a.Attribute("r_frame_rate")?.Value, afps = a.Attribute("avg_frame_rate")?.Value, framecount = a.Attribute("nb_frames")?.Value, duration = a.Attribute("duration")?.Value, }; var audio = from a in xml.Descendants("stream") where string.Equals("audio", (string)a.Attribute("codec_type"), IC) select new { id = (int)a.Attribute("index"), lang = a.Elements("tag").SingleOrDefault(x => string.Equals(x.Attribute("key").Value, "language", IC))?.Attribute("value")?.Value, codec = a.Attribute("codec_name").Value, sample = a.Attribute("sample_rate").Value, bitdepth = a.Attribute("sample_fmt").Value, channel = a.Attribute("channels").Value, duration = a.Attribute("duration")?.Value, }; var subtitle = from a in xml.Descendants("stream") where string.Equals("subtitle", (string)a.Attribute("codec_type"), IC) select new { id = (int)a.Attribute("index"), lang = a.Elements("tag").SingleOrDefault(x => string.Equals(x.Attribute("key").Value, "language", IC))?.Attribute("value")?.Value, codec = a.Attribute("codec_name").Value, }; var attachment = from a in xml.Descendants("stream") where string.Equals("attachment", (string)a.Attribute("codec_type"), IC) select new { id = (int)a.Attribute("index"), filename = a.Elements("tag").SingleOrDefault(x => string.Equals(x.Attribute("key").Value, "filename", IC))?.Attribute("value")?.Value, mimetype = a.Elements("tag").SingleOrDefault(x => string.Equals(x.Attribute("key").Value, "mimetype", IC))?.Attribute("value")?.Value, }; FilePath = filePath; foreach (var item in format) { ulong filesize = 0; ulong bitrate = 0; float time = 0; ulong.TryParse(item.size, out filesize); ulong.TryParse(item.bitrate, out bitrate); float.TryParse(item.duration, out time); FormatName = item.fmtcode; FormatNameFull = item.fmtlong; FileSize = filesize; BitRate = bitrate; Duration = time; break; // single only } foreach (var item in video) { int bpc = 8; int pix = 420; int w = 0; int h = 0; int fc = 0; int.TryParse(item.bpc, out bpc); int.TryParse(item.width, out w); int.TryParse(item.height, out h); int.TryParse(item.framecount, out fc); float num = 0; float den = 0; float.TryParse(item.fps.Split('/')[0], out num); float.TryParse(item.fps.Split('/')[1], out den); float fps = num / den; float.TryParse(item.afps.Split('/')[0], out num); float.TryParse(item.afps.Split('/')[1], out den); float afps = num / den; float du = Duration; if (!string.IsNullOrEmpty(item.duration)) { if (float.TryParse(item.duration, out du)) { du = Duration; } } if (string.IsNullOrEmpty(item.pixfmt)) { var mpix = Regex.Match(item.pixfmt, @"yuv(\d+)"); if (mpix.Success) { int.TryParse(mpix.Groups[1].Value, out pix); } else { pix = 420; } } if (bpc == 0) { var mbpc = Regex.Match(item.pixfmt, @"yuv\d+p(\d+)"); if (mbpc.Success) { int.TryParse(mbpc.Groups[1].Value, out bpc); } else { bpc = 8; } } Video.Add(new StreamVideo { Id = item.id, Language = string.IsNullOrEmpty(item.lang) ? "und" : item.lang, Codec = item.codec, Chroma = pix, BitDepth = bpc, Width = w, Height = h, FrameRateConstant = fps == afps, FrameRate = fps, FrameRateAvg = afps, FrameCount = fc, Duration = du, }); } foreach (var item in audio) { int sample = 44100; int bitdepth = 16; int channel = 2; int.TryParse(item.sample, out sample); int.TryParse(item.bitdepth, out bitdepth); int.TryParse(item.channel, out channel); if (bitdepth == 0) { bitdepth = 16; } if (bitdepth >= 32) { bitdepth = 24; } float du = 0; float.TryParse(item.duration, out du); Audio.Add(new StreamAudio { Id = item.id, Language = string.IsNullOrEmpty(item.lang) ? "und" : item.lang, Codec = item.codec, SampleRate = sample, BitDepth = bitdepth, Channel = channel, Duration = du, }); } foreach (var item in subtitle) { Subtitle.Add(new StreamSubtitle { Id = item.id, Language = string.IsNullOrEmpty(item.lang) ? "und" : item.lang, Codec = item.codec, }); } foreach (var item in attachment) { Attachment.Add(new StreamAttachment { Id = item.id, FileName = item.filename, MimeType = item.mimetype }); } // remove xml File.Delete(file); // error display if (ec > 0) { Console.ForegroundColor = ConsoleColor.Red; Console.Write(Run.errorString); Console.ResetColor(); } } catch (Exception) { throw; } }
public IHttpActionResult Upload(string projectId, string refTableName, Guid?requirementId = null) { using (TransactionScope tranScope = new TransactionScope()) { var refTableId = Attachment.GetRefTableId(refTableName, projectId); if (refTableId == Guid.Empty.ToString()) { var newId = Guid.NewGuid(); refTableId = newId.ToString(); switch (refTableName) { case "MajorLeaseChangePackage": { var entity = new MajorLeaseChangePackage(); entity.ProjectId = projectId; entity.Id = newId; entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.Add(); } break; case "ReimageSummary": { var entity = new ReimageSummary(); entity.ProjectId = projectId; entity.Id = newId; entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.Add(); } break; case "ReimageConsInfo": { var entity = new ReimageConsInfo(); entity.ProjectId = projectId; entity.Id = newId; entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.Add(); } break; case "ReimagePackage": { var entity = new ReimagePackage(); entity.ProjectId = projectId; entity.Id = newId; entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.Add(); } break; case "RebuildLegalReview": { var entity = new RebuildLegalReview(); entity.ProjectId = projectId; entity.Id = newId; entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.Add(); } break; case "ClosureLegalReview": { var entity = new ClosureLegalReview(); entity.ProjectId = projectId; entity.Id = newId; entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.Add(); } break; case "ClosureExecutiveSummary": { var entity = new ClosureExecutiveSummary(); entity.ProjectId = projectId; entity.Id = newId; entity.CreateTime = DateTime.Now; entity.CreatorAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.Add(); } break; case "ClosurePackage": { var entity = new ClosurePackage(); entity.ProjectId = projectId; entity.Id = newId; entity.CreateTime = DateTime.Now; entity.CreateUserAccount = ClientCookie.UserCode; entity.IsHistory = false; entity.Add(); } break; } } var userRole = ProjectUsers.Get(ClientCookie.UserCode, projectId); var files = HttpContext.Current.Request.Files; if (requirementId.HasValue) { var attReq = AttachmentRequirement.Get(requirementId.Value); var projectInfo = ProjectInfo.Get(projectId, attReq.FlowCode); var store = StoreBasicInfo.GetStorInfo(projectInfo.USCode); var attachNode = NodeInfo.FirstOrDefault(n => n.FlowCode == attReq.FlowCode && n.Code == attReq.NodeCode); if (attachNode != null) { ProjectInfo.FinishNode(projectId, attReq.FlowCode, attReq.NodeCode); } var file = files[0]; string fileName = Path.GetFileName(file.FileName); string fileExtension = Path.GetExtension(file.FileName); var current = System.Web.HttpContext.Current; string internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; file.SaveAs(absolutePath); Attachment att = Attachment.Get(refTableId, requirementId.Value); if (att == null) { att = new Attachment(); att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = file.ContentLength; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; att.ID = Guid.NewGuid(); att.RequirementId = requirementId; att.TypeCode = ""; Attachment.Add(att); } else { att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = file.ContentLength; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; Attachment.Update(att); } //TempClosure上传SignAgreement //if (requirementId.Value.Equals(new Guid("1E9B17AF-357A-4DC9-8A60-17766663FB75"))) //{ // var url = "/TempClosure/Main#/ClosureMemo?projectId=" + projectId; // var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == projectId && pu.RoleCode == ProjectUserRoleCode.AssetActor); // var title = string.Concat(projectId, " ", store.NameZHCN, " ", store.NameENUS); // TaskWork.Finish(t => t.ReceiverAccount == ClientCookie.UserCode && t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == FlowCode.TempClosure_ClosurePackage); // //TaskWork.SendTask(projectId, title, projectInfo.USCode, url, actor, FlowCode.TempClosure, FlowCode.TempClosure_ClosureMemo, "Start"); //} } else { List <Attachment> attachments = new List <Attachment>(); string typeCode = ""; if (refTableName == "RebuildLegalReview") { typeCode = "Contract"; } for (int i = 0; i < files.Count; i++) { var file = files[i]; string fileName = Path.GetFileName(file.FileName); string fileExtension = Path.GetExtension(file.FileName); var current = System.Web.HttpContext.Current; string internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; file.SaveAs(absolutePath); Attachment att = new Attachment(); att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = file.ContentLength; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; att.ID = Guid.NewGuid(); att.RequirementId = requirementId; att.TypeCode = typeCode; attachments.Add(att); } Attachment.Add(attachments.ToArray()); } tranScope.Complete(); return(Ok()); } }
public IHttpActionResult GenExecutiveSummaty(ClosureExecutiveSummary entity) { if (!ClosureExecutiveSummary.Any(i => i.ProjectId == entity.ProjectId && i.IsHistory == false)) { if (entity.Id == Guid.Empty || entity.Id == null) { entity.Id = Guid.NewGuid(); } entity.CreateTime = DateTime.Now; entity.CreatorAccount = ClientCookie.UserCode; ClosureExecutiveSummary.Add(entity); } else { ClosureExecutiveSummary.Update(entity); } var current = System.Web.HttpContext.Current; string path = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Executive_Summary_Template; string internalFileName = Guid.NewGuid() + ".xlsx"; string filePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalFileName; File.Copy(path, filePath); var fileInfo = new FileInfo(filePath); var excelPMTDirector = new ExcelDataInputDirector(fileInfo, ExcelDataInputType.ClosureExecutiveSummary); var closure = ClosureInfo.GetByProjectId(entity.ProjectId); var store = StoreBasicInfo.GetStore(closure.USCode); var inputInfo = new ExcelInputDTO { StoreNameCN = store.StoreBasicInfo.NameZHCN, USCode = store.StoreBasicInfo.StoreCode, City = store.StoreBasicInfo.CityENUS, Market = store.StoreBasicInfo.MarketENUS, OpenDate = store.StoreBasicInfo.OpenDate, Floor = store.StoreSTLocation.Floor, TotalArea = store.StoreSTLocation.TotalArea, TotalSeatsNo = store.StoreSTLocation.TotalSeatsNo, BE = store.StoreBEInfoList.Count, RentType = store.StoreContractInfo.RentType, RentStructure = store.StoreContractInfo.RentStructure, MiniMarket = entity.MiniMarket, StoreLocation = entity.StoreLocation, CurrentSituation = entity.CurrentSituation, NegotiationHistory = entity.NegotiationHistory, ProposedSolution = entity.ProposedSolution, SalesTransfer = entity.SalesTransfer }; var leaseRecapID = StoreContractInfo.SearchByProject(entity.ProjectId).FirstOrDefault().LeaseRecapID ?? 0; var storeAtt = StoreContractInfoAttached.Search(c => c.LeaseRecapID == leaseRecapID.ToString()).OrderByDescending(e => e.CreateDate).FirstOrDefault(); if (storeAtt != null) { inputInfo.LeasingTerm = store.StoreContractInfo.LeasePurchaseTerm; } if (store.StoreContractInfo.RentCommencementDate.HasValue) { inputInfo.RentCommencementDate = store.StoreContractInfo.RentCommencementDate.Value; } if (store.StoreContractInfo.EndDate.HasValue) { inputInfo.LeaseExpirationDate = store.StoreContractInfo.EndDate.Value; } var toolEntity = ClosureTool.Get(closure.ProjectId); if (toolEntity != null) { if (toolEntity.TotalSales_Adjustment_RMB != null) { inputInfo.TotalSales_TTM = string.Format("{0:f}", toolEntity.TotalSales_Adjustment_RMB); } if (toolEntity.CompSales_Adjustment != null) { inputInfo.SalesComp_TTM = string.Format("{0:f}", toolEntity.CompSales_Adjustment); } if (toolEntity.CompCG_Adjustment != null) { inputInfo.GCComp_TTM = string.Format("{0:f}", toolEntity.CompCG_Adjustment); } if (toolEntity.PAC_Adjustment != null) { inputInfo.PAC_TTM = string.Format("{0:f}", toolEntity.PAC_Adjustment); } if (toolEntity.SOI_Adjustment != null) { inputInfo.SOI_TTM = string.Format("{0:f}", toolEntity.SOI_Adjustment); } if (toolEntity.CashFlow_RMB_Adjustment != null) { inputInfo.CASHFLOW_TTM = string.Format("{0:f}", toolEntity.CashFlow_RMB_Adjustment); } if (toolEntity.TotalSales_TTMY1 != null) { inputInfo.TotalSales_TTMY1 = string.Format("{0:f}", toolEntity.TotalSales_TTMY1); } if (toolEntity.CompSales_TTMY1 != null) { inputInfo.CompSales_TTMY1 = string.Format("{0:f}", toolEntity.CompSales_TTMY1); } if (toolEntity.CompGC_TTMY1 != null) { inputInfo.CompGC_TTMY1 = string.Format("{0:f}", toolEntity.CompGC_TTMY1); } if (toolEntity.PAC_TTMY1 != null) { inputInfo.PAC_TTMY1 = string.Format("{0:f}", toolEntity.PAC_TTMY1); } if (toolEntity.SOI_TTMY1 != null) { inputInfo.SOI_TTMY1 = string.Format("{0:f}", toolEntity.SOI_TTMY1); } if (toolEntity.CashFlow_TTMY1 != null) { inputInfo.CashFlow_TTMY1 = string.Format("{0:f}", toolEntity.CashFlow_TTMY1); } if (toolEntity.TotalSales_TTMY2 != null) { inputInfo.TotalSales_TTMY2 = string.Format("{0:f}", toolEntity.TotalSales_TTMY2); } if (toolEntity.CompSales_TTMY2 != null) { inputInfo.CompSales_TTMY2 = string.Format("{0:f}", toolEntity.CompSales_TTMY2); } if (toolEntity.CompGC_TTMY2 != null) { inputInfo.CompGC_TTMY2 = string.Format("{0:f}", toolEntity.CompGC_TTMY2); } if (toolEntity.PAC_TTMY2 != null) { inputInfo.PAC_TTMY2 = string.Format("{0:f}", toolEntity.PAC_TTMY2); } if (toolEntity.SOI_TTMY2 != null) { inputInfo.SOI_TTMY2 = string.Format("{0:f}", toolEntity.SOI_TTMY2); } if (toolEntity.CashFlow_TTMY2 != null) { inputInfo.CashFlow_TTMY2 = string.Format("{0:f}", toolEntity.CashFlow_TTMY2); } List <StoreBEInfo> remoteBeList = new List <StoreBEInfo>(); List <StoreBEInfo> attachedBeList = new List <StoreBEInfo>(); StoreBEInfo mds = null; StoreBEInfo mcCafe = null; StoreBEInfo hour24 = null; if (store.StoreBEInfoList.Count > 0) { foreach (var beInfo in store.StoreBEInfoList) { switch (beInfo.BETypeName) { case "Remote Kiosk": remoteBeList.Add(beInfo); break; case "Attach Kiosk": attachedBeList.Add(beInfo); break; case "MDS": mds = beInfo; break; case "McCafe": mcCafe = beInfo; break; case "24 Hour": hour24 = beInfo; break; } } } inputInfo.RemoteKiosk1_Status = "No"; inputInfo.RemoteKiosk2_Status = "No"; inputInfo.RemoteKiosk3_Status = "No"; inputInfo.AttachedKiosk1_Status = "No"; inputInfo.AttachedKiosk2_Status = "No"; inputInfo.AttachedKiosk3_Status = "No"; inputInfo.MDS_Status = "No"; inputInfo.McCafe_Status = "No"; inputInfo.TwentyFourHour_Status = "No"; if (remoteBeList.Count > 0) { inputInfo.RemoteKiosk1_Status = "Yes"; inputInfo.RemoteKiosk1_OpenDate = remoteBeList[0].LaunchDate; if (remoteBeList.Count > 1) { inputInfo.RemoteKiosk2_Status = "Yes"; inputInfo.RemoteKiosk2_OpenDate = remoteBeList[1].LaunchDate; if (remoteBeList.Count > 2) { inputInfo.RemoteKiosk3_Status = "Yes"; inputInfo.RemoteKiosk3_OpenDate = remoteBeList[2].LaunchDate; } } } if (attachedBeList.Count > 0) { inputInfo.AttachedKiosk1_Status = "Yes"; inputInfo.AttachedKiosk1_OpenDate = attachedBeList[0].LaunchDate; if (attachedBeList.Count > 1) { inputInfo.AttachedKiosk2_Status = "Yes"; inputInfo.AttachedKiosk2_OpenDate = attachedBeList[1].LaunchDate; if (attachedBeList.Count > 2) { inputInfo.AttachedKiosk3_Status = "Yes"; inputInfo.AttachedKiosk3_OpenDate = attachedBeList[2].LaunchDate; } } } if (mds != null) { inputInfo.MDS_Status = "Yes"; inputInfo.MDS_OpenDate = mds.LaunchDate; } if (mcCafe != null) { inputInfo.McCafe_Status = "Yes"; inputInfo.McCafe_OpenDate = mcCafe.LaunchDate; } if (hour24 != null) { inputInfo.TwentyFourHour_Status = "Yes"; inputInfo.TwentyFourHour_OpenDate = hour24.LaunchDate; } var woEntity = ClosureWOCheckList.Get(closure.ProjectId); if (woEntity != null) { if (woEntity.LHI_NBV != null) { inputInfo.LHI_NBV = string.Format("{0:f}", woEntity.LHI_NBV); } if (woEntity.ESSD_NBV != null) { inputInfo.ESSD_NBV = string.Format("{0:f}", woEntity.ESSD_NBV); } if (woEntity.TotalCost_NBV != null) { inputInfo.TotalCost_NBV = string.Format("{0:f}", woEntity.TotalCost_NBV); } } } excelPMTDirector.Input(inputInfo); Attachment att = Attachment.GetAttachment("ClosureExecutiveSummary", entity.Id.ToString(), "Template"); if (att == null) { att = new Attachment(); att.RefTableName = "ClosureExecutiveSummary"; att.RefTableID = entity.Id.ToString(); att.CreateTime = DateTime.Now; att.ID = Guid.NewGuid(); att.TypeCode = "Template"; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = SiteFilePath.Executive_Summary_Template; att.InternalName = internalFileName; att.Extension = fileInfo.Extension; att.Length = Convert.ToInt32(fileInfo.Length); att.RequirementId = new Guid("79258ffb-c2ef-4eff-897d-ba8376c90071"); Attachment.Add(att); } else { att.CreateTime = DateTime.Now; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = SiteFilePath.Executive_Summary_Template; att.InternalName = internalFileName; att.Extension = fileInfo.Extension; att.Length = Convert.ToInt32(fileInfo.Length); att.RequirementId = new Guid("79258ffb-c2ef-4eff-897d-ba8376c90071"); Attachment.Update(att); } ProjectInfo.FinishNode(entity.ProjectId, FlowCode.Closure_ExecutiveSummary, NodeCode.Closure_ExecutiveSummary_Generate); return(Ok()); }
public IHttpActionResult UploadTemplate(string projectid) { HttpRequest request = System.Web.HttpContext.Current.Request; HttpFileCollection FileCollect = request.Files; string internalName = string.Empty; if (FileCollect.Count > 0) //如果集合的数量大于0 { ClosureWOCheckList entity = new ClosureWOCheckList(); //用key获取单个文件对象HttpPostedFile HttpPostedFile fileSave = FileCollect[0]; string fileName = Path.GetFileName(fileSave.FileName); string fileExtension = Path.GetExtension(fileSave.FileName); internalName = Guid.NewGuid() + fileExtension; string absolutePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalName; //通过此对象获取文件名 fileSave.SaveAs(absolutePath); var woEntity = ClosureExecutiveSummary.FirstOrDefault(e => e.ProjectId == projectid && e.IsHistory == false); if (woEntity == null) { woEntity = new ClosureExecutiveSummary(); woEntity.ProjectId = projectid; woEntity.Id = Guid.NewGuid(); woEntity.CreateTime = DateTime.Now; woEntity.CreatorAccount = ClientCookie.UserCode; ClosureExecutiveSummary.Add(woEntity); } Attachment att = Attachment.GetAttachment("ClosureExecutiveSummary", woEntity.Id.ToString(), "Template"); if (att == null) { att = new Attachment(); att.RefTableName = "ClosureExecutiveSummary"; att.RefTableID = woEntity.Id.ToString(); att.CreateTime = DateTime.Now; att.ID = Guid.NewGuid(); att.TypeCode = "Template"; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = fileName; att.InternalName = internalName; att.Name = fileName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; Attachment.Add(att); } else { att.CreateTime = DateTime.Now; att.CreatorID = ClientCookie.UserCode; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.Name = fileName; att.InternalName = internalName; att.Extension = fileExtension; att.Length = FileCollect[0].ContentLength; Attachment.Update(att); } //var closureInfo = closureHandler.GetByProjectId(projectid); //Store store = new Store(); //var storeInfo = store.GetStoreEntity(closureInfo.USCode); //string filePath = SiteFilePath.UploadFiles_DIRECTORY + "\\" + internalName; //Excel excel = new Excel(); //excel.Open(filePath); //var sheet = excel.Sheets["PMT"]; //sheet.Cells[1, 1].StrValue = closureInfo.StoreNameZHCN; //sheet.Cells[2, 1].StrValue = closureInfo.USCode; //if (storeInfo != null) //{ // sheet.Cells[3, 1].StrValue = storeInfo.CityName; // sheet.Cells[4, 1].StrValue = storeInfo.MarketName; // if (storeInfo.OpenDate != null) // { // sheet.Cells[5, 1].StrValue = storeInfo.OpenDate.Value.ToString("yyyy-MM-dd"); // } // sheet.Cells[7, 1].StrValue = storeInfo.TotalLeasedArea; // sheet.Cells[8, 1].StrValue = storeInfo.TotalSeatsNo; // sheet.Cells[10, 1].StrValue = storeInfo.LeasePurchaseTerm; // if (storeInfo.RentCommencementDate != null) // { // sheet.Cells[11, 1].StrValue = storeInfo.RentCommencementDate.Value.ToString("yyyy-MM-dd"); // } // if (storeInfo.EndDate != null) // { // sheet.Cells[12, 1].StrValue = storeInfo.EndDate.Value.ToString("yyyy-MM-dd"); // } // sheet.Cells[13, 1].StrValue = storeInfo.RentType; // sheet.Cells[13, 1].StrValue = storeInfo.RentStructure; //} //excel.Save(); } //return Ok(result); ProjectInfo.FinishNode(projectid, FlowCode.Closure_ExecutiveSummary, NodeCode.Finish); var resultStr = SiteInfo.WebUrl + "UploadFiles/" + internalName; return(Ok(resultStr)); }
public GetInfo(string FileMedia) { dynamic json = JsonConvert.DeserializeObject(new Run(FileMedia).Output); // General info FilePath = json.format.filename; FileSize = json.format.size; BitRate = json.format.bit_rate; Duration = json.format.duration; FormatName = json.format.format_name; FormatNameFull = json.format.format_long_name; // Capture stream type foreach (var stream in json.streams) { string type = stream.codec_type; if (string.Equals(type, "video", IgnoreCase)) { string r = stream.r_frame_rate; float.TryParse(r.Split('/')[0], out float rn); float.TryParse(r.Split('/')[1], out float rd); float rfps = rn / rd; string a = stream.avg_frame_rate; float.TryParse(a.Split('/')[0], out float an); float.TryParse(a.Split('/')[1], out float ad); float afps = an / ad; int pix = 420; if (!string.IsNullOrEmpty((string)stream.pix_fmt)) { var mpix = Regex.Match((string)stream.pix_fmt, @"yuv(\d+)"); if (mpix.Success) { int.TryParse(mpix.Groups[1].Value, out pix); } else { pix = 420; } } int bpc = stream.bits_per_raw_sample; if (bpc == 0) { var mbpc = Regex.Match((string)stream.pix_fmt, @"yuv\d+p(\d+)"); if (mbpc.Success) { int.TryParse(mbpc.Groups[1].Value, out bpc); } else { bpc = 8; } } string lang = stream.tags.language; if (string.IsNullOrEmpty(lang)) { lang = "und"; } Video.Add(new StreamVideo { Id = stream.index, Language = lang, Codec = stream.codec_name, Chroma = pix, BitDepth = stream.bits_per_raw_sample, Width = stream.width, Height = stream.height, FrameRateConstant = rfps == afps, FrameRate = rfps, FrameRateAvg = afps, FrameCount = (int)(Duration * afps), Duration = Duration, }); } if (string.Equals(type, "audio", IgnoreCase)) { int.TryParse((string)stream.sample_rate, out int sample); int.TryParse((string)stream.sample_fmt, out int bitdepth); int.TryParse((string)stream.channels, out int channel); if (bitdepth == 0) { bitdepth = 16; } else if (bitdepth >= 32) { bitdepth = 24; } string lang = stream.tags.language; if (string.IsNullOrEmpty(lang)) { lang = "und"; } Audio.Add(new StreamAudio { Id = stream.index, Language = lang, Codec = stream.codec_name, SampleRate = sample, BitDepth = bitdepth, Channel = channel, Duration = Duration, }); } if (string.Equals(type, "subtitle", IgnoreCase)) { string lang = stream.tags.language; if (string.IsNullOrEmpty(lang)) { lang = "und"; } Subtitle.Add(new StreamSubtitle { Id = stream.index, Language = lang, Codec = stream.codec_name, }); } if (string.Equals(type, "attachment", IgnoreCase)) { Attachment.Add(new StreamAttachment { Id = stream.index, FileName = stream.tags.filename, MimeType = stream.tags.mimetype }); } } }
public IHttpActionResult UploadAttachment(string flowCode, string typeCode, string usCode, Guid Id) { var refTableId = string.Empty; var refTableName = string.Empty; var projectInfo = ProjectInfo.Get(Id); var projectId = string.Empty; if (projectInfo == null) { projectId = ProjectInfo.CreateDLProject(Id, flowCode, usCode, NodeCode.Start, ClientCookie.UserCode, false); } else { projectId = projectInfo.ProjectId; } using (TransactionScope tranScope = new TransactionScope()) { switch (flowCode) { case FlowCode.Closure: refTableName = "ClosureInfo"; var closureInfo = ClosureInfo.FirstOrDefault(i => i.ProjectId == projectId); if (closureInfo != null) { refTableId = closureInfo.Id.ToString(); } else { closureInfo = new ClosureInfo(); closureInfo.Id = Guid.NewGuid(); closureInfo.ProjectId = projectId; closureInfo.USCode = usCode; closureInfo.CreateDate = DateTime.Now; closureInfo.CreateUserAccount = ClientCookie.UserCode; closureInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; closureInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; closureInfo.Add(); refTableId = closureInfo.Id.ToString(); } break; case FlowCode.Rebuild: refTableName = "RebuildInfo"; var rebuildInfo = RebuildInfo.FirstOrDefault(i => i.ProjectId == projectId); if (rebuildInfo != null) { refTableId = rebuildInfo.Id.ToString(); } else { rebuildInfo = new RebuildInfo(); rebuildInfo.Id = Guid.NewGuid(); rebuildInfo.ProjectId = projectId; rebuildInfo.USCode = usCode; rebuildInfo.CreateTime = DateTime.Now; rebuildInfo.CreateUserAccount = ClientCookie.UserCode; rebuildInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; rebuildInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; rebuildInfo.Add(); refTableId = rebuildInfo.Id.ToString(); } break; case FlowCode.MajorLease: refTableName = "MajorLeaseInfo"; var majorLeaseInfo = MajorLeaseInfo.FirstOrDefault(i => i.ProjectId == projectId); if (majorLeaseInfo != null) { refTableId = majorLeaseInfo.Id.ToString(); } else { majorLeaseInfo = new MajorLeaseInfo(); majorLeaseInfo.Id = Guid.NewGuid(); majorLeaseInfo.ProjectId = projectId; majorLeaseInfo.USCode = usCode; majorLeaseInfo.CreateTime = DateTime.Now; majorLeaseInfo.CreateUserAccount = ClientCookie.UserCode; majorLeaseInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; majorLeaseInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; majorLeaseInfo.Add(); refTableId = majorLeaseInfo.Id.ToString(); } break; case FlowCode.Renewal: refTableName = "RenewalInfo"; var renewalInfo = RenewalInfo.Get(projectId); if (renewalInfo != null) { refTableId = renewalInfo.Id.ToString(); } else { renewalInfo = new RenewalInfo(); renewalInfo.Id = Guid.NewGuid(); renewalInfo.ProjectId = projectId; renewalInfo.USCode = usCode; renewalInfo.CreateTime = DateTime.Now; renewalInfo.CreateUserAccount = ClientCookie.UserCode; renewalInfo.Add(); refTableId = renewalInfo.Id.ToString(); } break; case FlowCode.Reimage: refTableName = "ReimageInfo"; var reimageInfo = ReimageInfo.GetReimageInfo(projectId); if (reimageInfo != null) { refTableId = reimageInfo.Id.ToString(); } else { reimageInfo = new ReimageInfo(); reimageInfo.Id = Guid.NewGuid(); reimageInfo.ProjectId = projectId; reimageInfo.USCode = usCode; reimageInfo.CreateDate = DateTime.Now; reimageInfo.CreateUserAccount = ClientCookie.UserCode; reimageInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; reimageInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; reimageInfo.Add(); refTableId = reimageInfo.Id.ToString(); } break; } if (!string.IsNullOrEmpty(refTableId)) { var files = HttpContext.Current.Request.Files; var file = files[0]; string fileName = Path.GetFileName(file.FileName); string fileExtension = Path.GetExtension(file.FileName); var current = System.Web.HttpContext.Current; string internalName = Guid.NewGuid() + fileExtension; string absolutePath = current.Server.MapPath("~/") + "UploadFiles/" + internalName; file.SaveAs(absolutePath); Attachment att = Attachment.FirstOrDefault(i => i.RefTableID == refTableId && i.RefTableName == refTableName && i.TypeCode == typeCode); if (att != null) { att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = file.ContentLength; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; Attachment.Update(att); } else { att = new Attachment(); att.InternalName = internalName; att.RefTableName = refTableName; att.RefTableID = refTableId; att.RelativePath = "//"; att.Name = fileName; att.Extension = fileExtension; att.Length = file.ContentLength; att.CreateTime = DateTime.Now; att.CreatorNameZHCN = ClientCookie.UserNameZHCN; att.CreatorNameENUS = ClientCookie.UserNameENUS; att.CreatorID = ClientCookie.UserCode; att.ID = Guid.NewGuid(); att.TypeCode = typeCode; Attachment.Add(att); } } tranScope.Complete(); return(Ok()); } }