public HttpResponseMessage GetShortItem() { ReturnHelper rh = new ReturnHelper(200, null, 0, ""); string shortid = HttpContext.Current.Request["shortid"]; try { if (string.IsNullOrEmpty(shortid)) { rh.msg = "缺少微语id"; rh.code = 300; } else { Shorts obj = new Shorts(); string strWhere = string.Format(" Shortid='{0}' ", shortid); DataTable dt = obj.GetPage("*", "Report_Time desc", strWhere, 0, 1); if (dt.Rows.Count > 0) { rh.totals = 1; rh.data = dt; rh.msg = "获取成功"; } } } catch (Exception e) { rh.code = 500; rh.msg = "处理错误"; } return(ReturnJson(JsonConvert.SerializeObject(rh))); }
public HttpResponseMessage UpdateShort(Shorts obj) { ReturnHelper rh = new ReturnHelper(200, null, 0, ""); try { obj.Update_Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); obj.Ip = IPHelper.GetHostIP(); obj.Address = IPHelper.GetHostAddress(obj.Ip); int i = obj.Update(" Shortid=@Shortid", obj.Shortid); if (i > 0) { rh.msg = "更新微语成功"; rh.totals = i; } else { rh.msg = "更新微语失败"; rh.code = 400; } } catch (Exception e) { rh.code = 500; rh.msg = "服务器错误,请通知管理员"; } return(ReturnJson(JsonConvert.SerializeObject(rh))); }
public HttpResponseMessage DeleteShort(Shorts obj) { ReturnHelper rh = new ReturnHelper(200, null, 0, ""); try { int i = obj.Delete(" Shortid=@Shortid", obj.Shortid); if (i > 0) { rh.msg = "删除微语成功"; rh.totals = i; } else { rh.msg = "删除文章失败"; rh.code = 400; } } catch (Exception e) { rh.code = 500; rh.msg = "服务器错误,请通知管理员"; } return(ReturnJson(JsonConvert.SerializeObject(rh))); }
public NRF52840_Radio(Machine machine) : base(machine) { IRQ = new GPIO(); interruptManager = new InterruptManager <Events>(this, IRQ, "RadioIrq"); shorts = new Shorts(); events = new IFlagRegisterField[(int)Events.PHYEnd + 1]; rxBuffer = new ConcurrentQueue <byte[]>(); DefineRegisters(); Reset(); }
internal static ILayout GetLayout(string dataType, Config config, FieldConfig fieldConfig) { string vtype = string.Empty; if (Shorts.Contains(dataType) || Integers.Contains(dataType) || Longs.Contains(dataType)) { vtype = "int"; if (dataType.EndsWith("_strict")) { vtype = "int-strict"; } if (dataType.EndsWith("_strict2")) { vtype = "int-strict2"; } return(new TextBox(config, fieldConfig, vtype)); } if (Decimals.Contains(dataType)) { vtype = "dec"; if (dataType.EndsWith("_strict")) { vtype = "dec-strict"; } if (dataType.EndsWith("_strict2")) { vtype = "dec-strict2"; } return(new TextBox(config, fieldConfig, vtype)); } if (Bools.Contains(dataType)) { return(new Radios(config, fieldConfig)); } if (Dates.Contains(dataType)) { return(new TextBox(config, fieldConfig, "date")); } return(Files.Contains(dataType) ? new TextBox(config, fieldConfig, "file") : new TextBox(config, fieldConfig)); }
protected virtual void RunShort(XmlNode Node) { bool run = !(Node.ChildNodes.Count > 1); if (run) { XmlNode ThatParent = null, ThisParent = Node.ParentNode; Shorts.TryGetValue(Node.InnerText, out ThatParent); if (ThatParent == null) { Help.Log.log("未被记录的Xml缩写:" + Node.InnerText); return; } XmlNode Now = Node; foreach (XmlNode child in ThatParent.ChildNodes) { if (child.NodeType == XmlNodeType.Element) { XmlNode n = child.Clone() as XmlNode; ThisParent.InsertAfter(n, Now); Now = n; } } } else { string text = ""; foreach (XmlNode child in Node.ChildNodes) { if (child.NodeType == XmlNodeType.Text) { text = child.Value.Trim(); break; } } if (Shorts.ContainsKey(text)) { Shorts[text] = Node; } else { Shorts.Add(text, Node); } } }
public HttpResponseMessage GetShortsPage() { ReturnHelper rh = new ReturnHelper(200, null, 0, ""); string key = HttpContext.Current.Request["key"]; string limit = HttpContext.Current.Request["limit"]; string page = HttpContext.Current.Request["page"]; try { if (string.IsNullOrEmpty(limit) || string.IsNullOrEmpty(page)) { rh.msg = "缺少分页参数"; rh.code = 300; } else { Shorts obj = new Shorts(); string strWhere = " 1=1"; if (!string.IsNullOrEmpty(key)) { strWhere += string.Format(" and (Short_Content like '%{0}%')", key); } int begin = (Convert.ToInt32(page) - 1) * Convert.ToInt32(limit); int end = Convert.ToInt32(page) * Convert.ToInt32(limit); DataTable dt = obj.GetPage("*", "Report_Time desc", strWhere, begin, end); if (dt.Rows.Count > 0) { rh.totals = SqlHelper.Count(string.Format("select count(*) from Shorts where {0}", strWhere), SqlHelper.CreateConn()); rh.data = dt; rh.msg = "获取成功"; } } } catch (Exception e) { rh.code = 500; rh.msg = "处理错误"; } return(ReturnJson(JsonConvert.SerializeObject(rh))); }
public HttpResponseMessage LikeShort(Shorts obj) { ReturnHelper rh = new ReturnHelper(200, null, 0, ""); try { string selectsql = string.Format(" select Likes from Shorts where Shortid='{0}'", obj.Shortid); string likes = SqlHelper.ShowData(selectsql, "Likes", SqlHelper.CreateConn()); if (!string.IsNullOrEmpty(likes)) { obj.Likes = Convert.ToInt32(likes) + 1;//访问次数+1 } else { obj.Likes = 1;//第一次访问 } int i = obj.Update(" Shortid=@Shortid", obj.Shortid); if (i > 0) { rh.msg = "点赞成功"; rh.totals = i; } else { rh.msg = "点赞失败"; rh.code = 400; } } catch (Exception e) { rh.code = 500; rh.msg = "服务器错误,请通知管理员"; } return(ReturnJson(JsonConvert.SerializeObject(rh))); }
/// <summary> /// 根据给定的 TopNode,“建造” 一个空间环境 /// </summary> /// <remarks> /// 约定:所有的数据节点,都位于且仅位于 TopNode 的所有直接子节点下。 /// 就理论上而言,TopNode 的 Name 应当为 Window,但不会检查它。 /// 硬性规定:Page 成为一个子节点。 /// 在节点下,可以使用 FILE 节点标记另一个文件内的节点内容。 /// </remarks> /// <param name="TopNode">含有标记内容的 Xml 节点</param> /// <param name="Collection">控件包</param> /// <param name="Parent">这些控件的父控件</param> /// <param name="default_head_x">默认的 x 轴起始位置</param> /// <param name="defaule_head_y">默认的 y 轴起始位置</param> /// <returns>建造完毕后,得出的所有控件的尺寸</returns> public Size Build(System.Xml.XmlNode TopNode, System.Windows.Forms.Control.ControlCollection Collection, Control.ObjectEditor Parent = null, int default_head_x = 0, int defaule_head_y = 0) { // 如果控件包是空的,那生成个蛋 if (Collection == null) { return(new Size(0, 0)); } // 把所有变量初始化。 max_x = head_x = now_x = default_head_x; max_y = head_y = now_y = defaule_head_y; Shorts.Clear(); string NodeName, ControlName; // 依次扫描各个子节点 foreach (XmlNode ChildNode in TopNode.ChildNodes) { NodeName = ChildNode.Name; // 若为控制指令,则执行并计算下一条指令。 if (CheckControlNode(ChildNode)) { continue; } // 若为控件指令,则生成它。 if (ChildNode.Name.ToUpper() == "DATA") { // 查找控件名 ControlName = ""; foreach (XmlAttribute attr in ChildNode.Attributes) { if (attr.Name.ToUpper() == "TYPE") { ControlName = attr.InnerText; } } // 生成此控件 DataEditor.Control.ObjectEditor editor = Collector.Instance[ControlName] as DataEditor.Control.ObjectEditor; // 若生成失败,此节点被送往一个空方法 if (editor == null) { FailedBuildingNodes(ChildNode); continue; } // 生成函数参数结构体,并将此结构体上传给函数 // 若此控件是一个容器,则在生成函数参数结构体的同时,应当已经在内部进行了子控件生成。 DataEditor.Control.ControlArgs argument = editor.Load_Information(ChildNode); editor.Arguments = argument; // 标记其父编辑器 editor.Container = Parent; // 转换成控件形式 System.Windows.Forms.Control control = editor.Binding; // 若转换失败,依然将节点送往一个空方法 if (control == null) { FailedBuildingNodes(ChildNode); continue; } // 将事件绑定给控件 control.Enter += DataEditor.Control.ControlHelper.OnEnter; control.Leave += DataEditor.Control.ControlHelper.OnLeave; // 留下追踪信息 control.Tag = editor; // 生成和计算 Label 的影响 int extra_w = 0, extra_h = 0; Label label = GetLabel(now_x, now_y, argument.Text); int label_mode = argument.Label; { switch (label_mode) { // Label 放在上边 case 1: extra_h = control.Margin.Top + label.Height; break; // Label 放在左边 case 2: extra_w = control.Margin.Left + label.Width; break; } } control.Location = new Point(now_x + extra_w, now_y + extra_h); // 若以上结算全部成功,计算它的坐标值 CalcCoodinate(control, control.Width + extra_w, control.Height + extra_h); // 设置标签 if (label_mode > 0) { editor.Label = label; AddLabel(label, Collection); } // 上传到父控件中 AddControl(control, Collection); } else if (ChildNode.Name.ToUpper() == "LABEL") { Label lb = GetLabel(now_x, now_y, ChildNode.InnerText); AddLabel(lb, Collection); CalcCoodinate(lb, lb.Width, lb.Height); } // 此后,剩余的节点被送往一个空方法。 else { NotDefinedNodes(ChildNode); } } TopNode.OwnerDocument.Save("X.xml"); return(new Size(max_x, max_y)); }
static void Main(string[] args) { var shorts = new Shorts { Color = "Tan", Length = Length.School, Size = LegSize.Baby, NumberOfPockets = 6 }; var jeans1 = new Jeans { Color = "Black", Size = LegSize.Adult, NumberOfPockets = 4 }; var jeans2 = new Jeans { Color = "Black", Size = LegSize.Child, NumberOfPockets = 4 }; var jeans3 = new Jeans { Color = "Black", Size = LegSize.Baby, NumberOfPockets = 4 }; var skirt = new Skirt { Color = "Rainbow", Size = LegSize.Child, NumberOfPockets = 0, Material = "Strechy", Length = Length.Church }; var skirt1 = new Skirt { Color = "Sparkly", Size = LegSize.Adult, NumberOfPockets = 0, Material = "Sequins", Length = Length.StreetCorner }; var movers = new List <IMoveable> { shorts, skirt, jeans1, jeans2, jeans3, skirt1 }; foreach (var mover in movers) { mover.Walk(10); mover.Jump(10); mover.Run(15); switch (mover) { case Skirt s: Console.WriteLine($"Its a skirt made of {s.Material}"); break; case Jeans j: Console.WriteLine($"its {j.Color} jeans"); j.HowFarIMoved = 2000; break; case IMoveable m: m.Run(10); break; } Console.WriteLine($"The {mover.GetType().Name} moved {mover.HowFarIMoved} units."); } Console.ReadLine(); var myDictionary = new Dictionary <string, string>(); }
public virtual void TestNonIndexedFields() { Directory dir = NewDirectory(); RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, Similarity, TimeZone); Document doc = new Document(); doc.Add(new StoredField("bogusbytes", "bogus")); doc.Add(new StoredField("bogusshorts", "bogus")); doc.Add(new StoredField("bogusints", "bogus")); doc.Add(new StoredField("boguslongs", "bogus")); doc.Add(new StoredField("bogusfloats", "bogus")); doc.Add(new StoredField("bogusdoubles", "bogus")); doc.Add(new StoredField("bogusterms", "bogus")); doc.Add(new StoredField("bogustermsindex", "bogus")); doc.Add(new StoredField("bogusmultivalued", "bogus")); doc.Add(new StoredField("bogusbits", "bogus")); iw.AddDocument(doc); DirectoryReader ir = iw.Reader; iw.Dispose(); AtomicReader ar = GetOnlySegmentReader(ir); IFieldCache cache = FieldCache.DEFAULT; cache.PurgeAllCaches(); Assert.AreEqual(0, cache.CacheEntries.Length); Bytes bytes = cache.GetBytes(ar, "bogusbytes", true); Assert.AreEqual(0, bytes.Get(0)); Shorts shorts = cache.GetShorts(ar, "bogusshorts", true); Assert.AreEqual(0, shorts.Get(0)); Ints ints = cache.GetInts(ar, "bogusints", true); Assert.AreEqual(0, ints.Get(0)); Longs longs = cache.GetLongs(ar, "boguslongs", true); Assert.AreEqual(0, longs.Get(0)); Floats floats = cache.GetFloats(ar, "bogusfloats", true); Assert.AreEqual(0, floats.Get(0), 0.0f); Doubles doubles = cache.GetDoubles(ar, "bogusdoubles", true); Assert.AreEqual(0, doubles.Get(0), 0.0D); BytesRef scratch = new BytesRef(); BinaryDocValues binaries = cache.GetTerms(ar, "bogusterms", true); binaries.Get(0, scratch); Assert.AreEqual(0, scratch.Length); SortedDocValues sorted = cache.GetTermsIndex(ar, "bogustermsindex"); Assert.AreEqual(-1, sorted.GetOrd(0)); sorted.Get(0, scratch); Assert.AreEqual(0, scratch.Length); SortedSetDocValues sortedSet = cache.GetDocTermOrds(ar, "bogusmultivalued"); sortedSet.Document = 0; Assert.AreEqual(SortedSetDocValues.NO_MORE_ORDS, sortedSet.NextOrd()); Bits bits = cache.GetDocsWithField(ar, "bogusbits"); Assert.IsFalse(bits.Get(0)); // check that we cached nothing Assert.AreEqual(0, cache.CacheEntries.Length); ir.Dispose(); dir.Dispose(); }
static void Main(string[] args) { var shorts = new Shorts { Color = "Tan", Length = Length.School, Size = LegSize.Baby, NumberOfPockets = 6 }; var jeans1 = new Jeans { Color = "Black", Size = LegSize.Adult, NumberOfPockets = 4 }; var jeans2 = new Jeans { Color = "Black", Size = LegSize.Child, NumberOfPockets = 4 }; var jeans3 = new Jeans { Color = "Black", Size = LegSize.Baby, NumberOfPockets = 4 }; var skirt = new Skirt { Color = "Rainbow", Size = LegSize.Child, NumberOfPockets = 0, Material = "Stretchy", Length = Length.Church }; var skirt1 = new Skirt { Color = "Sparkly", Size = LegSize.Adult, NumberOfPockets = 0, Material = "Sequins", Length = Length.StreetCorner }; var legs = new List <LegBase> { shorts, skirt, jeans1, jeans2, jeans3, skirt1 }; foreach (var leg in legs) { leg.Walk(3); // if leg is a skirt type, put it in variable s if (leg is Skirt s) { s.Material = "jeans"; } } Console.ReadLine(); }
public override string ToString() { return($"LastReadAll: {LastReadAll}, Shorts: [{String.Join("\r\n\r\n/***/\r\n\r\n", Shorts.AsEnumerable())}]"); }