public void UpdateTagsCollection(string tagDisplayName, string tagValue, Dispatcher dispatcher) { bool tagFound = false; dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { foreach (TagInfo estop in _estopTags) { if (estop.TagName.Equals(tagDisplayName)) { int index = _estopTags.IndexOf(estop); _estopTags.RemoveAt(index); estop.TagName = tagDisplayName; estop.TagValue = tagValue; _estopTags.Insert(index, estop); tagFound = true; break; } } if (!tagFound) { TagInfo estop = new TagInfo(); estop.TagValue = tagValue; estop.TagName = tagDisplayName; _estopTags.Add(estop); } })); }
/// <summary> /// Copies the elements of the specified <see cref="TagInfo">TagInfo</see> array to the end of the collection. /// </summary> /// <param name="value">An array of type <see cref="TagInfo">TagInfo</see> containing the Components to add to the collection.</param> public void AddRange(TagInfo[] value) { for (int i = 0; (i < value.Length); i = (i + 1)) { this.Add(value[i]); } }
TagInfo li_root_tag; // This is the Last Import root tag public MetadataImporter () { tag_store = App.Instance.Database.Tags; tags_created = new Stack<Tag> (); li_root_tag = new TagInfo (Catalog.GetString ("Imported Tags"), LastImportIcon); }
public void UpdateTagsCollection(string tagDisplayName, string tagValue, Dispatcher dispatcher) { bool tagFound = false; dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { foreach (TagInfo summarySignal in _summaryStatusTags) { if (summarySignal.TagName.Equals(tagDisplayName)) { int index = _summaryStatusTags.IndexOf(summarySignal); _summaryStatusTags.RemoveAt(index); summarySignal.TagName = tagDisplayName; summarySignal.TagValue = tagValue; _summaryStatusTags.Insert(index, summarySignal); tagFound = true; break; } } if (!tagFound) { TagInfo summarySignal = new TagInfo(); summarySignal.TagValue = tagValue; summarySignal.TagName = tagDisplayName; _summaryStatusTags.Add(summarySignal); } })); }
public int InsertTag(TagInfo tag) { CheckSlug(tag); string cmdText = @"insert into [loachs_terms] ( [Type],[Name],[Slug],[Description],[Displayorder],[Count],[CreateDate] ) values ( @Type,@Name,@Slug,@Description,@Displayorder,@Count,@CreateDate )"; SqliteParameter[] prams = { SqliteDbHelper.MakeInParam("@Type",DbType.Int32,1,(int)TermType.Tag), SqliteDbHelper.MakeInParam("@Name",DbType.String,255,tag.Name), SqliteDbHelper.MakeInParam("@Slug",DbType.String,255,tag.Slug), SqliteDbHelper.MakeInParam("@Description",DbType.String,255,tag.Description), SqliteDbHelper.MakeInParam("@Displayorder",DbType.Int32,4,tag.Displayorder), SqliteDbHelper.MakeInParam("@Count",DbType.Int32,4,tag.Count), SqliteDbHelper.MakeInParam("@CreateDate",DbType.Date,8,tag.CreateDate) }; SqliteDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams); int newId = Convert.ToInt32(SqliteDbHelper.ExecuteScalar("select [termid] from [loachs_terms] order by [termid] desc limit 1")); return newId; }
public TagInfo GetTagInfo(string pathToAudioFile) { var tags = bassServiceProxy.GetTagsFromFile(pathToAudioFile); if (tags == null) { return new TagInfo { IsEmpty = true }; } int year; int.TryParse(tags.year, out year); TagInfo tagInfo = new TagInfo { Duration = tags.duration, Album = tags.album, Artist = tags.artist, Title = tags.title, AlbumArtist = tags.albumartist, Genre = tags.genre, Year = year, Composer = tags.composer, ISRC = tags.isrc }; return tagInfo; }
/// <summary> /// 更新数据 /// </summary> /// <param name="mod">TagInfo</param> /// <returns>受影响行数</returns> public int Update(TagInfo mod) { using (DbConnection conn = db.CreateConnection()) { conn.Open(); using (DbTransaction tran = conn.BeginTransaction()) { try { using (DbCommand cmd = db.GetStoredProcCommand("SP_Tag_Update")) { db.AddInParameter(cmd, "@TagID", DbType.Int32, mod.TagID); db.AddInParameter(cmd, "@TagName", DbType.String, mod.TagName); db.AddInParameter(cmd, "@State", DbType.Int32, mod.State); db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted); db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort); tran.Commit(); return db.ExecuteNonQuery(cmd); } } catch (Exception e) { tran.Rollback(); throw e; } finally { conn.Close(); } } } }
public int InsertTag(TagInfo tag) { CheckSlug(tag); string cmdText =string.Format(@"insert into [{0}category] ( [Type],[ParentId],[CateName],[Slug],[Description],[SortNum],[PostCount],[CreateTime] ) values ( @Type,@ParentId,@CateName,@Slug,@Description,@SortNum,@PostCount,@CreateTime )", ConfigHelper.Tableprefix); OleDbParameter[] prams = { OleDbHelper.MakeInParam("@Type",OleDbType.Integer,1,(int)CategoryType.Tag), OleDbHelper.MakeInParam("@ParentId",OleDbType.Integer,4,0), OleDbHelper.MakeInParam("@CateName",OleDbType.VarWChar,255,tag.CateName), OleDbHelper.MakeInParam("@Slug",OleDbType.VarWChar,255,tag.Slug), OleDbHelper.MakeInParam("@Description",OleDbType.VarWChar,255,tag.Description), OleDbHelper.MakeInParam("@SortNum",OleDbType.Integer,4,tag.SortNum), OleDbHelper.MakeInParam("@PostCount",OleDbType.Integer,4,tag.PostCount), OleDbHelper.MakeInParam("@CreateTime",OleDbType.Date,8,tag.CreateTime) }; OleDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams); int newId = Convert.ToInt32(OleDbHelper.ExecuteScalar(string.Format("select top 1 [categoryid] from [{0}category] order by [categoryid] desc",ConfigHelper.Tableprefix))); return newId; }
public int Delete(TagInfo tag) { string cmdText = string.Format("delete from [{0}category] where [categoryid] = @categoryid", ConfigHelper.Tableprefix); using (var conn = new DapperHelper().OpenConnection()) { return conn.Execute(cmdText, new { categoryid = tag.TagId }); } }
private void SerializeInternal(TagInfo model, IDictionary<string, object> result) { result.Add("tagid", model.TagID); result.Add("tagname", model.TagName); result.Add("state", model.State); result.Add("isdeleted", model.IsDeleted); result.Add("sort", model.Sort); }
public XmpTagsImporter(PhotoStore photo_store, TagStore tag_store) { this.tag_store = tag_store; tags_created = new Stack<Tag> (); li_root_tag = new TagInfo (Catalog.GetString ("Imported Tags"), LastImportIcon); taginfo_table [(Entity)Location] = new TagInfo (Catalog.GetString ("Location"), PlacesIcon); taginfo_table [(Entity)Country] = new TagInfo (Catalog.GetString ("Country"), PlacesIcon); taginfo_table [(Entity)City] = new TagInfo (Catalog.GetString ("City"), PlacesIcon); taginfo_table [(Entity)State] = new TagInfo (Catalog.GetString ("State"), PlacesIcon); }
public virtual void Init(Requirement r, Dictionary<string, object> meta) { Tag = new TagInfo { Req = r, Meta = meta }; Checked = meta.GetBoolFromMetadata(r.Name) ?? false; Anchor = AnchorStyles.Left | AnchorStyles.Right; AutoSize = false; CheckedChanged += (a, b) => { TagInfo m = (TagInfo)Tag; m.Meta[m.Req.Name] = Checked; }; }
public virtual void Init(Requirement r, Dictionary<string, object> meta) { Tag = new TagInfo {Req = r, Meta = meta}; Text = meta.GetStringFromMetadata(r.Name) ?? string.Empty; Anchor = AnchorStyles.Left | AnchorStyles.Right; AutoSize = false; TextChanged += (a, b) => { TagInfo m = (TagInfo) Tag; m.Meta[r.Name] = Text; }; }
public virtual void Init(Requirement r, Dictionary<string, object> meta) { Minimum = 0; Maximum = int.MaxValue; Tag = new TagInfo { Req = r, Meta = meta }; Value = (meta.GetIntFromMetadata(r.Name) ?? 0); Anchor = AnchorStyles.Left | AnchorStyles.Right; AutoSize = false; ValueChanged += (a, b) => { TagInfo m = (TagInfo)Tag; m.Meta[r.Name] = (int)Value; }; }
public override bool CanContainTag(TagInfo info) { if (info.Type == ElementType.Any) { return true; } if (info.TagName.ToLower().Equals("li")) { return true; } return false; }
/// <summary> /// ajax保存 /// </summary> protected void SaveData(string act) { TagInfo tag = new TagInfo(); if (act == "update") { tag = TagService.GetTag(PressRequest.GetFormInt("hidTagId", 0)); } else { tag.CreateTime = DateTime.Now; tag.PostCount = 0; } tag.CateName = HttpHelper.HtmlEncode(txtName.Text); tag.Slug = StringHelper.FilterSlug(tag.CateName, "tag"); tag.Description = HttpHelper.HtmlEncode(txtDescription.Text); tag.SortNum = TypeConverter.StrToInt(txtDisplayOrder.Text, 1000); if (tag.CateName == "") { return; } Dictionary<string, string> jsondic = new Dictionary<string, string>(); jsondic.Add("CateName", tag.CateName); jsondic.Add("Url", tag.Url); jsondic.Add("SortNum", tag.SortNum.ToString()); jsondic.Add("Description", tag.Description); if (act == "update")//更新操作 { jsondic.Add("Slug", tag.Slug); jsondic.Add("PostCount", tag.PostCount.ToString()); jsondic.Add("CreateTime", tag.CreateTime.ToShortDateString()); jsondic.Add("TagId", tag.TagId.ToString()); TagService.UpdateTag(tag); Response.Write(JsonHelper.DictionaryToJson(jsondic)); } else//添加操作 { int tagid = TagService.InsertTag(tag); jsondic.Add("TagId", tagid.ToString()); jsondic.Add("PostCount", "0"); jsondic.Add("CreateTime", DateTime.Now.ToShortDateString()); Response.Write(JsonHelper.DictionaryToJson(jsondic)); } Response.End(); }
public override bool CanContainTag(TagInfo info) { if (info.Type == ElementType.Any) { return true; } if ((info.Type == ElementType.Inline) | (info.Type == ElementType.Block)) { return true; } return false; }
public override bool CanContainTag(TagInfo info) { if (info.Type == ElementType.Any) { return true; } if ((info.Type == ElementType.Inline) | (info.TagName.ToLower().Equals("table")) | (info.TagName.ToLower().Equals("hr"))) { return true; } return false; }
/* Create and assign tags based on properties in the object */ public void assignObject( object p_object, string p_prefix ) { foreach (PropertyInfo property in p_object.GetType().GetProperties()) { TagInfo tmp = new TagInfo(); tmp.tagName = property.Name; /* Sanity Check. Ensure no null value */ tmp.tagValue = property.GetValue(p_object, null); if (tmp.tagValue == null) tmp.tagValue = String.Empty; /* Add the tag to the collection */ _tagCollection.Add(tmp); } }
/// <summary> /// 将reader转化为实体类 /// </summary> /// <param name="reader"></param> /// <returns></returns> public static TagInfo LoadSingleTagInfo(IDataReader reader) { TagInfo tag = new TagInfo(); tag.Tagid = TypeConverter.ObjectToInt(reader["tagid"]); tag.Tagname = reader["tagname"].ToString(); tag.Userid = TypeConverter.ObjectToInt(reader["userid"]); tag.Postdatetime = Convert.ToDateTime(reader["postdatetime"]); tag.Orderid = TypeConverter.ObjectToInt(reader["orderid"]); tag.Color = reader["color"].ToString(); tag.Count = TypeConverter.ObjectToInt(reader["count"]); tag.Fcount = TypeConverter.ObjectToInt(reader["fcount"]); tag.Pcount = TypeConverter.ObjectToInt(reader["pcount"]); tag.Scount = TypeConverter.ObjectToInt(reader["scount"]); tag.Vcount = TypeConverter.ObjectToInt(reader["vcount"]); return tag; }
/// <summary> /// 编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEdit_Click(object sender, EventArgs e) { TagInfo tag = new TagInfo(); if (Operate == OperateType.Update) { tag = TagManager.GetTag(tagId); } else { tag.CreateDate = DateTime.Now; tag.Count = 0; } tag.Name = StringHelper.HtmlEncode(txtName.Text.Trim()); //tag.Slug = txtSlug.Text.Trim(); //if (string.IsNullOrEmpty(tag.Slug)) //{ // tag.Slug = tag.Name; //} //tag.Slug = StringHelper.HtmlEncode(PageUtils.FilterSlug(tag.Slug, "tag")); //tag.Slug = StringHelper.HtmlEncode(PageUtils.FilterSlug(txtSlug.Text,"tag")); tag.Slug = PageUtils.FilterSlug(tag.Name, "tag"); tag.Description = StringHelper.HtmlEncode(txtDescription.Text); tag.Displayorder = StringHelper.StrToInt(txtDisplayOrder.Text, 1000); if (tag.Name == "") { ShowError("请输入名称!"); return; } if (Operate == OperateType.Update) { TagManager.UpdateTag(tag); Response.Redirect("taglist.aspx?result=2&page=" + Pager1.PageIndex); } else { TagManager.InsertTag(tag); Response.Redirect("taglist.aspx?result=1&page=" + Pager1.PageIndex); } }
Tag EnsureTag (TagInfo info, Category parent) { Tag tag = tag_store.GetTagByName (info.TagName); if (tag != null) return tag; tag = tag_store.CreateCategory (parent, info.TagName, false); if (info.HasIcon) { tag.ThemeIconName = info.IconName; tag_store.Commit(tag); } tags_created.Push (tag); return tag; }
private GameResult GetResults(TagInfo tag, PlayersRepo playersRepo, Dictionary<string, PlayerAnswers> playerAnswers) { IDictionary<string, int> wordStats = playerAnswers.SelectMany(ans => ans.Value.Answers).CountStatistics(word => word); return new GameResult { Results = playerAnswers.Keys.Select( k => new PlayerResult { Player = playersRepo.Find(k), WordsScores = playerAnswers[k].Answers.Select(ans => Tuple.Create(ans, wordStats[ans])).ToArray(), Score = playerAnswers[k].Answers.Sum(ans => wordStats[ans]) } ).OrderByDescending(p => p.Score).ToArray(), Tag = tag, WordsScores = wordStats.OrderByDescending(kv => kv.Value).Select(kv => Tuple.Create(kv.Key, kv.Value)).ToArray() }; }
public virtual void Init(Requirement r, Dictionary<string, object> meta) { Tag = new TagInfo { Req = r, Meta = meta }; foreach (string op in r.Options) Items.Add(op); Anchor = AnchorStyles.Left | AnchorStyles.Right; AutoSize = false; DropDownStyle=ComboBoxStyle.DropDownList; SelectedIndexChanged += (a, b) => { if (SelectedIndex != -1) { TagInfo m = (TagInfo)Tag; m.Meta[r.Name] = (string) SelectedItem; } }; string def = meta.GetStringFromMetadata(r.Name); if (r.Options.Contains(def)) { SelectedIndex = r.Options.IndexOf(def); } }
public TagInfo Process(string line) { Dictionary<string, string> tokenPairs = ParseLine(line); //long id = System.Int64.Parse(tokenPairs["tag"], System.Globalization.NumberStyles.AllowHexSpecifier); TagId id = new TagId(); if (!tokenPairs.ContainsKey("tag")) throw new ApplicationException("The keyword tag does not exist in the read packet: " + line); id.Value = tokenPairs["tag"]; if (!tokenPairs.ContainsKey("freq")) throw new ApplicationException("The keyword freq does not exist in the read packet: " + line); float frequency = System.Single.Parse(tokenPairs["freq"]); if (!tokenPairs.ContainsKey("sig")) throw new ApplicationException("The keyword sig does not exist in the read packet: " + line); float signalStrength = System.Single.Parse(tokenPairs["sig"]); if (!tokenPairs.ContainsKey("ant")) throw new ApplicationException("The keyword ant does not exist in the read packet: " + line); int antenna = System.Int32.Parse(tokenPairs["ant"]); if (!tokenPairs.ContainsKey("time")) throw new ApplicationException("The keyword time does not exist in the read packet: " + line); long time = System.Int64.Parse(tokenPairs["time"]); TagInfo tagInfo = new TagInfo(id, frequency, signalStrength, antenna, time); return tagInfo; }
public virtual void Init(Requirement r, Dictionary<string, object> meta) { Tag = new TagInfo { Req = r, Meta = meta }; Anchor = AnchorStyles.Left | AnchorStyles.Right; AutoSize = false; Button but = new Button {Text = "...", Size = new Size(24, 23), Dock=DockStyle.Right}; TextBox txt = new TextBox { Text = meta.GetStringFromMetadata(r.Name) ?? string.Empty, Anchor = AnchorStyles.Left | AnchorStyles.Right, Size = new Size(10, 20), Location = new Point(0, 2) }; txt.TextChanged += (a, b) => { TagInfo m = (TagInfo)Tag; m.Meta[m.Req.Name] = Text; }; but.Click+=(a,b)=> { FolderBrowserDialog dialog=new FolderBrowserDialog(); if (Directory.Exists(txt.Text)) dialog.SelectedPath = txt.Text; DialogResult dl = dialog.ShowDialog(); if (dl == DialogResult.OK) { if (Directory.Exists(dialog.SelectedPath)) txt.Text = dialog.SelectedPath; } }; Panel fill = new Panel { Dock = DockStyle.Fill, Anchor = AnchorStyles.Left | AnchorStyles.Top, Size = new Size(10, 24) }; fill.Controls.Add(txt); Panel spacer = new Panel { Size = new Size(10, 24), Dock = DockStyle.Right }; Controls.Add(fill); Controls.Add(spacer); Controls.Add(but); }
public static List<YouTubeVideoQuality> GetYouTubeVideoUrls(string videoUrl) { var list = new List<YouTubeVideoQuality>(); var id = GetVideoIDFromUrl(videoUrl); var infoUrl = string.Format("http://www.youtube.com/get_video_info?&video_id={0}&el=detailpage&ps=default&eurl=&gl=US&hl=en", id); var infoText = new WebClient().DownloadString(infoUrl); var infoValues = HttpUtility.ParseQueryString(infoText); var title = infoValues["title"]; var videoDuration = infoValues["length_seconds"]; var videos = infoValues["url_encoded_fmt_stream_map"].Split(','); foreach (var item in videos) { try { var data = HttpUtility.ParseQueryString(item); var server = Uri.UnescapeDataString(data["fallback_host"]); var signature = data["sig"] ?? data["signature"]; var url = Uri.UnescapeDataString(data["url"]) + "&fallback_host=" + server; if (!string.IsNullOrEmpty(signature)) url += "&signature=" + signature; var size = GetSize(url); var videoItem = new YouTubeVideoQuality(); videoItem.DownloadUrl = url; videoItem.VideoSize = size; videoItem.VideoTitle = title; var tagInfo = new TagInfo(Uri.UnescapeDataString(data["itag"])); videoItem.Dimension = tagInfo.VideoDimensions; videoItem.Extention = tagInfo.VideoExtentions; videoItem.Length = long.Parse(videoDuration); list.Add(videoItem); } catch { } } return list; }
public JsonResult Save(TagInfo cat) { if (string.IsNullOrEmpty(cat.PageName)) { cat.PageName = cat.CateName; } cat.PageName = HttpHelper.HtmlEncode(StringHelper.FilterPageName(cat.PageName, "tag")); cat.SortNum = TypeConverter.StrToInt(cat.SortNum, 1000); if (cat.TagId > 0) { var oldcat = _tagService.GetTag(cat.TagId); cat.CreateTime = oldcat.CreateTime; cat.PostCount = oldcat.PostCount; _tagService.UpdateTag(cat); } else { cat.CreateTime = DateTime.Now; cat.PostCount = 0; _tagService.InsertTag(cat); } return Json(cat, JsonRequestBehavior.AllowGet); }
/// <summary> /// 将数据集放入Node /// </summary> /// <param name="col"></param> /// <param name="mongoConnSvrKey"></param> /// <returns></returns> public static TreeNode FillCollectionInfoToTreeNode(IMongoCollection <BsonDocument> col, string mongoConnSvrKey) { var strShowColName = col.CollectionNamespace.CollectionName; var databaseName = col.CollectionNamespace.DatabaseNamespace.DatabaseName; if (!GuiConfig.IsUseDefaultLanguage) { switch (strShowColName) { case "chunks": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameChunks) + "(" + strShowColName + ")"; } break; case "collections": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameCollections) + "(" + strShowColName + ")"; } break; case "changelog": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameChangelog) + "(" + strShowColName + ")"; } break; case "databases": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameDatabases) + "(" + strShowColName + ")"; } break; case "lockpings": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameLockpings) + "(" + strShowColName + ")"; } break; case "locks": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameLocks) + "(" + strShowColName + ")"; } break; case "mongos": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameMongos) + "(" + strShowColName + ")"; } break; case "settings": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameSettings) + "(" + strShowColName + ")"; } break; case "shards": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameShards) + "(" + strShowColName + ")"; } break; case "tags": //ADD: 2013/01/04 Mongo2.2.2开始支持ShardTag了 if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameTags) + "(" + strShowColName + ")"; } break; case "version": if (databaseName == "config") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameVersion) + "(" + strShowColName + ")"; } break; case "me": if (databaseName == "local") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameMe) + "(" + strShowColName + ")"; } break; case "sources": if (databaseName == "local") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameSources) + "(" + strShowColName + ")"; } break; case "slaves": if (databaseName == "local") { strShowColName = GuiConfig.GetText( TextType.SystemcColnameSlaves) + "(" + strShowColName + ")"; } break; case ConstMgr.CollectionNameGfsChunks: strShowColName = GuiConfig.GetText( TextType.CollectionNameGfsChunks) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameGfsFiles: strShowColName = GuiConfig.GetText( TextType.CollectionNameGfsFiles) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameOperationLog: strShowColName = GuiConfig.GetText( TextType.CollectionNameOperationLog) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameSystemIndexes: strShowColName = GuiConfig.GetText( TextType.CollectionNameSystemIndexes) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameJavascript: strShowColName = GuiConfig.GetText( TextType.CollectionNameJavascript) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameSystemReplset: strShowColName = GuiConfig.GetText( TextType.CollectionNameSystemReplset) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameReplsetMinvalid: strShowColName = GuiConfig.GetText( TextType.CollectionNameReplsetMinvalid) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameUser: strShowColName = GuiConfig.GetText(TextType.CollectionNameUser) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameRole: //New From 2.6 strShowColName = GuiConfig.GetText(TextType.CollectionNameRole) + "(" + strShowColName + ")"; break; case ConstMgr.CollectionNameSystemProfile: strShowColName = GuiConfig.GetText( TextType.CollectionNameSystemProfile) + "(" + strShowColName + ")"; break; default: break; } } //Collection件数的表示 long colCount = 0; Expression <Func <BsonDocument, bool> > countfun = x => true; var task = Task.Run( async() => { colCount = await col.CountAsync(countfun); } ); task.Wait(); strShowColName = strShowColName + "(" + colCount + ")"; var mongoColNode = new TreeNode(strShowColName); switch (col.CollectionNamespace.CollectionName) { case ConstMgr.CollectionNameGfsFiles: mongoColNode.Tag = ConstMgr.GridFileSystemTag + ":" + mongoConnSvrKey + "/" + databaseName + "/" + col.CollectionNamespace.CollectionName; break; case ConstMgr.CollectionNameUser: mongoColNode.Tag = ConstMgr.UserListTag + ":" + mongoConnSvrKey + "/" + databaseName + "/" + col.CollectionNamespace.CollectionName; break; default: mongoColNode.Tag = TagInfo.CreateTagInfo(mongoConnSvrKey, databaseName, col.CollectionNamespace.CollectionName); break; } //MongoCollection mongoCol = mongoDB.GetCollection(strColName); ////Start ListIndex //var mongoIndexes = new TreeNode("Indexes"); //var indexList = mongoCol.GetIndexes(); IAsyncCursor <BsonDocument> indexCursor = null; task = Task.Run( async() => { indexCursor = await col.Indexes.ListAsync(); } ); task.Wait(); List <BsonDocument> IndexDoc = null; task = Task.Run( async() => { IndexDoc = await indexCursor.ToListAsync(); } ); task.Wait(); foreach (var indexDoc in IndexDoc) { var mongoIndexes = new TreeNode(); mongoIndexes.Text = indexDoc.GetElement("name").Value.ToString(); foreach (var item in indexDoc.Elements) { mongoIndexes.Nodes.Add(string.Empty, item.Name + ":" + item.Value, (int)GetSystemIcon.MainTreeImageType.KeyInfo, (int)GetSystemIcon.MainTreeImageType.KeyInfo); } mongoIndexes.ImageIndex = (int)GetSystemIcon.MainTreeImageType.Keys; mongoIndexes.SelectedImageIndex = (int)GetSystemIcon.MainTreeImageType.Keys; mongoIndexes.Tag = ConstMgr.IndexesTag + ":" + mongoConnSvrKey + "/" + databaseName + "/" + col.CollectionNamespace.CollectionName; mongoColNode.Nodes.Add(mongoIndexes); } #region Legacy //foreach (var indexDoc in indexList.ToList()) //{ // var mongoIndex = new TreeNode(); // if (!GUIConfig.IsUseDefaultLanguage) // { // mongoIndex.Text = // (GUIConfig.MStringResource.GetText(TextType.Index_Name) + ":" + // indexDoc.Name); // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_Keys) + ":" + // GetKeyString(indexDoc.Key), (int) GetSystemIcon.MainTreeImageType.KeyInfo, // (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_RepeatDel) + ":" + // indexDoc.DroppedDups, (int) GetSystemIcon.MainTreeImageType.KeyInfo, // (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_Background) + ":" + // indexDoc.IsBackground, (int) GetSystemIcon.MainTreeImageType.KeyInfo, // (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_Sparse) + ":" + // indexDoc.IsSparse, (int) GetSystemIcon.MainTreeImageType.KeyInfo, // (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_Unify) + ":" + // indexDoc.IsUnique, (int) GetSystemIcon.MainTreeImageType.KeyInfo, // (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_NameSpace) + ":" + // indexDoc.Namespace, (int) GetSystemIcon.MainTreeImageType.KeyInfo, // (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_Version) + ":" + // indexDoc.Version, (int) GetSystemIcon.MainTreeImageType.KeyInfo, // (int) GetSystemIcon.MainTreeImageType.KeyInfo); // if (indexDoc.TimeToLive == TimeSpan.MaxValue) // { // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_ExpireData) + // ":Not Set", // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // } // else // { // mongoIndex.Nodes.Add(string.Empty, // GUIConfig.MStringResource.GetText(TextType.Index_ExpireData) + // ":" + // indexDoc.TimeToLive.TotalSeconds, (int) GetSystemIcon.MainTreeImageType.KeyInfo, // (int) GetSystemIcon.MainTreeImageType.KeyInfo); // } // } // else // { // mongoIndex.Text = "IndexName:" + indexDoc.Name; // mongoIndex.Nodes.Add(string.Empty, "Keys:" + GetKeyString(indexDoc.Key), // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "DroppedDups :" + indexDoc.DroppedDups, // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "IsBackground:" + indexDoc.IsBackground, // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "IsSparse:" + indexDoc.IsSparse, // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "IsUnique:" + indexDoc.IsUnique, // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "NameSpace:" + indexDoc.Namespace, // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "Version:" + indexDoc.Version, // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // if (indexDoc.TimeToLive == TimeSpan.MaxValue) // { // mongoIndex.Nodes.Add(string.Empty, "Expire Data:Not Set", // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // } // else // { // mongoIndex.Nodes.Add(string.Empty, "Expire Data(sec):" + indexDoc.TimeToLive.TotalSeconds, // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // } // } // if (indexDoc.RawDocument.Contains("default_language")) // { // //TextIndex // mongoIndex.Nodes.Add(string.Empty, "weights:" + indexDoc.RawDocument["weights"], // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "default_language:" + indexDoc.RawDocument["default_language"], // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "language_override:" + indexDoc.RawDocument["language_override"], // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // mongoIndex.Nodes.Add(string.Empty, "textIndexVersion:" + indexDoc.RawDocument["textIndexVersion"], // (int) GetSystemIcon.MainTreeImageType.KeyInfo, (int) GetSystemIcon.MainTreeImageType.KeyInfo); // } // mongoIndex.ImageIndex = (int) GetSystemIcon.MainTreeImageType.DBKey; // mongoIndex.SelectedImageIndex = (int) GetSystemIcon.MainTreeImageType.DBKey; // mongoIndex.Tag = ConstMgr.INDEX_TAG + ":" + mongoConnSvrKey + "/" + DatabaseName + "/" + strColName + // "/" + // indexDoc.Name; // mongoIndexes.Nodes.Add(mongoIndex); //} //mongoIndexes.ImageIndex = (int) GetSystemIcon.MainTreeImageType.Keys; //mongoIndexes.SelectedImageIndex = (int) GetSystemIcon.MainTreeImageType.Keys; //mongoIndexes.Tag = ConstMgr.INDEXES_TAG + ":" + mongoConnSvrKey + "/" + DatabaseName + "/" + strColName; //mongoColNode.Nodes.Add(mongoIndexes); ////End ListIndex //mongoColNode.ToolTipText = strColName + Environment.NewLine; //mongoColNode.ToolTipText += "IsCapped:" + mongoCol.GetStats().IsCapped; #endregion if (col.CollectionNamespace.CollectionName == ConstMgr.CollectionNameUser) { mongoColNode.ImageIndex = (int)GetSystemIcon.MainTreeImageType.UserIcon; mongoColNode.SelectedImageIndex = (int)GetSystemIcon.MainTreeImageType.UserIcon; } else { mongoColNode.ImageIndex = (int)GetSystemIcon.MainTreeImageType.Collection; mongoColNode.SelectedImageIndex = (int)GetSystemIcon.MainTreeImageType.Collection; } //End Data return(mongoColNode); }
public static string ToJson(this TagInfo item) => string.Concat(item);
/// <summary> /// Get the corresponding dictionary for the source tags /// </summary> private Dictionary <string, MtTag> GetSourceTagsDict() { //build dict by adding the new tag which is used for translation process and the actual tag from segment that will be used to display the translation in editor _dict = new Dictionary <string, MtTag>(); var languagePlatformDllName = "Sdl.LanguagePlatform.Core.Tag"; try { for (var i = 0; i < _sourceSegment.Elements.Count; i++) { var elType = _sourceSegment.Elements[i].GetType(); if (elType.ToString() == languagePlatformDllName) //if tag, add to dictionary { var theTag = new MtTag((Tag)_sourceSegment.Elements[i].Duplicate()); var tagText = string.Empty; var tagInfo = new TagInfo { TagType = theTag.SdlTag.Type, Index = i, IsClosed = false, TagId = theTag.SdlTag.TagID }; if (!TagsInfo.Any(n => n.TagId.Equals(tagInfo.TagId))) { TagsInfo.Add(tagInfo); } var tag = GetCorrespondingTag(theTag.SdlTag.TagID); if (theTag.SdlTag.Type == TagType.Start) { if (tag != null) { tagText = $"<tg{tag.TagId}>"; } } if (theTag.SdlTag.Type == TagType.End) { if (tag != null) { tag.IsClosed = true; tagText = $"</tg{tag.TagId}>"; } } if (theTag.SdlTag.Type.Equals(TagType.Standalone) || theTag.SdlTag.Type.Equals(TagType.TextPlaceholder) || theTag.SdlTag.Type.Equals(TagType.LockedContent)) { if (tag != null) { tagText = $"<tg{tag.TagId}/>"; } } PreparedSourceText += tagText; //now we have to figure out whether this tag is preceded and/or followed by whitespace if (i > 0 && !_sourceSegment.Elements[i - 1].GetType().ToString().Equals(languagePlatformDllName)) { var prevText = _sourceSegment.Elements[i - 1].ToString(); if (!prevText.Trim().Equals("")) //and not just whitespace { //get number of trailing spaces for that segment var whitespace = prevText.Length - prevText.TrimEnd().Length; //add that trailing space to our tag as leading space theTag.PadLeft = prevText.Substring(prevText.Length - whitespace); } } if (i < _sourceSegment.Elements.Count - 1 && !_sourceSegment.Elements[i + 1].GetType().ToString().Equals(languagePlatformDllName)) { //here we don't care whether it is only whitespace //get number of leading spaces for that segment var nextText = _sourceSegment.Elements[i + 1].ToString(); var whitespace = nextText.Length - nextText.TrimStart().Length; //add that trailing space to our tag as leading space theTag.PadRight = nextText.Substring(0, whitespace); } _dict.Add(tagText, theTag); //add our new tag code to the dict with the corresponding tag } else { PreparedSourceText += _sourceSegment.Elements[i].ToString(); } } TagsInfo.Clear(); } catch (Exception ex) { _logger.Error($"{MethodBase.GetCurrentMethod().Name} {ex.Message}\n { ex.StackTrace}"); } return(_dict); }
/// <summary> /// Update basic information ListView Once receiving a new tag report from RFID reader /// </summary> /// <param name="tagInfo">an object containing all information of a tag in one tag report</param> public void UpdateListView(TagInfo tagInfo) { //Update counter in status strip tsslblCounter.Text = tagInfo.TotalTagCount.ToString(); //Update run time in status strip UpdateRunTime(); _tagsTable.AddTagInfo(tagInfo); ListViewItem foundItem = lvBasicInfo.FindItemWithText(tagInfo.EPC); if (foundItem != null) { // Tag already exists foundItem.SubItems[2].Text = tagInfo.Antenna.ToString(); foundItem.SubItems[3].Text = tagInfo.ChannelIndex.ToString(); foundItem.SubItems[4].Text = tagInfo.RSSI.ToString(); foundItem.SubItems[5].Text = tagInfo.AcutalPhaseInRadian.ToString(); foundItem.SubItems[6].Text = tagInfo.DopplerShift.ToString(); foundItem.SubItems[7].Text = tagInfo.Velocity.ToString(); foundItem.SubItems[8].Text = Convert.ToString(Convert.ToInt32(foundItem.SubItems[8].Text) + 1); //if (tabControlChart.SelectedTab.Text != "Holographics") chartRSSI.Series[foundItem.Index].Points.AddXY((tagInfo.FirstSeenTime - _firstReportTime) / 1000, tagInfo.RSSI); chartPhase.Series[foundItem.Index].Points.AddXY((tagInfo.FirstSeenTime - _firstReportTime) / 1000, tagInfo.AcutalPhaseInRadian); } else { // New tag is coming if (tagInfo.TotalTagCount == 1) { _firstReportTime = tagInfo.FirstSeenTime; } // Update Listview ListViewItem lvi = new ListViewItem(Convert.ToString(_index++)); lvi.SubItems.Add(tagInfo.EPC); lvi.SubItems.Add(tagInfo.Antenna.ToString()); lvi.SubItems.Add(tagInfo.ChannelIndex.ToString()); lvi.SubItems.Add(tagInfo.RSSI.ToString()); lvi.SubItems.Add(tagInfo.AcutalPhaseInRadian.ToString()); lvi.SubItems.Add(tagInfo.DopplerShift.ToString()); lvi.SubItems.Add(tagInfo.Velocity.ToString()); lvi.SubItems.Add(Convert.ToString(1)); lvBasicInfo.Items.Add(lvi); //Update Chart if (lvBasicInfo.Items.Count == 1) { //Chart title for RSSI Title titleRSSI = new Title("RSSI", Docking.Top); titleRSSI.Alignment = System.Drawing.ContentAlignment.MiddleCenter; titleRSSI.Font = new System.Drawing.Font("Microsoft Sans Serif", 20, System.Drawing.FontStyle.Bold); chartRSSI.Titles.Add(titleRSSI); Title titlePhase = new Title("Phase", Docking.Top); titlePhase.Alignment = System.Drawing.ContentAlignment.MiddleCenter; titlePhase.Font = new System.Drawing.Font("Microsoft Sans Serif", 20, System.Drawing.FontStyle.Bold); chartPhase.Titles.Add(titlePhase); } //------RSSI------ //Create a new curve Series seriesRSSI = new Series("RSSI:" + tagInfo.EPC); //Set chart type seriesRSSI.ChartType = SeriesChartType.FastLine; //Set different curve colors seriesRSSI.BorderDashStyle = (ChartDashStyle)lvBasicInfo.Items.Count; //Set curve width seriesRSSI.BorderWidth = 3; chartRSSI.Series.Add(seriesRSSI); //Create a new legend Legend legendRSSI = new Legend("RSSI:" + tagInfo.EPC); //Set legend propertities legendRSSI.Title = "EPC"; legendRSSI.TitleFont = new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Bold); legendRSSI.Font = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Bold); legendRSSI.LegendStyle = LegendStyle.Table; legendRSSI.Alignment = System.Drawing.StringAlignment.Center; legendRSSI.IsDockedInsideChartArea = false; legendRSSI.Docking = Docking.Bottom; legendRSSI.BorderDashStyle = ChartDashStyle.Dash; legendRSSI.BorderColor = System.Drawing.Color.LightBlue; legendRSSI.BorderWidth = 3; chartRSSI.Legends.Add(legendRSSI); //Set Docking of the legend chart to the Default Chart Area chartRSSI.Legends["RSSI:" + tagInfo.EPC].DockedToChartArea = "RSSI"; seriesRSSI.Points.AddXY((tagInfo.FirstSeenTime - _firstReportTime) / 1000, tagInfo.RSSI); //------RSSI------ //------Phase------ //Create a new curve Series seriesPhase = new Series("Phase:" + tagInfo.EPC); //Set chart type //seriesPhase.ChartType = SeriesChartType.FastPoint; seriesPhase.ChartType = SeriesChartType.FastLine; //Set different curve colors seriesPhase.BorderDashStyle = (ChartDashStyle)lvBasicInfo.Items.Count; //Set curve width seriesPhase.BorderWidth = 3; //seriesPhase.MarkerSize = 5; chartPhase.Series.Add(seriesPhase); //Create a new legend Legend legendPhase = new Legend("Phase:" + tagInfo.EPC); //Set legend propertities legendPhase.Title = "EPC"; legendPhase.Font = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Bold); legendPhase.TitleFont = new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Bold); legendPhase.LegendStyle = LegendStyle.Table; legendPhase.Alignment = System.Drawing.StringAlignment.Center; legendPhase.IsDockedInsideChartArea = false; legendPhase.Docking = Docking.Bottom; legendPhase.BorderDashStyle = ChartDashStyle.Dash; legendPhase.BorderColor = System.Drawing.Color.LightBlue; legendPhase.BorderWidth = 3; chartPhase.Legends.Add(legendPhase); chartPhase.Legends["Phase:" + tagInfo.EPC].DockedToChartArea = "Phase"; seriesPhase.Points.AddXY((tagInfo.FirstSeenTime - _firstReportTime) / 1000, tagInfo.AcutalPhaseInRadian); //------Phase------ //Update Tag Filter if (!cbMask.Items.Contains(tagInfo.EPC)) { cbMask.Items.Add(tagInfo.EPC); } if (!cbExtraMask.Items.Contains(tagInfo.EPC)) { cbExtraMask.Items.Add(tagInfo.EPC); } SyntheticApertureRadar sar = new SyntheticApertureRadar(); _sar.Add(tagInfo.EPC, sar); } SARParameter sarPara = new SARParameter(); sarPara.AntennaX = Convert.ToDouble(tbxAntXStart.Text.Trim()) + _simulationIndex * Convert.ToDouble(tbxSamplingAntennaSpeed.Text.Trim()) * Convert.ToDouble(tbxSimulationSamplingTime.Text.Trim()); sarPara.AntennaY = Convert.ToDouble(tbxAntYStart.Text.Trim()); sarPara.TagInformation = new TagInfo(); sarPara.TagInformation.EPC = tagInfo.EPC; sarPara.TagInformation.Frequency = 1000000 * RFIDReaderParameter.ReaderCapabilities.FrequencyDic[tagInfo.ChannelIndex]; sarPara.TagInformation.AcutalPhaseInRadian = tagInfo.AcutalPhaseInRadian; sarPara.TagInformation.TotalTagCount = tagInfo.TotalTagCount; _sarParaQueue.Enqueue(sarPara); }
//添加相位记录 public void addPhaseRecord(TagInfo tagInfo) { PhaseRecord phaseRecord = new PhaseRecord(tagInfo); phaseRecords.Add(phaseRecord); }
private TrackData GetActualTrack(TagInfo tags) { return(!string.IsNullOrEmpty(tags.ISRC) ? modelService.ReadTrackByISRC(tags.ISRC) : modelService.ReadTrackByArtistAndTitleName(tags.Artist, tags.Title).FirstOrDefault()); }
private void readFrames(BinaryReader source, TagInfo Tag, MetaDataIO.ReadTagParams readTagParams) { string frameName; string strValue; int frameDataSize; long valuePosition; int frameFlags; source.BaseStream.Seek(Tag.FileSize - Tag.DataShift - Tag.Size, SeekOrigin.Begin); // Read all stored fields for (int iterator = 0; iterator < Tag.FrameCount; iterator++) { frameDataSize = source.ReadInt32(); frameFlags = source.ReadInt32(); frameName = StreamUtils.ReadNullTerminatedString(source, Utils.Latin1Encoding); // Slightly more permissive than what APE specs indicate in terms of allowed characters ("Space(0x20), Slash(0x2F), Digits(0x30...0x39), Letters(0x41...0x5A, 0x61...0x7A)") valuePosition = source.BaseStream.Position; if ((frameDataSize > 0) && (frameDataSize <= 500)) { /* * According to spec : "Items are not zero-terminated like in C / C++. * If there's a zero character, multiple items are stored under the key and the items are separated by zero characters." * * => Values have to be splitted */ strValue = Utils.StripEndingZeroChars(Encoding.UTF8.GetString(source.ReadBytes(frameDataSize))); strValue = strValue.Replace('\0', Settings.InternalValueSeparator).Trim(); SetMetaField(frameName.Trim().ToUpper(), strValue, readTagParams.ReadAllMetaFrames); } else if (frameDataSize > 0) // Size > 500 => Probably an embedded picture { int picturePosition; PictureInfo.PIC_TYPE picType = decodeAPEPictureType(frameName); if (picType.Equals(PictureInfo.PIC_TYPE.Unsupported)) { addPictureToken(getImplementedTagType(), frameName); picturePosition = takePicturePosition(getImplementedTagType(), frameName); } else { addPictureToken(picType); picturePosition = takePicturePosition(picType); } if (readTagParams.ReadPictures || readTagParams.PictureStreamHandler != null) { // Description seems to be a null-terminated ANSI string containing // * The frame name // * A byte (0x2E) // * The picture type (3 characters; similar to the 2nd part of the mime-type) String description = StreamUtils.ReadNullTerminatedString(source, Utils.Latin1Encoding); ImageFormat imgFormat = ImageUtils.GetImageFormatFromMimeType(description.Substring(description.Length - 3, 3)); PictureInfo picInfo = new PictureInfo(imgFormat, picType, getImplementedTagType(), frameName, picturePosition); picInfo.Description = description; picInfo.PictureData = new byte[frameDataSize - description.Length - 1]; source.BaseStream.Read(picInfo.PictureData, 0, frameDataSize - description.Length - 1); tagData.Pictures.Add(picInfo); if (readTagParams.PictureStreamHandler != null) { MemoryStream mem = new MemoryStream(picInfo.PictureData); readTagParams.PictureStreamHandler(ref mem, picInfo.PicType, picInfo.NativeFormat, picInfo.TagType, picInfo.NativePicCode, picInfo.Position); mem.Close(); } } } source.BaseStream.Seek(valuePosition + frameDataSize, SeekOrigin.Begin); } }
private TrackInfo GetActualTrack(TagInfo tags) { return(modelService.ReadTrackById(tags.ISRC)); }
private void ToolStripMenuItem_testWriteContentToNewChip_Click(object sender, EventArgs e) { #if NO // 准备好一个芯片内容 byte[] data = Element.FromHexString( @"91 00 05 1c be 99 1a 14 02 01 d0 14 02 04 b3 46 07 44 1c b6 e2 e3 35 d6 83 02 07 ac c0 9e ba a0 6f 6b 00 00" ); // 测试 BlockRange.GetBlockRanges() List <BlockRange> ranges = BlockRange.GetBlockRanges( data, "ll....lll", 4); Debug.Assert(ranges[0].BlockCount == 2); Debug.Assert(ranges[0].Locked == true); Debug.Assert(ranges[0].Bytes.SequenceEqual( Element.FromHexString( @"91 00 05 1c be 99 1a 14" ) )); Debug.Assert(ranges[1].BlockCount == 4); Debug.Assert(ranges[1].Locked == false); Debug.Assert(ranges[1].Bytes.SequenceEqual( Element.FromHexString( @"02 01 d0 14 02 04 b3 46 07 44 1c b6 e2 e3 35 d6" ) )); Debug.Assert(ranges[2].BlockCount == 3); Debug.Assert(ranges[2].Locked == true); Debug.Assert(ranges[2].Bytes.SequenceEqual( Element.FromHexString( @"83 02 07 ac c0 9e ba a0 6f 6b 00 00" ) )); #endif GetTagInfoResult result = _driver.GetTagInfo(GetCurrentReaderName(), null); MessageBox.Show(this, "初始芯片内容: " + result.ToString()); TagInfo new_chip = result.TagInfo.Clone(); new_chip.Bytes = Element.FromHexString( @"91 00 05 1c be 99 1a 14 02 01 d0 14 02 04 b3 46 07 44 1c b6 e2 e3 35 d6 83 02 07 ac c0 9e ba a0 6f 6b 00 00"); new_chip.LockStatus = "ww....www"; NormalResult write_result = _driver.WriteTagInfo(GetCurrentReaderName(), result.TagInfo, new_chip); MessageBox.Show(this, write_result.ToString()); }
void Awake() { boneAnimation = gameObject.GetComponent<BoneAnimation>(); currentMotion = boneAnimation[0].name; if (boneAnimation.triggerFrames != null && boneAnimation.triggerFrames.Length > 0) { if (tags == null) { tags = new List<TagInfo>(); } foreach (var frame in boneAnimation.triggerFrames) { if (frame.triggerFrameBones != null) { foreach (var bone in frame.triggerFrameBones) { if (bone.triggerEventTypes.Contains(TriggerFrameBone.TRIGGER_EVENT_TYPE.UserTrigger)) { TagInfo info = new TagInfo() { clipIndex = frame.clipIndex, frame = frame.frame, boneNodeIndex = bone.boneNodeIndex, tag = bone.userTriggerTag, }; tags.Add(info); } } } } } List<string> res = new List<string>(); foreach (var entity in tags) { if (entity.tag.Contains("=")) { string[] keyValue = entity.tag.Split('='); if (keyValue[0] == "sound") { // temp comment out /* int soundId = int.Parse(keyValue[1]); SFXEntity soundEntity = TableLoader.GetTable<SFXEntity>().Get(soundId); res.Add(soundEntity.resource); */ } else if (keyValue[0] == "effect") { int effectId = int.Parse(keyValue[1]); VFXEntity effectEntity = TableLoader.GetTable<VFXEntity>().Get(effectId); res.Add(effectEntity.resource); } } } foreach (var entity in res) { RecycleManager.Instance.Preload(entity); } }
Tag CreateSpecificTag(TagInfo info, string numberValue) { try { if (info.IsGps) { switch (info.Name.ToLower()) { case "gpslatituderef": return(new Tag <GpsLatitudeRef> { TypedValue = GpsLatitudeRef.FromKey(numberValue) }); case "gpslongituderef": return(new Tag <GpsLongitudeRef> { TypedValue = GpsLongitudeRef.FromKey(numberValue) }); case "gpsaltituderef": return(new Tag <GpsAltitudeRef> { TypedValue = GpsAltitudeRef.FromKey(byte.Parse(numberValue)) }); case "gpsstatus": return(new Tag <GpsStatus> { TypedValue = GpsStatus.FromKey(numberValue) }); case "gpsmeasuremode": return(new Tag <GpsMeasureMode> { TypedValue = GpsMeasureMode.FromKey(numberValue) }); case "gpsspeedref": return(new Tag <GpsSpeedRef> { TypedValue = GpsSpeedRef.FromKey(numberValue) }); case "gpstrackref": return(new Tag <GpsTrackRef> { TypedValue = GpsTrackRef.FromKey(numberValue) }); case "gpsimgdirectionref": return(new Tag <GpsImgDirectionRef> { TypedValue = GpsImgDirectionRef.FromKey(numberValue) }); case "gpsdestlatituderef": return(new Tag <GpsDestLatitudeRef> { TypedValue = GpsDestLatitudeRef.FromKey(numberValue) }); case "gpsdestlongituderef": return(new Tag <GpsDestLongitudeRef> { TypedValue = GpsDestLongitudeRef.FromKey(numberValue) }); case "gpsdestbearingref": return(new Tag <GpsDestBearingRef> { TypedValue = GpsDestBearingRef.FromKey(numberValue) }); case "gpsdestdistanceref": return(new Tag <GpsDestDistanceRef> { TypedValue = GpsDestDistanceRef.FromKey(numberValue) }); case "gpsdifferential": return(new Tag <GpsDifferential> { TypedValue = GpsDifferential.FromKey(ushort.Parse(numberValue)) }); } } if (info.IsNikon) { switch (info.Name.ToLower()) { case "colorspace": return(new Tag <NikonColorSpace> { TypedValue = NikonColorSpace.FromKey(ushort.Parse(numberValue)) }); case "vibrationreduction": return(new Tag <NikonVibrationReduction> { TypedValue = NikonVibrationReduction.FromKey(byte.Parse(numberValue)) }); case "vrmode": return(new Tag <NikonVRMode> { TypedValue = NikonVRMode.FromKey(byte.Parse(numberValue)) }); case "imageauthentication": return(new Tag <NikonImageAuthentication> { TypedValue = NikonImageAuthentication.FromKey(byte.Parse(numberValue)) }); case "actived-lighting": return(new Tag <NikonActiveDLighting> { TypedValue = NikonActiveDLighting.FromKey(ushort.Parse(numberValue)) }); case "picturecontroladjust": return(new Tag <NikonPictureControlAdjust> { TypedValue = NikonPictureControlAdjust.FromKey(byte.Parse(numberValue)) }); case "filtereffect": return(new Tag <NikonFilterEffect> { TypedValue = NikonFilterEffect.FromKey(byte.Parse(numberValue)) }); case "toningeffect": return(new Tag <NikonToningEffect> { TypedValue = NikonToningEffect.FromKey(byte.Parse(numberValue)) }); case "daylightsavings": return(new Tag <NikonDaylightSavings> { TypedValue = NikonDaylightSavings.FromKey(byte.Parse(numberValue)) }); case "datedisplayformat": return(new Tag <NikonDateDisplayFormat> { TypedValue = NikonDateDisplayFormat.FromKey(byte.Parse(numberValue)) }); case "isoexpansion": return(new Tag <NikonIsoExpansion> { TypedValue = NikonIsoExpansion.FromKey(ushort.Parse(numberValue)) }); case "isoexpansion2": return(new Tag <NikonIsoExpansion2> { TypedValue = NikonIsoExpansion2.FromKey(ushort.Parse(numberValue)) }); case "vignettecontrol": return(new Tag <NikonVignetteControl> { TypedValue = NikonVignetteControl.FromKey(ushort.Parse(numberValue)) }); case "autodistortioncontrol": return(new Tag <NikonAutoDistortionControl> { TypedValue = NikonAutoDistortionControl.FromKey(byte.Parse(numberValue)) }); case "hdr": return(new Tag <NikonHdr> { TypedValue = NikonHdr.FromKey(byte.Parse(numberValue)) }); case "hdrlevel": return(new Tag <NikonHdrLevel> { TypedValue = NikonHdrLevel.FromKey(byte.Parse(numberValue)) }); case "hdrsmoothing": return(new Tag <NikonHdrSmoothing> { TypedValue = NikonHdrSmoothing.FromKey(byte.Parse(numberValue)) }); case "hdrlevel2": return(new Tag <NikonHdrLevel2> { TypedValue = NikonHdrLevel2.FromKey(byte.Parse(numberValue)) }); case "textencoding": return(new Tag <NikonTextEncoding> { TypedValue = NikonTextEncoding.FromKey(byte.Parse(numberValue)) }); case "flashmode": return(new Tag <NikonFlashMode> { TypedValue = NikonFlashMode.FromKey(byte.Parse(numberValue)) }); case "afareamode": return(new Tag <NikonAfAreaMode> { TypedValue = NikonAfAreaMode.FromKey(byte.Parse(numberValue)) }); case "afpoint": return(new Tag <NikonAfPoint> { TypedValue = NikonAfPoint.FromKey(byte.Parse(numberValue)) }); case "afpointsinfocus": return(new Tag <NikonAfPointsInFocus> { TypedValue = NikonAfPointsInFocus.FromKey(ushort.Parse(numberValue)) }); case "nefcompression": return(new Tag <NikonNefCompression> { TypedValue = NikonNefCompression.FromKey(ushort.Parse(numberValue)) }); case "retouchhistory": return(new Tag <NikonRetouchHistory> { TypedValue = NikonRetouchHistory.FromKey(ushort.Parse(numberValue)) }); case "flashsource": return(new Tag <NikonFlashSource> { TypedValue = NikonFlashSource.FromKey(byte.Parse(numberValue)) }); case "flashcolorfilter": return(new Tag <NikonFlashColorFilter> { TypedValue = NikonFlashColorFilter.FromKey(byte.Parse(numberValue)) }); case "highisonoisereduction": return(new Tag <NikonHighIsoNoiseReduction> { TypedValue = NikonHighIsoNoiseReduction.FromKey(ushort.Parse(numberValue)) }); } } if (info.IsExif) { switch (info.Name.ToLower()) { case "interopindex": return(new Tag <InteropIndex> { TypedValue = InteropIndex.FromKey(numberValue) }); case "subfiletype": return(new Tag <SubfileType> { TypedValue = SubfileType.FromKey(uint.Parse(numberValue)) }); case "oldsubfiletype": return(new Tag <OldSubfileType> { TypedValue = OldSubfileType.FromKey(ushort.Parse(numberValue)) }); case "compression": return(new Tag <Compression> { TypedValue = Compression.FromKey(ushort.Parse(numberValue)) }); case "photometricinterpretation": return(new Tag <PhotometricInterpretation> { TypedValue = PhotometricInterpretation.FromKey(ushort.Parse(numberValue)) }); case "thresholding": return(new Tag <Thresholding> { TypedValue = Thresholding.FromKey(ushort.Parse(numberValue)) }); case "fillorder": return(new Tag <FillOrder> { TypedValue = FillOrder.FromKey(ushort.Parse(numberValue)) }); case "orientation": return(new Tag <Orientation> { TypedValue = Orientation.FromKey(ushort.Parse(numberValue)) }); case "planarconfiguration": return(new Tag <PlanarConfiguration> { TypedValue = PlanarConfiguration.FromKey(ushort.Parse(numberValue)) }); case "grayresponseunit": return(new Tag <GrayResponseUnit> { TypedValue = GrayResponseUnit.FromKey(ushort.Parse(numberValue)) }); case "resolutionunit": return(new Tag <ResolutionUnit> { TypedValue = ResolutionUnit.FromKey(ushort.Parse(numberValue)) }); case "predictor": return(new Tag <Predictor> { TypedValue = Predictor.FromKey(ushort.Parse(numberValue)) }); case "cleanfaxdata": return(new Tag <CleanFaxData> { TypedValue = CleanFaxData.FromKey(ushort.Parse(numberValue)) }); case "inkset": return(new Tag <InkSet> { TypedValue = InkSet.FromKey(ushort.Parse(numberValue)) }); case "extrasamples": return(new Tag <ExtraSamples> { TypedValue = ExtraSamples.FromKey(ushort.Parse(numberValue)) }); case "sampleformat": return(new Tag <SampleFormat> { TypedValue = SampleFormat.FromKey(ushort.Parse(numberValue)) }); case "indexed": return(new Tag <Indexed> { TypedValue = Indexed.FromKey(ushort.Parse(numberValue)) }); case "opiproxy": return(new Tag <OpiProxy> { TypedValue = OpiProxy.FromKey(ushort.Parse(numberValue)) }); case "profiletype": return(new Tag <ProfileType> { TypedValue = ProfileType.FromKey(ushort.Parse(numberValue)) }); case "faxprofile": return(new Tag <FaxProfile> { TypedValue = FaxProfile.FromKey(ushort.Parse(numberValue)) }); case "jpegproc": return(new Tag <JpegProc> { TypedValue = JpegProc.FromKey(ushort.Parse(numberValue)) }); case "ycbcrsubsampling": return(new Tag <YCbCrSubSampling> { TypedValue = YCbCrSubSampling.FromKey(numberValue) }); case "ycbcrpositioning": return(new Tag <YCbCrPositioning> { TypedValue = YCbCrPositioning.FromKey(ushort.Parse(numberValue)) }); case "sonyrawfiletype": return(new Tag <SonyRawFileType> { TypedValue = SonyRawFileType.FromKey(ushort.Parse(numberValue)) }); case "rasterpadding": return(new Tag <RasterPadding> { TypedValue = RasterPadding.FromKey(ushort.Parse(numberValue)) }); case "imagecolorindicator": return(new Tag <ImageColorIndicator> { TypedValue = ImageColorIndicator.FromKey(ushort.Parse(numberValue)) }); case "backgroundcolorindicator": return(new Tag <BackgroundColorIndicator> { TypedValue = BackgroundColorIndicator.FromKey(ushort.Parse(numberValue)) }); case "hcusage": return(new Tag <HCUsage> { TypedValue = HCUsage.FromKey(ushort.Parse(numberValue)) }); case "exposureprogram": return(new Tag <ExposureProgram> { TypedValue = ExposureProgram.FromKey(ushort.Parse(numberValue)) }); case "sensitivitytype": return(new Tag <SensitivityType> { TypedValue = SensitivityType.FromKey(ushort.Parse(numberValue)) }); case "componentsconfiguration": return(new Tag <ComponentsConfiguration> { TypedValue = ComponentsConfiguration.FromKey(ushort.Parse(numberValue)) }); case "meteringmode": return(new Tag <MeteringMode> { TypedValue = MeteringMode.FromKey(ushort.Parse(numberValue)) }); case "lightsource": case "calibrationilluminant1": case "calibrationilluminant2": return(new Tag <LightSource> { TypedValue = LightSource.FromKey(ushort.Parse(numberValue)) }); case "flash": return(new Tag <FlashValue> { TypedValue = FlashValue.FromKey(ushort.Parse(numberValue)) }); case "focalplaneresolutionunit": return(new Tag <FocalPlaneResolutionUnit> { TypedValue = FocalPlaneResolutionUnit.FromKey(ushort.Parse(numberValue)) }); case "securityclassification": return(new Tag <SecurityClassification> { TypedValue = SecurityClassification.FromKey(numberValue) }); case "sensingmethod": return(new Tag <SensingMethod> { TypedValue = SensingMethod.FromKey(ushort.Parse(numberValue)) }); case "colorspace": return(new Tag <ColorSpace> { TypedValue = ColorSpace.FromKey(ushort.Parse(numberValue)) }); case "filesource": return(new Tag <FileSource> { TypedValue = FileSource.FromKey(ushort.Parse(numberValue)) }); case "scenetype": return(new Tag <SceneType> { TypedValue = SceneType.FromKey(ushort.Parse(numberValue)) }); case "customrendered": return(new Tag <CustomRendered> { TypedValue = CustomRendered.FromKey(ushort.Parse(numberValue)) }); case "exposuremode": return(new Tag <ExposureMode> { TypedValue = ExposureMode.FromKey(ushort.Parse(numberValue)) }); case "whitebalance": return(new Tag <WhiteBalance> { TypedValue = WhiteBalance.FromKey(ushort.Parse(numberValue)) }); case "scenecapturetype": return(new Tag <SceneCaptureType> { TypedValue = SceneCaptureType.FromKey(ushort.Parse(numberValue)) }); case "gaincontrol": return(new Tag <GainControl> { TypedValue = GainControl.FromKey(ushort.Parse(numberValue)) }); case "contrast": return(new Tag <Contrast> { TypedValue = Contrast.FromKey(ushort.Parse(numberValue)) }); case "saturation": return(new Tag <Saturation> { TypedValue = Saturation.FromKey(ushort.Parse(numberValue)) }); case "sharpness": return(new Tag <Sharpness> { TypedValue = Sharpness.FromKey(ushort.Parse(numberValue)) }); case "subjectdistancerange": return(new Tag <SubjectDistanceRange> { TypedValue = SubjectDistanceRange.FromKey(ushort.Parse(numberValue)) }); case "pixelformat": return(new Tag <PixelFormat> { TypedValue = PixelFormat.FromKey(ushort.Parse(numberValue)) }); case "transformation": return(new Tag <Transformation> { TypedValue = Transformation.FromKey(ushort.Parse(numberValue)) }); case "uncompressed": return(new Tag <Uncompressed> { TypedValue = Uncompressed.FromKey(ushort.Parse(numberValue)) }); case "imagedatadiscard": return(new Tag <ImageDataDiscard> { TypedValue = ImageDataDiscard.FromKey(ushort.Parse(numberValue)) }); case "alphadatadiscard": return(new Tag <AlphaDataDiscard> { TypedValue = AlphaDataDiscard.FromKey(ushort.Parse(numberValue)) }); case "usptooriginalcontenttype": return(new Tag <USPTOOriginalContentType> { TypedValue = USPTOOriginalContentType.FromKey(ushort.Parse(numberValue)) }); case "cfalayout": return(new Tag <CFALayout> { TypedValue = CFALayout.FromKey(ushort.Parse(numberValue)) }); case "makernotesafety": return(new Tag <MakerNoteSafety> { TypedValue = MakerNoteSafety.FromKey(ushort.Parse(numberValue)) }); case "profileembedpolicy": return(new Tag <ProfileEmbedPolicy> { TypedValue = ProfileEmbedPolicy.FromKey(ushort.Parse(numberValue)) }); case "previewcolorspace": return(new Tag <PreviewColorSpace> { TypedValue = PreviewColorSpace.FromKey(ushort.Parse(numberValue)) }); case "profilehuesatmapencoding": return(new Tag <ProfileHueSatMapEncoding> { TypedValue = ProfileHueSatMapEncoding.FromKey(ushort.Parse(numberValue)) }); case "profilelooktableencoding": return(new Tag <ProfileLookTableEncoding> { TypedValue = ProfileLookTableEncoding.FromKey(ushort.Parse(numberValue)) }); case "defaultblackrender": return(new Tag <DefaultBlackRender> { TypedValue = DefaultBlackRender.FromKey(ushort.Parse(numberValue)) }); } } // ---- VALUE TAG ---- if (string.IsNullOrEmpty(info.ValueType)) { return(new Tag()); } switch (info.ValueType.ToLower()) { case "int8u": return(new Tag <byte> { TypedValue = byte.Parse(numberValue) }); case "int8s": return(new Tag <sbyte> { TypedValue = sbyte.Parse(numberValue) }); case "int16u": return(new Tag <ushort> { TypedValue = ushort.Parse(numberValue) }); case "int16s": return(new Tag <short> { TypedValue = short.Parse(numberValue) }); case "int32u": return(new Tag <uint> { TypedValue = uint.Parse(numberValue) }); case "integer": case "int32s": return(new Tag <int> { TypedValue = int.Parse(numberValue) }); case "int64u": return(new Tag <ulong> { TypedValue = ulong.Parse(numberValue) }); case "int64s": return(new Tag <long> { TypedValue = long.Parse(numberValue) }); case "float": case "rational32s": case "rational32u": return(new Tag <float> { TypedValue = float.Parse(numberValue) }); case "double": case "rational": case "rational64s": case "rational64u": case "real": return(new Tag <double> { TypedValue = double.Parse(numberValue) }); case "boolean": return(new Tag <bool> { TypedValue = bool.Parse(numberValue) }); } } catch { if (!Quiet) { Console.WriteLine($"error converting {info.TableName}::{info.Id} with name {info.Name}. Expected type: {info.ValueType} but got value: {numberValue}"); } } return(new Tag()); }
public static void SetTags(ColumnBase obj, TagInfo value) { obj.SetValue(TagsProperty, value); }
/// <summary> /// 加载文章列表 /// </summary> protected void LoadPostList() { int categoryId = -1; int tagId = -1; int userId = -1; string keyword = string.Empty; string data = string.Empty; string begindate = string.Empty; string enddate = string.Empty; int pageindex = RequestHelper.QueryInt("page", 1); string messageinfo = string.Empty; string url = MakeUrl(string.Empty, string.Empty, string.Empty); if (pageType == "category") { string slug = RequestHelper.QueryString("slug"); CategoryInfo cate = CategoryManager.GetCategory(slug); if (cate != null) { categoryId = cate.CategoryId; th.Put(TagFields.META_KEYWORDS, cate.Name); th.Put(TagFields.META_DESCRIPTION, cate.Description); th.Put(TagFields.PAGE_TITLE, cate.Name); messageinfo = string.Format("<h2 class=\"post-message\">分类:{0}</h2>", cate.Name); url = MakeUrl("category", "slug", Server.UrlEncode(slug)); } } else if (pageType == "tag") { string slug = RequestHelper.QueryString("slug"); TagInfo tag = TagManager.GetTagBySlug(slug); if (tag != null) { tagId = tag.TagId; th.Put(TagFields.META_KEYWORDS, tag.Name); th.Put(TagFields.META_DESCRIPTION, tag.Description); th.Put(TagFields.PAGE_TITLE, tag.Name); messageinfo = string.Format("<h2 class=\"post-message\">标签:{0}</h2>", tag.Name); url = MakeUrl("tag", "slug", Server.UrlEncode(slug)); } } else if (pageType == "author") { string userName = RequestHelper.QueryString("username"); UserInfo user = UserManager.GetUser(userName); if (user != null) { userId = user.UserId; th.Put(TagFields.META_KEYWORDS, user.Name); th.Put(TagFields.META_DESCRIPTION, user.Description); th.Put(TagFields.PAGE_TITLE, user.Name); messageinfo = string.Format("<h2 class=\"post-message\">作者:{0}</h2>", user.Name); url = MakeUrl("author", "username", Server.UrlEncode(userName)); } } else if (pageType == "search") { keyword = StringHelper.CutString(StringHelper.SqlEncode(RequestHelper.QueryString("keyword")), 15); th.Put(TagFields.META_KEYWORDS, keyword); th.Put(TagFields.META_DESCRIPTION, keyword); th.Put(TagFields.PAGE_TITLE, keyword); th.Put(TagFields.SEARCH_KEYWORD, keyword); messageinfo = string.Format("<h2 class=\"post-message\">搜索:{0}</h2>", keyword); url = MakeUrl("search", "keyword", Server.UrlEncode(keyword)); } else if (pageType == "archive") //先按月归档 { string datestr = RequestHelper.QueryString("date"); string year = datestr.Substring(0, 4); string month = datestr.Substring(4, 2); DateTime date = Convert.ToDateTime(year + "-" + month); begindate = date.ToString(); enddate = date.AddMonths(1).ToString(); th.Put(TagFields.META_KEYWORDS, "归档"); th.Put(TagFields.META_DESCRIPTION, SettingManager.GetSetting().SiteName + date.ToString("yyyy-MM") + "的归档"); th.Put(TagFields.PAGE_TITLE, "归档:" + date.ToString("yyyy-MM")); messageinfo = string.Format("<h2 class=\"post-message\">归档:{0}</h2>", date.ToString("yyyy-MM")); url = MakeUrl("archive", "date", datestr); } else //首页 { if (pageindex == 1) { th.Put(TagFields.IS_DEFAULT, "1"); } } th.Put(TagFields.POST_MESSAGE, messageinfo); // th.Put(TagFields.PAGER_INDEX, pageindex); int recordCount = 0; th.Put(TagFields.POSTS, PostManager.GetPostList(SettingManager.GetSetting().PageSizePostCount, pageindex, out recordCount, categoryId, tagId, userId, -1, 1, -1, 0, begindate, enddate, keyword)); th.Put(TagFields.PAGER, Pager.CreateHtml(SettingManager.GetSetting().PageSizePostCount, recordCount, url)); Display("default.html"); }
/// <summary> /// Builds list of matching tags by profile pattern /// Ensures only one instance of a given tag in results unlike GetAllMatchingTags method /// with highest confidence level for that tag pattern /// </summary> /// <param name="tagPattern"></param> /// <returns></returns> private List <TagInfo> GetTagInfoListByTagGroup(TagGroup tagGroup, bool addNotFound = true) { List <TagInfo> result = new List <TagInfo>(); HashSet <string> hashSet = new HashSet <string>(); foreach (TagSearchPattern pattern in tagGroup.Patterns ?? new List <TagSearchPattern>()) { if (pattern.Detected)//set at program.RollUp already so don't search for again { var tagPatternRegex = pattern.Expression; foreach (var match in _appMetaData?.Matches ?? new List <MatchRecord>()) { foreach (var tagItem in match.Tags ?? new string[] { }) { if (tagPatternRegex.IsMatch(tagItem)) { if (!hashSet.Contains(pattern.SearchPattern)) { result.Add(new TagInfo { Tag = tagItem, Confidence = match.Confidence.ToString(), Severity = match.Severity.ToString(), ShortTag = pattern.DisplayName, StatusIcon = pattern.DetectedIcon, Detected = true }); hashSet.Add(pattern.SearchPattern); pattern.Confidence = match.Confidence.ToString(); } else { //ensure we get highest confidence, severity as there are likely multiple matches for this tag pattern foreach (TagInfo updateItem in result) { if (updateItem.Tag == tagItem) { Confidence oldConfidence; Enum.TryParse(updateItem.Confidence, out oldConfidence); if (match.Confidence > oldConfidence) { updateItem.Confidence = match.Confidence.ToString(); pattern.Confidence = match.Confidence.ToString(); } Severity oldSeverity; Enum.TryParse(updateItem.Severity, out oldSeverity); if (match.Severity > oldSeverity) { updateItem.Severity = match.Severity.ToString(); } break; } } } } } } } else if (addNotFound) //allow to report on false presense items { TagInfo tagInfo = new TagInfo { Tag = pattern.SearchPattern, Detected = false, ShortTag = pattern.DisplayName, StatusIcon = pattern.NotDetectedIcon, Confidence = "", Severity = "" }; pattern.Confidence = ""; result.Add(tagInfo); hashSet.Add(tagInfo.Tag); } } return(result); }
private object[] GetNotFoundLine(TagInfo tags) { return(new object[] { ToTrackString(tags), "No match found!", false, 0, 0, 0, 0, 0 }); }
/// <summary> /// Disconnect /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DisconnectToolStripMenuItem_Click(object sender, EventArgs e) { if (RuntimeMongoDbContext.SelectTagType == ConstMgr.ConnectionExceptionTag) { return; } //关闭相关的Tab var connectionTag = trvsrvlst.SelectedNode.Tag.ToString(); MultiTabManger.SelectObjectTagPrefixDeleted(ConstMgr.CollectionTag + ":" + TagInfo.GetTagPath(connectionTag)); RuntimeMongoDbContext.RemoveConnectionConfig( RuntimeMongoDbContext.CurrentMongoConnectionconfig.ConnectionName); trvsrvlst.Nodes.Remove(trvsrvlst.SelectedNode); RefreshToolStripMenuItem_Click(sender, e); }
private ListViewItem inspectClass(Type t, string fileName, string virtualPath) { var lvi = new ListViewItem(); var ti = new TagInfo { Dataviews = new List <Resource>(), Tables = new List <Resource>(), VirtualPath = virtualPath, AssemblyName = fileName, ClassName = t.FullName }; lvi.Tag = ti; //var o = Activator.CreateInstance(_alternateDomain, fileName, t.FullName).Unwrap(); var o = Activator.CreateInstance(t); var resourceNames = "(Any)"; string singleResource = null; var rez = o as IDataResource; if (rez != null && rez.ResourceNames != null && rez.ResourceNames.Length > 0) { resourceNames = String.Join(", ", rez.ResourceNames); singleResource = rez.ResourceNames[0]; } var dvText = "-"; var tblText = "-"; if (o is IDataviewReadDataTrigger || o is IDataviewSaveDataTrigger) { // dataview trigger dvText = resourceNames; foreach (var r in rez.ResourceNames) { ti.Dataviews.Add(new Resource { ID = base.getDataviewID(r), Name = r }); } } if (o is ITableReadDataTrigger || o is ITableSaveDataTrigger) { // assume table trigger tblText = resourceNames; foreach (var r in rez.ResourceNames) { ti.Tables.Add(new Resource { ID = base.getTableID(r), Name = r }); } } lvi.Text = dvText; lvi.SubItems.Add(tblText); // class name lvi.SubItems.Add(t.Name); var desc = o as IDataTriggerDescription; if (desc != null) { // lvi.SubItems.Add(desc.GetTitle("en-US")); ti.Title = desc.GetTitle("en-US"); ti.Description = desc.GetDescription("en-US"); lvi.SubItems.Add(ti.Description); } return(lvi); }
public static bool IsTagged(this Component component, TagInfo tagInfo) => component != null && component.CompareTag(tagInfo.Name);
/// <summary> /// Processes a list of nodes. All XmlElements among the nodes are processed, /// any other types of nodes (comments, etc.) are ignored. /// </summary> /// <param name="xmlNodeList"> /// The list of nodes /// </param> /// <param name="tagInfos"> /// Specifies all tags (= node names) that are permissable. You get an exception if there is a node /// that is not listed here. However, see childNodeNameRegex. /// /// The nodes are not listed in the order in which they appear in the list. Instead, first all nodes /// with the name listed in the first TagInfo in tagInfos are processed. Then those in the second TagInfo, etc. /// /// This way, you can for example first process all appenders, and then all loggers. /// /// If there are no nodes at all for a tag name given in tagInfo, the /// XmlElementProcessor given in the tagInfo is called once with a null XmlElement. /// </param> /// <param name="context">parentName, appenderNames, sequence and sb get passed to the processor method that is listed for each tag in tagInfos.</param> /// <param name="sequence"></param> /// <param name="sb"></param> /// <param name="childNodeNameRegex"> /// If this is given, then only those nodes in xmlNodeList whose name matches childNodeNameRegex will be processed. /// The other nodes will be completely ignored. /// /// If this is not given, no filtering takes place and all nodes are processed. /// </param> public static void ProcessNodeList( XmlNodeList xmlNodeList, List <TagInfo> tagInfos, string parentName, Dictionary <string, string> appenderNames, Sequence sequence, StringBuilder sb, string childNodeNameRegex = ".*") { // Ensure there are no child nodes with names that are unknown - that is, not listed in tagInfos foreach (XmlNode xmlNode in xmlNodeList) { XmlElement xe = xmlNode as XmlElement; if (xe != null) { if (!Regex.IsMatch(xe.Name, childNodeNameRegex)) { continue; } if (!(tagInfos.Any(t => t.Tag == xe.Name))) { throw new UnknownTagException(xe.Name); } } } // Process each child node // // Note that the tagInfo list may be added to when tagInfo.XmlElementProcessor is called. // Because of this, use for, not foreach for (int i = 0; i < tagInfos.Count; i++) { TagInfo tagInfo = tagInfos[i]; int nbrTagsFound = 0; foreach (XmlNode xmlNode in xmlNodeList) { XmlElement xe = xmlNode as XmlElement; // If xmlNode is not an XmlElement, ignore it. // This will be the case when xmlNode is a comment. if (xe == null) { continue; } if (!Regex.IsMatch(xe.Name, childNodeNameRegex)) { continue; } if (xe.Name == tagInfo.Tag) { // Check that all attributes are valid EnsureAllAttributesKnown(xe, tagInfo.AttributeInfos); nbrTagsFound++; tagInfo.XmlElementProcessor(xe, parentName, appenderNames, sequence, tagInfo.AttributeInfos, sb); } } if (nbrTagsFound > tagInfo.MaxNbrTags) { throw new TooManyTagsException(tagInfo.Tag, tagInfo.MaxNbrTags, nbrTagsFound); } if (nbrTagsFound == 0) { tagInfo.XmlElementProcessor(null, parentName, appenderNames, sequence, tagInfo.AttributeInfos, sb); } } }
// 根据前端发来的 tagInfo 构造一个 TagData 对象 public TagData Build(TagInfo source, string protocol = InventoryInfo.ISO15693) { // Debug.Assert(false); // testing if (this._readers.Count == 0) { throw new Exception("当前没有任何(模拟的)读卡器,因此无法添加标签信息"); } var tag = TagData.Build(source, protocol); InventoryInfo inventory = tag.InventoryInfo; TagInfo tagInfo = tag.TagInfo; // 自动生成一些成员 // inventory inventory.TagType = 0; // ??? inventory.AipID = 0; // ??? // tagInfo Reader reader = null; if (string.IsNullOrEmpty(tagInfo.ReaderName)) { // 自动取协议合适的第一个读卡器? reader = _readers.Find((r) => { return(StringUtil.IsInList(protocol, r.Protocols) == true); }); if (reader == null) { throw new Exception($"没有找到满足 '{protocol}' 协议的读卡器"); } } else { var result = GetReader(tagInfo.ReaderName, out reader); if (result.Value == -1) { throw new Exception($"读卡器 '{tagInfo.ReaderName}' 没有找到"); } Debug.Assert(reader != null); } // tagInfo.ReaderName; if (string.IsNullOrEmpty(tagInfo.ReaderName)) { Debug.Assert(string.IsNullOrEmpty(reader.Name) == false); tagInfo.ReaderName = reader.Name; } // tagInfo.UID; // 自动发生 // 8 bytes? if (string.IsNullOrEmpty(tagInfo.UID)) { tagInfo.UID = ByteArray.GetHexTimeStampString(Guid.NewGuid().ToByteArray()); } // public byte DSFID { get; set; } // public byte AFI { get; set; } // public byte IcRef { get; set; } // 每个块内包含的字节数 tagInfo.BlockSize = 4; // 设置为默认值 // 块最大总数 tagInfo.MaxBlockCount = 28; // 设置为默认值 // public bool EAS { get; set; } // tagInfo.AntennaID; // 检查是否符合范围。否则设置为第一个天线 if (tagInfo.AntennaID < reader.AntennaStart || tagInfo.AntennaID >= reader.AntennaStart + reader.AntennaCount) { tagInfo.AntennaID = (uint)reader.AntennaStart; } // 锁定状态字符串。表达每个块的锁定状态 // 例如 "ll....lll"。'l' 表示锁定,'.' 表示没有锁定。缺省为 '.'。空字符串表示全部块都没有被锁定 // LockStatus { get; set; } // 芯片全部内容字节 // Bytes { get; set; } tag.RefreshInventoryInfo(); return(tag); }
private Dictionary <string, DeepLTag> GetSourceTagsDict() { _tagsDictionary = new Dictionary <string, DeepLTag>(); try { //build dict for (var i = 0; i < _sourceSegment.Elements.Count; i++) { var elType = _sourceSegment.Elements[i].GetType(); if (elType.ToString() == "Sdl.LanguagePlatform.Core.Tag") //if tag, add to dictionary { var theTag = new DeepLTag((Tag)_sourceSegment.Elements[i].Duplicate()); var tagText = string.Empty; var tagInfo = new TagInfo { TagType = theTag.SdlTag.Type, Index = i, IsClosed = false, TagId = theTag.SdlTag.TagID }; if (theTag.SdlTag.Type == TagType.Start) { tagText = "<tg" + tagInfo.TagId + ">"; } if (theTag.SdlTag.Type == TagType.End) { tagInfo.IsClosed = true; tagText = "</tg" + tagInfo.TagId + ">"; } if (theTag.SdlTag.Type == TagType.Standalone || theTag.SdlTag.Type == TagType.TextPlaceholder || theTag.SdlTag.Type == TagType.LockedContent) { tagText = "<tg" + tagInfo.TagId + "/>"; } _preparedSourceText += tagText; //now we have to figure out whether this tag is preceded and/or followed by whitespace if (i > 0 && !_sourceSegment.Elements[i - 1].GetType().ToString().Equals("Sdl.LanguagePlatform.Core.Tag")) { var prevText = _sourceSegment.Elements[i - 1].ToString(); if (!prevText.Trim().Equals("")) //and not just whitespace { //get number of trailing spaces for that segment var whitespace = prevText.Length - prevText.TrimEnd().Length; //add that trailing space to our tag as leading space theTag.PadLeft = prevText.Substring(prevText.Length - whitespace); } } if (i < _sourceSegment.Elements.Count - 1 && !_sourceSegment.Elements[i + 1].GetType().ToString().Equals("Sdl.LanguagePlatform.Core.Tag")) { //here we don't care whether it is only whitespace //get number of leading spaces for that segment var nextText = _sourceSegment.Elements[i + 1].ToString(); var whitespace = nextText.Length - nextText.TrimStart().Length; //add that trailing space to our tag as leading space theTag.PadRight = nextText.Substring(0, whitespace); } //add our new tag code to the dict with the corresponding tag if it's not already there if (!_tagsDictionary.ContainsKey(tagText)) { _tagsDictionary.Add(tagText, theTag); } } else { //if not a tag var str = HttpUtility.HtmlEncode(_sourceSegment.Elements[i].ToString()); //HtmlEncode our plain text to be better processed by google and add to string _preparedSourceText += _sourceSegment.Elements[i].ToString(); } } TagsInfo.Clear(); } catch (Exception e) { Log.Logger.Error($"{e.Message}\n {e.StackTrace}"); } return(_tagsDictionary); }
// parameters: // one_reader_name 不能用通配符 // style randomizeEasAfiPassword public NormalResult WriteTagInfo(// byte[] uid, UInt32 tag_type string one_reader_name, TagInfo old_tag_info, TagInfo new_tag_info //, // string style ) { StringBuilder debugInfo = new StringBuilder(); debugInfo.AppendLine($"WriteTagInfo() one_reader_name={one_reader_name}"); debugInfo.AppendLine($"old_tag_info={old_tag_info.ToString()}"); debugInfo.AppendLine($"new_tag_info={new_tag_info.ToString()}"); WriteDebugLog(debugInfo.ToString()); // 要确保 new_tag_info.Bytes 包含全部 byte,避免以前标签的内容在保存后出现残留 EnsureBytes(new_tag_info); EnsureBytes(old_tag_info); NormalResult result = GetReader(one_reader_name, out Reader reader); if (result.Value == -1) { return(result); } // 锁定一个读卡器 LockReader(reader); try { // TODO: 选择天线 // 2019/9/27 // 选择天线 if (reader.AntennaCount > 1) { /* * var hr = rfidlib_reader.RDR_SetAcessAntenna(reader.ReaderHandle, * (byte)old_tag_info.AntennaID); * if (hr != 0) * { * return new GetTagInfoResult * { * Value = -1, * ErrorInfo = $"3 RDR_SetAcessAntenna() error. hr:{hr},reader_name:{reader.Name},antenna_id:{old_tag_info.AntennaID}", * ErrorCode = GetErrorCode(hr, reader.ReaderHandle) * }; * } */ } var tag = FindTag(old_tag_info.UID, reader.Name); if (tag == null) { return new NormalResult { Value = -1, ErrorInfo = "connectTag Error" } } ; var tagInfo = tag.TagInfo; /* * UInt32 tag_type = RFIDLIB.rfidlib_def.RFID_ISO15693_PICC_ICODE_SLI_ID; * UIntPtr hTag = _connectTag(reader.ReaderHandle, old_tag_info.UID, tag_type); * if (hTag == UIntPtr.Zero) * return new NormalResult { Value = -1, ErrorInfo = "connectTag Error" }; */ try { // TODO: 如果是新标签,第一次执行修改密码命令 // *** 分段写入内容 bytes if (new_tag_info.Bytes != null) { // 写入时候自动跳过锁定的块 List <BlockRange> new_ranges = BlockRange.GetBlockRanges( (int)old_tag_info.BlockSize, new_tag_info.Bytes, old_tag_info.LockStatus, 'l'); // 检查要跳过的块,要对比新旧 bytes 是否完全一致。 // 不一致则说明数据修改过程有问题 { List <BlockRange> compare_ranges = BlockRange.GetBlockRanges( (int)old_tag_info.BlockSize, old_tag_info.Bytes, old_tag_info.LockStatus, 'l'); NormalResult result0 = CompareLockedBytes( compare_ranges, new_ranges); if (result0.Value == -1) { return(result0); } } int current_block_count = 0; foreach (BlockRange range in new_ranges) { if (range.Locked == false) { NormalResult result0 = TagData.WriteBlocks( tagInfo, (uint)current_block_count, (uint)range.BlockCount, range.Bytes); if (result0.Value == -1) { return new NormalResult { Value = -1, ErrorInfo = result0.ErrorInfo, ErrorCode = result0.ErrorCode } } ; } current_block_count += range.BlockCount; } } // *** 兑现锁定 'w' 状态的块 if (new_tag_info.Bytes != null) { List <BlockRange> ranges = BlockRange.GetBlockRanges( (int)old_tag_info.BlockSize, new_tag_info.Bytes, // TODO: 研究一下此参数其实应该允许为 null new_tag_info.LockStatus, 'w'); // 检查,原来的 'l' 状态的块,不应后来被当作 'w' 再次锁定 string error_info = CheckNewlyLockStatus(old_tag_info.LockStatus, new_tag_info.LockStatus); if (string.IsNullOrEmpty(error_info) == false) { return new NormalResult { Value = -1, ErrorInfo = error_info, ErrorCode = "checkTwoLockStatusError" } } ; int current_block_count = 0; foreach (BlockRange range in ranges) { if (range.Locked == true) { string error_code = TagData.LockBlocks( tagInfo, (uint)current_block_count, (uint)range.BlockCount); if (string.IsNullOrEmpty(error_code) == false) { return new NormalResult { Value = -1, ErrorInfo = "LockBlocks error", ErrorCode = error_code } } ; } current_block_count += range.BlockCount; } } // 写入 DSFID if (old_tag_info.DSFID != new_tag_info.DSFID) { tagInfo.DSFID = new_tag_info.DSFID; /* * NormalResult result0 = WriteDSFID(reader.ReaderHandle, hTag, new_tag_info.DSFID); * if (result0.Value == -1) * return result0; */ } // 写入 AFI if (old_tag_info.AFI != new_tag_info.AFI) { tagInfo.AFI = new_tag_info.AFI; /* * NormalResult result0 = WriteAFI(reader.ReaderHandle, hTag, new_tag_info.AFI); * if (result0.Value == -1) * return result0; */ } // 设置 EAS 状态 if (old_tag_info.EAS != new_tag_info.EAS) { tagInfo.EAS = new_tag_info.EAS; /* * NormalResult result0 = EnableEAS(reader.ReaderHandle, hTag, new_tag_info.EAS); * if (result0.Value == -1) * return result0; */ } tag.RefreshInventoryInfo(); return(new NormalResult()); } finally { // _disconnectTag(reader.ReaderHandle, ref hTag); } } finally { UnlockReader(reader); } }
public void InitMock() { _tagDb = new TagDb() { TagId = "tag1", Content = "C#" }; _tagDbFirst = new List <TagDb>() { _tagDb, new TagDb() { TagId = "tag2", Content = "ASP" }, }; _tagDbSecond = new List <TagDb>() { new TagDb() { TagId = "tag3", Content = "Java" }, new TagDb() { TagId = "tag4", Content = "Javascript" }, }; _tagInfo = new TagInfo() { TagId = "tag1", Content = "C#" }; _tagInfoFirst = new List <TagInfo>() { _tagInfo, new TagInfo() { TagId = "tag2", Content = "ASP" }, }; _tagInfoSecond = new List <TagInfo>() { new TagInfo() { TagId = "tag3", Content = "Java" }, new TagInfo() { TagId = "tag4", Content = "Javascript" }, }; _coursesDb = new List <CourseDb>() { new CourseDb() { CourseId = "idCourse1", Name = "Course1", Price = 10, Date = DateTime.Now, Description = "Description1", Level = 1, Raiting = 5, RateCount = 3, Tags = _tagDbFirst }, new CourseDb() { CourseId = "idCourse2", Name = "Course2", Price = 20, Date = DateTime.Now, Description = "Description2", Level = 2, Raiting = 4, RateCount = 10, Tags = _tagDbSecond }, new CourseDb() { CourseId = "idCourse3", Name = "Course3", Price = 30, Date = DateTime.Now, Description = "Description3", Level = 2, Raiting = 3, RateCount = 15, Tags = _tagDbSecond }, new CourseDb() { CourseId = "idCourse4", Name = "Course4", Price = 40, Date = DateTime.Now, Description = "Description4", Level = 1, Raiting = 2, RateCount = 12, Tags = _tagDbFirst }, new CourseDb() { CourseId = "idCourse5", Name = "Course5", Price = 50, Date = DateTime.Now, Description = "Description5", Level = 2, Raiting = 3, RateCount = 24, Tags = _tagDbFirst }, }.AsQueryable(); _coursesInfo = new List <CourseInfo>() { new CourseInfo() { Name = "Course1", Price = 10, Description = "Description1", Duration = 15, Level = 1, Raiting = 5 }, new CourseInfo() { Name = "Course2", Price = 20, Description = "Description2", Duration = 25, Level = 2, Raiting = 4 }, new CourseInfo() { Name = "Course3", Price = 30, Description = "Description3", Duration = 35, Level = 2, Raiting = 3 }, new CourseInfo() { Name = "Course4", Price = 40, Description = "Description4", Duration = 45, Level = 1, Raiting = 2 }, new CourseInfo() { Name = "Course5", Price = 50, Description = "Description5", Duration = 55, Level = 2, Raiting = 3 } }.AsQueryable(); _oneCourseDb = new CourseDb() { CourseId = "idCourseFirst", Name = "CourseFirst", Price = 40, Date = DateTime.Now, Description = "DescriptionFirst", Level = 1, Raiting = 5 }; _oneCourseInfo = new CourseInfo() { Name = "CourseFirst", Price = 40, Description = "DescriptionFirst", Duration = 45, Level = 1, Raiting = 5 }; //_autorsDb = new List<AuthorDb>() { // new AuthorDb(){ AuthorId = "id1", Name = "name1", Lastname = "lastname1", Annotation = "Annotation1", Professions = "Professions1", AuthorCourses = _coursesDb}, // new AuthorDb(){ AuthorId = "id2", Name = "name2", Lastname = "lastname2", Annotation = "Annotation2", Professions = "Professions2" }, // new AuthorDb(){ AuthorId = "id3", Name = "name3", Lastname = "lastname3", Annotation = "Annotation3", Professions = "Professions3" } //}.AsQueryable(); //_oneAuthorDb = new AuthorDb() { AuthorId = "id4", Name = "name4", Lastname = "lastname4", Annotation = "Annotation4", Professions = "Professions4" }; //_authorsInfo = new List<AuthorInfo>() { // new AuthorInfo(){ Name = "name1", Lastname = "lastname1", Annotation = "Annotation1", Professions = "Professions1" }, // new AuthorInfo(){ Name = "name2", Lastname = "lastname2", Annotation = "Annotation2", Professions = "Professions2" }, // new AuthorInfo(){ Name = "name3", Lastname = "lastname3", Annotation = "Annotation3", Professions = "Professions3" } //}.AsQueryable(); //_oneAuthorInfo = new AuthorInfo() { Name = "name4", Lastname = "lastname4", Annotation = "Annotation4", Professions = "Professions4" }; _mockSet = new Mock <DbSet <CourseDb> >(); _mockSet.As <IQueryable <CourseDb> >().Setup(m => m.Expression).Returns(_coursesDb.Expression); _mockSet.As <IQueryable <CourseDb> >().Setup(m => m.ElementType).Returns(_coursesDb.ElementType); _mockSet.As <IQueryable <CourseDb> >().Setup(m => m.GetEnumerator()).Returns(_coursesDb.GetEnumerator()); _mockContext = new Mock <VideoDbContext>(); _mockMapper = new Mock <IMapper>(); }
public TrackData(TagInfo tags) : this(tags.ISRC, tags.Artist, tags.Title, tags.Album, tags.Year, tags.Duration) { }
private bool readFrames(BinaryReader source, TagInfo Tag, MetaDataIO.ReadTagParams readTagParams) { string frameName; string strValue; int frameDataSize; long valuePosition; int frameFlags; source.BaseStream.Seek(Tag.FileSize - Tag.DataShift - Tag.Size, SeekOrigin.Begin); // Read all stored fields for (int iterator = 0; iterator < Tag.FrameCount; iterator++) { frameDataSize = source.ReadInt32(); frameFlags = source.ReadInt32(); frameName = StreamUtils.ReadNullTerminatedString(source, Utils.Latin1Encoding); // Slightly more permissive than what APE specs indicate in terms of allowed characters ("Space(0x20), Slash(0x2F), Digits(0x30...0x39), Letters(0x41...0x5A, 0x61...0x7A)") valuePosition = source.BaseStream.Position; if (frameDataSize < 0 || valuePosition + frameDataSize > Tag.FileSize) { LogDelegator.GetLogDelegate()(Log.LV_ERROR, "Invalid value found while reading APEtag frame"); return(false); } if ((frameDataSize > 0) && (frameDataSize <= 1000)) { /* * According to spec : "Items are not zero-terminated like in C / C++. * If there's a zero character, multiple items are stored under the key and the items are separated by zero characters." * * => Values have to be splitted */ strValue = Utils.StripEndingZeroChars(Encoding.UTF8.GetString(source.ReadBytes(frameDataSize))); strValue = strValue.Replace('\0', Settings.InternalValueSeparator).Trim(); SetMetaField(frameName.Trim().ToUpper(), strValue, readTagParams.ReadAllMetaFrames); } else if (frameDataSize > 0 && !frameName.ToLower().Contains("lyrics")) // Size > 1000 => Probably an embedded picture { int picturePosition; PictureInfo.PIC_TYPE picType = decodeAPEPictureType(frameName); if (picType.Equals(PictureInfo.PIC_TYPE.Unsupported)) { addPictureToken(getImplementedTagType(), frameName); picturePosition = takePicturePosition(getImplementedTagType(), frameName); } else { addPictureToken(picType); picturePosition = takePicturePosition(picType); } if (readTagParams.ReadPictures) { // Description seems to be a null-terminated ANSI string containing // * The frame name // * A byte (0x2E) // * The picture type (3 characters; similar to the 2nd part of the mime-type) string description = StreamUtils.ReadNullTerminatedString(source, Utils.Latin1Encoding); PictureInfo picInfo = PictureInfo.fromBinaryData(source.BaseStream, frameDataSize - description.Length - 1, picType, getImplementedTagType(), frameName, picturePosition); picInfo.Description = description; tagData.Pictures.Add(picInfo); } } source.BaseStream.Seek(valuePosition + frameDataSize, SeekOrigin.Begin); } return(true); }
private static string ParseImpl(bool isInnerHtml, PageInfo pageInfo, ContextInfo contextInfo, int tagLevel, int totalNum, bool isOrderByCount, string theme) { var innerHtml = string.Empty; if (isInnerHtml) { innerHtml = StringUtils.StripTags(contextInfo.OuterHtml, ElementName); } var tagsBuilder = new StringBuilder(); if (!isInnerHtml) { tagsBuilder.Append($@" <link rel=""stylesheet"" href=""{SiteFilesAssets.Tags.GetStyleUrl(pageInfo.ApiUrl, theme)}"" type=""text/css"" /> "); tagsBuilder.Append(@"<ul class=""tagCloud"">"); } if (contextInfo.ContextType == EContextType.Undefined) { contextInfo.ContextType = contextInfo.ContentId != 0 ? EContextType.Content : EContextType.Channel; } var contentId = 0; if (contextInfo.ContextType == EContextType.Content) { contentId = contextInfo.ContentId; } var tagInfoList = StlTagCache.GetTagInfoList(pageInfo.SiteId, contentId, isOrderByCount, totalNum); tagInfoList = TagUtils.GetTagInfoList(tagInfoList, totalNum, tagLevel); if (contextInfo.ContextType == EContextType.Content && contextInfo.ContentInfo != null) { var tagInfoList2 = new List <TagInfo>(); var tagNameList = TranslateUtils.StringCollectionToStringList(contextInfo.ContentInfo.Tags.Trim().Replace(" ", ",")); foreach (var tagName in tagNameList) { if (!string.IsNullOrEmpty(tagName)) { var isAdd = false; foreach (var tagInfo in tagInfoList) { if (tagInfo.Tag == tagName) { isAdd = true; tagInfoList2.Add(tagInfo); break; } } if (!isAdd) { var tagInfo = new TagInfo(0, pageInfo.SiteId, contentId.ToString(), tagName, 1); tagInfoList2.Add(tagInfo); } } } tagInfoList = tagInfoList2; } foreach (var tagInfo in tagInfoList) { if (isInnerHtml) { var tagHtml = innerHtml; tagHtml = StringUtils.ReplaceIgnoreCase(tagHtml, "{Tag.Name}", tagInfo.Tag); tagHtml = StringUtils.ReplaceIgnoreCase(tagHtml, "{Tag.Count}", tagInfo.UseNum.ToString()); tagHtml = StringUtils.ReplaceIgnoreCase(tagHtml, "{Tag.Level}", tagInfo.Level.ToString()); var innerBuilder = new StringBuilder(tagHtml); StlParserManager.ParseInnerContent(innerBuilder, pageInfo, contextInfo); tagsBuilder.Append(innerBuilder); } else { var url = PageUtility.ParseNavigationUrl(pageInfo.SiteInfo, $"@/utils/tags.html?tagName={PageUtils.UrlEncode(tagInfo.Tag)}", pageInfo.IsLocal); tagsBuilder.Append($@" <li class=""tag_popularity_{tagInfo.Level}""><a target=""_blank"" href=""{url}"">{tagInfo.Tag}</a></li> "); } } if (!isInnerHtml) { tagsBuilder.Append("</ul>"); } return(tagsBuilder.ToString()); }
public AddingTagEventArgs(TagInfo tag) { Tag = tag; }
private string ToTrackString(TagInfo tag) { return(string.Format("{0}-{1}", tag.Artist, tag.Title)); }
// GetTagInfo(bytes<8, 4>) -> buffer<unknown<0x58>, 0x1a> public ResultCode GetTagInfo(ServiceCtx context) { ResultCode resultCode = CheckNfcIsEnabled(); if (resultCode != ResultCode.Success) { return(resultCode); } if (context.Request.RecvListBuff.Count == 0) { return(ResultCode.WrongArgument); } long outputPosition = context.Request.RecvListBuff[0].Position; context.Response.PtrBuff[0] = context.Response.PtrBuff[0].WithSize(Marshal.SizeOf(typeof(TagInfo))); MemoryHelper.FillWithZeros(context.Memory, outputPosition, Marshal.SizeOf(typeof(TagInfo))); uint deviceHandle = (uint)context.RequestData.ReadUInt64(); if (context.Device.System.NfpDevices.Count == 0) { return(ResultCode.DeviceNotFound); } for (int i = 0; i < context.Device.System.NfpDevices.Count; i++) { if (context.Device.System.NfpDevices[i].Handle == (PlayerIndex)deviceHandle) { if (context.Device.System.NfpDevices[i].State == NfpDeviceState.TagRemoved) { resultCode = ResultCode.TagNotFound; } else { if (context.Device.System.NfpDevices[i].State == NfpDeviceState.TagMounted || context.Device.System.NfpDevices[i].State == NfpDeviceState.TagFound) { byte[] Uuid = VirtualAmiibo.GenerateUuid(context.Device.System.NfpDevices[i].AmiiboId, context.Device.System.NfpDevices[i].UseRandomUuid); if (Uuid.Length > AmiiboConstants.UuidMaxLength) { throw new ArgumentOutOfRangeException(); } TagInfo tagInfo = new TagInfo { UuidLength = (byte)Uuid.Length, Reserved1 = new Array21 <byte>(), Protocol = uint.MaxValue, // All Protocol TagType = uint.MaxValue, // All Type Reserved2 = new Array6 <byte>() }; Uuid.CopyTo(tagInfo.Uuid.ToSpan()); context.Memory.Write((ulong)outputPosition, tagInfo); resultCode = ResultCode.Success; } else { resultCode = ResultCode.WrongDeviceState; } } break; } } return(resultCode); }
/// <summary> /// 将数据库放入Node /// </summary> /// <param name="strDbName"></param> /// <param name="mongoSvrKey"></param> /// <param name="client"></param> /// <returns></returns> public static TreeNode FillDataBaseInfoToTreeNode(string strDbName, string mongoSvrKey, MongoClient client = null) { var strShowDbName = strDbName; if (!GuiConfig.IsUseDefaultLanguage) { if (StringResource.LanguageType == "Chinese") { switch (strDbName) { case ConstMgr.DatabaseNameAdmin: strShowDbName = "管理员权限(admin)"; break; case "local": strShowDbName = "本地(local)"; break; case "config": strShowDbName = "配置(config)"; break; default: break; } } } var mongoDbNode = new TreeNode(strShowDbName); mongoDbNode.Tag = TagInfo.CreateTagInfo(mongoSvrKey, strDbName); var userNode = new TreeNode("User", (int)GetSystemIcon.MainTreeImageType.UserIcon, (int)GetSystemIcon.MainTreeImageType.UserIcon); userNode.Tag = ConstMgr.UserListTag + ":" + mongoSvrKey + "/" + strDbName + "/" + ConstMgr.CollectionNameUser; mongoDbNode.Nodes.Add(userNode); var jsNode = new TreeNode("JavaScript", (int)GetSystemIcon.MainTreeImageType.JavaScriptList, (int)GetSystemIcon.MainTreeImageType.JavaScriptList); jsNode.Tag = ConstMgr.JavascriptTag + ":" + mongoSvrKey + "/" + strDbName + "/" + ConstMgr.CollectionNameJavascript; mongoDbNode.Nodes.Add(jsNode); var gfsNode = new TreeNode("Grid File System", (int)GetSystemIcon.MainTreeImageType.Gfs, (int)GetSystemIcon.MainTreeImageType.Gfs); gfsNode.Tag = ConstMgr.GridFileSystemTag + ":" + mongoSvrKey + "/" + strDbName + "/" + ConstMgr.CollectionNameGfsFiles; mongoDbNode.Nodes.Add(gfsNode); var mongoSysColListNode = new TreeNode("Collections(System)", (int)GetSystemIcon.MainTreeImageType.SystemCol, (int)GetSystemIcon.MainTreeImageType.SystemCol); mongoSysColListNode.Tag = ConstMgr.SystemCollectionListTag + ":" + mongoSvrKey + "/" + strDbName; mongoDbNode.Nodes.Add(mongoSysColListNode); var mongoColListNode = new TreeNode("Collections(General)", (int)GetSystemIcon.MainTreeImageType.CollectionList, (int)GetSystemIcon.MainTreeImageType.CollectionList); mongoColListNode.Tag = ConstMgr.CollectionListTag + ":" + mongoSvrKey + "/" + strDbName; var colNameList = GetConnectionInfo.GetCollectionList(client, strDbName); foreach (var colDoc in colNameList) { var strColName = colDoc.GetElement("name").Value.ToString(); switch (strColName) { case ConstMgr.CollectionNameUser: //system.users,fs,system.js这几个系统级别的Collection不需要放入 break; case ConstMgr.CollectionNameJavascript: //foreach (var doc in MongoHelper.NewUtility.GetConnectionInfo.GetCollectionInfo(client, strDBName, ConstMgr.COLLECTION_NAME_JAVASCRIPT).Find<BsonDocument>(null,null)) //{ // var js = new TreeNode(doc.GetValue(ConstMgr.KEY_ID).ToString()); // js.ImageIndex = (int) GetSystemIcon.MainTreeImageType.JsDoc; // js.SelectedImageIndex = (int) GetSystemIcon.MainTreeImageType.JsDoc; // js.Tag = ConstMgr.JAVASCRIPT_DOC_TAG + ":" + mongoSvrKey + "/" + strDBName + "/" + // ConstMgr.COLLECTION_NAME_JAVASCRIPT + "/" + doc.GetValue(ConstMgr.KEY_ID); // JsNode.Nodes.Add(js); //} break; default: var mongoColNode = new TreeNode(); try { var col = GetConnectionInfo.GetCollectionInfo(client, strDbName, strColName); mongoColNode = FillCollectionInfoToTreeNode(col, mongoSvrKey); } catch (Exception ex) { mongoColNode = new TreeNode(strColName + "[exception:]"); mongoColNode.ImageIndex = (int)GetSystemIcon.MainTreeImageType.Err; mongoColNode.SelectedImageIndex = (int)GetSystemIcon.MainTreeImageType.Err; Utility.ExceptionDeal(ex); } if (Operater.IsSystemCollection(strDbName, strColName)) { switch (strColName) { case ConstMgr.CollectionNameGfsChunks: case ConstMgr.CollectionNameGfsFiles: gfsNode.Nodes.Add(mongoColNode); break; default: mongoSysColListNode.Nodes.Add(mongoColNode); break; } } else { mongoColListNode.Nodes.Add(mongoColNode); } break; } } mongoDbNode.Nodes.Add(mongoColListNode); mongoDbNode.ImageIndex = (int)GetSystemIcon.MainTreeImageType.Database; mongoDbNode.SelectedImageIndex = (int)GetSystemIcon.MainTreeImageType.Database; return(mongoDbNode); }
/// <summary> /// 由标签名称列表返回标签ID列表,带{},新标签自动添加 /// </summary> /// <param name="tagNameList"></param> /// <returns></returns> protected string GetTagIdList(string tagNames) { if (string.IsNullOrEmpty(tagNames)) { return string.Empty; } string tagIds = string.Empty; tagNames = tagNames.Replace(",", ","); string[] names = tagNames.Split(','); foreach (string n in names) { if (!string.IsNullOrEmpty(n)) { TagInfo t = TagManager.GetTag(n); //if (t == null) //{ // t = TagManager.GetTagBySlug(n); //} // int tagId = TagManager.GetTagId(n); if (t == null) { t = new TagInfo(); t.Count = 0; t.CreateDate = DateTime.Now; t.Description = n; t.Displayorder = 1000; t.Name = n; t.Slug = StringHelper.HtmlEncode(PageUtils.FilterSlug(n, "tag")); t.TagId = TagManager.InsertTag(t); } tagIds += "{" + t.TagId + "}"; } } return tagIds; }
private string ToTrackString(TagInfo tag) { return($"{tag.Artist}-{tag.Title}"); }