Esempio n. 1
0
    public Table(TableNode node, DataRow row, DataTable columns)
    {
      owningNode = node;
      IsNew = row == null;

      Columns = new TablePartCollection<Column>();
      Indexes = new TablePartCollection<Index>();
      ForeignKeys = new TablePartCollection<ForeignKey>();

      // set some defaults that may be overridden with actual table data
      Engine = node.DefaultStorageEngine;
      PackKeys = PackKeysMethod.Default;
      Schema = node.Database;

      if (row != null)
        ParseTableData(row);
      if (columns != null)
        ParseColumns(columns);
      if (!IsNew)
      {
        LoadIndexes();
        LoadForeignKeys();
      }

      // now save our current values as old
      OldTable = new Table();
      ObjectHelper.Copy(this, OldTable);
      node.DataSaved += new EventHandler(node_DataSaved);
    }
Esempio n. 2
0
    public ForeignKeyDialog(TableNode node)
    {
      tableNode = node;
      Application.EnableVisualStyles();
      InitializeComponent();

      // create a list of all tables in this database
      DataTable dt = tableNode.GetDataTable(
        String.Format(@"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
          WHERE TABLE_SCHEMA = '{0}' AND ENGINE = 'InnoDB'", tableNode.Database));
      List<string> tables = new List<string>();
      foreach (DataRow row in dt.Rows)
        tables.Add(row[0].ToString());
      refTable.DataSource = tables;

      colGridColumn.HeaderText = tableNode.Table.Name;
      colGridColumn.Items.Add(None);
      foreach (Column c in tableNode.Table.Columns)
      {
        if (c.ColumnName == null) continue;
        columnNames.Add(c.ColumnName);
        colGridColumn.Items.Add(c.ColumnName);
      }
     
      foreignKeyBindingSource.DataSource = tableNode.Table.ForeignKeys;
      fkList.DataSource = foreignKeyBindingSource;
      if (!InEditMode) ShowEditControls(false);
    }
Esempio n. 3
0
        private VBDocument GetDeleteDocument(TableNode tableNode)
        {
            var dbName = tableNode.DatabaseNode.Name;

            SetConnectionString(tableNode);
            var document = Generator.DeleteProvider.Create(Generator.ServerManager.GetDataSet(dbName), tableNode.Name, tableNode.DatabaseNode.Name, tableNode.DatabaseNode.Name);

            return(document);
        }
Esempio n. 4
0
        // ServerName

        public override SelectStatement TranslateOrder(DevicePlan devicePlan, TableNode node, SelectStatement statement, bool inContextOrderBy)
        {
            if (statement.Modifiers == null)
            {
                statement.Modifiers = new LanguageModifiers();
            }
            statement.Modifiers.Add(new LanguageModifier("OptimizerHints", "option (fast 1)"));
            return(base.TranslateOrder(devicePlan, node, statement, inContextOrderBy));
        }
Esempio n. 5
0
        private CSDocument GetRepositoryPackDocument(TableNode tableNode)
        {
            var dbName = tableNode.DatabaseNode.Name;

            SetConnectionString(tableNode);
            var document = Generator.RepositoryPackProvider.CreateDocument(Generator.ServerManager.GetDataSet(dbName), tableNode.Name, tableNode.DatabaseNode.Name, tableNode.DatabaseNode.Name);

            return(document);
        }
Esempio n. 6
0
 void MapIntermediateClass(TableNode tn, NDO.Mapping.Class cl)
 {
     if (tn.Table.PrimaryKey == "")
     {
         tn.Table.PrimaryKey = cl.Oid.ColumnName;
     }
     //TODO: Intermediate class berücksichtigen
     tn.MapClass(null, EventArgs.Empty);
 }
Esempio n. 7
0
        private void VerifyFooterNav(TableNode node, string cssClass)
        {
            node.Element.TagName.Should().Be("div");
            this.VerifyCssClass(node.Element, "pull-right");
            this.VerifyCssClass(node.Element, "NavBtnContainer");
            TableNode link = this.OnlyInner(node, "a");

            this.VerifyCssClass(link.Element, cssClass);
        }
Esempio n. 8
0
        private void Refresh()
        {
            var selectedNode = Form.SelectedNode;

            if (selectedNode != null && selectedNode is TableNode)
            {
                TableNode tableNode = selectedNode as TableNode;
                tableNode.Refresh();
            }
        }
Esempio n. 9
0
        public TableNodeRenderer(TableNode table)
            : base(table)
        {
            this.table = table;
            this.view = new UITableView (new RectangleF (0, 0, 100, 100), UITableViewStyle.Grouped);
            SetView (view);

            TableNodeDataSource data = new TableNodeDataSource (table);
            view.DataSource = data;
        }
Esempio n. 10
0
        public override object InternalExecute(Program program)
        {
            string AKeyColumnNames = Nodes.Count > 2 ? (string)Nodes[2].Execute(program) : null;
            bool   AInsertOnly     = Nodes.Count > 3 ? (bool)Nodes[3].Execute(program) : false;

            TableNode ASourceTable = (TableNode)Nodes[0];
            TableNode ATargetTable = (TableNode)Nodes[1];

            return(InternalCopy(program, _dataType, ASourceTable, ATargetTable, AKeyColumnNames, AInsertOnly));
        }
Esempio n. 11
0
        public TableNodeRenderer(TableNode table) : base(table)
        {
            this.table = table;
            this.view  = new UITableView(new RectangleF(0, 0, 100, 100), UITableViewStyle.Grouped);
            SetView(view);

            TableNodeDataSource data = new TableNodeDataSource(table);

            view.DataSource = data;
        }
Esempio n. 12
0
 public IntermediateClassWizardModel(TableNode tableNode, IList allTableNodes)
 {
     this.tableNode        = tableNode;
     this.allTableNodes    = allTableNodes;
     intermediateClassInfo = new IntermediateClassInfo[]
     {
         new IntermediateClassInfo(),
         new IntermediateClassInfo()
     };
 }
Esempio n. 13
0
        /// <summary>
        /// Quick & Dirty Hack to skip collection elements in the Xml Schema. If we have a schema like that:
        /// RootElement / Actions / Action
        /// the Action elements should be a 1:n child of RootElement.
        /// </summary>
        /// <param name="cunit"></param>
        public void AddSubelementsOfSkippedElement()
        {
            if (!this.generateXmlConstructor)                // Generate subelements only, if we reverse engineer a Xml Schema
            {
                return;
            }

            TableNode parentNode = (TableNode)this.tableNode.UserData["parentnode"];

            AddSubelementsOfSkippedElement(parentNode, this.tableNode.Name);
        }
Esempio n. 14
0
    protected void removeEntryClicked(object sender, EventArgs e)
    {
        if (manager.active && nodeview.NodeSelection.SelectedNode != null)
        {
            TableNode selected = (MainWindow.TableNode)nodeview.NodeSelection.SelectedNode;

            manager.activeWad.RemoveEntry(selected.entry);
            manager.mapEntries.Remove(selected.colName);
            nodeview.NodeStore.RemoveNode(selected);
        }
    }
Esempio n. 15
0
        public override DynValue Visit(TableNode tableNode)
        {
            var tbl = new Table();

            for (var i = 0; i < tableNode.Initializers.Count; i++)
            {
                tbl[i] = Visit(tableNode.Initializers[i]);
            }

            return(new(tbl));
        }
Esempio n. 16
0
 private void PrepareEmployeeOrder(out TableNode tn, out ColumnNode cn)
 {
     ApplicationController.WizardControllerFactory = new WizardControllerFactory(this.GetType().Assembly, "TestApp.RelationTests+FkWizardController");
     tn = (TableNode)FindNode(ApplicationController.Instance.DatabaseNode.Nodes, "Employees");
     tn.MapClass(null, EventArgs.Empty);
     tn = (TableNode)FindNode(ApplicationController.Instance.DatabaseNode.Nodes, "Orders");
     tn.MapClass(null, EventArgs.Empty);
     cn = (ColumnNode)FindNode(tn.Nodes, "EmployeeID");
     cn.ChangeMapping(null, EventArgs.Empty);
     cn.MakeForeignKey(null, EventArgs.Empty);
 }
Esempio n. 17
0
 protected void SetConnectionString(TableNode tableNode)
 {
     if (Generator.ServerManager.DbAccess.Connection.ConnectionString == tableNode.ConnectionString)
     {
         return;
     }
     if (Generator.ServerManager.DbAccess.Connection.State == System.Data.ConnectionState.Open)
     {
         Generator.ServerManager.DbAccess.Connection.Close();
     }
     Generator.ServerManager.DbAccess.Connection.ConnectionString = tableNode.ConnectionString;
 }
Esempio n. 18
0
        public ClassGenerator(TableNode tableNode)
        {
            this.tableNode = tableNode;
            Database database = ((DatabaseNode)tableNode.Parent).Database;

            this.generateXmlConstructor = database.IsXmlSchema;
            if (this.generateXmlConstructor)
            {
                this.namespaceWrapper = (NamespaceWrapper)database.DataSet.ExtendedProperties["namespacewrapper"];
            }
            this.targetLanguage = ApplicationController.Instance.AssemblyNode.Assembly.TargetLanguage;
        }
Esempio n. 19
0
    void onSelectionChanged(object o, EventArgs args)
    {
        if (o == null)
        {
            return;
        }
        NodeSelection selection = (NodeSelection)o;
        TableNode     node      = (TableNode)selection.SelectedNode;


        Console.WriteLine("Selection Changed");
    }
Esempio n. 20
0
    private void InvalidatePage(Vector2Int id)
    {
        TableNode node = null;

        if (!m_ActivePages.TryGetValue(id, out node))
        {
            return;
        }

        node.Payload.Reset();
        m_ActivePages.Remove(id);
    }
Esempio n. 21
0
 protected void PrepareTableNode(Schema.DevicePlan plan, TableNode node)
 {
     node.CursorType          = CursorType.Dynamic;
     node.RequestedCursorType = plan.Plan.CursorContext.CursorType;
     node.CursorCapabilities  =
         CursorCapability.Navigable |
         CursorCapability.BackwardsNavigable |
         CursorCapability.Bookmarkable |
         CursorCapability.Searchable |
         (plan.Plan.CursorContext.CursorCapabilities & CursorCapability.Updateable);
     node.CursorIsolation = plan.Plan.CursorContext.CursorIsolation;
 }
Esempio n. 22
0
        public override LazyList <string> Visit(TableNode node, Context context)
        {
            Contracts.AssertValue(node);

            context = context.Indent();
            bool hasNewline;
            var  generatedNodes = PreGenerateNodes(context, node.SourceList, out hasNewline);
            bool useNewlines    = node.Count > 1 || hasNewline;

            var result = LazyList <string> .Empty;

            foreach (var source in node.SourceList.Sources.Where(source => !(source is WhitespaceSource)))
            {
                var nodeSource  = source as NodeSource;
                var tokenSource = source as TokenSource;
                if (nodeSource != null)
                {
                    result = result.With(generatedNodes[nodeSource]);
                }
                else if (tokenSource != null && tokenSource.Token.Kind == TokKind.Comma)
                {
                    if (useNewlines)
                    {
                        result = result
                                 .With(GetScriptForToken(tokenSource.Token))
                                 .With(GetNewLine(context.IndentDepth + 1));
                    }
                    else
                    {
                        result = result
                                 .With(GetScriptForToken(tokenSource.Token))
                                 .With(" ");
                    }
                }
                else if (tokenSource != null && tokenSource.Token.Kind == TokKind.BracketOpen && useNewlines)
                {
                    result = result
                             .With(GetScriptForToken(tokenSource.Token))
                             .With(GetNewLine(context.IndentDepth + 1));
                }
                else if (tokenSource != null && tokenSource.Token.Kind == TokKind.BracketClose && useNewlines)
                {
                    result = result
                             .With(GetNewLine(context.IndentDepth))
                             .With(GetScriptForToken(tokenSource.Token));
                }
                else
                {
                    result = result.With(source.Tokens.Select(GetScriptForToken));
                }
            }
            return(result);;
        }
Esempio n. 23
0
        private void InternalPrepare(Schema.DevicePlan plan, TableNode planNode)
        {
            RestrictNode restrictNode = planNode as RestrictNode;

            if (restrictNode != null)
            {
                // Prepare the source
                InternalPrepare(plan, restrictNode.SourceNode);

                if (plan.IsSupported)
                {
                    if (restrictNode.IsSeekable)
                    {
                        // TODO: If this is a seek to the Id and there is more than one search parameter, this should not be supported
                        // TODO: Many FHIR servers don't support wide open queries, so if something isn't filtered, we would need to be able to indicate (warning maybe?) that the query will likely not return any data (maybe even an error, although some systems do support it).
                        // Verify that each condition corresponds to a known search parameter for this resource
                        foreach (ColumnConditions columnConditions in restrictNode.Conditions)
                        {
                            if (!IsSearchParamColumn(columnConditions.Column))
                            {
                                plan.TranslationMessages.Add(new Schema.TranslationMessage(String.Format("Service does not support restriction by {0}.", columnConditions.Column.Name)));
                                plan.IsSupported = false;
                                break;
                            }
                        }
                    }
                    else if (restrictNode.Nodes[1] is SatisfiesSearchParamNode)
                    {
                        plan.IsSupported = true;
                    }
                    else
                    {
                        plan.TranslationMessages.Add(new Schema.TranslationMessage("Service does not support arbitrary restriction."));
                        plan.IsSupported = false;
                    }
                }

                return;
            }

            BaseTableVarNode baseTableVarNode = planNode as BaseTableVarNode;

            if (baseTableVarNode != null)
            {
                ResourceType = MetaData.GetTag(baseTableVarNode.TableVar.MetaData, "FHIR.ResourceType", Schema.Object.Unqualify(baseTableVarNode.TableVar.Name));
                return;
            }

            plan.TranslationMessages.Add(new Schema.TranslationMessage("Service does not support arbitrary queries."));
            plan.IsSupported = false;
            return;
        }
Esempio n. 24
0
        public HtmlParsedTableWithHeader(HtmlNode table_node, string[] alternative_headers = null)
        {
            this.TableNode = table_node;

            var rows = TableNode.SelectNodes("tr");

            if (rows.Count <= 0)
            {
                throw new ApplicationException("Table: rows.Count <= 0");
            }

            // ヘッダリストの取得
            HeaderList = new List <string>();

            if (alternative_headers == null)
            {
                var header_coulmns = rows[0].SelectNodes("td");

                foreach (var column in header_coulmns)
                {
                    HeaderList.Add(column.GetSimpleText());
                }
            }
            else
            {
                HeaderList = alternative_headers.ToList();
            }

            // データリストの取得
            this.DataList = new List <Dictionary <string, HtmlParsedTableData> >();

            for (int i = 1; i < rows.Count; i++)
            {
                var td_list = rows[i].SelectNodes("td");


                Dictionary <string, HtmlParsedTableData> data_list = new Dictionary <string, HtmlParsedTableData>();

                if (td_list.Count != this.HeaderList.Count)
                {
                    throw new ApplicationException("td_list.Count != this.HeaderList.Count");
                }

                for (int j = 0; j < td_list.Count; j++)
                {
                    data_list[HeaderList[j]] = new HtmlParsedTableData(td_list[j]);
                }

                DataList.Add(data_list);
            }
        }
Esempio n. 25
0
        void RemoveRelationNodeFromTable(string tableName, string nodeName)
        {
            TableNode tn = (TableNode)databaseNode.FindNode(tableName);

            if (tn != null)
            {
                RelationNode relNode = (RelationNode)tn.FindNode(nodeName, typeof(RelationNode));
                if (relNode != null)
                {
                    relNode.Remove();
                }
                //tn.Nodes. Remove(relNode);
            }
        }
Esempio n. 26
0
        public void FooterText()
        {
            _tableConfig.Footer.Text = "Text";

            this.ActAndValidate();

            TableNode footerCell = this.OnlyInner(this.OnlyInner(this.Node("tfoot"), "tr"), "td");
            TableNode container  = footerCell.InnerContent.Single(ic =>
                                                                  ic.Element.Attributes["class"].Contains("FooterTextContainer"));
            TableNode text = this.OnlyInner(container, "span");

            this.VerifyCssClass(text.Element, "FooterText");
            this.VerifyInnerHtml(text.Element, "Text");
        }
Esempio n. 27
0
        public void TestIntermediateClass()
        {
            TableNode tn;

            PrepareOrderDetails(out tn);
            Assertion.Assert("Mapping type wrong #1", tn.Table.MappingType == TableMappingType.MappedAsIntermediateClass);
            TreeNodeCollection nodes = ApplicationController.Instance.DatabaseNode.Nodes;
            object             o     = FindNode(nodes, tn.Text);

            Assertion.AssertNotNull("Intermediate Class '" + tn.Text + "' not found", o);
            Assertion.AssertSame("Node should be the same table node", tn, o);
            RelationNode rn = tn.FindRelationNode("OrderID", "Orders");

            Assertion.AssertNotNull("Relation to Orders should be there", rn);
            Assertion.Assert("Wrong relation type", rn.Relation is FkRelation);
            rn = tn.FindRelationNode("ProductID", "Products");
            Assertion.AssertNotNull("Relation to Products should be there", rn);
            Assertion.Assert("Wrong relation type", rn.Relation is FkRelation);

            TableNode tnOrders = (TableNode)FindNode(nodes, "Orders");

            rn = tnOrders.FindRelationNode("OrderID", "Order Details");
            Assertion.AssertNotNull("OrderID relation not found", rn);
            TableNode tnProducts = (TableNode)FindNode(nodes, "Products");

//			foreach(NDOTreeNode trn in tnProducts.Nodes)
//			{
//				RelationNode rn2 = trn as RelationNode;
//				if (rn2 != null)
//				{
//					Debug.WriteLine(rn2.Text + " " + rn2.Relation.GetType().Name);
//					ForeignFkRelation fkr = rn2.Relation as ForeignFkRelation;
//					if (fkr != null)
//						Debug.WriteLine(fkr.RelatedTable);
//				}
//			}
            rn = tnProducts.FindRelationNode("ProductID", "Order Details");
            Assertion.AssertNull("Relation is directed", rn);
            tn.UnmapIntermediateClass(null, EventArgs.Empty);

            Assertion.Assert("Mapping type wrong #1", tn.Table.MappingType == TableMappingType.NotMapped);

            rn = tn.FindRelationNode("OrderID", "Orders");
            Assertion.AssertNull("Relation to Orders should be removed", rn);
            rn = tn.FindRelationNode("ProductID", "Products");
            Assertion.AssertNull("Relation to Products should be removed", rn);

            rn = tnOrders.FindRelationNode("OrderID", "Order Details");
            Assertion.AssertNull("Relation should be removed", rn);
        }
Esempio n. 28
0
        public TableEditor(TableEditorPane pane, TableNode node)
        {
            this.pane    = pane;
            tableNode    = node;
            node.Saving += delegate { EndGridEditMode(); };
            InitializeComponent();

            dataTypes = Metadata.GetDataTypes(true);
            TypeColumn.Items.AddRange((object[])dataTypes);

            tableNode.DataLoaded += new EventHandler(OnDataLoaded);
            columnGrid.RowTemplate.HeaderCell = new MyDataGridViewRowHeaderCell();
            SetupCommands();
        }
Esempio n. 29
0
 /// <summary>
 /// 获取VCT表节点
 /// </summary>
 public TableNode GetTableNode()
 {
     try
     {
         TableNode pTableNode = new TableNode();
         pTableNode.TableName = (this.m_pITable as IDataset).Name;
         return(pTableNode);
     }
     catch (Exception ex)
     {
         LogAPI.WriteErrorLog(ex);
         return(null);
     }
 }
Esempio n. 30
0
        private static void ImportExcelXml(Stream stream, WfMatrix matrix, Action notifier)
        {
            WorkbookNode workbook = new WorkbookNode();

            workbook.Load(stream);

            ExceptionHelper.FalseThrow(workbook.Worksheets.Contains("Matrix"),
                                       "The workbook must contains a 'Matrix' worksheet.");

            NamedLocationCollection fieldLocations = workbook.Names.ToLocations();

            TableNode table = workbook.Worksheets["Matrix"].Table;

            int baseRowIndex = GetStartRow(fieldLocations);

            RowNode titleRow = table.GetRowByIndex(baseRowIndex);

            int currentRowIndex = table.Rows.IndexOf(titleRow) + 1;

            if (table.Rows.Count > currentRowIndex)
            {
                int currentVirtualRow = baseRowIndex;
                int count             = table.Rows.Count - currentRowIndex;
                for (int i = 0; i < count; i++)
                {
                    RowNode row = table.Rows[currentRowIndex];

                    if (row.Index > 0)
                    {
                        currentVirtualRow = row.Index;
                    }
                    else
                    {
                        currentVirtualRow++;
                    }

                    GenerateMatrixRow(matrix, row, fieldLocations, i);

                    if (notifier != null)
                    {
                        notifier();
                    }

                    currentRowIndex++;
                }
            }
            WfMatrixAdapter.Instance.DeleteByProcessKey(matrix.ProcessKey);
            WfMatrixAdapter.Instance.Update(matrix);
        }
Esempio n. 31
0
        public static object ValidateValue(Program program, Schema.ScalarType type, object tempValue, Schema.Operator fromOperator)
        {
            program.Stack.Push(tempValue);
            try
            {
                TableNode.ValidateScalarTypeConstraints(program, type, false);
                TableNode.ExecuteScalarTypeValidateHandlers(program, type, fromOperator);
            }
            finally
            {
                tempValue = program.Stack.Pop();
            }

            return(tempValue);
        }
Esempio n. 32
0
        private void CollectInnerType(TableNode node, PackageType packageType)
        {
            var tableType = builder.GenerateTableType(
                node.TypeNode,
                packageType.Name + "." + node.Name);

            bool ok = packageType.AddType(tableType);

            types.AddType(tableType);

            if (!ok)
            {
                Log(String.Format("Таблица с именем {0} уже существует", node.Name), node);
            }
        }
Esempio n. 33
0
        public void UnmapIntermediateTable(IntermediateTableNode itn)
        {
            TableNode tn    = itn.OriginalTableNode;
            int       index = databaseNode.Nodes.IndexOf(itn);

            tn.Remove();             // Was inserted as node in itn.
            itn.Remove();
            databaseNode.Nodes.Insert(index, tn);
            tn.TreeView.SelectedNode = tn;
            for (int tableNr = 0; tableNr < 2; tableNr++)
            {
                RelatedTableInfo rti = itn.IntermediateTable[tableNr];
                RemoveRelationNodeFromTable(rti.Table, rti.ForeignKeyColumnName);
            }
        }
Esempio n. 34
0
    public TableIndexDialog(TableNode node)
    {
      tableNode = node;
      table = tableNode.Table;
      InitializeComponent();

      foreach (Index i in tableNode.Table.Indexes)
        indexList.Items.Add(i.Name);

      bool isOk = tableNode.Table.Columns.Count > 0 &&
                  !String.IsNullOrEmpty(tableNode.Table.Columns[0].ColumnName) &&
                  !String.IsNullOrEmpty(tableNode.Table.Columns[0].DataType);
      addButton.Enabled = isOk;
      deleteButton.Enabled = false;
      indexList.Enabled = isOk;
    }
Esempio n. 35
0
 public override void LoadChilds()
 {
     if (Metadata == null)
     {
         XmlDocument doc = new XmlDocument();
         using (Stream stream = DataProviderHelper.GetConfigurationStream())
         {
             doc.Load(stream);
             stream.Close();
         }
         Metadata = doc.SelectSingleNode(String.Format("//add[@invariant='{0}']/SchemaBrowser",
            Connection.InvariantName));
     }
     if (Metadata != null)
     {
         DbConnection dbConnection = DataProviderHelper.CreateDbConnection(Connection.InvariantName);
         dbConnection.ConnectionString = Connection.ConnectionString;
         dbConnection.Open();
         try
         {
             foreach (XmlNode child in Metadata)
             {
                 if (child.NodeType != XmlNodeType.Element || child.Name != "node")
                     continue;
                 XmlElement node = (XmlElement)child;
                 if (node.HasAttribute("collection"))
                 {
                     DataTable collection = dbConnection.GetSchema(node.GetAttribute("collection"),
                         GetRestrictionValues(node.GetAttribute("restrictions")));
                     foreach (DataRow row in collection.Rows)
                     {
                         Node childNode;
                         XmlElement target = (XmlElement)node.SelectSingleNode("target");
                         int imageIndex = -1;
                         if (target != null)
                         {
                             childNode = new TableNode(Connection, GetValue(row, target.GetAttribute("schema")),
                                 GetValue(row, target.GetAttribute("name")));
                             imageIndex = 3;
                         }
                         else
                         {
                             childNode = new DatabaseNode(Connection, node, row);
                             imageIndex = 1;
                         }
                         childNode.Text = GetValue(row, node.GetAttribute("caption"));
                         XmlElement image = (XmlElement)node.SelectSingleNode("image");
                         if (image != null)
                             imageIndex = Convert.ToInt32(image.GetAttribute("index"));
                         childNode.SelectedImageIndex =
                             childNode.ImageIndex = imageIndex;
                         Nodes.Add(childNode);
                     }
                 }
                 else
                 {
                     DatabaseNode childNode = new DatabaseNode(Connection, node, null);
                     childNode.Text = GetValue(Data, node.GetAttribute("caption"));
                     XmlElement image = (XmlElement)node.SelectSingleNode("image");
                     if (image != null)
                         childNode.SelectedImageIndex =
                             childNode.ImageIndex = Convert.ToInt32(image.GetAttribute("index"));
                     Nodes.Add(childNode);
                 }
             }
         }
         finally
         {
             dbConnection.Close();
         }
     }
 }
Esempio n. 36
0
	public string GenerateLaneTable (GetViewTableDataResponse response, DBLane lane, DBHost host, bool horizontal, int page, int limit)
	{
		StringBuilder matrix = new StringBuilder ();
		StringBuilder tooltip = new StringBuilder ();
		bool new_revision = true;
		int revision_id = 0;
		List<DBRevisionWorkView> views = response.RevisionWorkViews;
		List<List<TableNode>> table = new List<List<TableNode>> ();
		List<TableNode> row = new List<TableNode> ();
		List<TableNode> header = new List<TableNode> ();

		for (int i = 0; i < views.Count; i++) {
			while (header.Count <= views [i].sequence) {
				header.Add (null);
			}
			if (header [views [i].sequence] != null)
				continue;

			var node = new TableNode (string.Format ("<a href='ViewWorkTable.aspx?lane_id={0}&amp;host_id={1}&amp;command_id={2}'>{3}</a>", lane.id, host.id, views [i].command_id, views [i].command));
			node.command_id = views [i].command_id;
			header [views [i].sequence] = node;
		}
		header.RemoveAll (delegate (TableNode match) { return match == null; });
		header.Insert (0, new TableNode ("Revision", true));
		header.Insert (1, new TableNode ("Diff", true));
		header.Insert (2, new TableNode ("Author", true));
		//if (Authentication.IsInRole (response, MonkeyWrench.DataClasses.Logic.Roles.Administrator)) {
		//    header.Insert (3, new TableNode ("Select", true));
		//}
		header.Add (new TableNode ("Host", true));
		header.Add (new TableNode ("Duration", true));
		table.Add (header);

		bool failed = false;
		double duration = 0;

		for (int i = 0; i < views.Count; i++) {
			DBRevisionWorkView view = views [i];
			DBState revisionwork_state = (DBState) view.revisionwork_state;
			DBState state = (DBState) view.state;

			new_revision = revision_id != view.revision_id;
			revision_id = view.revision_id;

			if (new_revision) {
				if (i > 0) {
					table.Add (row);
					row [row.Count - 1] = new TableNode (TimeSpan.FromSeconds (duration).ToString (), row [0].@class);
				}

				string revision = view.revision;
				long dummy;
				if (revision.Length > 16 && !long.TryParse (revision, out dummy))
					revision = revision.Substring (0, 8);

				string clazz = revisionwork_state.ToString ().ToLower ();
				clazz = clazz + " " + DarkenColor (clazz, table.Count);
				row = new List<TableNode> ();

				tooltip.Length = 0;
				tooltip.AppendFormat ("Author: {0}.", view.author);
				if (view.starttime.Date.Year > 2000)
					tooltip.AppendFormat (" Build start date: {0}.", view.starttime.ToUniversalTime ().ToString ("yyyy/MM/dd HH:mm:ss UTC"));

				row.Add (new TableNode (string.Format ("<a href='ViewLane.aspx?lane_id={0}&amp;host_id={1}&amp;revision_id={2}' title='{4}'>{3}</a>", lane.id, host.id, view.revision_id, revision, tooltip.ToString ()), clazz));
				row.Add (new TableNode (string.Format ("<a href='GetRevisionLog.aspx?id={0}'>diff</a>", view.revision_id)));
				row.Add (new TableNode (view.author));
				
				//if (Authentication.IsInRole (response, MonkeyWrench.DataClasses.Logic.Roles.Administrator))
				//    row.Add (new TableNode (string.Format ("<input type=checkbox id='id_revision_chk_{1}' name='revision_id_{0}' />", view.revision_id, i)));
				while (row.Count < header.Count - 2)
					row.Add (new TableNode ("-"));
				row.Add (new TableNode (view.workhost ?? ""));
				row.Add (new TableNode (""));
				failed = false;
				duration = 0;
			}

			if (view.endtime > view.starttime)
				duration += (view.endtime - view.starttime).TotalSeconds;

			if (state == DBState.Failed && !view.nonfatal)
				failed = true;
			else if (revisionwork_state == DBState.Failed)
				failed = true;

			// result
			string result;
			bool completed = true;
			switch (state) {
			case DBState.NotDone:
				completed = false;
				result = failed ? "skipped" : "queued"; break;
			case DBState.Executing:
				completed = false;
				result = "running"; break;
			case DBState.Failed:
				result = view.nonfatal ? "issues" : "failure"; break;
			case DBState.Success:
				result = "success"; break;
			case DBState.Aborted:
				result = "aborted"; break;
			case DBState.Timeout:
				result = "timeout"; break;
			case DBState.Paused:
				completed = false;
				result = "paused"; break;
			case DBState.Ignore:
				completed = false;
				result = "ignore"; break;
			default:
				completed = true;
				result = "unknown"; break;
			}

			for (int j = 2; j < header.Count; j++) {
				if (header [j].command_id == view.command_id) {
					if (completed) {
						row [j] = new TableNode (string.Format ("<a href='{0}'>{1}</a>", Utilities.CreateWebServiceDownloadUrl (Request, view.id, view.command + ".log", true), result));
					} else {
						row [j] = new TableNode (result);
					}
					row [j].@class = result + " " + DarkenColor (result, table.Count);
					break;
				}
			}
		}

		table.Add (row);
		row [row.Count - 1] = new TableNode (TimeSpan.FromSeconds (duration).ToString (), row [0].@class);

		matrix.AppendLine ("<table class='buildstatus'>");
		if (horizontal) {
			for (int i = 0; i < header.Count; i++) {
				matrix.Append ("<tr>");
				for (int j = 0; j < table.Count; j++) {
					TableNode node = table [j] [i];
					string td = node.is_header ? "th" : "td";
					matrix.Append ('<');
					matrix.Append (td);
					if (node.@class != null) {
						matrix.Append (" class='");
						matrix.Append (node.@class);
						matrix.Append ("'");
					}
					/*
					if (node.style != null) {
						matrix.Append (" style='");
						matrix.Append (node.style);
						matrix.Append ("'");
					}*/
					matrix.Append (">");
					matrix.Append (node.text);
					matrix.Append ("</");
					matrix.Append (td);
					matrix.Append (">");
				}
				matrix.AppendLine ("</tr>");
			}
		} else {
			for (int i = 0; i < table.Count; i++) {
				matrix.Append ("<tr>");
				for (int j = 0; j < row.Count; j++) {
					TableNode node = table [i] [j];
					string td = node.is_header ? "th" : "td";
					matrix.Append ('<');
					matrix.Append (td);
					if (node.@class != null) {
						matrix.Append (" class='");
						matrix.Append (node.@class);
						matrix.Append ("'");
					}
					/*
					if (node.style != null) {
						matrix.Append (" style='");
						matrix.Append (node.style);
						matrix.Append ("'");
					}*/
					matrix.Append (">");
					matrix.Append (node.text);
					matrix.Append ("</");
					matrix.Append (td);
					matrix.Append (">");
				}
				matrix.AppendLine ("</tr>");
			}
		}
		matrix.AppendLine ("</table>");
		return matrix.ToString ();
	}
Esempio n. 37
0
 public TableNodeDataSource(TableNode node)
 {
     this.node = node;
 }
		public static void AddAllTableNodes(NGTreeNode tableCollectionNode)
		{
			// Create a dictionary of folders to TreeNodes relation
			var folderDict = new Dictionary<string, NGTreeNode>();
			folderDict.Add(ProjectFolder.RootFolderName, tableCollectionNode); // add the root folder node to the dictionary

			tableCollectionNode.Nodes.Clear();
			foreach (var table in Current.Project.DataTableCollection)
			{
				var parentNode = ProjectFolders.AddFolderNodeRecursively(table.FolderName, folderDict);
				var node = new TableNode(table);
				parentNode.Nodes.Add(node);
			}
		}
 public GenerateChangeScriptDialog(TableNode node)
 {
     sql = node.GetSaveSql();
     InitializeComponent();
     sqlBox.Text = sql;
 }