public void SetNewTargetNumber(uint targetNumber) { TargetNumber = targetNumber; Head = null; GenerateNumberRow(targetNumber); }
public void IsValid(Document doc, string configuration = null) { ProductStructure prod; if (doc.ModelConfigurations.ConfigurationCount == 0) { prod = doc.GetProductStructures().FirstOrDefault(); } else { prod = doc.GetProductStructures().Where(x => x.Name == configuration).FirstOrDefault(); } RowElement row = prod.GetAllRowElements().Where( x => x.ParentRowElement == null).FirstOrDefault(); SchemeDataConfig schemeConfig = new SchemeDataConfig(prod); SchemeData scheme = schemeConfig.GetScheme(); ElementDataConfig dataConfig = new ElementDataConfig(row, scheme); ElementData elemData = dataConfig.ConfigData(); if ((elemData.MainSection == "Документация" || elemData.MainSection == "Сборочные единицы" || elemData.MainSection == "Комплекты") && elemData.DocCode == string.Empty) { throw new DocStructureDocTypeNotValidException(doc.FileName); } else if (Next != null) { Next.IsValid(doc, configuration); } }
//----< wrapper function to check the row size equivalence >------------------------------ public void Check(RowElement r) { if (!isSameRowSize(r)) { Console.WriteLine("The number of integers in each row is not matched."); } }
private void GenerateNumberRow(uint targetNumber) { if (targetNumber < MIN_TARGET_VALUE) { Head = new RowElement(0); return; } RowElement previous = null; for (uint i = 0; i < targetNumber; i++) { if ((ulong)i * i >= targetNumber) { break; } if (Head == null) { Head = new RowElement(i); previous = Head; continue; } if (previous != null) { previous.Next = new RowElement(i); previous = previous.Next; } } }
public IEnumerable <Cell> Cells() { XNamespace s = "http://schemas.openxmlformats.org/spreadsheetml/2006/main"; SpreadsheetDocument doc = (SpreadsheetDocument)Parent.OpenXmlPackage; SharedStringTablePart sharedStringTable = doc.WorkbookPart.SharedStringTablePart; return (from cell in this.RowElement.Elements(s + "c") let cellType = (string)cell.Attribute("t") let sharedString = cellType == "s" ? sharedStringTable .GetXDocument() .Root .Elements(s + "si") .Skip((int)cell.Element(s + "v")) .First() .Descendants(s + "t") .StringConcatenate(e => (string)e) : null let column = (string)cell.Attribute("r") select new Cell(this) { CellElement = cell, Row = (string)RowElement.Attribute("r"), Column = column, ColumnId = column.Split('0', '1', '2', '3', '4', '5', '6', '7', '8', '9').First(), Type = (string)cell.Attribute("t"), Formula = (string)cell.Element(s + "f"), Value = (string)cell.Element(s + "v"), SharedString = sharedString }); }
private T CreateCharacterList <T>(VisualElement root, string label, params string[] characters) where T : ColumnElement, new() { var columnElem = new T(); root.Add(columnElem); columnElem.Add(new Label(label)); if (characters.Length > 0) { var rowContainer = new RowContainer(); columnElem.Add(rowContainer); for (var i = 0; i < characters.Length; i++) { var rowElem = new RowElement { value = characters[i] }; columnElem.Add(rowElem); } } return(columnElem); }
private T CreateCommandList <T>(VisualElement root, string label, IReadOnlyList <Command> commands) where T : ColumnElement, new() { var columnElem = new T(); root.Add(columnElem); columnElem.Add(new Label(label)); if (commands.Count > 0) { var rowContainer = new RowContainer(); columnElem.Add(rowContainer); for (var i = 0; i < commands.Count; i++) { var rowElem = new RowElement { value = commands[i].Id }; columnElem.Add(rowElem); } } return(columnElem); }
void SetupElements() { m_MemoryUsageTable.Clear(); RowElement latestRow = default(RowElement); for (int i = 0; i < m_Elements.Count; i++) { var row = m_MemoryUsageBreakdownLegednRowViewTree.CloneTree(); m_MemoryUsageTable.Add(row); latestRow = new RowElement(row); m_Elements[i].SetupRow(this, latestRow); } if (ShowUnknown) { var unkownRow = m_MemoryUsageBreakdownLegednRowViewTree.CloneTree(); m_MemoryUsageTable.Add(unkownRow); m_UnknownRow = new RowElement(unkownRow); m_UnknownRow.ShowUsed = false; m_UnknownRow.RowName.text = UnknownName; m_UnknownRow.ColorBox.AddToClassList("background-color__memory-summary-category__unknown"); m_UnknownRow.RowSize.text = "?? B"; latestRow = m_UnknownRow; } latestRow.SetupAsLastRow(); SetTotalUsed(m_TotalBytes, m_Normalized, m_MaxTotalBytesToNormalizeTo, force: true); }
static void Main(string[] args) { Ticket tick1 = new Ticket(1, "09-04-2020", 1, "A", 15); Ticket tick2 = new Ticket(1, "09-04-2020", 1, "A", 16); Ticket tick3 = new Ticket(1, "09-04-2020", 1, "A", 17); JsonSerializerOptions options = new JsonSerializerOptions { WriteIndented = true, IgnoreNullValues = true, IgnoreReadOnlyProperties = true }; //STORE JSON OBJECT var jsonString = JsonSerializer.Serialize(new Ticket[] { tick1, tick2, tick3 }, options); Console.WriteLine(jsonString); File.WriteAllText("data.json", jsonString); //READ AND UPDATE JSON OBJECT string jsonText = File.ReadAllText("data.json"); List <Ticket> tickets = new List <Ticket>(); using (JsonDocument document = JsonDocument.Parse(jsonString)) { JsonElement root = document.RootElement; JsonElement ticketsArrayElement = root; foreach (JsonElement ticket in ticketsArrayElement.EnumerateArray()) { //Make .NET object is values are present in JSON if (ticket.TryGetProperty("Price", out JsonElement PriceElement) && ticket.TryGetProperty("Date", out JsonElement DateElement) && ticket.TryGetProperty("TheaterNumber", out JsonElement TheaterElement) && ticket.TryGetProperty("SeatNumber", out JsonElement SeatElement) && SeatElement.TryGetProperty("Row", out var RowElement) && SeatElement.TryGetProperty("Seat", out var SeatNumElement) ) { int price = PriceElement.GetInt32(); string date = DateElement.GetString(); int theaterNumber = TheaterElement.GetInt32(); string row = RowElement.GetString(); int seat = SeatNumElement.GetInt32(); tickets.Add(new Ticket(price, date, theaterNumber, row, seat)); } } } tickets[0].Date = "DATE HAS BEEN MODIFIED"; jsonText = JsonSerializer.Serialize(tickets, options); File.WriteAllText("data.json", jsonText); }
public void addRow(RowElement r) { this.rowBody.Row.Add(r); if (this.rowBody.Row.Count >= CAPACITY) { putRowBody(this.tableName, "falsekey", this.rowBody, CAPACITY); RowsPut += CAPACITY; Console.WriteLine(RowsPut + " rows put in " + tableName); this.rowBody.Row.Clear(); } }
public IList <Element> GetCells() { var cells = new List <Element>(); foreach (var childElement in RowElement.GetChildElements()) { if (childElement.IsNamed("td") || childElement.IsNamed("th")) { cells.Add(childElement); } } return(cells); }
public List <RowElement> ConvertToRowElements <T>(List <T> Allelements, List <ColumnMapper> mapper) { var type = typeof(T); List <RowElement> allElements = new List <RowElement>(); foreach (var item in Allelements) { var rowElement = new RowElement(); foreach (var mapElement in mapper) { var currentProp = type.GetProperty(mapElement.ClassFieldName); var propValue = (string)currentProp.GetValue(item, null); switch (mapElement.Column) { case ColumnsEnum.ColumnID: rowElement.RowID = propValue; break; case ColumnsEnum.Column1: rowElement.RowItem1 = propValue; break; case ColumnsEnum.Column2: rowElement.RowItem2 = propValue; break; case ColumnsEnum.Column3: rowElement.RowItem3 = propValue; break; case ColumnsEnum.Column4: rowElement.RowItem4 = propValue; break; default: break; } } allElements.Add(rowElement); // var rowElement = new RowElement(); } return(allElements); // type.GetProperties() }
public int GetIndexOfCell(Element element) { int index = 0; foreach (var cell in RowElement.GetChildElements()) { if (element.Text == cell.Text) { return(index); } index++; } return(-1); }
public String ajax_MasterGridData(q_PowerUnit sh) { a_PowerUnit ac = new a_PowerUnit() { Connection = getSQLConnection(), logPlamInfo = plamInfo }; var r = ac.SearchMaster(sh, LoginUserId); HandleResultAjaxFiles(r, Resources.Res.NoMessage); int page = (sh.page == null ? 1 : sh.page.CInt()); //int.Parse(getPage); int startRecord = PageCount.PageInfo(page, this.DefPageSize, r.Count); JQGridDataObject dataObject = new JQGridDataObject(); List <RowElement> setRowElement = new List <RowElement>(); foreach (var v in r.SearchData) { RowElement re = new RowElement(); re.id = v.progid.ToString(); re.cell = new String[8]; re.cell[0] = v.progname; for (int i = 0; i < v.Powers.Count; i++) { re.cell[i + 1] = JsonConvert.SerializeObject(v.Powers[i], new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } setRowElement.Add(re); } dataObject.rows = setRowElement.ToArray(); dataObject.total = PageCount.TotalPage; dataObject.page = PageCount.Page; dataObject.records = PageCount.RecordCount; return(JsonConvert.SerializeObject(dataObject, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore })); }
public override string ajax_MasterGridData(q_Unit queryObj) { #region 連接BusinessLogicLibary資料庫並取得資料 ac = new a_Unit(); ac.Connection = this.getSQLConnection(); RunQueryPackage <m_Unit> HResult = ac.SearchMaster(queryObj, LoginUserId); HandleResultCheck(HResult); #endregion #region 設定 Page物件 頁數 總筆數 每頁筆數 int page = (queryObj.page == null ? 1 : queryObj.page.CInt()); int startRecord = PageCount.PageInfo(page, this.DefPageSize, HResult.Count); #endregion #region 組成資料 List <RowElement> setRowElement = new List <RowElement>(); var drDataCollect = HResult.SearchData.Skip(startRecord).Take(this.DefPageSize); this.Tab = new UnitData(); foreach (var dr in drDataCollect) { RowElement GridRow = new RowElement() { id = dr.id.ToString(), cell = new String[3] }; GridRow.cell[0] = dr.id.ToString(); GridRow.cell[1] = dr.name; GridRow.cell[2] = dr.sort.ToString(); setRowElement.Add(GridRow); } #endregion #region 回傳JSON資料 JQGridDataObject dataObj = new JQGridDataObject() { rows = setRowElement.ToArray(), total = PageCount.TotalPage, page = PageCount.Page, records = PageCount.RecordCount }; return(JsonConvert.SerializeObject(dataObj, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore })); #endregion }
public List <Cell> Cells() { XNamespace s = "http://schemas.openxmlformats.org/spreadsheetml/2006/main"; var doc = (SpreadsheetDocument)Parent.OpenXmlPackage; var sharedStringTable = doc.WorkbookPart.SharedStringTablePart; var cells = RowElement.Elements(S.c); var r = cells .Select(cell => { var cellType = (string)cell.Attribute("t"); var sharedString = cellType == "s" ? sharedStringTable .GetXDocument() .Root .Elements(s + "si") .Skip((int)cell.Element(s + "v")) .First() .Descendants(s + "t") .StringConcatenate(e => (string)e) : null; var column = (string)cell.Attribute("r"); var columnAddress = column.Split('0', '1', '2', '3', '4', '5', '6', '7', '8', '9').First(); var columnIndex = XlsxTables.ColumnAddressToIndex(columnAddress); var newCell = new Cell(this) { CellElement = cell, Row = (string)RowElement.Attribute("r"), Column = column, ColumnAddress = columnAddress, ColumnIndex = columnIndex, Type = cellType, Formula = (string)cell.Element(S.f), Style = (int?)cell.Attribute("s"), Value = (string)cell.Element(S.v), SharedString = sharedString }; return(newCell); }); var ra = r.ToList(); return(ra); }
private void IsValidStructure(ProductStructure structure) { Document currentDoc = structure.Document; // существование родителя if (structure.GetAllRowElements().Where(x => x.ParentRowElement == null).Count() != 1) { throw new DocStructureParentException(currentDoc.FileName); } // проверка обозначения родителя на валидность RowElement parentItem = structure.GetAllRowElements().Where( x => x.ParentRowElement == null).FirstOrDefault(); SchemeDataConfig schemeConfig = new SchemeDataConfig(structure); SchemeData scheme = schemeConfig.GetScheme(); ElementDataConfig dataConfig = new ElementDataConfig(parentItem, scheme); ElementData itemData = dataConfig.ConfigData(); if (itemData.Sign == string.Empty || itemData.MainSection != "Документация" && itemData.Sign.Contains("СБ")) { throw new DocStructureParentSignNotValidException(currentDoc.FileName); } // проверка типа документа у родителя if ((itemData.MainSection == "Документация" || itemData.MainSection == "Сборочные единицы" || itemData.MainSection == "Комплекты") && itemData.DocCode == string.Empty) { throw new DocStructureDocTypeNotValidException(currentDoc.FileName); } // проверка обозначения у родителя if (itemData.Sign == String.Empty || itemData.Section == String.Empty) { throw new DocStructurePerentPropsException(); } }
/// <summary> /// Disposes all the resources used by the <see cref="Syncfusion.UI.Xaml.TreeGrid.TreeDataRowBase"/> class. /// </summary> /// <param name="isDisposing">Indicates whether the call is from Dispose method or from a finalizer.</param> protected virtual void Dispose(bool disposing) { if (disposing) { if (this.visibleColumns != null) { foreach (var item in visibleColumns) { item.Dispose(); } visibleColumns.Clear(); visibleColumns = null; } if (this.RowElement != null) { RowElement.Dispose(); this.RowElement = null; } this.rowData = null; this.TreeGrid = null; this.node = null; } }
//----< Matrix Addition O(n*m) >------------------------------ public bool Addition(MatrixElement a, MatrixElement b, ref MatrixElement result) { Console.WriteLine("matrix addition"); List<RowElement> aRows = a.getRows(); List<RowElement> bRows = b.getRows(); if (aRows.Count != bRows.Count) return false; List<RowElement> resRow = new List<RowElement>(); for (int i = 0; i < aRows.Count; ++i) { RowElement r = new RowElement(); for (int j = 0; j < aRows[i].Count(); ++j) { r.addElement(aRows[i].getElement(j) + bRows[i].getElement(j)); } result.addRows(r); } return true; }
private void AddFormTransaction(Transaction transaction, FormElement form) { Dictionary<string, int> Counters = new Dictionary<string, int>(); Counters.Add("GridCounter", 1); //FormElement form = instance.Transaction.Form; RowElement row = new RowElement(); ColumnElement col = null; ColumnElement col2 = null; Transaction trn = form.Instance.Transaction.Transaction; List<Artech.Genexus.Common.Objects.Attribute> lista = new List<Artech.Genexus.Common.Objects.Attribute>(); if (trn != null && trn != transaction) { foreach (TransactionAttribute ta2 in trn.Structure.Root.Attributes) { lista.Add(ta2.Attribute); } } bool geraAtt = true; foreach (IStructureItem item in transaction.Structure.Root.Items) { if (item is TransactionLevel) { TransactionLevel subLevel = item as TransactionLevel; bool hasMoreLevels = (subLevel.Levels.Count > 0); if (hasMoreLevels) { AddGridFreeStyle(subLevel, form, Counters); } else { AddGridStandard(subLevel, form, Counters); } } if (item is TransactionAttribute) { TransactionAttribute ta = item as TransactionAttribute; geraAtt = true; // if (!ta.is.Properties.GetPropertyValue<bool>(Properties..tra.TransactionAttribute.ShowInDefaultForms)) // { // geraAtt = false; // } if (trn != null && trn != transaction) { if (lista.Contains(ta.Attribute)) { geraAtt = false; } } if (geraAtt) { AttributeElement ae = new AttributeElement(ta.Attribute); ae.Description = ta.Attribute.ContextualTitleProperty; bool SameBeforeColumn = AddSuggestAttribute(row, ae, transaction); if (col2 != null && (SameBeforeColumn || (settings.Template.InferedAttributeInSameBeforeColumn && ta.IsInferred))) { col2.Add(ae); } else { // Cria Linha form.Add(row); // Cria Coluna de TextBlock col = row.AddColumn(); // Cria Textblock TextElement te = col.AddText(); te.Name = "tb" + ta.Name; te.Caption = BuildCaption(ta, "=" + ta.Name + ".ContextualTitle"); // Cria Coluna de Atributo col2 = row.AddColumn(); // Cria Atributo col2.Add(ae); if (ta.IsForeignKey && settings.Template.SuggestEventIsValidForForeignKey && String.IsNullOrEmpty(ae.IsValid)) { ae.IsValid = BuildIsValid(transaction, ta); } // Problema trava ao apagar objeto, loop infinito /* if (ta.IsForeignKey && settings.Template.PromptSuggestForeignKey && ae.Link == null) { BuildPrompt(form.Instance,ae, ta, trn); } */ row = new RowElement(); } } } } }
private static void EnableDisableEditRow(RowElement objr, StringBuilder ret, string operacao) { string tabula = "\t\t\t"; foreach (ColumnElement objc in objr.Columns) { foreach (IHPatternInstanceElement obji in objc.Items) { if (obji is AttributeElement) { AttributeElement obja = (AttributeElement)obji; if (!obja.Visible) { ret.AppendLine(tabula + String.Format("ctl{0}.Visible = false", obja.AttributeName)); } else { if (obja.Readonly) { ret.AppendLine(tabula + String.Format("ctl{0}.Enabled = false", obja.AttributeName)); } else { ret.AppendLine(tabula + String.Format("ctl{0}.Enabled = {1}", obja.AttributeName, operacao)); } } } if (obji is VariableElement) { VariableElement objv = (VariableElement)obji; if (!objv.Visible) { ret.AppendLine(tabula + String.Format("&{0}.Visible = false", objv.Name)); } else { if (objv.Readonly) { ret.AppendLine(tabula + String.Format("&{0}.Enabled = false", objv.Name)); } else { ret.AppendLine(tabula + String.Format("&{0}.Enabled = {1}", objv.Name, operacao)); } } } } } }
private static void ApplyRow(StringBuilder atts, RowElement row, KBObject objeto, Boolean geraBC, String sigla, HPatternSettings settings, bool overwrite) { atts.AppendLine("<tr>"); Transaction transaction = null; if (objeto is Transaction) transaction = (Transaction)objeto; foreach (ColumnElement col in row.Columns) { atts.AppendLine("<td align=\"" + col.GetAlign() + "\" colspan='" + col.ColSpan.ToString() + "' rowspan='" + col.RowSpan.ToString() + "'>"); foreach (Object obj in col.Items) { if (obj is AttributeElement) { AttributeElement att = (AttributeElement)obj; if (geraBC) { Dictionary<string, object> properties = new Dictionary<string, object>(); properties[Properties.HTMLATT.FieldSpecifier] = att.AttributeName; bool vreadonly = false; TransactionAttribute ta = null; if (transaction != null) { ta = transaction.Structure.Root.GetAttribute(att.AttributeName); if (ta == null) { vreadonly = true; } else { if (ta.IsInferred) { vreadonly = true; } } } if (att.Readonly) { vreadonly = true; } if (vreadonly) { properties[Properties.HTMLATT.ReadOnly] = true; } string themeClass = "Attribute"; if (transaction != null && ta != null) { if (ta.IsKey && !String.IsNullOrEmpty(settings.Theme.AttributeKey)) themeClass = settings.Theme.AttributeKey; } if (att.ThemeClass != String.Empty) themeClass = att.ThemeClass; if (vreadonly) { if (att.Format.ToLower() == "text") properties[Properties.HTMLATT.Format] = Properties.HTMLATT.Format_Values.Text; if (att.Format.ToLower() == "html") properties[Properties.HTMLATT.Format] = Properties.HTMLATT.Format_Values.Html; if (att.Format.ToLower() == "raw html") properties[Properties.HTMLATT.Format] = Properties.HTMLATT.Format_Values.RawHtml; if (att.Format.ToLower() == "text with meaningful spaces") properties[Properties.HTMLATT.Format] = Properties.HTMLATT.Format_Values.TextWithMeaningfulSpaces; } GetControlInfo(att, properties); atts.AppendLine(WebForm.Variable((transaction != null ? transaction.Name : "") + sigla, themeClass, null, properties)); } else { string themeClass = null; if (transaction != null) { TransactionAttribute ta = transaction.Structure.Root.GetAttribute(att.AttributeName); if (ta.IsKey && !String.IsNullOrEmpty(settings.Theme.AttributeKey)) themeClass = settings.Theme.AttributeKey; } if (att.ThemeClass != String.Empty) themeClass = att.ThemeClass; Dictionary<string, object> properties = new Dictionary<string, object>(); if (att.Readonly) { properties[Properties.HTMLATT.ReadOnly] = true; } GetControlSize(att, properties); atts.AppendLine(WebForm.Attribute(att.AttributeName, themeClass, null, properties)); } LinkBuild(atts, att, settings); if (!String.IsNullOrEmpty(att.MaskPicture)) { Dictionary<string, object> props = new Dictionary<string, object>(); props.Add("Picture", att.MaskPicture); props.Add("Reverse", att.Reverse); props.Add("Signed", att.Signed); props.Add("UnmaskedChars", att.UnmaskedChars); props.Add("UnmaskedValue",att.UnmaskedValue); atts.AppendLine(WebFormHelper.BeginControl("HMask2", att.AttributeName + "HMask", props)); atts.AppendLine(WebFormHelper.EndControl("HMask2")); } } if (obj is VariableElement) { VariableElement var = (VariableElement)obj; string themeClass = "Attribute"; if (var.ThemeClass != String.Empty) themeClass = var.ThemeClass; Dictionary<string, object> properties = new Dictionary<string, object>(); GetControlSize(var, properties); atts.AppendLine(WebForm.Variable(var.Name, themeClass, null, properties)); LinkBuild(atts, var, settings); if (!String.IsNullOrEmpty(var.MaskPicture)) { Dictionary<string, object> props = new Dictionary<string, object>(); props.Add("Picture", var.MaskPicture); props.Add("Reverse", var.Reverse); props.Add("Signed", var.Signed); props.Add("UnmaskedChars", var.UnmaskedChars); props.Add("UnmaskedValue", var.UnmaskedValue); atts.AppendLine(WebFormHelper.BeginControl("HMask2", var.Name + "HMask", props)); atts.AppendLine(WebFormHelper.EndControl("HMask2")); } } if (obj is TextElement) { TextElement text = (TextElement)obj; TemplateInternal.RenderText(text, row,atts,transaction); } if (obj is GroupElement) { GroupElement gobj = (GroupElement)obj; contaGroup++; string name = "Group"+contaGroup.ToString().Trim(); string tema = settings.Theme.Group; if (String.IsNullOrEmpty(tema)) tema = "Group"; if (!String.IsNullOrEmpty(gobj.Class)) tema = gobj.Class; atts.AppendLine(WebForm.BeginGroup(name, tema, gobj.Caption)); atts.AppendLine(WebForm.BeginTable("Table"+name,null)); foreach (RowElement row2 in gobj.Rows) { ApplyRow(atts, row2, objeto, geraBC, sigla, settings, overwrite); } atts.AppendLine(WebForm.EndTable()); atts.AppendLine(WebForm.EndGroup()); } if (obj is UserTableElement) { WebFormPart wform = null; if (transaction != null) { wform = transaction.WebForm; } else if (objeto is WebPanel) { wform = ((WebPanel)objeto).WebForm; } AddUserTable((UserTableElement)obj, atts, wform, overwrite); } if (!geraBC) { if (obj is GridFreeStyleElement) { GridFreeStyleElement grid = obj as GridFreeStyleElement; AddGridFreeStyle(atts, grid, settings); } if (obj is GridStandardElement) { GridStandardElement grid = obj as GridStandardElement; AddGridStandard(atts, grid, settings); } } } atts.AppendLine("</td>"); } atts.AppendLine("</tr>"); }
//----< transpose of a matrix >------------------------------ public void Reverse(out MatrixElement element) { element = new MatrixElement(); List<int> all = Serialize(); int cols = all.Count / numOfRows; for (int i = 0; i < cols; ++i) { RowElement r = new RowElement(); for (int j = 0; j < numOfRows; ++j) { r.addElement(all[j * cols + i]); } element.addRows(r); } }
private static void PromptRulesRow(StringBuilder ret, RowElement row, HPatternSettings settings, string prefix) { // Percorre as colunas foreach (ColumnElement col in row.Columns) { // Percorre os elementos foreach (IHPatternInstanceElement ele in col.Items) { if (ele is AttributeElement || ele is VariableElement) { PromptRulesElement(ret, ele, settings,prefix); } if (ele is GroupElement) { GroupElement grp = (GroupElement)ele; foreach (RowElement row2 in grp.Rows) { PromptRulesRow(ret, row2, settings, prefix); } } } } }
public abstract void VisitRowElement(RowElement element);
private void ApplyFieldsRow(IBaseCollection<IHPatternInstanceElement> ret, RowElement row) { foreach (ColumnElement col in row.Columns) { foreach (IHPatternInstanceElement i in col.Items) { if (i is AttributeElement || i is VariableElement || i is TextElement) { ret.Add(i); } else { if (i is GroupElement) { GroupElement grp = (GroupElement)i; foreach (RowElement row2 in grp.Rows) { ApplyFieldsRow(ret, row2); } } } } } }
//----< visit a Vector (Row) Operation >------------------------------ public override void VisitRowElement(RowElement element) { //Console.WriteLine("VisitRowElement"); List<int> row = element.getRow(); for (int i = 0; i < element.Count(); ++i) { Console.Write(row[i] + " "); dele(row[i].ToString() + " "); } Console.WriteLine(); dele("\n"); }
//----< VisitRowElement >------------------------------ public override void VisitRowElement(RowElement element) { Console.WriteLine("VisitRowElement"); }
//----< Matrix Multiplication O(n*n*n) >------------------------------ public bool Multiplication(MatrixElement a, MatrixElement b, ref MatrixElement result) { int rowNumOfA = a.GetNumOfRows(); int colNumOfA = a.GetNumOfCols(); int rowNumOfB = b.GetNumOfRows(); int colNumOfB = b.GetNumOfCols(); MatrixElement reverseB = new MatrixElement(); b.Reverse(out reverseB); List<RowElement> RowA = a.getRows(); List<RowElement> RowBReverse = reverseB.getRows(); for (int i = 0; i < rowNumOfA; ++i) { RowElement r = new RowElement(); RowElement partA = RowA[i]; for (int j = 0; j < colNumOfB; ++j) { int sum = 0; RowElement partB = RowBReverse[j]; for (int k = 0; k < colNumOfA; ++k) { int first = partA.getElement(k); int second = partB.getElement(k); sum += first * second; } r.addElement(sum); } result.addRows(r); } return true; }
private static void GetRowsAllTabsPP(IBaseCollection<RowElement> rows, RowElement row, bool GridFreeStyle, bool GridStandard, IHPatternInstanceElement trni) { // GetRowsAllTabs++ a revolta das Rows, a continuação :D rows.Add(row); foreach (ColumnElement col in row.Columns) { foreach (GroupElement grp in col.Groups) { foreach (RowElement row2 in grp.Rows) { GetRowsAllTabsPP(rows, row2,GridFreeStyle, GridStandard,trni); } } if (GridFreeStyle) { foreach (GridFreeStyleElement grid in col.GridFreeStyles) { GetRowsGridFreeStylePP(rows, grid, row, col, grid); } } if (GridStandard) { foreach (GridStandardElement grid in col.GridStandards) { GetRowsGridPP(rows, grid.Attributes.Attributes, row, col, grid); } } } }
private static void GetRowsGridFreeStylePP(IBaseCollection<RowElement> rows, GridFreeStyleElement grid, RowElement baserow, ColumnElement basecol, IHPatternInstanceElement trni) { GetRowsGridPP(rows, grid.Attributes, baserow, basecol, grid); foreach (GridFreeStyleElement grid2 in grid.GridFreeStyles) { GetRowsGridFreeStylePP(rows, grid2, baserow, basecol, grid2); } foreach (GridStandardElement grid2 in grid.GridStandards) { GetRowsGridPP(rows, grid2.Attributes.Attributes, baserow, basecol, grid2); } }
private void ExportStructure(ProductStructure structure, bool isConfig = false) { // верификация структуры IsValidStructure(structure); // текущий документ Document currentDoc = structure.Document; // схема структуры SchemeDataConfig schemeConfig = new SchemeDataConfig(structure); SchemeData scheme = schemeConfig.GetScheme(); // родительский элемент RowElement parentItem = structure.GetAllRowElements().Where( x => x.ParentRowElement == null).FirstOrDefault(); ElementDataConfig dataConfig = new ElementDataConfig(parentItem, scheme); ElementData itemData = dataConfig.ConfigData(); // если структура является исполнением, то обозначением головного элемента // является наименование структуры if (isConfig) { itemData.Sign = structure.Name; } // логирование log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(); // команды TFlexObjSynchRepository synchRep = new TFlexObjSynchRepository(); // родительский элемент decimal?parent = null; // код БД decimal code = 0; decimal doccode = 0; // синхронизация с КИС "Омега" V_SEPO_TFLEX_OBJ_SYNCH synchObj = synchRep.GetSynchObj( itemData.MainSection, itemData.DocCode, itemData.Sign, itemData.ObjectType); // если головной элемент не синхронизирован - выход if (synchObj == null) { return; } #region экспорт родителя switch (synchObj.KOTYPE) { case (decimal)ObjTypes.SpecFixture: #region Спецификация оснастки CreateSpecFix.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, fixTypeCode, ref code); // очищение спецификации ClearSpecification.Exec(code); // родительский элемент parent = code; // поиск файла спецификации по шаблону string signPattern = Regex.Replace(itemData.Sign, @"\D", ""); string[] files = Directory.GetFiles(currentDoc.FilePath); foreach (var file in files) { if (file.Contains(itemData.Sign) && file.Contains("СП")) { AddFile.Exec(code, file, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); } } #endregion Спецификация оснастки break; case (decimal)ObjTypes.SpecDraw: #region Сборочный чертеж CreateSpecDraw.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); #endregion Сборочный чертеж break; case (decimal)ObjTypes.Document: case (decimal)ObjTypes.UserDocument: #region Документация CreateDocument.Exec( synchObj.BOTYPE, itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); #endregion Документация break; case (decimal)ObjTypes.Detail: #region Деталь CreateDetail.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); // модели для детали var models = structure.GetAllRowElements().Where(x => x.ParentRowElement == parentItem); foreach (var model in models) { ElementDataConfig modelDataConfig = new ElementDataConfig(model, scheme); ElementData modelData = modelDataConfig.ConfigData(); if (modelData.FilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = modelData.Section; log.Position = modelData.Position; log.Sign = modelData.Sign; log.Name = modelData.Name; log.Qty = modelData.Qty; log.Doccode = modelData.DocCode; log.FilePath = modelData.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, modelData.FilePath, ompUserCode, synchObj.FILEGROUP, doccode, fileAdditional, ref linkdoccode); } } // моделями также являются невидимые фрагменты у деталей foreach (var fragment in currentDoc.GetFragments().Where(x => !x.Visible)) { if (fragment.FullFilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = null; log.Position = null; log.Sign = null; log.Name = null; log.Qty = null; log.Doccode = null; log.FilePath = fragment.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, fragment.FullFilePath, ompUserCode, synchObj.FILEGROUP, doccode, fileAdditional, ref linkdoccode); } } #endregion Деталь break; case (decimal)ObjTypes.Fixture: #region Оснастка CreateFixture.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, fixTypeCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); // модели для детали var fix_models = structure.GetAllRowElements().Where(x => x.ParentRowElement == parentItem); foreach (var model in fix_models) { ElementDataConfig modelDataConfig = new ElementDataConfig(model, scheme); ElementData modelData = modelDataConfig.ConfigData(); if (modelData.FilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = modelData.Section; log.Position = modelData.Position; log.Sign = modelData.Sign; log.Name = modelData.Name; log.Qty = modelData.Qty; log.Doccode = modelData.DocCode; log.FilePath = modelData.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, modelData.FilePath, ompUserCode, synchObj.FILEGROUP, doccode, fileAdditional, ref linkdoccode); } } // моделями также являются невидимые фрагменты у деталей foreach (var fragment in currentDoc.GetFragments().Where(x => !x.Visible)) { if (fragment.FullFilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = null; log.Position = null; log.Sign = null; log.Name = null; log.Qty = null; log.Doccode = null; log.FilePath = fragment.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, fragment.FullFilePath, ompUserCode, synchObj.FILEGROUP, doccode, fileAdditional, ref linkdoccode); } } #endregion Оснастка break; default: break; } #endregion экспорт родителя #region элементы спецификации if (itemData.MainSection == "Сборочные единицы") { foreach (var elem in structure .GetAllRowElements() .Where(x => x.ParentRowElement == parentItem) ) { // получение данных о документе dataConfig = new ElementDataConfig(elem, scheme); itemData = dataConfig.ConfigData(); // логирование log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(); // если обозначение или секция пустые, то переход на следующий элемент if (itemData.Sign == String.Empty || itemData.Section == String.Empty) { continue; } //System.Windows.Forms.MessageBox.Show(itemData.SignFull + " |" + itemData.Section + " | " // + itemData.MainSection + " | " + itemData.ObjectType); // синхронизация с КИС "Омега" synchObj = synchRep.GetSynchObj( itemData.MainSection, itemData.DocCode, itemData.Sign, itemData.ObjectType); // переход на следующий элемент, если позиция не синхронизирована if (synchObj == null) { continue; } switch (synchObj.KOTYPE) { case (decimal)ObjTypes.SpecFixture: #region Спецификация оснастки CreateSpecFix.Exec( itemData.SignFull, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, fixTypeCode, ref code); // очищение спецификации ClearSpecification.Exec(code); // если у сборки есть фрагмент... if (itemData.FilePath != null) { try { if (!File.Exists(itemData.FilePath)) { throw new FileNotFoundException(); } // открыть документ входящей сборки в режиме чтения Document linkDoc = TFlex.Application.OpenDocument(itemData.FilePath, false, true); // добавить документ в стек stackDocs.Add(linkDoc); // экспорт документа ExportDoc(linkDoc, itemData.SignFull); // закрытие документа linkDoc.Close(); // удалить из стека документ stackDocs.Remove(linkDoc); } catch (FileNotFoundException e) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(e); } catch (Exception) { throw; } } #endregion Спецификация оснастки break; case (decimal)ObjTypes.SpecDraw: #region Сборочный чертеж CreateSpecDraw.Exec( itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // присоединенный файл AddFile.Exec(code, currentDoc.FileName, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); #endregion Сборочный чертеж break; case (decimal)ObjTypes.Document: case (decimal)ObjTypes.UserDocument: #region Документация CreateDocument.Exec( synchObj.BOTYPE, itemData.Sign, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // файл if (itemData.FilePath != null) { AddFile.Exec(code, itemData.FilePath, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); } #endregion Документация break; case (decimal)ObjTypes.Detail: #region Деталь CreateDetail.Exec( itemData.SignFull, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, ref code); // файл if (itemData.FilePath != null) { AddFile.Exec(code, itemData.FilePath, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); } // модели для детали var models = structure.GetAllRowElements().Where(x => x.ParentRowElement == elem); foreach (var model in models) { ElementDataConfig modelDataConfig = new ElementDataConfig(model, scheme); ElementData modelData = modelDataConfig.ConfigData(); if (modelData.FilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = modelData.Section; log.Position = modelData.Position; log.Sign = modelData.Sign; log.Name = modelData.Name; log.Qty = modelData.Qty; log.Doccode = modelData.DocCode; log.FilePath = modelData.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.TryExec(log, code, modelData.FilePath, ompUserCode, synchObj.FILEGROUP, (doccode == 0) ? null : (decimal?)doccode, fileAdditional, ref linkdoccode); } } // открывается документ на деталь, если есть if (itemData.FilePath != null) { try { if (!File.Exists(itemData.FilePath)) { throw new FileNotFoundException(); } // открыть документ входящей сборки в режиме чтения Document linkDoc = TFlex.Application.OpenDocument(itemData.FilePath, false, true); // добавить документ в стек stackDocs.Add(linkDoc); // экспорт документа ExportDoc(linkDoc, itemData.SignFull); // закрытие документа linkDoc.Close(); // удалить из стека документ stackDocs.Remove(linkDoc); } catch (FileNotFoundException e) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(e); } catch (Exception) { throw; } } #endregion Деталь break; case (decimal)ObjTypes.Fixture: #region Оснастка CreateFixture.Exec( itemData.SignFull, itemData.Name, ownerCode, synchObj.BOSTATECODE, ompUserCode, fixTypeCode, ref code); // файл if (itemData.FilePath != null) { AddFile.Exec(code, itemData.FilePath, ompUserCode, synchObj.FILEGROUP, null, fileMain, ref doccode); } // модели для детали var fix_models = structure.GetAllRowElements().Where(x => x.ParentRowElement == elem); foreach (var model in fix_models) { ElementDataConfig modelDataConfig = new ElementDataConfig(model, scheme); ElementData modelData = modelDataConfig.ConfigData(); if (modelData.FilePath != null) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = modelData.Section; log.Position = modelData.Position; log.Sign = modelData.Sign; log.Name = modelData.Name; log.Qty = modelData.Qty; log.Doccode = modelData.DocCode; log.FilePath = modelData.FilePath; log.Error = null; decimal linkdoccode = 0; AddFile.Exec(code, modelData.FilePath, ompUserCode, synchObj.FILEGROUP, (doccode == 0) ? null : (decimal?)doccode, fileAdditional, ref linkdoccode); } } // открывается документ на деталь, если есть if (itemData.FilePath != null) { try { if (!File.Exists(itemData.FilePath)) { throw new FileNotFoundException(); } // открыть документ входящей сборки в режиме чтения Document linkDoc = TFlex.Application.OpenDocument(itemData.FilePath, false, true); // добавить документ в стек stackDocs.Add(linkDoc); // экспорт документа ExportDoc(linkDoc, itemData.SignFull); // закрытие документа linkDoc.Close(); // удалить из стека документ stackDocs.Remove(linkDoc); } catch (FileNotFoundException e) { log.Span = sw.Elapsed; log.User = settings.UserName; log.Document = this.doc.FileName; log.Section = itemData.Section; log.Position = itemData.Position; log.Sign = itemData.Sign; log.Name = itemData.Name; log.Qty = itemData.Qty; log.Doccode = itemData.DocCode; log.FilePath = itemData.FilePath; log.Error = null; log.Write(e); } catch (Exception) { throw; } } #endregion Оснастка break; default: code = 0; break; } // добавить очередной элемент в спецификацию if (code != 0) { AddElement.Exec( parent.Value, code, synchObj.KOTYPE, synchObj.OMPSECTION, itemData.Qty.Value, itemData.Position, ompUserCode); } } } #endregion элементы спецификации }
private bool AddSuggestAttribute(RowElement row, AttributeElement att, Transaction transaction) { bool ret = false; foreach (SettingsSuggestInstanceElement sugg in settings.Template.Suggests) { bool achou = false; foreach (SettingsAttributeDefinitionElement ad in sugg.AttributeDefinitions) { if (att.AttributeName.Trim() == ad.Name.Trim() || att.AttributeName.IndexOf(ad.Name) >= 0 || String.IsNullOrEmpty(ad.Name)) { if (ad.TypeAll) { achou = true; } else { switch (att.Attribute.Type) { case eDBType.CHARACTER: if (ad.TypeCharacter) achou = true; break; case eDBType.VARCHAR: if (ad.TypeCharacter) achou = true; break; case eDBType.LONGVARCHAR: if (ad.TypeCharacter) achou = true; break; case eDBType.NUMERIC: if (ad.TypeNumeric) achou = true; break; case eDBType.INT: if (ad.TypeNumeric) achou = true; break; case eDBType.DATE: if (ad.TypeData) achou = true; break; case eDBType.DATETIME: if (ad.TypeData) achou = true; break; } } if (achou) { if (ad.TypeSize > 0 && ad.TypeSize != att.Attribute.Length) achou = false; if (ad.TypeDecimal > 0 && ad.TypeDecimal != att.Attribute.Decimals) achou = false; } if (achou) break; } } if (achou) { if (sugg.Picture.ToLower() != "none" && sugg.Picture != String.Empty) { att.Picture = sugg.Picture; } if (sugg.Required.ToLower() != "none") { att.Required = sugg.Required; } if (sugg.RequiredMessage != String.Empty) { att.RequiredMessage = sugg.RequiredMessage; } if (sugg.RequiredAfterValidate != SettingsSuggestInstanceElement.RequiredAfterValidateValue.None) { att.RequiredAfterValidate = sugg.RequiredAfterValidate; } if (sugg.Rule.ToLower() != "none") { att.Rule = sugg.Rule; } if (sugg.ValueRule != String.Empty) { att.ValueRule = sugg.ValueRule; } if (sugg.IsValid != String.Empty) { att.IsValid = sugg.IsValid; } if (sugg.Readonly.ToLower() != "none") { att.Readonly = sugg.Readonly.ToLower() == "true" ? true : false; } if (sugg.Visible.ToLower() != "none") { att.Visible = sugg.Visible.ToLower() == "true" ? true : false; if (row != null) row.Visible = sugg.Visible.ToLower() == "true" ? true : false; } if (sugg.AttributeInSameBeforeColumn) { ret = true; } if (sugg.Description != String.Empty) { att.Description = sugg.Description; } if (!String.IsNullOrEmpty(sugg.EventValidation)) { att.EventValidation = sugg.EventValidation; } if (!String.IsNullOrEmpty(sugg.MaskPicture)) { att.MaskPicture = sugg.MaskPicture; att.Reverse = sugg.Reverse; att.Signed = sugg.Signed; att.UnmaskedChars = sugg.UnmaskedChars; att.UnmaskedValue = sugg.UnmaskedValue; } if (!String.IsNullOrEmpty(sugg.EventStart)) { att.EventStart = sugg.EventStart; } } } return ret; }
public static IElement ParseElement(string localizedType, string designedId, string designedName, IElement parent) { IElement element = null; switch (localizedType.ToLower()) { case ElementBase.WINDOW: element = new WindowElement(); element.Attributes.ElementType = ElementBase.WINDOW_TYPE; break; case ElementBase.DIALOG: element = new WindowElement(); element.Attributes.ElementType = ElementBase.DIALOG_TYPE; break; case ElementBase.BUTTON: element = new ButtonElement(); element.Attributes.ElementType = ElementBase.BUTTON_TYPE; break; case ElementBase.COMBO_BOX: element = new ComboBoxElement(); element.Attributes.ElementType = ElementBase.COMBOBOX_TYPE; break; case ElementBase.TEXT: element = new TextElement(); element.Attributes.ElementType = ElementBase.TEXT_TYPE; break; case ElementBase.PANE: element = new ContainerElement(); element.Attributes.ElementType = ElementBase.CONTAINER_TYPE; break; case ElementBase.TITLE_BAR: element = new TitleBarElement(); element.Attributes.ElementType = ElementBase.TITLEBAR_TYPE; break; case ElementBase.MENU_BAR: element = new MenuBarElement(); element.Attributes.ElementType = ElementBase.MENUBAR_TYPE; break; case ElementBase.DOCUMENT: element = new EditableTextElement(); element.Attributes.ElementType = ElementBase.EDITABLETEXT_TYPE; break; case ElementBase.TAB: element = new TabPageElement(); element.Attributes.ElementType = ElementBase.TABPAGE_TYPE; break; case ElementBase.TAB_ITEM: element = new TabItemElement(); element.Attributes.ElementType = ElementBase.TABITEM_TYPE; break; case ElementBase.SCROLL_BAR: element = new ScrollBarElement(); element.Attributes.ElementType = ElementBase.SCROLLBAR_TYPE; break; //case THUMB: case ElementBase.TREE: element = new TreeViewElement(); element.Attributes.ElementType = ElementBase.TREEVIEW_TYPE; break; case ElementBase.TREE_VIEW: element = new TreeViewElement(); element.Attributes.ElementType = ElementBase.TREEVIEW_TYPE; break; case ElementBase.TREE_ITEM: element = new TreeItemElement(); element.Attributes.ElementType = ElementBase.TREEITEM_TYPE; break; case ElementBase.TABLE: element = new TableElement(); element.Attributes.ElementType = ElementBase.TABLE_TYPE; break; //? case ElementBase.HEADER: element = new HeaderElement(); element.Attributes.ElementType = ElementBase.HEADER_TYPE; break; case ElementBase.ITEM: if (parent != null && (parent is TableElement || parent is DatagridElement)) { element = new RowElement(); element.Attributes.ElementType = ElementBase.ROW_TYPE; } break; case ElementBase.LIST: //(listview or checkedlistbox) element = new ListElement(); element.Attributes.ElementType = ElementBase.LIST_TYPE; break; case ElementBase.LIST_VIEW: //(listview or checkedlistbox) element = new ListElement(); element.Attributes.ElementType = ElementBase.LIST_TYPE; break; case ElementBase.LIST_ITEM: //(table) element = new ListItemElement(); element.Attributes.ElementType = ElementBase.LISTITEM_TYPE; break; case ElementBase.EDIT: //textbox element = new EditableTextElement(); element.Attributes.ElementType = ElementBase.EDITABLETEXT_TYPE; break; case ElementBase.CHECK_BOX: element = new CheckBoxElement(); element.Attributes.ElementType = ElementBase.CHECKBOX_TYPE; break; case ElementBase.RADIO_BUTTON: element = new RadioButtonElement(); element.Attributes.ElementType = ElementBase.RADIO_BUTTON_TYPE; break; case ElementBase.CALENDAR: element = new CalendarElement(); element.Attributes.ElementType = "Calendar"; break; case ElementBase.CUSTOM: element = new CustomElement(); element.Attributes.ElementType = "Custom"; break; case ElementBase.DATAGRID: element = new DatagridElement(); element.Attributes.ElementType = "DataGrid"; break; case ElementBase.DATAGRID2: element = new DatagridElement(); element.Attributes.ElementType = "DataGrid"; break; case ElementBase.DATAITEM: element = new DataitemElement(); element.Attributes.ElementType = "dataitem"; break; case ElementBase.GROUP: element = new GroupELement(); element.Attributes.ElementType = ElementBase.GROUP_TYPE; break; case ElementBase.HEADER_ITEM: element = new HeaderItemElement(); element.Attributes.ElementType = "HeaderItem"; break; case ElementBase.HYPERLINK: element = new LinkElement(); element.Attributes.ElementType = "Hyperlink"; break; case ElementBase.IMAGE: element = new ImageElement(); element.Attributes.ElementType = "Image"; break; case ElementBase.MENU: element = new MenuElement(); element.Attributes.ElementType = "Menu"; break; case ElementBase.PROGRESS_BAR: element = new ProgressBarElement(); element.Attributes.ElementType = "ProgressBar"; break; case ElementBase.SEPARATOR: element = new SeparatorElement(); element.Attributes.ElementType = "Separator"; break; case ElementBase.SLIDER: element = new SliderElement(); element.Attributes.ElementType = "Slider"; break; case ElementBase.SPINNER: element = new SpinnerElement(); element.Attributes.ElementType = "Spinner"; break; case ElementBase.SPLIT_BUTTON: element = new SplitButtonElement(); element.Attributes.ElementType = "SplitButton"; break; case ElementBase.STATUS_BAR: element = new StatusBarElement(); element.Attributes.ElementType = "StatusBar"; break; case ElementBase.TOOL_BAR: element = new ToolBarElement(); element.Attributes.ElementType = "ToolBar"; break; case ElementBase.TOOL_TIP: element = new ToolTipElement(); element.Attributes.ElementType = "ToolTip"; break; //? case ElementBase.MENU_ITEM: element = new MenuItemElement(); element.Attributes.ElementType = "MenuItem"; break; case ElementBase.LINK: element = new LinkElement(); element.Attributes.ElementType = ElementBase.LINK_TYPE; break; } if (element == null) { if (parent is TableElement || parent is DatagridElement) { element = new RowElement(); element.Attributes.ElementType = ElementBase.ROW_TYPE; } else if (parent is RowElement) { element = new CellElement(); element.Attributes.ElementType = ElementBase.CELL_TYPE; } else { element = new UnknownELement(); element.Attributes.ElementType = ElementBase.UNKNOWN_TYPE; } } element.Attributes.DesignedId = designedId; return(element); }
public static void RenderText(TextElement text, RowElement row, StringBuilder atts, Transaction transaction) { HPatternSettings settings = text.Instance.Settings; string themeClass = settings.Theme.PlainText; string textCaption = text.Caption; bool isHTML = settings.Labels.HTMLFormat; SettingsCaptionElement rule = null; if (text.HTMLFormat == TextElement.HTMLFormatValue.True) isHTML = true; if (String.IsNullOrEmpty(text.Class)) { if (Template.IsEmpty(text.Caption)) { themeClass = settings.Theme.PlainTextEmpty; } } if (!String.IsNullOrEmpty(text.Rule) && text.Rule.ToLower() != "none") { if (text.Rule.ToLower() == "runtime") { if (row != null) { rule = IdentifyRule(row, transaction, settings); } } else { rule = settings.CustomCaptions.FindCaption(text.Rule); } } bool isTemClass = false; if (rule != null) { if (!String.IsNullOrEmpty(rule.Class)) { themeClass = rule.Class; isTemClass = true; } textCaption = ResolveDescription(text.Instance.Model, null, null, textCaption); textCaption = String.Format(rule.Rule, textCaption); if (rule.HTMLFormat == SettingsCaptionElement.HTMLFormatValue.True) isHTML = true; } if (String.IsNullOrEmpty(text.Class)) { if (row != null) { if (!isTemClass) { themeClass = TextLabelPK(themeClass, row, transaction, settings.Theme.LabelKey); } } } else { themeClass = text.Class; } if (isHTML) { Dictionary<string,object> props = new Dictionary<string,object>(); props.Add(Properties.HTMLSPAN.Format, Properties.HTMLSPAN.Format_Values.Html); atts.AppendLine(WebForm.TextBlock(text.Name, themeClass, textCaption, props)); } else { atts.AppendLine(WebForm.TextBlock(text.Name, themeClass, textCaption)); } }
public void addRows(RowElement r) { rows.Add(r); numOfRows++; }
private static SettingsCaptionElement IdentifyRule(RowElement row, Transaction transaction, HPatternSettings settings) { SettingsCaptionElement rule = null; bool achou = false; foreach (ColumnElement col2 in row.Columns) { foreach (IHPatternInstanceElement obj2 in col2.Items) { if (obj2 is AttributeElement) { AttributeElement att2 = (AttributeElement)obj2; bool ipk = false; bool ifk = false; bool inull = false; bool ireq = att2.getRequired(transaction); if (transaction != null) { TransactionAttribute ta = transaction.Structure.Root.GetAttribute(att2.AttributeName); if (ta != null) { ipk = ta.IsKey; ifk = ta.IsForeignKey; inull = ta.IsNullable == TableAttribute.IsNullableValue.True; } } foreach (SettingsCaptionElement cap in settings.CustomCaptions) { bool isValido = true; if (cap.SetPrimaryKey && !ipk) { continue; } if (cap.SetForeignKey && !ifk) { continue; } if (cap.SetNullable == SettingsCaptionElement.SetNullableValue.Null && !inull) { continue; } if (cap.SetNullable == SettingsCaptionElement.SetNullableValue.NotNull && inull) { continue; } if (cap.SetEditable == SettingsCaptionElement.SetEditableValue.Editable && (att2.Readonly || !att2.Visible)) { continue; } if (cap.SetEditable == SettingsCaptionElement.SetEditableValue.ReadOnly && !att2.Readonly) { continue; } if (cap.SetRequired == SettingsCaptionElement.SetRequiredValue.Required && !ireq) { continue; } if (cap.SetRequired == SettingsCaptionElement.SetRequiredValue.NotRequired && ireq) { continue; } if (isValido) { rule = cap; achou = true; break; } } } if (achou) break; } if (achou) break; } return rule; }
private static string TextLabelPK(string mthemeClass, RowElement row, Transaction transaction, string LabelKey) { string themeClass = mthemeClass; bool achou = false; foreach (ColumnElement col2 in row.Columns) { foreach (IHPatternInstanceElement obj2 in col2.Items) { if (obj2 is AttributeElement) { AttributeElement att2 = (AttributeElement)obj2; if (transaction != null) { TransactionAttribute ta = transaction.Structure.Root.GetAttribute(att2.AttributeName); if (ta != null && ta.IsKey && !String.IsNullOrEmpty(LabelKey)) { themeClass = LabelKey; achou = true; break; } } } } if (achou) break; } return themeClass; }
public ElementDataConfig(RowElement elem, SchemeData scheme) { Element = elem; Scheme = scheme; }
public void addRow(RowElement r) { this.setRow(r.getRow()); }
private static void GetRowsGridPP(IBaseCollection<RowElement> rows, IBaseCollection<AttributeElement> atts, RowElement baserow, ColumnElement basecol,IHPatternInstanceElement trni) { RowElement row = baserow.Clone(); row.Parent = trni; row.Columns.Clear(); ColumnElement col = basecol.Clone(); col.Items.Clear(); foreach (AttributeElement att in atts) { col.Items.Add(att); } row.Columns.Add(col); rows.Add(row); }
public static void ApplyRow(StringBuilder atts, RowElement row, Transaction transaction, Boolean geraBC, String sigla, HPatternSettings settings) { atts.AppendLine("<tr>"); foreach (ColumnElement col in row.Columns) { atts.AppendLine("<td colspan='" + col.ColSpan.ToString() + "' rowspan='" + col.RowSpan.ToString() + "'>"); foreach (Object obj in col.Items) { if (obj is AttributeElement) { AttributeElement att = (AttributeElement)obj; if (geraBC) { Dictionary<string, object> properties = new Dictionary<string, object>(); properties[Properties.HTMLATT.FieldSpecifier] = att.AttributeName; TransactionAttribute ta = transaction.Structure.Root.GetAttribute(att.AttributeName); bool vreadonly = false; if (ta == null) { vreadonly = true; } else { if (ta.IsInferred) { vreadonly = true; } } if (att.Readonly) { vreadonly = true; } if (vreadonly) { properties[Properties.HTMLATT.ReadOnly] = true; } string themeClass = "Attribute"; if (att.ThemeClass != String.Empty) themeClass = att.ThemeClass; if (vreadonly) { if (att.Format.ToLower() == "text") properties[Properties.HTMLATT.Format] = Properties.HTMLATT.Format_Values.Text; if (att.Format.ToLower() == "html") properties[Properties.HTMLATT.Format] = Properties.HTMLATT.Format_Values.Html; if (att.Format.ToLower() == "raw html") properties[Properties.HTMLATT.Format] = Properties.HTMLATT.Format_Values.RawHtml; if (att.Format.ToLower() == "text with meaningful spaces") properties[Properties.HTMLATT.Format] = Properties.HTMLATT.Format_Values.TextWithMeaningfulSpaces; } atts.AppendLine(WebForm.Variable(transaction.Name + sigla, themeClass, null, properties)); } else { Dictionary<string, object> properties = new Dictionary<string, object>(); if (att.Readonly) { properties[Properties.HTMLATT.ReadOnly] = true; } atts.AppendLine(WebForm.Attribute(att.AttributeName, null, null, properties)); } } if (obj is VariableElement) { VariableElement var = (VariableElement)obj; string themeClass = "Attribute"; if (var.ThemeClass != String.Empty) themeClass = var.ThemeClass; atts.AppendLine(WebForm.Variable(var.Name, themeClass)); } if (obj is TextElement) { TextElement text = (TextElement)obj; //contaAtts++; atts.AppendLine(WebForm.TextBlock(text.Name, settings.Theme.PlainText, text.Caption)); } } atts.AppendLine("</td>"); } atts.AppendLine("</tr>"); }
//----< check whether one row in the matrix has the same size as the first row >------------------------------ public bool isSameRowSize(RowElement r) { if (rows.Count > 0) { RowElement first = rows[0]; if (r.Count() != first.Count()) { return false; } } return true; }