public string ToJsonString() { JsonProfile jsonProfile = new JsonProfile { File = FileName, Clipboard = Text, Type = ClipBoardTypeToString(GetProfileType()) }; JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(jsonProfile)); }
internal static void ReportInternalEvent( int type, string name, string value, Dictionary <string, object> environment) { if (type >= 1 && type <= 99 && (type != 14 && type != 15)) { return; } byte[] numArray = value == null ? (byte[])null : Encoding.UTF8.GetBytes(value); string environment1 = environment != null?environment.ToJson(JsonProfile.GetCompact(), (System.Type) null, 1) : (string)null; YandexMetrica.Report(EventFactory.Create((ReportMessage.Session.Event.EventType)type, numArray, name, environment1)); }
/// <summary> /// Returns the author profile as a JsonProfile object for json serialization. /// </summary> /// <param name="username"></param> /// <returns></returns> public static JsonProfile ToJson(string username) { var j = new JsonProfile(); var p = Profiles.Find(ap => ap.UserName.Equals(username, StringComparison.OrdinalIgnoreCase)); if (p != null) { j.AboutMe = p.AboutMe; j.Birthday = p.Birthday.ToShortDateString(); j.CityTown = p.CityTown; j.Country = p.Country; j.DisplayName = p.DisplayName; j.EmailAddress = p.EmailAddress; j.PhoneFax = p.PhoneFax; j.FirstName = p.FirstName; j.Private = p.Private.ToString(); j.LastName = p.LastName; j.MiddleName = p.MiddleName; j.PhoneMobile = p.PhoneMobile; j.PhoneMain = p.PhoneMain; j.PhotoUrl = p.PhotoUrl; j.RegionState = p.RegionState; } else { j.AboutMe = ""; j.Birthday = "01/01/1900"; j.CityTown = ""; j.Country = ""; j.DisplayName = username; j.EmailAddress = ""; j.PhoneFax = ""; j.FirstName = username; j.Private = "yes"; j.LastName = ""; j.MiddleName = ""; j.PhoneMobile = ""; j.PhoneMain = ""; j.PhotoUrl = ""; j.RegionState = ""; } return(j); }
private static Profile GetProfileBy(ClipboardType type, JsonProfile jsonProfile, IWebDav webDav) { switch (type) { case ClipboardType.Text: return(new TextProfile(jsonProfile.Clipboard)); case ClipboardType.File: { if (FileIsImage(jsonProfile.File)) { return(new ImageProfile(jsonProfile, webDav)); } return(new FileProfile(jsonProfile, webDav)); } case ClipboardType.Image: return(new ImageProfile(jsonProfile, webDav)); } return(null); }
public ImageProfile(JsonProfile jsonProfile, IWebDav webdav) : base(jsonProfile, webdav) { }
private bool LoadJsonProfile(string profile) { // TODO: 测试 // TODO: FLAC -> lossless(auto) string profileStr = File.ReadAllText(profile); JsonProfile okeProj = JsonConvert.DeserializeObject <JsonProfile>(profileStr); DirectoryInfo projDir = new DirectoryInfo(wizardInfo.ProjectFile).Parent; // 检查参数 if (okeProj.Version != 2) { return(false); } if (okeProj.EncoderType.ToLower() != "x265") { return(false); } wizardInfo.EncoderType = okeProj.EncoderType.ToLower(); // 获取编码器全路径 FileInfo encoder = new FileInfo(projDir.FullName + "\\" + okeProj.Encoder); if (encoder.Exists) { wizardInfo.EncoderPath = encoder.FullName; wizardInfo.EncoderInfo = this.GetEncoderInfo(wizardInfo.EncoderPath); } wizardInfo.EncoderParam = okeProj.EncoderParam; Dictionary <string, ComboBoxItem> comboItems = new Dictionary <string, ComboBoxItem>() { { "MKV", MKVContainer }, { "MP4", MP4Container }, { "HEVC", HEVCVideo }, { "AVC", AVCVideo }, { "FLAC", FLACAudio }, { "AAC", AACAudio }, }; // 设置封装格式 wizardInfo.ContainerFormat = okeProj.ContainerFormat.ToUpper(); if (wizardInfo.ContainerFormat != "MKV" && wizardInfo.ContainerFormat != "MP4" && wizardInfo.ContainerFormat != "NULL" && wizardInfo.ContainerFormat != "RAW") { return(false); } comboItems[wizardInfo.ContainerFormat].IsSelected = true; // 设置视频编码 if (okeProj.VideoFormat.ToUpper() != "HEVC") { return(false); } wizardInfo.VideoFormat = okeProj.VideoFormat.ToUpper(); comboItems[wizardInfo.VideoFormat].IsSelected = true; if (okeProj.AudioTracks.Count > 0) { // 包含音轨 wizardInfo.AudioFormat = okeProj.AudioTracks[0].Format.ToUpper(); wizardInfo.AudioBitrate = okeProj.AudioTracks[0].Bitrate; foreach (var track in okeProj.AudioTracks) { wizardInfo.AudioTracks.Add(track); } } if (wizardInfo.AudioFormat != "FLAC" && wizardInfo.AudioFormat != "AAC" && wizardInfo.AudioFormat != "ALAC") { return(false); } comboItems[wizardInfo.AudioFormat].IsSelected = true; var scriptFile = new FileInfo(projDir.FullName + "\\" + okeProj.InputScript); if (scriptFile.Exists) { wizardInfo.InputScript = scriptFile.FullName; wizardInfo.VSScript = File.ReadAllText(wizardInfo.InputScript); } // 预览 wizardInfo.ProjectPreview += "项目名字: " + wizardInfo.TaskNamePrefix; wizardInfo.ProjectPreview += "\n\n编码器类型: " + wizardInfo.EncoderType; wizardInfo.ProjectPreview += "\n编码器路径: \n" + wizardInfo.EncoderPath; wizardInfo.ProjectPreview += "\n编码参数: \n" + wizardInfo.EncoderParam; wizardInfo.ProjectPreview += "\n\n封装格式: " + wizardInfo.ContainerFormat; wizardInfo.ProjectPreview += "\n视频编码: " + wizardInfo.VideoFormat; wizardInfo.ProjectPreview += "\n音频编码(主音轨): " + wizardInfo.AudioFormat; return(true); }
public FileProfile(JsonProfile jsonProfile, IWebDav webDav) { FileName = jsonProfile.File; _webDav = webDav; SetMd5(jsonProfile.Clipboard); }
public static ReportMessage.Session.Event Create <TItem>( string name, TItem serializableItem) { return(EventFactory.Create(ReportMessage.Session.Event.EventType.EVENT_CLIENT, ((object)serializableItem).ToJson(JsonProfile.GetFormatted(), (System.Type)null, 1), name)); }