Exemplo n.º 1
0
 public static void CreateBuiltinDataValues()
 {
     DataStoreTreeNode ds0 = new DataStoreTreeNode();
     {
         ds0.Id       = 11;
         ds0.ParentId = -1;
         ds0.IsFolder = true;
         ds0.Name     = "ROOT";
         ds0.Save();
     }
     DataStoreTreeNode ds1 = new DataStoreTreeNode();
     {
         ds1.Id               = 1;
         ds1.ParentId         = ds0.Id;
         ds1.IsFolder         = false;
         ds1.Name             = "alex";
         ds1.SyntaxProvider   = "Oracle 12";
         ds1.MetadataProvider = "#$%^";
         ds1.Save();
     }
     DataStoreTreeNode ds2 = new DataStoreTreeNode();
     {
         ds2.Id       = 2;
         ds2.ParentId = ds0.Id;
         ds2.IsFolder = true;
         ds2.Name     = "simone";
         ds2.Save();
     }
     DataStoreTreeNode ds3 = new DataStoreTreeNode();
     {
         ds3.Id               = 3;
         ds3.ParentId         = ds2.Id;
         ds3.IsFolder         = false;
         ds3.Name             = "simone occulate";
         ds3.SyntaxProvider   = "Oracle adfa12";
         ds3.MetadataProvider = "12345";
         ds3.Save();
     }
     DataStoreTreeNode ds4 = new DataStoreTreeNode();
     {
         ds4.Id               = 4;
         ds4.ParentId         = ds2.Id;
         ds4.IsFolder         = false;
         ds4.Name             = "Alex occulate";
         ds4.SyntaxProvider   = "SQL Server";
         ds4.MetadataProvider = "12345";
         ds4.Save();
     }
     DataStoreTreeNode ds5 = new DataStoreTreeNode();
     {
         ds5.Id       = 5;
         ds5.ParentId = ds2.Id;
         ds5.IsFolder = true;
         ds5.Name     = "folder";
         ds5.Save();
     }
 }
        private void wizardControl1_FinishClick(object sender, CancelEventArgs e)
        {
            FinishClicked = true;
            {
                ParentName = this.parentTreeListLookUpEdit.Text;
                {
                    //Session session = new Session();
                    //session.ConnectionString = XpoDefault.ConnectionString;

                    // Obtain the persistent object class info required by the GetObjects method
                    XPClassInfo dstnClass = XpoDefault.Session.GetClassInfo(typeof(DataStoreTreeNode));

                    // Create criteria to get objects
                    CriteriaOperator criteria;
                    criteria = null; // new BinaryOperator("Discontinued", true);

                    // Create a sort list if objects must be processed in a specific order
                    SortingCollection sortProps = null; // new SortingCollection(null);
                    // sortProps.Add(new SortProperty("Price", DevExpress.Xpo.DB.SortingDirection.Ascending));

                    // Create criteria patcher to filter out the objects marked as "deleted"
                    // and to support loading of inherited objects of a given base persistent class
                    CollectionCriteriaPatcher patcher = new DevExpress.Xpo.Generators.CollectionCriteriaPatcher(false, XpoDefault.Session.TypesManager);
                    // Call GetObjects
                    ICollection collection = XpoDefault.Session.GetObjects(dstnClass, criteria, sortProps, 0, patcher, true);

                    int max = int.MinValue;
                    // Do processing
                    foreach (DataStoreTreeNode dstn in collection)
                    {
                        max = Math.Max(max, dstn.Id);
                    }
                    NewDataStoreTreeNode = new DataStoreTreeNode();
                    {
                        NewDataStoreTreeNode.Id               = max + 1;
                        NewDataStoreTreeNode.ParentId         = (int)this.parentTreeListLookUpEdit.EditValue;
                        NewDataStoreTreeNode.IsFolder         = isItFolderCheckEdit.Checked;
                        NewDataStoreTreeNode.Name             = this.nameTextEdit.Text;
                        NewDataStoreTreeNode.SyntaxProvider   = this.syntaxProviderComboBoxEdit.SelectedItem as string;
                        NewDataStoreTreeNode.ConnectionString = this.connectionStringMemoEdit.Text;
                        NewDataStoreTreeNode.Description      = this.descriptionNodeMemoEdit.Text;
                        NewDataStoreTreeNode.Save();
                    }
                }
            }
            this.Close();
        }