private void UpdateByUpload() { if (HifFile.PostedFile == null || HifFile.PostedFile.FileName == "") { return; } var filePath = HifFile.PostedFile.FileName; if (!StringUtils.EqualsIgnoreCase(Path.GetExtension(filePath), ".nupkg")) { FailMessage("必须上传后缀为.nupkg的文件"); return; } var idAndVersion = Path.GetFileNameWithoutExtension(filePath); var directoryPath = PathUtils.GetPackagesPath(idAndVersion); var localFilePath = PathUtils.Combine(directoryPath, idAndVersion + ".nupkg"); if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } HifFile.PostedFile.SaveAs(localFilePath); ZipUtils.UnpackFiles(localFilePath, directoryPath); AuthRequest.AddAdminLog("手动升级 SiteServer CMS 版本:" + idAndVersion); LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl()); }
private void UpdateByVersion() { //string errorMessage; //if (!SystemManager.GetPackageAndUpdate(TbVersion.Text, out errorMessage)) //{ // FailMessage($"手动升级 SiteServer CMS 版本失败:{errorMessage}"); // return; //} AuthRequest.AddAdminLog($"手动升级 SiteServer CMS 版本:{TbVersion.Text}"); LayerUtils.CloseAndRedirect(Page, PageManagement.GetRedirectUrl()); }
protected override void Render(HtmlTextWriter writer) { var builder = new StringBuilder(); var tabList = TabManager.GetTabList(TopId, SiteId); var treeContent = BuildNavigationTree(tabList); if (!string.IsNullOrEmpty(treeContent)) { var linkHtml = string.Empty; if (string.IsNullOrEmpty(TopId) && PermissionList.Contains(ConfigManager.PluginsPermissions.Management)) { linkHtml = $@"<a id=""updatePackagesLink"" href=""{PageUtils.GetLoadingUrl(PageManagement.GetRedirectUrl(4))}"" onclick=""closeMenu()"" class=""badge badge-warning"" style=""display: none"" target=""right""></a>"; } builder.Append($@"<li class=""text-muted menu-title"">{Title}{linkHtml}</li>{treeContent}"); } writer.Write(builder); }
public PageServices() { pageManagement = new PageManagement(); }
public override void LoadSubtitle(Subtitle subtitle, List <string> lines, string fileName) { const int startPosition = 256 * 3; // First 256 bytes block is just id, two next blocks are ProgramManagementInformation, then comes the list of PageManagementInformations _errorCount = 0; subtitle.Paragraphs.Clear(); subtitle.Header = null; var buffer = FileUtil.ReadAllBytesShared(fileName); int index = startPosition; string label = Encoding.ASCII.GetString(buffer, 0, 8); if (label != "DCAPTION" && label != "BCAPTION" && label != "MCAPTION") { return; } var programManagementInformation = new ProgramManagement(buffer, 256 + 4); while (index + 255 < buffer.Length) { if (buffer[index + 4] == 0x2a) // Page management information { int blockstart = index; int length = (buffer[index + 2] << 8) + buffer[index + 3]; index += 5; var pageManagementInformationLength = (buffer[index++] << 8) + buffer[index++]; var pageManagementInformation = new PageManagement(buffer, index); index += pageManagementInformationLength; if (buffer[index] == 0x3a) // Caption text page management data { index++; var captionTextPageManagementLength = (buffer[index++] << 8) + buffer[index++]; var captionTextPageManagement = new CaptionTextPageManagement(buffer, index); index += captionTextPageManagementLength; if (buffer[index] == 0x4a) // Caption text data { index++; var subtitleDataLength = (buffer[index++] << 8) + buffer[index++]; try { var captionText = new CaptionText(buffer, index, captionTextPageManagement.Iso639LanguageCode); var p = new Paragraph { StartTime = pageManagementInformation.GetStartTime(), EndTime = pageManagementInformation.GetEndTime() }; foreach (var unit in captionText.CaptionTextUnits) { foreach (var text in unit.AribText.Texts) { p.Text = (p.Text + Environment.NewLine + text.Text).Trim(); } } subtitle.Paragraphs.Add(p); } catch { _errorCount++; } } } index = RoundUp(blockstart + length, 256); } else { index += 256; } } for (int i = 0; i < subtitle.Paragraphs.Count - 1; i++) { var paragraph = subtitle.Paragraphs[i]; if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.001) { var next = subtitle.Paragraphs[i + 1]; paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; } } if (subtitle.Paragraphs.Count > 0 && Math.Abs(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds) < 0.001) { var p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text); } subtitle.Renumber(); }
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName) { const int startPosition = 256 * 3; // First 256 bytes block is just id, two next blocks are ProgramManagementInformation, then comes the list of PageManagementInformations _errorCount = 0; subtitle.Paragraphs.Clear(); subtitle.Header = null; var buffer = FileUtil.ReadAllBytesShared(fileName); int index = startPosition; string label = Encoding.ASCII.GetString(buffer, 0, 8); if (label != "DCAPTION" && label != "BCAPTION" && label != "MCAPTION") return; var programManagementInformation = new ProgramManagement(buffer, 256 + 4); while (index + 255 < buffer.Length) { if (buffer[index + 4] == 0x2a) // Page management information { int blockstart = index; int length = (buffer[index + 2] << 8) + buffer[index + 3]; index += 5; var pageManagementInformationLength = (buffer[index++] << 8) + buffer[index++]; var pageManagementInformation = new PageManagement(buffer, index); index += pageManagementInformationLength; if (buffer[index] == 0x3a) // Caption text page management data { index++; var captionTextPageManagementLength = (buffer[index++] << 8) + buffer[index++]; var captionTextPageManagement = new CaptionTextPageManagement(buffer, index); index += captionTextPageManagementLength; if (buffer[index] == 0x4a) // Caption text data { index++; var subtitleDataLength = (buffer[index++] << 8) + buffer[index++]; try { var captionText = new CaptionText(buffer, index, captionTextPageManagement.Iso639Languagecode); var p = new Paragraph { StartTime = pageManagementInformation.GetStartTime(), EndTime = pageManagementInformation.GetEndTime() }; foreach (var unit in captionText.CaptionTextUnits) { foreach (var text in unit.AribText.Texts) { p.Text = (p.Text + Environment.NewLine + text.Text).Trim(); } } subtitle.Paragraphs.Add(p); } catch { _errorCount++; } } } index = RoundUp(blockstart + length, 256); } else { index += 256; } } for (int i = 0; i < subtitle.Paragraphs.Count - 1; i++) { var paragraph = subtitle.Paragraphs[i]; if (Math.Abs(paragraph.EndTime.TotalMilliseconds) < 0.001) { var next = subtitle.Paragraphs[i + 1]; paragraph.EndTime.TotalMilliseconds = next.StartTime.TotalMilliseconds - Configuration.Settings.General.MinimumMillisecondsBetweenLines; } } if (subtitle.Paragraphs.Count > 0 && Math.Abs(subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds) < 0.001) { var p = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1]; p.EndTime.TotalMilliseconds = p.StartTime.TotalMilliseconds + Utilities.GetOptimalDisplayMilliseconds(p.Text); } subtitle.Renumber(); }