protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Append anti-CSRF token to Logoff URL var url = new HRef(ResolveUrl("~/Default.aspx?action=logoff")); url["token"] = AntiCsrf.Current.SecureToken; LogoutMenuLink.NavigateUrl = url.ToString(); InitSearchBox(); InitMenuStyleButton(); InitMenuModeButton(); InitLangMenuButton(); //cbxEnableCompactMode.Checked = _compactMode; litVersion.Text = FineUIPro.GlobalConfig.ProductVersion; InitOnlineUserCount(); btnUserName.Text = UserInfo.Current.ChineseName; linkCompanyTitle.InnerText = UserInfo.Current.CompanyName; btnUserName.IconUrl = UserInfo.Current.UserPortraitPath; //Tab1.IFrameUrl = "~/Home2.aspx"; //Tab1.RefreshIFrame(); } }
private string valToString(HVal val) { if (val == null) { return(""); } if (val == HMarker.VAL) { return("\u2713"); } if (val is HRef) { HRef href = (HRef)val; string s = "@" + href.val; if (href.disSet) { s += " " + href.display(); } return(s); } return(val.ToString()); }
public Task <HGrid> hisWriteAsync(HRef id, HHisItem[] items) { HDict meta = new HDictBuilder().add("id", id).toDict(); HGrid req = HGridBuilder.hisItemsToGrid(meta, items); return(CallAsync("hisWrite", req, "text/zinc")); }
public void testRef() { HaystackToken hrefVal = HaystackToken.refh; verifyToks("@125b780e-0684e169", new object[] { hrefVal, HRef.make("125b780e-0684e169") }); verifyToks("@demo:_:-.~", new object[] { hrefVal, HRef.make("demo:_:-.~") }); }
public void testBasics() { HRow row = BuildRows( new[] { "id", "site", "geoAddr", "area", "date", "null" }, new HVal[] { HRef.make("aaaa-bbbb"), HMarker.VAL, HStr.make("Richmond, Va"), HNum.make(1200, "ft"), HDate.make(2000, 12, 3), null }) .First(); // size Assert.AreEqual(row.size(), 6); Assert.IsFalse(row.isEmpty()); // configured tags Assert.IsTrue(row.get("id").hequals(HRef.make("aaaa-bbbb"))); Assert.IsTrue(row.get("site").hequals(HMarker.VAL)); Assert.IsTrue(row.get("geoAddr").hequals(HStr.make("Richmond, Va"))); Assert.IsTrue(row.get("area").hequals(HNum.make(1200, "ft"))); Assert.IsTrue(row.get("date").hequals(HDate.make(2000, 12, 3))); Assert.AreEqual(row.get("null", false), null); try { row.get("null"); Assert.Fail(); } catch (HaystackUnknownNameException) { Assert.IsTrue(true); } // missing tag Assert.IsFalse(row.has("foo")); Assert.IsTrue(row.missing("foo")); Assert.IsNull(row.get("foo", false)); try { row.get("foo"); Assert.Fail(); } catch (HaystackUnknownNameException) { Assert.IsTrue(true); } try { row.get("foo", true); Assert.Fail(); } catch (HaystackUnknownNameException) { Assert.IsTrue(true); } }
/** * Write a set of history time-series data to the given point record. * The record must already be defined and must be properly tagged as * a historized point. The timestamp timezone must exactly match the * point's configured "tz" tag. If duplicate or out-of-order items are * inserted then they must be gracefully merged. */ public override void hisWrite(HRef id, HHisItem[] items) { HDict meta = new HDictBuilder().add("id", id).toDict(); HGrid req = HGridBuilder.hisItemsToGrid(meta, items); call("hisWrite", req); }
// Depart from Java - This has a method where mimetype selection can be specified - NOTE: This toolkit // does not yet support a JsonReader public HGrid invokeAction(HRef id, string action, HDict args, string mimetype) { HDict meta = new HDictBuilder().add("id", id).add("action", action).toDict(); HGrid req = HGridBuilder.dictsToGrid(meta, new HDict[] { args }); return(call("invokeAction", req, mimetype)); }
public void testInclude() { HDict a = new HDictBuilder() .add("dis", "a") .add("num", 100) .add("foo", 99) .add("date", HDate.make(2011, 10, 5)) .toDict(); HDict b = new HDictBuilder() .add("dis", "b") .add("num", 200) .add("foo", 88) .add("date", HDate.make(2011, 10, 20)) .add("bar") .add("ref", HRef.make("a")) .toDict(); HDict c = new HDictBuilder() .add("dis", "c") .add("num", 300) .add("ref", HRef.make("b")) .add("bar") .toDict(); Dictionary <string, HDict> db = new Dictionary <string, HDict>(); db.Add("a", a); db.Add("b", b); db.Add("c", c); verifyInclude(db, "dis", "a,b,c"); verifyInclude(db, "dis == \"b\"", "b"); verifyInclude(db, "dis != \"b\"", "a,c"); verifyInclude(db, "dis <= \"b\"", "a,b"); verifyInclude(db, "dis > \"b\"", "c"); verifyInclude(db, "num < 200", "a"); verifyInclude(db, "num <= 200", "a,b"); verifyInclude(db, "num > 200", "c"); verifyInclude(db, "num >= 200", "b,c"); verifyInclude(db, "date", "a,b"); verifyInclude(db, "date == 2011-10-20", "b"); verifyInclude(db, "date < 2011-10-10", "a"); verifyInclude(db, "foo", "a,b"); verifyInclude(db, "not foo", "c"); verifyInclude(db, "foo == 88", "b"); verifyInclude(db, "foo != 88", "a"); verifyInclude(db, "foo == \"x\"", ""); verifyInclude(db, "ref", "b,c"); verifyInclude(db, "ref->dis", "b,c"); verifyInclude(db, "ref->dis == \"a\"", "b"); verifyInclude(db, "ref->bar", "c"); verifyInclude(db, "not ref->bar", "a,b"); verifyInclude(db, "foo and bar", "b"); verifyInclude(db, "foo or bar", "a,b,c"); verifyInclude(db, "(foo and bar) or num==300", "b,c"); verifyInclude(db, "foo and bar and num==300", ""); }
public void testSimple() { HGridBuilder b = new HGridBuilder(); b.addCol("id"); b.addCol("dis"); b.addCol("area"); b.addRow(new HVal[] { HRef.make("a"), HStr.make("Alpha"), HNum.make(1200) }); b.addRow(new HVal[] { HRef.make("b"), null, HNum.make(1400) }); // meta HGrid g = b.toGrid(); Assert.AreEqual(g.meta.size(), 0); // cols //HCol c; Assert.AreEqual(g.numCols, 3); verifyCol(g, 0, "id"); verifyCol(g, 1, "dis"); verifyCol(g, 2, "area"); // rows Assert.AreEqual(g.numRows, 2); Assert.IsFalse(g.isEmpty()); HRow r; r = g.row(0); Assert.IsTrue(r.get("id").hequals(HRef.make("a"))); Assert.IsTrue(r.get("dis").hequals(HStr.make("Alpha"))); Assert.IsTrue(r.get("area").hequals(HNum.make(1200))); r = g.row(1); Assert.IsTrue(r.get("id").hequals(HRef.make("b"))); Assert.IsNull(r.get("dis", false)); Assert.IsTrue(r.get("area").hequals(HNum.make(1400))); try { r.get("dis"); Assert.Fail(); } catch (UnknownNameException) { Assert.IsTrue(true); } Assert.IsNull(r.get("fooBar", false)); try { r.get("fooBar"); Assert.Fail(); } catch (UnknownNameException) { Assert.IsTrue(true); } // HRow no-nulls HRow it = g.row(0); Assert.IsFalse(it.Size > 3); verifyRowIterator(it, 0, "id", HRef.make("a")); verifyRowIterator(it, 1, "dis", HStr.make("Alpha")); verifyRowIterator(it, 2, "area", HNum.make(1200)); // HRow with nulls it = g.row(1); Assert.IsFalse(it.Size > 3); verifyRowIterator(it, 0, "id", HRef.make("b")); verifyRowIterator(it, 2, "area", HNum.make(1400)); // iterating verifyGridIterator(g); }
public void testIsId() { Assert.IsFalse(HRef.isId("")); Assert.IsFalse(HRef.isId("%")); Assert.IsTrue(HRef.isId("a")); Assert.IsTrue(HRef.isId("a-b:c")); Assert.IsFalse(HRef.isId("a b")); Assert.IsFalse(HRef.isId("a\u0129b")); }
private void WriteCell(StringBuilder sb, string pageText, string cssClass) { string linktext = pageText; string rel = null; bool createLink = true; if (pageText == PAGER_DOTS) { cssClass += " dots"; createLink = false; } else if (pageText == _prev) { cssClass += " prev"; rel = "prev"; pageText = PageCurrent.ToString(); } else if (pageText == _next) { cssClass += " next"; rel = "next"; pageText = (PageCurrent + 2).ToString(); } else if (pageText == (PageCurrent + 1).ToString()) { cssClass += " current"; createLink = false; } if (createLink) { sb.Append(@"<a href="""); sb.Append(HRef.Replace("page=-1", "page=" + pageText)); sb.Append(@""" title=""go to page "); sb.Append(pageText); sb.Append(@""""); if (rel != null) { sb.Append(@" rel=""" + rel + @""""); } sb.Append(">"); } sb.Append(@"<span class="""); sb.Append(cssClass); sb.Append(@""">"); sb.Append(linktext); sb.Append("</span>"); if (createLink) { sb.Append("</a>"); } sb.AppendLine(); }
////////////////////////////////////////////////////////////////////////// // History ////////////////////////////////////////////////////////////////////////// /** * Read history time-series data for given record and time range. The * items returned are exclusive of start time and inclusive of end time. * Raise exception if id does not map to a record with the required tags * "his" or "tz". The range may be either a String or a HDateTimeRange. * If HTimeDateRange is passed then must match the timezone configured on * the history record. Otherwise if a String is passed, it is resolved * relative to the history record's timezone. */ public override HGrid hisRead(HRef id, object range) { HGridBuilder b = new HGridBuilder(); b.addCol("id"); b.addCol("range"); b.addRow(new HVal[] { id, HStr.make(range.ToString()) }); HGrid req = b.toGrid(); HGrid res = call("hisRead", req); return(res); }
private HVal parseLiteral() { object val = m_curVal; if (m_tokCur == HaystackToken.refh && m_tokPeek == HaystackToken.str) { val = HRef.make(((HRef)val).val, ((HStr)m_peekVal).Value); consume(HaystackToken.refh); } consume(); return((HVal)val); }
internal void Export(XmlWriter writer, bool printIndex) { if (IsEmpty()) { return; } if (!MergeStart && ParentRow.ParentSheet.IsCellMerged(this)) { return; } writer.WriteStartElement("Cell"); if (!StyleID.IsNullOrEmpty() && ParentRow.StyleID != StyleID && StyleID != "Default") { writer.WriteAttributeString("ss", "StyleID", null, StyleID); } if (printIndex) { writer.WriteAttributeString("ss", "Index", null, (CellIndex + 1).ToString(CultureInfo.InvariantCulture)); } if (!HRef.IsNullOrEmpty()) { writer.WriteAttributeString("ss", "HRef", null, HRef.XmlEncode()); } if (MergeStart) { Worksheet ws = ParentRow.ParentSheet; Range range = ws._MergedCells.Find(rangeToFind => rangeToFind.CellFrom == this); if (range != null) { int rangeCols = range.ColumnCount - 1; int rangeRows = range.RowCount - 1; if (rangeCols > 0) { writer.WriteAttributeString("ss", "MergeAcross", null, rangeCols.ToString(CultureInfo.InvariantCulture)); } if (rangeRows > 0) { writer.WriteAttributeString("ss", "MergeDown", null, rangeRows.ToString(CultureInfo.InvariantCulture)); } } } ExportContent(writer); ExportComment(writer); List <string> namedRanges = GetParentBook().CellInNamedRanges(this); foreach (string range in namedRanges) { writer.WriteStartElement("NamedCell"); writer.WriteAttributeString("ss", "Name", null, range); writer.WriteEndElement(); } writer.WriteEndElement(); }
/** * Return the current status * of a point's priority array. * The result is returned grid with following columns: * <ul> * <li>level: number from 1 - 17 (17 is default) * <li>levelDis: human description of level * <li>val: current value at level or null * <li>who: who last controlled the value at this level * </ul> */ public HGrid pointWriteArray(HRef id) { HGridBuilder b = new HGridBuilder(); b.addCol("id"); b.addRow(new HVal[] { id }); HGrid req = b.toGrid(); HGrid res = call("pointWrite", req); return(res); }
////////////////////////////////////////////////////////////////////////// // Reads ////////////////////////////////////////////////////////////////////////// /** * Call "read" to lookup an entity record by it's unique identifier. * If not found then return null or throw an UnknownRecException based * on checked. * NOTE: Was final */ public HDict readById(HRef id, bool bChecked) { HDict rec = readById(id); if (rec != null) { return(rec); } if (bChecked) { throw new Exception("rec not found for: " + id.ToString()); } return(null); }
public void testBadRefConstruction() { string[] badRefs = new string[] { "@a", "a b", "a\n", "@" }; foreach (string strID in badRefs) { HRef.make(strID); } }
public void testBasics() { HRef hrefTest = HRef.make("a"); HStr str = HStr.make("string"); List <HVal> items = new List <HVal>(); items.Add(hrefTest); items.Add(str); HList list = HList.make(items); Assert.AreEqual(list.size(), 2); Assert.AreEqual(list.get(0), hrefTest); Assert.AreEqual(list.get(1), str); }
////////////////////////////////////////////////////////////////////////// // Reads ////////////////////////////////////////////////////////////////////////// protected override HDict onReadById(HRef id) { HGrid res = readByIds(new HRef[] { id }, false); if (res.isEmpty()) { return(null); } HDict rec = res.row(0); if (rec.missing("id")) { return(null); } return(rec); }
public static void RedirectToAccessDeniedPage(string reasonCode, bool useStaticPage, string queryString) { if (useStaticPage) { HttpContext.Current.Response.Redirect("~/Local/AccessDenied.htm?" + reasonCode, true); } else { Authentication.SignOut(); HttpContext.Current.Session.Abandon(); HRef page = new HRef(Global.SiteRootPath + "/AccessDenied.aspx"); page["ReasonCode"] = reasonCode; page.Merge(queryString); HttpContext.Current.Response.Redirect(page.ToString(), true); } }
public void testJson() { // Arrange. HRef hrefTest = HRef.make("a"); HStr str = HStr.make("string"); List <HVal> items = new List <HVal>(); items.Add(hrefTest); items.Add(str); HList list = HList.make(items); // Act. var json = list.toJson(); // Assert. Assert.AreEqual("[{\"_kind\":\"ref\",\"val\":\"a\",\"dis\":null},\"string\"]", json); }
public void testWriter() { HGridBuilder gb = new HGridBuilder(); gb.addCol("a"); gb.addCol("b"); gb.addRow(new HVal[] { HNA.VAL, HBool.TRUE }); // Original Unit test had null - this is not valid gb.addRow(new HVal[] { HMarker.VAL, HNA.VAL }); gb.addRow(new HVal[] { HRemove.VAL, HNA.VAL }); gb.addRow(new HVal[] { HStr.make("test"), HStr.make("with:colon") }); gb.addRow(new HVal[] { HNum.make(12), HNum.make(72.3, "\u00b0F") }); gb.addRow(new HVal[] { HNum.make(double.NegativeInfinity), HNum.make(Double.NaN) }); gb.addRow(new HVal[] { HDate.make(2015, 6, 9), HTime.make(1, 2, 3) }); var tz = HTimeZone.make("UTC", true); gb.addRow(new HVal[] { HDateTime.make(634429600180690000L, tz), HUri.make("foo.txt") }); gb.addRow(new HVal[] { HRef.make("abc"), HRef.make("abc", "A B C") }); gb.addRow(new HVal[] { HBin.make("text/plain"), HCoord.make(90, -123) }); HGrid grid = gb.toGrid(); string actual = HJsonWriter.gridToString(grid); // System.out.println(actual); string[] lines = actual.Split('\n'); Assert.AreEqual(lines[0], "{"); Assert.AreEqual(lines[1], "\"meta\": {\"ver\":\"2.0\"},"); Assert.AreEqual(lines[2], "\"cols\":["); Assert.AreEqual(lines[3], "{\"name\":\"a\"},"); Assert.AreEqual(lines[4], "{\"name\":\"b\"}"); Assert.AreEqual(lines[5], "],"); Assert.AreEqual(lines[6], "\"rows\":["); Assert.AreEqual(lines[7], "{\"a\":\"z:\", \"b\":true},"); Assert.AreEqual(lines[8], "{\"a\":\"m:\", \"b\":\"z:\"},"); Assert.AreEqual(lines[9], "{\"a\":\"x:\", \"b\":\"z:\"},"); Assert.AreEqual(lines[10], "{\"a\":\"test\", \"b\":\"s:with:colon\"},"); Assert.AreEqual(lines[11], "{\"a\":\"n:12\", \"b\":\"n:72.3 \u00b0F\"},"); Assert.AreEqual(lines[12], "{\"a\":\"n:-INF\", \"b\":\"n:NaN\"},"); Assert.AreEqual(lines[13], "{\"a\":\"d:2015-06-09\", \"b\":\"h:01:02:03\"},"); Assert.AreEqual(lines[14], "{\"a\":\"t:2011-06-06T12:26:58.069Z UTC\", \"b\":\"u:foo.txt\"},"); Assert.AreEqual(lines[15], "{\"a\":\"r:abc\", \"b\":\"r:abc A B C\"},"); Assert.AreEqual(lines[16], "{\"a\":\"b:text/plain\", \"b\":\"c:90.0,-123.0\"}"); Assert.AreEqual(lines[17], "]"); Assert.AreEqual(lines[18], "}"); }
public void testBasics() { HDict tags = new HDictBuilder() .add("id", HRef.make("aaaa-bbbb")) .add("site") .add("geoAddr", "Richmond, Va") .add("area", 1200, "ft") .add("date", HDate.make(2000, 12, 3)) .add("null", (HVal)null) .toDict(); // size Assert.AreEqual(tags.size(), 5); Assert.IsFalse(tags.isEmpty()); // configured tags Assert.IsTrue(tags.get("id").hequals(HRef.make("aaaa-bbbb"))); Assert.IsTrue(tags.get("site").hequals(HMarker.VAL)); Assert.IsTrue(tags.get("geoAddr").hequals(HStr.make("Richmond, Va"))); Assert.IsTrue(tags.get("area").hequals(HNum.make(1200, "ft"))); Assert.IsTrue(tags.get("date").hequals(HDate.make(2000, 12, 3))); Assert.AreEqual(tags.get("null", false), null); try { tags.get("null"); Assert.Fail(); } catch (HaystackUnknownNameException) { Assert.IsTrue(true); } // missing tag Assert.IsFalse(tags.has("foo")); Assert.IsTrue(tags.missing("foo")); Assert.IsNull(tags.get("foo", false)); try { tags.get("foo"); Assert.Fail(); } catch (HaystackUnknownNameException) { Assert.IsTrue(true); } try { tags.get("foo", true); Assert.Fail(); } catch (HaystackUnknownNameException) { Assert.IsTrue(true); } }
public override string ToString() { if (PageCount == 1) { return(""); } var sb = new StringBuilder(512); sb.Append(@"<div class="""); sb.Append(CssClass); sb.Append(@""">"); foreach (int pageSize in PageSizes) { sb.Append(@"<a href="""); sb.Append(HRef.Replace("pagesize=-1", "pagesize=" + pageSize)); sb.Append(@""" title="""); sb.Append("show "); sb.Append(pageSize); sb.Append(@" items per page"""); if (pageSize == CurrentPageSize) { sb.Append(@" class=""current page-numbers"""); } else { sb.Append(@" class=""page-numbers"""); } sb.Append(">"); sb.Append(pageSize); sb.AppendLine("</a>"); } sb.AppendLine(@"<span class=""page-numbers desc"">per page</span>"); sb.Append("</div>"); return(sb.ToString()); }
/// <summary> /// Compara si es la misma referencia /// </summary> /// <param name="comparar">Archivo a comparar</param> /// <returns>True si se trata del mismo archivo importado</returns> public Boolean EsMismoArchivo(ArchivoImportadoDocumento comparar) { if (comparar == null) { return(false); } if (HRef == null || !HRef.Equals(comparar.HRef)) { return(false); } if (TipoArchivo != SCHEMA_REF) { if (String.IsNullOrEmpty(Role) && !String.IsNullOrEmpty(comparar.Role)) { return(false); } if (Role != null && !Role.Equals(comparar.Role)) { return(false); } if (String.IsNullOrEmpty(RoleUri) && !String.IsNullOrEmpty(comparar.RoleUri)) { return(false); } if (RoleUri != null && !RoleUri.Equals(comparar.RoleUri)) { return(false); } } return(true); }
/// <summary> /// Compara los atributos para evaluar la equivalencia del DTS /// </summary> /// <param name="comparar"></param> /// <returns></returns> public override Boolean Equals(Object comparar) { if (!(comparar is DtsDocumentoInstanciaDto)) { return(false); } var dtsComparar = comparar as DtsDocumentoInstanciaDto; if (HRef == null || !HRef.Equals(dtsComparar.HRef)) { return(false); } if (Tipo != SCHEMA_REF) { if (String.IsNullOrEmpty(Role) && !String.IsNullOrEmpty(dtsComparar.Role)) { return(false); } if (Role != null && !Role.Equals(dtsComparar.Role)) { return(false); } if (String.IsNullOrEmpty(RoleUri) && !String.IsNullOrEmpty(dtsComparar.RoleUri)) { return(false); } if (RoleUri != null && !RoleUri.Equals(dtsComparar.RoleUri)) { return(false); } } return(true); }
private HaystackToken refh() { if (m_cCur < 0) { err("Unexpected eof in refh"); } consume('@'); StringBuilder s = new StringBuilder(); while (true) { if (HRef.isIdChar(m_cCur)) { s.Append((char)m_cCur); consume(); } else { break; } } m_val = HRef.make(s.ToString(), null); return(HaystackToken.refh); }
////////////////////////////////////////////////////////////////////////// // PointWrite ////////////////////////////////////////////////////////////////////////// /** * Write to a given level of a writable point, and return the current status * of a writable point's priority array (see pointWriteArray()). * * @param id Ref identifier of writable point * @param level Number from 1-17 for level to write * @param val value to write or null to auto the level * @param who optional username performing the write, otherwise user dis is used * @param dur Number with duration unit if setting level 8 */ public HGrid pointWrite(HRef id, int level, string who, HVal val, HNum dur) { HGridBuilder b = new HGridBuilder(); b.addCol("id"); b.addCol("level"); b.addCol("who"); b.addCol("val"); b.addCol("duration"); b.addRow(new HVal[] { id, HNum.make(level), HStr.make(who), val, dur }); HGrid req = b.toGrid(); HGrid res = call("pointWrite", req); return(res); }
public static Link CreateUpLink(Uri baseUri, HRef href) { return(CreateUpLink(new Uri(baseUri, href).ToString())); }
public static Link CreateUpLink(HRef href) { return(new Link(Relations.up, href)); }