public async Task ImportAll()
        {
            uSyncBackOfficeContext.Instance.Init();

            await Out.WriteLineAsync("Importing all migration changes from disk");
            var migrationManager = new MigrationManager("~/usync/migrations/");

            var actions = migrationManager.ApplyMigrations();
            if (actions.Any(x => x.Change > ChangeType.NoChange))
            {
                await Out.WriteLineAsync(
                    string.Format("Migrations Imported {0} items, {1} changes",
                        actions.Count(), actions.Count(x => x.Change > ChangeType.NoChange
                    )));

                foreach(var action in actions.Where(x => x.Change > ChangeType.NoChange))
                {
                    await Out.WriteLineAsync(
                        string.Format("{0,-30}, {1,10} {2}", action.Name, action.Change, action.Message));
                }
            }
            else
            {
                await Out.WriteLineAsync(
                    string.Format("{0} items processed, but no changes where made", actions.Count()));
            }

        }
        public async Task Create(string name)
        {
            uSyncBackOfficeContext.Instance.Init();

            if (string.IsNullOrEmpty(name))
                name = DateTime.Now.ToString("ddMMyyyy_HHmmss");

            await Out.WriteLineAsync("Creating new migration: " + name);

            var migrationManager = new MigrationManager("~/usync/migrations/");
            var actions = migrationManager.CreateMigration(name);

            if (actions.FileCount > 0)
            {
                await Out.WriteLineAsync("Migration Created with " + actions.FileCount + " files");
            }
            else
            {
                await Out.WriteLineAsync("Migration contained no changes and has not being saved");
            }
        }
Beispiel #3
0
 public CustomNodeManager(NodeFactory nodeFactory, MigrationManager migrationManager)
 {
     this.nodeFactory      = nodeFactory;
     this.migrationManager = migrationManager;
 }
Beispiel #4
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "Geometry.ClosestPointTo", "Geometry.ClosestPointTo@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            var connector0 = data.FindFirstConnector(oldInPort0);
            var oldInPort1 = new PortId(newNodeId, 1, PortType.Input);
            var connector1 = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(connector0, oldInPort0);
            data.ReconnectToPort(connector1, oldInPort1);

            var oldDOut = new PortId(newNodeId, 2, PortType.Output);
            var oldTOut = new PortId(newNodeId, 1, PortType.Output);

            if ((connector0 != null) && (data.FindConnectors(oldDOut) != null))
            {
                // Get the original output ports connected to input
                var ptInputNodeId = connector0.Attributes["start"].Value;
                var ptInputIndex  = int.Parse(connector0.Attributes["start_index"].Value);

                // make distance to node
                var distTo = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 1, "ProtoGeometry.dll",
                    "Geometry.DistanceTo",
                    "Geometry.DistanceTo@Geometry");
                migrationData.AppendNode(distTo);
                var distToId = MigrationManager.GetGuidFromXmlElement(distTo);

                data.CreateConnector(newNode, 0, distTo, 0);
                data.CreateConnectorFromId(ptInputNodeId, ptInputIndex, distToId, 1);

                var newDOut        = new PortId(distToId, 0, PortType.Output);
                var oldDConnectors = data.FindConnectors(oldDOut);

                if (oldDConnectors != null)
                {
                    oldDConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newDOut));
                }
            }

            if ((connector1 != null) && (data.FindConnectors(oldTOut) != null))
            {
                var crvInputNodeId = connector1.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(connector1.Attributes["start_index"].Value);

                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut        = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTConnectors = data.FindConnectors(oldTOut);

                if (oldTConnectors != null)
                {
                    oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
                }
            }

            return(migrationData);
        }
Beispiel #5
0
 private void SetTemplate()
 {
     Bootstrap.LogInstance?.Stop();
     MigrationMgr           = new MigrationManager();
     LayoutRoot.DataContext = MigrationMgr;
 }
Beispiel #6
0
 public void TestGetUniqueIndex00()
 {
     Assert.AreEqual(0, MigrationManager.GetUniqueIndex(null));
 }
Beispiel #7
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode   = data.MigratedNodes.ElementAt(0);
            string     oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);

            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "CoordinateSystem.PostMultiplyBy",
                                                  "CoordinateSystem.PostMultiplyBy@CoordinateSystem");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Create new nodes
            XmlElement vectorCrossFrom = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "Vector.Cross", "Vector.Cross@Vector");

            migrationData.AppendNode(vectorCrossFrom);
            string vectorCrossFromId = MigrationManager.GetGuidFromXmlElement(vectorCrossFrom);

            XmlElement vectorCrossTo = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll",
                "Vector.Cross", "Vector.Cross@Vector");

            migrationData.AppendNode(vectorCrossTo);
            string vectorCrossToId = MigrationManager.GetGuidFromXmlElement(vectorCrossTo);

            XmlElement csFrom = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 2, "ProtoGeometry.dll", "CoordinateSystem.ByOriginVectors",
                "CoordinateSystem.ByOriginVectors@Autodesk.DesignScript.Geometry.Point,"
                + "Autodesk.DesignScript.Geometry.Vector,Autodesk.DesignScript.Geometry"
                + ".Vector,Autodesk.DesignScript.Geometry.Vector");
            string csFromId = MigrationManager.GetGuidFromXmlElement(csFrom);

            migrationData.AppendNode(csFrom);

            XmlElement csTo = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 3, "ProtoGeometry.dll", "CoordinateSystem.ByOriginVectors",
                "CoordinateSystem.ByOriginVectors@Autodesk.DesignScript.Geometry.Point,"
                + "Autodesk.DesignScript.Geometry.Vector,Autodesk.DesignScript.Geometry"
                + ".Vector,Autodesk.DesignScript.Geometry.Vector");
            string csToId = MigrationManager.GetGuidFromXmlElement(csTo);

            migrationData.AppendNode(csTo);

            XmlElement csInverse = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 4, "ProtoGeometry.dll",
                "CoordinateSystem.Inverse", "CoordinateSystem.Inverse");

            migrationData.AppendNode(csInverse);

            //append asVector Node
            XmlElement pointAsVector0 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 5, "ProtoGeometry.dll",
                "Point.AsVector", "Point.AsVector");

            migrationData.AppendNode(pointAsVector0);
            string pointAsVector0Id = MigrationManager.GetGuidFromXmlElement(pointAsVector0);

            XmlElement pointAsVector1 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 6, "ProtoGeometry.dll",
                "Point.AsVector", "Point.AsVector");

            migrationData.AppendNode(pointAsVector1);
            string pointAsVector1Id = MigrationManager.GetGuidFromXmlElement(pointAsVector1);

            XmlElement pointAsVector2 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 7, "ProtoGeometry.dll",
                "Point.AsVector", "Point.AsVector");

            migrationData.AppendNode(pointAsVector2);
            string pointAsVector2Id = MigrationManager.GetGuidFromXmlElement(pointAsVector2);

            XmlElement pointAsVector3 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 8, "ProtoGeometry.dll",
                "Point.AsVector", "Point.AsVector");

            migrationData.AppendNode(pointAsVector3);
            string pointAsVector3Id = MigrationManager.GetGuidFromXmlElement(pointAsVector3);

            PortId pToV0 = new PortId(pointAsVector0Id, 0, PortType.INPUT);
            PortId pToV1 = new PortId(pointAsVector1Id, 0, PortType.INPUT);
            PortId pToV2 = new PortId(pointAsVector2Id, 0, PortType.INPUT);
            PortId pToV3 = new PortId(pointAsVector3Id, 0, PortType.INPUT);

            // Update connectors
            PortId csFrom0 = new PortId(csFromId, 0, PortType.INPUT);
            PortId csFrom1 = new PortId(csFromId, 1, PortType.INPUT);
            PortId csFrom2 = new PortId(csFromId, 2, PortType.INPUT);
            PortId csFrom3 = new PortId(csFromId, 3, PortType.INPUT);
            PortId csTo0   = new PortId(csToId, 0, PortType.INPUT);
            PortId csTo1   = new PortId(csToId, 1, PortType.INPUT);
            PortId csTo2   = new PortId(csToId, 2, PortType.INPUT);
            PortId csTo3   = new PortId(csToId, 3, PortType.INPUT);

            PortId oldInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            PortId oldInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
            PortId oldInPort2 = new PortId(newNodeId, 2, PortType.INPUT);
            PortId oldInPort3 = new PortId(newNodeId, 3, PortType.INPUT);
            PortId oldInPort4 = new PortId(newNodeId, 4, PortType.INPUT);
            PortId oldInPort5 = new PortId(newNodeId, 5, PortType.INPUT);

            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);
            XmlElement connector4 = data.FindFirstConnector(oldInPort4);
            XmlElement connector5 = data.FindFirstConnector(oldInPort5);

            data.ReconnectToPort(connector0, csFrom0);
            data.ReconnectToPort(connector1, pToV0);
            data.ReconnectToPort(connector2, pToV1);
            data.ReconnectToPort(connector3, csTo0);
            data.ReconnectToPort(connector4, pToV2);
            data.ReconnectToPort(connector5, pToV3);

            data.CreateConnector(pointAsVector0, 0, csFrom, 3);
            data.CreateConnector(pointAsVector1, 0, csFrom, 2);
            data.CreateConnector(pointAsVector2, 0, csTo, 3);
            data.CreateConnector(pointAsVector3, 0, csTo, 2);

            data.CreateConnector(pointAsVector0, 0, vectorCrossFrom, 1);
            data.CreateConnector(pointAsVector1, 0, vectorCrossFrom, 0);
            data.CreateConnector(pointAsVector2, 0, vectorCrossTo, 1);
            data.CreateConnector(pointAsVector3, 0, vectorCrossTo, 0);

            data.CreateConnector(vectorCrossFrom, 0, csFrom, 1);
            data.CreateConnector(vectorCrossTo, 0, csTo, 1);
            data.CreateConnector(csFrom, 0, csInverse, 0);
            data.CreateConnector(csInverse, 0, newNode, 1);
            data.CreateConnector(csTo, 0, newNode, 0);

            return(migrationData);
        }
Beispiel #8
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migratedData = new NodeMigrationData(data.Document);
            XmlElement        oldNode      = data.MigratedNodes.ElementAt(0);
            string            oldNodeId    = MigrationManager.GetGuidFromXmlElement(oldNode);

            //create the node itself
            XmlElement coordinateNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(coordinateNode, "ProtoGeometry.dll",
                                                  "CoordinateSystem.ByOriginVectors",
                                                  "CoordinateSystem.ByOriginVectors@Autodesk.DesignScript.Geometry.Point," +
                                                  "Autodesk.DesignScript.Geometry.Vector,Autodesk.DesignScript.Geometry.Vector," +
                                                  "Autodesk.DesignScript.Geometry.Vector");

            migratedData.AppendNode(coordinateNode);
            string coordinateNodeId = MigrationManager.GetGuidFromXmlElement(coordinateNode);

            XmlElement asVectorNode0 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll", "Point.AsVector", "Point.AsVector");

            migratedData.AppendNode(asVectorNode0);
            string asVectorNode0Id = MigrationManager.GetGuidFromXmlElement(asVectorNode0);

            XmlElement asVectorNode1 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll", "Point.AsVector", "Point.AsVector");

            migratedData.AppendNode(asVectorNode1);
            string asVectorNode1Id = MigrationManager.GetGuidFromXmlElement(asVectorNode1);

            XmlElement vectorCrossNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 2, "ProtoGeometry.dll", "Vector.Cross", "Vector.Cross@Vector");

            migratedData.AppendNode(vectorCrossNode);
            string vectorCrossNodeId = MigrationManager.GetGuidFromXmlElement(vectorCrossNode);

            XmlElement vectorReverseNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 3, "ProtoGeometry.dll", "Vector.Reverse", "Vector.Reverse");

            migratedData.AppendNode(vectorReverseNode);
            string vectorReverseNodeId = MigrationManager.GetGuidFromXmlElement(vectorReverseNode);

            //create and reconnect the connecters
            PortId     oldInPort0 = new PortId(oldNodeId, 0, PortType.INPUT);
            XmlElement connector0 = data.FindFirstConnector(oldInPort0);

            PortId     oldInPort1 = new PortId(oldNodeId, 1, PortType.INPUT);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);

            PortId     oldInPort2 = new PortId(oldNodeId, 2, PortType.INPUT);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            PortId newInPort0 = new PortId(coordinateNodeId, 0, PortType.INPUT);
            PortId newInPort1 = new PortId(coordinateNodeId, 1, PortType.INPUT);
            PortId newInPort2 = new PortId(coordinateNodeId, 2, PortType.INPUT);
            PortId newInPort3 = new PortId(coordinateNodeId, 3, PortType.INPUT);

            PortId newInPort4 = new PortId(asVectorNode0Id, 0, PortType.INPUT);
            PortId newInPort5 = new PortId(asVectorNode1Id, 0, PortType.INPUT);

            data.ReconnectToPort(connector0, newInPort0);
            data.ReconnectToPort(connector1, newInPort4);
            data.ReconnectToPort(connector2, newInPort5);

            data.CreateConnector(asVectorNode0, 0, vectorCrossNode, 0);
            data.CreateConnector(asVectorNode1, 0, vectorCrossNode, 1);
            data.CreateConnector(vectorCrossNode, 0, vectorReverseNode, 0);
            data.CreateConnector(vectorReverseNode, 0, coordinateNode, 1);
            data.CreateConnector(asVectorNode1, 0, coordinateNode, 2);
            data.CreateConnector(asVectorNode0, 0, coordinateNode, 3);

            return(migratedData);
        }
Beispiel #9
0
 public MigrationJob(ILoggerFactory loggerFactory, MigrationManager migrationManager, ExceptionlessElasticConfiguration configuration)
     : base(loggerFactory)
 {
     _migrationManager = migrationManager;
     _configuration    = configuration;
 }
 /// <summary>
 /// This function creates CustomNodeManager
 /// </summary>
 /// <param name="nodeFactory">NodeFactory</param>
 /// <param name="migrationManager">MigrationManager</param>
 /// <param name="libraryServices">LibraryServices</param>
 public CustomNodeManager(NodeFactory nodeFactory, MigrationManager migrationManager, LibraryServices libraryServices)
 {
     this.nodeFactory      = nodeFactory;
     this.migrationManager = migrationManager;
     this.libraryServices  = libraryServices;
 }
Beispiel #11
0
        public async void LoadAllDifficultiesAndLevelsAsync(bool forceServerRefresh = false)
        {
            Debug.WriteLine("LoadAllDifficultiesAndLevelsAsync Started");

            if (isLoadingDifficultiesAndLevel)
            {
                return;
            }

            this.NotifyLongLoadingStart();
            this.isLoadingDifficultiesAndLevel = true;

            try
            {
                List <Difficulty> difficulties = this.GameProvider.GetDifficulties();
                List <BaseLevel>  levels       = this.GameProvider.GetBaseLevels();

                var serverLevels = await this.GameProvider.GetDlLevelListAsync(forceServerRefresh);



                var terminatedOnV1 = new MigrationManager().GetMQ1PacksCompleted();;

                List <DifficultyPresenter> diffs = new List <DifficultyPresenter>();

                foreach (var item in difficulties)
                {
                    DifficultyPresenter difPresenter = new DifficultyPresenter();
                    difPresenter.Id   = item.Id;
                    difPresenter.Name = item.Name;

                    List <LevelPresenter> presentedLevels = new List <LevelPresenter>();
                    var difLevels = levels.Where(m => m.DifficultyId == item.Id);

                    foreach (var aBaseLevel in difLevels)
                    {
                        Level          aLevel     = this.GameProvider.GetLevel(aBaseLevel.Id);
                        LevelPresenter levPresent = new LevelPresenter();
                        levPresent.Id              = aLevel.Id;
                        levPresent.Number          = aLevel.Val;
                        levPresent.IsLocal         = true;
                        levPresent.PercentProgress = aLevel.Progression;


                        for (int i = 0; i < aLevel.Packs.Count && i < 3; i++)
                        {
                            if (i == 0)
                            {
                                levPresent.Title1           = aLevel.Packs[i].Title;
                                levPresent.DifficultyTitle1 = aLevel.Packs[i].Difficulty;
                            }
                            else if (i == 1)
                            {
                                levPresent.Title2           = aLevel.Packs[i].Title;
                                levPresent.DifficultyTitle2 = aLevel.Packs[i].Difficulty;
                            }
                            else if (i == 2)
                            {
                                levPresent.Title3           = aLevel.Packs[i].Title;
                                levPresent.DifficultyTitle3 = aLevel.Packs[i].Difficulty;
                            }
                        }
                        presentedLevels.Add(levPresent);
                    }

                    foreach (var serverLevel in serverLevels.Where(m => m.DifficultyId == item.Id)) // Adding sever levels
                    {
                        if (!difLevels.Select(m => m.Id).Contains(serverLevel.Id))
                        {
                            LevelPresenter levPresent = new LevelPresenter();
                            levPresent.Id      = serverLevel.Id;
                            levPresent.Number  = serverLevel.Value;
                            levPresent.IsLocal = false;
                            presentedLevels.Add(levPresent);

                            // We update progress percent depending on MovieQuizz1 packs terminated (migration stuff)
                            int nbPacksTerminatedOnV1 = 0;
                            foreach (var aServerPack in serverLevel.Packs)
                            {
                                if (aServerPack.Fextra1.HasValue && terminatedOnV1.Contains(((int)aServerPack.Fextra1.Value)))
                                {
                                    nbPacksTerminatedOnV1++;
                                    levPresent.PacksIdTerminatedOnV1.Add(aServerPack.Id);
                                }
                            }

                            levPresent.PercentProgress = (double)(((double)nbPacksTerminatedOnV1) / serverLevel.Packs.Count);

                            for (int i = 0; i < serverLevel.Packs.Count || i < 3; i++)
                            {
                                if (i == 0)
                                {
                                    levPresent.Title1           = serverLevel.Packs[i].Title;
                                    levPresent.DifficultyTitle1 = serverLevel.Packs[i].Difficulty.HasValue ? (double)serverLevel.Packs[i].Difficulty : 1;
                                }
                                else if (i == 1)
                                {
                                    levPresent.Title2           = serverLevel.Packs[i].Title;
                                    levPresent.DifficultyTitle2 = serverLevel.Packs[i].Difficulty.HasValue ? (double)serverLevel.Packs[i].Difficulty : 1;
                                }
                                else if (i == 2)
                                {
                                    levPresent.Title3           = serverLevel.Packs[i].Title;
                                    levPresent.DifficultyTitle3 = serverLevel.Packs[i].Difficulty.HasValue ? (double)serverLevel.Packs[i].Difficulty : 1;
                                }
                            }
                        }
                    }

                    // reorder by value;
                    difPresenter.Levels = new ObservableCollection <LevelPresenter>(presentedLevels.OrderBy(m => m.Number));

                    diffs.Add(difPresenter);
                }


                this.Difficulties = new ObservableCollection <DifficultyPresenter>(diffs);
            }
            catch (Exception e)
            {
                Debug.WriteLine("LoadAllDifficultiesAndLevelsAsync exception : " + e);
            }

            this.isLoadingDifficultiesAndLevel = false;
            this.NotifyLongLoadingStop();
        }
Beispiel #12
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            #region Migration Setup Steps

            NodeMigrationData migratedData = new NodeMigrationData(data.Document);

            // Legacy "ModelText" node takes in the following 6 inputs:
            //
            //      0 - text (string)
            //      1 - position (XYZ)
            //      2 - normal (XYZ)
            //      3 - up (XYZ)
            //      4 - depth (double)
            //      5 - text type name (string)
            //
            // The new "ModelText.ByTextSketchPlaneAndPosition" node takes in
            // the following inputs:
            //
            //      0 - text (string)
            //      1 - sketchPlane (SketchPlane)
            //      2 - xCoordinateInPlane (double)
            //      3 - yCoordinateInPlane (double)
            //      4 - textDepth (double)
            //      5 - modelTextType (ModelTextType)
            //
            XmlElement oldNode   = data.MigratedNodes.ElementAt(0);
            string     oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);

            #endregion

            #region Create New Nodes...

            XmlElement dsModelText = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(dsModelText, "RevitNodes.dll",
                                                  "ModelText.ByTextSketchPlaneAndPosition",
                                                  "ModelText.ByTextSketchPlaneAndPosition@" +
                                                  "string,SketchPlane,double,double,double,ModelTextType");

            migratedData.AppendNode(dsModelText);
            string dsModelTextId = MigrationManager.GetGuidFromXmlElement(dsModelText);

            // Create a "Plane.ByOriginNormal" that takes a "Point" (origin) and
            // a "Vector" (normal). This new node will convert both the "position"
            // and "normal" to a "Plane".
            XmlElement plane = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll", "Plane.ByOriginNormal",
                "Plane.ByOriginNormal@Point,Vector");

            migratedData.AppendNode(plane);
            string planeId = MigrationManager.GetGuidFromXmlElement(plane);

            // Create a "SketchPlane.ByPlane" node which converts a "Plane"
            // into a "SketchPlane".
            XmlElement dsSketchPlane = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "RevitNodes.dll",
                "SketchPlane.ByPlane", "SketchPlane.ByPlane@Plane");

            migratedData.AppendNode(dsSketchPlane);
            string dsSketchPlaneId = MigrationManager.GetGuidFromXmlElement(dsSketchPlane);

            // Create a "ModelTextType.ByName" node that converts a "string"
            // into "ModelTextType" node.
            XmlElement dsModelTextType = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 2, "RevitNodes.dll",
                "ModelTextType.ByName", "ModelTextType.ByName@string");

            migratedData.AppendNode(dsModelTextType);
            string dsModelTextTypeId = MigrationManager.GetGuidFromXmlElement(dsModelTextType);

            //append asVector Node
            XmlElement pointAsVector0 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 3, "ProtoGeometry.dll",
                "Point.AsVector", "Point.AsVector");
            migratedData.AppendNode(pointAsVector0);
            string pointAsVector0Id = MigrationManager.GetGuidFromXmlElement(pointAsVector0);

            //append number Node
            XmlElement numberNode = MigrationManager.CreateCodeBlockNodeModelNode(
                data.Document, oldNode, 4, "0;");
            migratedData.AppendNode(numberNode);

            #endregion

            #region Move Connectors Onto the New Nodes

            // Move connector for "text" over to the new node.
            PortId     oldInPort = new PortId(oldNodeId, 0, PortType.Input);
            PortId     newInPort = new PortId(dsModelTextId, 0, PortType.Input);
            XmlElement connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);

            // Move connector for "position" over to "Plane" node.
            oldInPort = new PortId(oldNodeId, 1, PortType.Input);
            newInPort = new PortId(planeId, 0, PortType.Input);
            connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);

            // Move connector for "normal" over to "Plane" node.
            oldInPort = new PortId(oldNodeId, 2, PortType.Input);
            newInPort = new PortId(pointAsVector0Id, 0, PortType.Input);
            connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);
            data.CreateConnector(pointAsVector0, 0, plane, 1);

            // Connect from "Plane" to "SketchPlane".
            data.CreateConnector(plane, 0, dsSketchPlane, 0);

            // Connect from "SketchPlane" to the new node.
            data.CreateConnector(dsSketchPlane, 0, dsModelText, 1);

            oldInPort = new PortId(oldNodeId, 3, PortType.Input);
            data.RemoveFirstConnector(oldInPort);

            // Move connector for "depth" over to the new node.
            oldInPort = new PortId(oldNodeId, 4, PortType.Input);
            newInPort = new PortId(dsModelTextId, 4, PortType.Input);
            connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);

            // Move connector for "text type name" over to "ModelTextType" node.
            oldInPort = new PortId(oldNodeId, 5, PortType.Input);
            newInPort = new PortId(dsModelTextTypeId, 0, PortType.Input);
            connector = data.FindFirstConnector(oldInPort);
            data.ReconnectToPort(connector, newInPort);

            // Connect from "ModelTextType" to the new node.
            data.CreateConnector(dsModelTextType, 0, dsModelText, 5);

            data.CreateConnector(numberNode, 0, dsModelText, 2);
            data.CreateConnector(numberNode, 0, dsModelText, 3);

            #endregion

            return(migratedData);
        }
Beispiel #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, BasicSeedManager seedManager, MigrationManager migrationManager)
        {
            var stopwatch = Stopwatch.StartNew();

            try
            {
                loggerFactory.AddSerilog();

                Log.Logger().Information("Application is starting...");
                Log.Logger().Information("Configuration:");

                ConfigurationProvider.GetType().GetProperties().ToList().ForEach(prop =>
                {
                    Log.Logger().Information("[{name}] = '{value}'", prop.Name,
                                             prop.GetValue(ConfigurationProvider));
                });

                DateTimeContext.Initialize(ConfigurationProvider.TimeZone);

                Log.Logger().Information("Configure EF Mappings...");
                MappingConfig.RegisterMappings();


                Log.Logger().Information("Configure Jwt Bearer Authentication...");
                app.ConfigJwtBearerMiddleware();

                app.UseDefaultFiles();
                app.UseStaticFiles();

                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Default}/{action=Index}/{id?}");

                    routes.MapRoute(
                        name: "admin",
                        template: "{*url}",
                        defaults: new { controller = "Default", action = "Index" }
                        );
                });



                //app.Use(async (context, next) =>
                //{
                //  await next();
                //  if (context.Response.StatusCode == 404 &&
                //      !Path.HasExtension(context.Request.Path.Value) &&
                //      !context.Request.Path.Value.StartsWith("/api/"))
                //  {
                //    context.Request.Path = "/index.html";
                //    await next();
                //  }
                //});

                if (env.IsDevelopment())
                {
                    app.UseDeveloperExceptionPage();

                    migrationManager.ApplyMigrations(ConfigurationProvider);

                    //seedManager.Seed();
                }
                else
                {
                    app.UseExceptionHandler("/error");
                }
            }
            catch (Exception e)
            {
                Log.Logger().Error(e, "Application failed to start");
                throw;
            }
            finally
            {
                stopwatch.Stop();
                Log.Logger().Information("Startup time: {Seconds}s", stopwatch.Elapsed.Seconds);
            }
        }
Beispiel #14
0
        /// <summary>
        ///   Starts the network services.
        /// </summary>
        /// <returns>
        ///   A task that represents the asynchronous operation.
        /// </returns>
        /// <remarks>
        ///   Starts the various IPFS and PeerTalk network services.  This should
        ///   be called after any configuration changes.
        /// </remarks>
        /// <exception cref="Exception">
        ///   When the engine is already started.
        /// </exception>
        public async Task StartAsync()
        {
            if (stopTasks.Count > 0)
            {
                throw new Exception("IPFS engine is already started.");
            }

            // Repository must be at the correct version.
            log.Debug("Starting migration of local engine");
            await MigrationManager.MirgrateToVersionAsync(MigrationManager.LatestVersion)
            .ConfigureAwait(false);

            log.Debug("Migration completed");

            var localPeer = await LocalPeer.ConfigureAwait(false);

            log.Debug("starting " + localPeer.Id);

            // Everybody needs the swarm.
            var swarm = await SwarmService.ConfigureAwait(false);

            stopTasks.Add(async() =>
            {
                await swarm.StopAsync().ConfigureAwait(false);
            });
            await swarm.StartAsync().ConfigureAwait(false);

            var peerManager = new PeerManager {
                Swarm = swarm
            };
            await peerManager.StartAsync().ConfigureAwait(false);

            stopTasks.Add(async() =>
            {
                await peerManager.StopAsync().ConfigureAwait(false);
            });

            // Start the primary services.
            var tasks = new List <Func <Task> >
            {
                async() =>
                {
                    var bitswap = await BitswapService.ConfigureAwait(false);

                    stopTasks.Add(async() => await bitswap.StopAsync().ConfigureAwait(false));
                    await bitswap.StartAsync().ConfigureAwait(false);
                },
                async() =>
                {
                    var dht = await DhtService.ConfigureAwait(false);

                    stopTasks.Add(async() => await dht.StopAsync().ConfigureAwait(false));
                    await dht.StartAsync().ConfigureAwait(false);
                },
                async() =>
                {
                    var ping = await PingService.ConfigureAwait(false);

                    stopTasks.Add(async() => await ping.StopAsync().ConfigureAwait(false));
                    await ping.StartAsync().ConfigureAwait(false);
                },
                async() =>
                {
                    var pubsub = await PubSubService.ConfigureAwait(false);

                    stopTasks.Add(async() => await pubsub.StopAsync().ConfigureAwait(false));
                    await pubsub.StartAsync().ConfigureAwait(false);
                },
            };

            log.Debug("waiting for services to start");
            await Task.WhenAll(tasks.Select(t => t())).ConfigureAwait(false);

            // Starting listening to the swarm.
            var json = await Config.GetAsync("Addresses.Swarm").ConfigureAwait(false);

            var numberListeners = 0;

            foreach (string a in json)
            {
                try
                {
                    await swarm.StartListeningAsync(a).ConfigureAwait(false);

                    ++numberListeners;
                }
                catch (Exception e)
                {
                    log.Warn($"Listener failure for '{a}'", e);
                    // eat the exception
                }
            }
            if (numberListeners == 0)
            {
                log.Error("No listeners were created.");
            }

            // Now that the listener addresses are established, the discovery
            // services can begin.
            MulticastService multicast = null;

            if (!Options.Discovery.DisableMdns)
            {
                multicast = new MulticastService();
#pragma warning disable CS1998
                stopTasks.Add(async() => multicast.Dispose());
#pragma warning restore CS1998
            }

            var autodialer = new AutoDialer(swarm)
            {
                MinConnections = Options.Swarm.MinConnections
            };
#pragma warning disable CS1998
            stopTasks.Add(async() => autodialer.Dispose());
#pragma warning restore CS1998

            tasks = new List <Func <Task> >
            {
                // Bootstrap discovery
                async() =>
                {
                    var bootstrap = new PeerTalk.Discovery.Bootstrap
                    {
                        Addresses = await this.Bootstrap.ListAsync()
                    };
                    bootstrap.PeerDiscovered += OnPeerDiscovered;
                    stopTasks.Add(async() => await bootstrap.StopAsync().ConfigureAwait(false));
                    await bootstrap.StartAsync().ConfigureAwait(false);
                },
                // New multicast DNS discovery
                async() =>
                {
                    if (Options.Discovery.DisableMdns)
                    {
                        return;
                    }
                    var mdns = new PeerTalk.Discovery.MdnsNext
                    {
                        LocalPeer        = localPeer,
                        MulticastService = multicast
                    };
                    if (Options.Swarm.PrivateNetworkKey != null)
                    {
                        mdns.ServiceName = $"_p2p-{Options.Swarm.PrivateNetworkKey.Fingerprint().ToHexString()}._udp";
                    }
                    mdns.PeerDiscovered += OnPeerDiscovered;
                    stopTasks.Add(async() => await mdns.StopAsync().ConfigureAwait(false));
                    await mdns.StartAsync().ConfigureAwait(false);
                },
                // Old style JS multicast DNS discovery
                async() =>
                {
                    if (Options.Discovery.DisableMdns || Options.Swarm.PrivateNetworkKey != null)
                    {
                        return;
                    }
                    var mdns = new PeerTalk.Discovery.MdnsJs
                    {
                        LocalPeer        = localPeer,
                        MulticastService = multicast
                    };
                    mdns.PeerDiscovered += OnPeerDiscovered;
                    stopTasks.Add(async() => await mdns.StopAsync().ConfigureAwait(false));
                    await mdns.StartAsync().ConfigureAwait(false);
                },
                // Old style GO multicast DNS discovery
                async() =>
                {
                    if (Options.Discovery.DisableMdns || Options.Swarm.PrivateNetworkKey != null)
                    {
                        return;
                    }
                    var mdns = new PeerTalk.Discovery.MdnsGo
                    {
                        LocalPeer        = localPeer,
                        MulticastService = multicast
                    };
                    mdns.PeerDiscovered += OnPeerDiscovered;
                    stopTasks.Add(async() => await mdns.StopAsync().ConfigureAwait(false));
                    await mdns.StartAsync().ConfigureAwait(false);
                },
                async() =>
                {
                    if (Options.Discovery.DisableRandomWalk)
                    {
                        return;
                    }
                    var randomWalk = new RandomWalk {
                        Dht = Dht
                    };
                    stopTasks.Add(async() => await randomWalk.StopAsync().ConfigureAwait(false));
                    await randomWalk.StartAsync().ConfigureAwait(false);
                }
            };
            log.Debug("waiting for discovery services to start");
            await Task.WhenAll(tasks.Select(t => t())).ConfigureAwait(false);

            multicast?.Start();

            log.Debug("started");
        }
Beispiel #15
0
        void Init(string repopath = null)
        {
            // Init the core api inteface.
            log.Debug($"Rebuilding RepositoryOptions with parameter path = {repopath}");
            if (repopath != null)
            {
                Options.Repository = new RepositoryOptions(repopath);
            }
            log.Debug($"RepositoryOptions rebuilded and now equal to {Options.Repository.Folder}");

            Bitswap         = new BitswapApi(this);
            Block           = new BlockApi(this);
            BlockRepository = new BlockRepositoryApi(this);
            Bootstrap       = new BootstrapApi(this);
            Config          = new ConfigApi(this);
            Dag             = new DagApi(this);
            Dht             = new DhtApi(this);
            Dns             = new DnsApi(this);
            FileSystem      = new FileSystemApi(this);
            Generic         = new GenericApi(this);
            Key             = new KeyApi(this);
            Name            = new NameApi(this);
            Object          = new ObjectApi(this);
            Pin             = new PinApi(this);
            PubSub          = new PubSubApi(this);
            Stats           = new StatsApi(this);
            Swarm           = new SwarmApi(this);

            MigrationManager = new MigrationManager(this);

            // Async properties
            LocalPeer = new AsyncLazy <Peer>(async() =>
            {
                log.Debug("Building local peer");
                var keyChain = await KeyChainAsync().ConfigureAwait(false);
                log.Debug("Getting key info about self");
                var self      = await keyChain.FindKeyByNameAsync("self").ConfigureAwait(false);
                var localPeer = new Peer
                {
                    Id              = self.Id,
                    PublicKey       = await keyChain.GetPublicKeyAsync("self").ConfigureAwait(false),
                    ProtocolVersion = "ipfs/0.1.0"
                };
                var version            = typeof(IpfsEngine).GetTypeInfo().Assembly.GetName().Version;
                localPeer.AgentVersion = $"net-ipfs/{version.Major}.{version.Minor}.{version.Revision}";
                log.Debug("Built local peer");
                return(localPeer);
            });
            SwarmService = new AsyncLazy <Swarm>(async() =>
            {
                log.Debug("Building swarm service");
                if (Options.Swarm.PrivateNetworkKey == null)
                {
                    var path = Path.Combine(Options.Repository.Folder, "swarm.key");
                    if (File.Exists(path))
                    {
                        using (var x = File.OpenText(path))
                        {
                            Options.Swarm.PrivateNetworkKey = new PreSharedKey();
                            Options.Swarm.PrivateNetworkKey.Import(x);
                        }
                    }
                }
                var peer     = await LocalPeer.ConfigureAwait(false);
                var keyChain = await KeyChainAsync().ConfigureAwait(false);
                var self     = await keyChain.GetPrivateKeyAsync("self").ConfigureAwait(false);
                var swarm    = new Swarm
                {
                    LocalPeer        = peer,
                    LocalPeerKey     = PeerTalk.Cryptography.Key.CreatePrivateKey(self),
                    NetworkProtector = Options.Swarm.PrivateNetworkKey == null
                        ? null
                        : new Psk1Protector {
                        Key = Options.Swarm.PrivateNetworkKey
                    }
                };
                if (Options.Swarm.PrivateNetworkKey != null)
                {
                    log.Debug($"Private network {Options.Swarm.PrivateNetworkKey.Fingerprint().ToHexString()}");
                }

                log.Debug("Built swarm service");
                return(swarm);
            });
            BitswapService = new AsyncLazy <BlockExchange.Bitswap>(async() =>
            {
                log.Debug("Building bitswap service");
                var bitswap = new BlockExchange.Bitswap
                {
                    Swarm        = await SwarmService.ConfigureAwait(false),
                    BlockService = Block
                };
                log.Debug("Built bitswap service");
                return(bitswap);
            });
            DhtService = new AsyncLazy <PeerTalk.Routing.Dht1>(async() =>
            {
                log.Debug("Building DHT service");
                var dht = new PeerTalk.Routing.Dht1
                {
                    Swarm = await SwarmService.ConfigureAwait(false)
                };
                dht.Swarm.Router = dht;
                log.Debug("Built DHT service");
                return(dht);
            });
            PingService = new AsyncLazy <PeerTalk.Protocols.Ping1>(async() =>
            {
                log.Debug("Building Ping service");
                var ping = new PeerTalk.Protocols.Ping1
                {
                    Swarm = await SwarmService.ConfigureAwait(false)
                };
                log.Debug("Built Ping service");
                return(ping);
            });
            PubSubService = new AsyncLazy <PeerTalk.PubSub.NotificationService>(async() =>
            {
                log.Debug("Building PubSub service");
                var pubsub = new PeerTalk.PubSub.NotificationService
                {
                    LocalPeer = await LocalPeer.ConfigureAwait(false)
                };
                pubsub.Routers.Add(new PeerTalk.PubSub.FloodRouter
                {
                    Swarm = await SwarmService.ConfigureAwait(false)
                });
                log.Debug("Built PubSub service");
                return(pubsub);
            });
        }
        public async Task ListMigrations()
        {
            uSyncBackOfficeContext.Instance.Init();

            var migrationManager = new MigrationManager("~/usync/migrations");
            var migrations = migrationManager.ListMigrations();

            if (migrations.Any()) 
            {
                await Out.WriteLineAsync(string.Format("Found {0} migrations\n================", migrations.Count()));

                foreach(var migration in migrations)
                {
                    await Out.WriteLineAsync(
                        string.Format("{0,-30} {1} [{2} file{3}]",
                        migration.Name, migration.Time, migration.FileCount, migration.FileCount > 1 ? "s" : ""));
                }
            }
            else
            {
                await Out.WriteLineAsync("there are no migrations, use Migration create to create one");
            }
        }
Beispiel #17
0
        public async void LoadAllDifficultiesAndLevels(bool forceServerRefresh = false)
        {
            this.NotifyLongLoadingStart();

            var difficulties = this.GameProvider.GetDifficulties();
            var levels       = this.GameProvider.GetBaseLevels();
            var serverLevels = await this.GameProvider.GetDlLevelListAsync(forceServerRefresh);



            var terminatedOnV1 = new MigrationManager().GetMQ1PacksCompleted();;

            this.Difficulties = new ObservableCollection <DifficultyPresenter>();
            this.AllPacks     = new ObservableCollection <Pack>();


            //List<DifficultyPresenter> diffs = new List<DifficultyPresenter>();
            //List<Pack> packs = new List<Pack>();

            foreach (var item in difficulties)
            {
                DifficultyPresenter difPresenter = new DifficultyPresenter();
                difPresenter.Id   = item.Id;
                difPresenter.Name = item.Name;

                List <LevelPresenter> presentedLevels = new List <LevelPresenter>();
                var difLevels = levels.Where(m => m.DifficultyId == item.Id);

                foreach (var aBaseLevel in difLevels)
                {
                    Level          aLevel     = this.GameProvider.GetLevel(aBaseLevel.Id);
                    LevelPresenter levPresent = new LevelPresenter();
                    levPresent.Id              = aLevel.Id;
                    levPresent.Number          = aLevel.Val;
                    levPresent.IsLocal         = true;
                    levPresent.PercentProgress = aLevel.Progression;
                    presentedLevels.Add(levPresent);

                    foreach (var p in aLevel.Packs)
                    {
                        this.AllPacks.Add(p);
                    }
                }

                foreach (var serverLevel in serverLevels.Where(m => m.DifficultyId == item.Id)) // Adding sever levels
                {
                    if (!difLevels.Select(m => m.Id).Contains(serverLevel.Id))
                    {
                        LevelPresenter levPresent = new LevelPresenter();
                        levPresent.Id      = serverLevel.Id;
                        levPresent.Number  = serverLevel.Value;
                        levPresent.IsLocal = false;
                        presentedLevels.Add(levPresent);

                        // We update progress percent depending on MovieQuizz1 packs terminated (migration stuff)
                        int nbPacksTerminatedOnV1 = 0;
                        foreach (var aServerPack in serverLevel.Packs)
                        {
                            if (aServerPack.Fextra1.HasValue && terminatedOnV1.Contains(((int)aServerPack.Fextra1.Value)))
                            {
                                nbPacksTerminatedOnV1++;
                                levPresent.PacksIdTerminatedOnV1.Add(aServerPack.Id);
                            }


                            Pack pck = new Pack();
                            pck.Title        = aServerPack.Title;
                            pck.IsRemotePack = true;
                            pck.LevelId      = aServerPack.LevelId;
                            pck.Difficulty   = serverLevel.DifficultyId;
                            for (int i = 0; i < 10; i++)
                            {
                                pck.Medias.Add(new Media()
                                {
                                    IsCompleted = false
                                });
                            }

                            this.AllPacks.Add(pck);
                        }

                        levPresent.PercentProgress = (double)(((double)nbPacksTerminatedOnV1) / serverLevel.Packs.Count);
                    }
                }

                // reorder by value;
                difPresenter.Levels = new ObservableCollection <LevelPresenter>(presentedLevels.OrderBy(m => m.Number));

                this.Difficulties.Add(difPresenter);

                //this.AllPacks = new ObservableCollection<Pack>(packs);
            }


            //this.Difficulties = new ObservableCollection<DifficultyPresenter>(diffs);

            this.NotifyLongLoadingStop();
        }
Beispiel #18
0
        public MyDatabaseMigrations()
        {
            MigrationManager migrationsManager = new MigrationManager();

            migrationsManager.RunMe();
        }
Beispiel #19
0
 public PreferencesDatabase(string databaseFilePath, int maxCharacterSlots)
 {
     _databaseFilePath  = databaseFilePath;
     _maxCharacterSlots = maxCharacterSlots;
     MigrationManager.PerformUpgrade(GetDbConnectionString());
 }
Beispiel #20
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode   = data.MigratedNodes.ElementAt(0);
            string     oldNodeId = MigrationManager.GetGuidFromXmlElement(oldNode);

            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "CoordinateSystem.Rotate", "CoordinateSystem.Rotate@Point,Vector,double");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Create new node
            XmlElement identityCoordinateSystem = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "CoordinateSystem.Identity",
                "CoordinateSystem.Identity");

            migrationData.AppendNode(identityCoordinateSystem);

            XmlElement converterNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "DSCoreNodes.dll",
                "Math.RadiansToDegrees", "Math.RadiansToDegrees@double");

            migrationData.AppendNode(converterNode);
            string converterNodeId = MigrationManager.GetGuidFromXmlElement(converterNode);

            //append asVector Node
            XmlElement pointAsVector0 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll",
                "Point.AsVector", "Point.AsVector");

            migrationData.AppendNode(pointAsVector0);
            string pointAsVector0Id = MigrationManager.GetGuidFromXmlElement(pointAsVector0);

            // Update connectors
            PortId oldInPort0 = new PortId(newNodeId, 0, PortType.INPUT);
            PortId oldInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
            PortId oldInPort2 = new PortId(newNodeId, 2, PortType.INPUT);

            PortId newInPort1 = new PortId(newNodeId, 1, PortType.INPUT);
            PortId newInPort2 = new PortId(pointAsVector0Id, 0, PortType.INPUT);

            PortId converterInPort = new PortId(converterNodeId, 0, PortType.INPUT);

            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector1 = data.FindFirstConnector(oldInPort1);
            XmlElement connector2 = data.FindFirstConnector(oldInPort2);

            data.ReconnectToPort(connector0, newInPort1);
            data.ReconnectToPort(connector1, newInPort2);
            data.ReconnectToPort(connector2, converterInPort);

            data.CreateConnector(converterNode, 0, newNode, 3);
            data.CreateConnector(identityCoordinateSystem, 0, newNode, 0);
            data.CreateConnector(pointAsVector0, 0, newNode, 2);

            return(migrationData);
        }
 protected virtual void Configure(MigrationManager manager)
 {
 }
Beispiel #22
0
 public void TestExtractFileIndex05()
 {
     Assert.AreEqual(123, MigrationManager.ExtractFileIndex("abc.123.backup"));
 }
Beispiel #23
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "EllipseArc.ByPlaneRadiiStartAngleSweepAngle",
                                                  "EllipseArc.ByPlaneRadiiStartAngleSweepAngle@Plane,double,double,double,double");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            // Create new node
            XmlElement zAxis = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "Vector.ZAxis",
                "Vector.ZAxis");

            migrationData.AppendNode(zAxis);

            XmlElement planeNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "", "Plane.ByOriginNormal",
                "Plane.ByOriginNormal@Point,Vector");

            planeNode.SetAttribute("isVisible", "false");
            migrationData.AppendNode(planeNode);
            string planeNodeId = MigrationManager.GetGuidFromXmlElement(planeNode);

            XmlElement converterNode0 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 2, "DSCoreNodes.dll",
                "Math.RadiansToDegrees", "Math.RadiansToDegrees@double");

            migrationData.AppendNode(converterNode0);
            string converterNode0Id = MigrationManager.GetGuidFromXmlElement(converterNode0);

            XmlElement converterNode1 = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 3, "DSCoreNodes.dll",
                "Math.RadiansToDegrees", "Math.RadiansToDegrees@double");

            migrationData.AppendNode(converterNode1);
            string converterNode1Id = MigrationManager.GetGuidFromXmlElement(converterNode1);

            XmlElement minusNode = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 4, "", "-", "-@,");

            migrationData.AppendNode(minusNode);
            string minusNodeId = MigrationManager.GetGuidFromXmlElement(minusNode);

            // Update connectors
            PortId oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            PortId oldInPort3 = new PortId(newNodeId, 3, PortType.Input);
            PortId oldInPort4 = new PortId(newNodeId, 4, PortType.Input);

            PortId planeNodeInPort  = new PortId(planeNodeId, 0, PortType.Input);
            PortId converterInPort  = new PortId(converterNode0Id, 0, PortType.Input);
            PortId minusNodeInPort0 = new PortId(minusNodeId, 0, PortType.Input);
            PortId minusNodeInPort1 = new PortId(minusNodeId, 1, PortType.Input);

            XmlElement connector0 = data.FindFirstConnector(oldInPort0);
            XmlElement connector3 = data.FindFirstConnector(oldInPort3);
            XmlElement connector4 = data.FindFirstConnector(oldInPort4);

            data.ReconnectToPort(connector0, planeNodeInPort);
            data.ReconnectToPort(connector3, converterInPort);
            data.ReconnectToPort(connector4, minusNodeInPort0);

            if (connector3 != null)
            {
                XmlElement connector5 = MigrationManager.CreateFunctionNodeFrom(connector3);
                data.CreateConnector(connector5);
                data.ReconnectToPort(connector5, minusNodeInPort1);
            }

            data.CreateConnector(minusNode, 0, converterNode1, 0);
            data.CreateConnector(converterNode0, 0, newNode, 3);
            data.CreateConnector(converterNode1, 0, newNode, 4);
            data.CreateConnector(zAxis, 0, planeNode, 1);
            data.CreateConnector(planeNode, 0, newNode, 0);

            return(migrationData);
        }
Beispiel #24
0
 public void TestGetUniqueIndex01()
 {
     Assert.AreEqual(0, MigrationManager.GetUniqueIndex(new string[] { }));
 }
Beispiel #25
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var migrationData = new NodeMigrationData(data.Document);

            #region Create DSFunction node

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "Geometry.Intersect", "Geometry.Intersect@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0      = new PortId(newNodeId, 0, PortType.Input);
            var faceInConnector = data.FindFirstConnector(oldInPort0);
            var oldInPort1      = new PortId(newNodeId, 1, PortType.Input);
            var crvInConnector  = data.FindFirstConnector(oldInPort1);

            // probably unnecessary
            data.ReconnectToPort(faceInConnector, oldInPort0);
            data.ReconnectToPort(crvInConnector, oldInPort1);

            #endregion

            // in ports of curve-face intersection

            // 1) crv   -> stays the same
            // 2) face  -> stays the same

            // out ports of curve-face intersection

            // 1) result    -> this will be killed off by the migration
            // 2) xyz       -> this is out port 1 of oldNode
            // 3) uv        -> use Surface.ParameterAtPoint
            // 4) t         -> use Curve.ParameterAtPoint
            // 5) edge      -> killed
            // 6) edge t    -> killed


            // reconnect output port at 1 to 0
            var oldXYZOut   = new PortId(newNodeId, 1, PortType.Output);
            var newXyzOut   = new PortId(newNodeId, 0, PortType.Output);
            var xyzConnects = data.FindConnectors(oldXYZOut);

            if (xyzConnects != null)
            {
                xyzConnects.ToList().ForEach(x => data.ReconnectToPort(x, newXyzOut));
            }

            // get uv parm
            if (faceInConnector != null)
            {
                var faceInputNodeId = faceInConnector.Attributes["start"].Value;
                var faceInputIndex  = int.Parse(faceInConnector.Attributes["start_index"].Value);

                // get the parameter as a vector
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Surface.UVParameterAtPoint",
                    "Surface.UVParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(faceInputNodeId, faceInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newUVOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldUVOut = new PortId(newNodeId, 2, PortType.Output);

                var oldUVConnectors = data.FindConnectors(oldUVOut);
                if (oldUVConnectors != null)
                {
                    oldUVConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newUVOut));
                }
            }

            // get v parm
            if (crvInConnector != null)
            {
                var crvInputNodeId = crvInConnector.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(crvInConnector.Attributes["start_index"].Value);

                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 3, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);
                if (oldTConnectors != null)
                {
                    oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
                }
            }

            return(migrationData);
        }
Beispiel #26
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);
            XmlElement        oldNode       = data.MigratedNodes.ElementAt(0);
            string            oldNodeId     = MigrationManager.GetGuidFromXmlElement(oldNode);

            var newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "RevitNodes.dll",
                                                  "Solid.Torus", "Solid.Torus@Vector,Point,double,double");

            migrationData.AppendNode(newNode);

            // Add default values
            foreach (XmlNode child in oldNode.ChildNodes)
            {
                var newChild = child.Clone() as XmlElement;

                switch (newChild.GetAttribute("index"))
                {
                case "0":
                    PortId     oldInPort0 = new PortId(oldNodeId, 0, PortType.Input);
                    XmlElement connector0 = data.FindFirstConnector(oldInPort0);
                    if (connector0 != null)
                    {
                        break;
                    }

                    XmlElement zAxis0 = MigrationManager.CreateFunctionNode(
                        data.Document, oldNode, 0, "ProtoGeometry.dll",
                        "Vector.ZAxis", "Vector.ZAxis");
                    migrationData.AppendNode(zAxis0);
                    data.CreateConnector(zAxis0, 0, newNode, 0);
                    break;

                case "1":
                    PortId     oldInPort1 = new PortId(oldNodeId, 1, PortType.Input);
                    XmlElement connector1 = data.FindFirstConnector(oldInPort1);
                    if (connector1 != null)
                    {
                        break;
                    }

                    XmlElement cbn1 = MigrationManager.CreateCodeBlockNodeModelNode(
                        data.Document, oldNode, 1, "Point.ByCoordinates(0,0,1);");
                    migrationData.AppendNode(cbn1);
                    data.CreateConnector(cbn1, 0, newNode, 1);
                    break;

                case "2":
                case "3":
                    newNode.AppendChild(newChild);
                    break;

                default:
                    break;
                }
            }

            return(migrationData);
        }
Beispiel #27
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            var migrationData = new NodeMigrationData(data.Document);

            // Create DSFunction node
            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "Geometry.Intersect", "Geometry.Intersect@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0 = new PortId(newNodeId, 0, PortType.Input);
            var connector0 = data.FindFirstConnector(oldInPort0);
            var oldInPort1 = new PortId(newNodeId, 1, PortType.Input);
            var connector1 = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(connector0, oldInPort0);
            data.ReconnectToPort(connector1, oldInPort1);

            // reconnect output port at 1 to 0
            var oldXYZOut   = new PortId(newNodeId, 1, PortType.Output);
            var newXyzOut   = new PortId(newNodeId, 0, PortType.Output);
            var xyzConnects = data.FindConnectors(oldXYZOut);

            if (xyzConnects != null)
            {
                xyzConnects.ToList().ForEach(x => data.ReconnectToPort(x, newXyzOut));
            }

            // get u parm
            if (connector0 != null)
            {
                var crvInputNodeId = connector0.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(connector0.Attributes["start_index"].Value);

                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 2, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);

                oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            // get v parm
            if (connector1 != null)
            {
                var crvInputNodeId = connector1.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(connector1.Attributes["start_index"].Value);

                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Curve.ParameterAtPoint",
                    "Curve.ParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                var oldTOut = new PortId(newNodeId, 3, PortType.Output);

                var oldTConnectors = data.FindConnectors(oldTOut);

                oldTConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }

            return(migrationData);
        }
Beispiel #28
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);

            #region Create new DSFunction node - Geometry.ClosestPointTo@Geometry

            XmlElement oldNode = data.MigratedNodes.ElementAt(0);
            var        newNode = MigrationManager.CreateFunctionNodeFrom(oldNode);
            MigrationManager.SetFunctionSignature(newNode, "ProtoGeometry.dll",
                                                  "Geometry.ClosestPointTo", "Geometry.ClosestPointTo@Geometry");
            migrationData.AppendNode(newNode);
            string newNodeId = MigrationManager.GetGuidFromXmlElement(newNode);

            var oldInPort0      = new PortId(newNodeId, 0, PortType.Input);
            var ptInConnector   = data.FindFirstConnector(oldInPort0);
            var oldInPort1      = new PortId(newNodeId, 1, PortType.Input);
            var faceInConnector = data.FindFirstConnector(oldInPort1);

            data.ReconnectToPort(ptInConnector, oldInPort1);
            data.ReconnectToPort(faceInConnector, oldInPort0);

            #endregion

            #region Reconnect the old UV out port

            // if necessary, get the face UV
            var oldUVOut        = new PortId(newNodeId, 1, PortType.Output);
            var oldUVConnectors = data.FindConnectors(oldUVOut);

            if (oldUVConnectors != null && oldUVConnectors.Any())
            {
                // make parm at point node
                var parmAtPt = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Surface.UVParameterAtPoint",
                    "Surface.UVParameterAtPoint@Point");
                migrationData.AppendNode(parmAtPt);
                var parmAtPtId = MigrationManager.GetGuidFromXmlElement(parmAtPt);

                var crvInputNodeId = faceInConnector.Attributes["start"].Value;
                var crvInputIndex  = int.Parse(faceInConnector.Attributes["start_index"].Value);

                // connect output of project to parm at pt
                data.CreateConnectorFromId(crvInputNodeId, crvInputIndex, parmAtPtId, 0);
                data.CreateConnector(newNode, 0, parmAtPt, 1);

                // reconnect remaining output ports to new nodes
                var newTOut = new PortId(parmAtPtId, 0, PortType.Output);
                oldUVConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newTOut));
            }
            #endregion

            #region Reconnect the old distance out port

            var oldDOut        = new PortId(newNodeId, 2, PortType.Output);
            var oldDConnectors = data.FindConnectors(oldDOut);

            // If necessary, get the distance to the projected point
            if (oldDConnectors != null && oldDConnectors.Any())
            {
                // Get the original output ports connected to input
                var ptInputNodeId = ptInConnector.Attributes["start"].Value;
                var ptInputIndex  = int.Parse(ptInConnector.Attributes["start_index"].Value);

                // make distance to node
                var distTo = MigrationManager.CreateFunctionNode(
                    data.Document, oldNode, 0, "ProtoGeometry.dll",
                    "Geometry.DistanceTo",
                    "Geometry.DistanceTo@Geometry");
                migrationData.AppendNode(distTo);
                var distToId = MigrationManager.GetGuidFromXmlElement(distTo);

                data.CreateConnector(newNode, 0, distTo, 0);
                data.CreateConnectorFromId(ptInputNodeId, ptInputIndex, distToId, 1);

                var newDOut = new PortId(distToId, 0, PortType.Output);
                oldDConnectors.ToList().ForEach(x => data.ReconnectToPort(x, newDOut));
            }

            #endregion

            return(migrationData);
        }
Beispiel #29
0
 private void CreateBrandNewSqlDatabase(DatabaseContext dbContext)
 {
     ConfigureDatabaseConnection(dbContext);
     MigrationManager.CreateVersionTable();
 }
Beispiel #30
0
 public CustomNodeManager(NodeFactory nodeFactory, MigrationManager migrationManager)
 {
     this.nodeFactory = nodeFactory;
     this.migrationManager = migrationManager;
 }
Beispiel #31
0
        public CertifyManager(bool useWindowsNativeFeatures = true)
        {
            _useWindowsNativeFeatures = useWindowsNativeFeatures;

            _serverConfig = SharedUtils.ServiceConfigManager.GetAppServiceConfig();

            SettingsManager.LoadAppSettings();

            InitLogging(_serverConfig);

            Util.SetSupportedTLSVersions();
            try
            {
                _itemManager = new ItemManager(null, _serviceLog);

                if (!_itemManager.IsInitialised())
                {
                    _serviceLog.Error($"Item Manager failed to initialise properly. Check service logs for more information.");
                }
            }
            catch (Exception exp)
            {
                _serviceLog.Error($"Failed to open or upgrade the managed items database. Check service has required file access permissions. :: {exp}");
            }

            _credentialsManager = new CredentialsManager(useWindowsNativeFeatures);
            _serverProvider     = (ICertifiedServer) new ServerProviderIIS(_serviceLog);

            _progressResults = new ObservableCollection <RequestProgressState>();

            _pluginManager = new PluginManager();
            _pluginManager.EnableExternalPlugins = CoreAppSettings.Current.IncludeExternalPlugins;
            _pluginManager.LoadPlugins(new List <string> {
                "Licensing", "DashboardClient", "DeploymentTasks", "CertificateManagers", "DnsProviders"
            });

            _migrationManager = new MigrationManager(_itemManager, _credentialsManager, _serverProvider);

            LoadCertificateAuthorities();


            // init remaining utilities and optionally enable telematics
            _challengeDiagnostics = new ChallengeDiagnostics(CoreAppSettings.Current.EnableValidationProxyAPI);

            if (CoreAppSettings.Current.EnableAppTelematics)
            {
                _tc = new Util().InitTelemetry(Locales.ConfigResources.AIInstrumentationKey);
            }

            _httpChallengePort = _serverConfig.HttpChallengeServerPort;
            _httpChallengeServerClient.Timeout = new TimeSpan(0, 0, 20);

            if (_tc != null)
            {
                _tc.TrackEvent("ServiceStarted");
            }

            _serviceLog?.Information("Certify Manager Started");

            try
            {
                PerformAccountUpgrades().Wait();
            }
            catch (Exception exp)
            {
                _serviceLog.Error($"Failed to perform ACME account upgrades. :: {exp}");
            }

            PerformManagedCertificateMigrations().Wait();
        }
Beispiel #32
0
        /// <summary>
        ///     Deserialize a function definition from a given path.  A side effect of this function is that
        ///     the node is added to the dictionary of loadedNodes.
        /// </summary>
        /// <param name="funcDefGuid">The function guid we're currently loading</param>
        /// <param name="def">The resultant function definition</param>
        /// <returns></returns>
        private bool GetDefinitionFromPath(Guid funcDefGuid, out CustomNodeDefinition def)
        {
            try
            {
                var xmlPath = GetNodePath(funcDefGuid);

                #region read xml file

                var xmlDoc = new XmlDocument();
                xmlDoc.Load(xmlPath);

                string funName     = null;
                string category    = "";
                double cx          = 0;
                double cy          = 0;
                string description = "";
                string version     = "";

                double zoom = 1.0;
                string id   = "";

                // load the header

                // handle legacy workspace nodes called dynWorkspace
                // and new workspaces without the dyn prefix
                XmlNodeList workspaceNodes = xmlDoc.GetElementsByTagName("Workspace");
                if (workspaceNodes.Count == 0)
                {
                    workspaceNodes = xmlDoc.GetElementsByTagName("dynWorkspace");
                }

                foreach (XmlNode node in workspaceNodes)
                {
                    foreach (XmlAttribute att in node.Attributes)
                    {
                        if (att.Name.Equals("X"))
                        {
                            cx = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        }
                        else if (att.Name.Equals("Y"))
                        {
                            cy = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        }
                        else if (att.Name.Equals("zoom"))
                        {
                            zoom = double.Parse(att.Value, CultureInfo.InvariantCulture);
                        }
                        else if (att.Name.Equals("Name"))
                        {
                            funName = att.Value;
                        }
                        else if (att.Name.Equals("Category"))
                        {
                            category = att.Value;
                        }
                        else if (att.Name.Equals("Description"))
                        {
                            description = att.Value;
                        }
                        else if (att.Name.Equals("ID"))
                        {
                            id = att.Value;
                        }
                        else if (att.Name.Equals("Version"))
                        {
                            version = att.Value;
                        }
                    }
                }

                Version fileVersion = MigrationManager.VersionFromString(version);

                var currentVersion = MigrationManager.VersionFromWorkspace(dynamoModel.HomeSpace);

                if (fileVersion > currentVersion)
                {
                    bool resume = Utils.DisplayFutureFileMessage(this.dynamoModel, xmlPath, fileVersion, currentVersion);
                    if (!resume)
                    {
                        def = null;
                        return(false);
                    }
                }

                var decision = MigrationManager.ShouldMigrateFile(fileVersion, currentVersion);
                if (decision == MigrationManager.Decision.Abort)
                {
                    Utils.DisplayObsoleteFileMessage(this.dynamoModel, xmlPath, fileVersion, currentVersion);

                    def = null;
                    return(false);
                }
                else if (decision == MigrationManager.Decision.Migrate)
                {
                    string backupPath = string.Empty;
                    bool   isTesting  = DynamoModel.IsTestMode; // No backup during test.
                    if (!isTesting && MigrationManager.BackupOriginalFile(xmlPath, ref backupPath))
                    {
                        string message = string.Format(
                            "Original file '{0}' gets backed up at '{1}'",
                            Path.GetFileName(xmlPath), backupPath);

                        dynamoModel.Logger.Log(message);
                    }

                    MigrationManager.Instance.ProcessWorkspaceMigrations(this.dynamoModel, xmlDoc, fileVersion);
                    MigrationManager.Instance.ProcessNodesInWorkspace(this.dynamoModel, xmlDoc, fileVersion);
                }

                // we have a dyf and it lacks an ID field, we need to assign it
                // a deterministic guid based on its name.  By doing it deterministically,
                // files remain compatible
                if (string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(funName))
                {
                    id = GuidUtility.Create(GuidUtility.UrlNamespace, funName).ToString();
                }

                #endregion

                //DynamoCommands.WriteToLogCmd.Execute("Loading node definition for \"" + funName + "\" from: " + xmlPath);
                this.dynamoModel.Logger.Log("Loading node definition for \"" + funName + "\" from: " + xmlPath);

                var ws = new CustomNodeWorkspaceModel(dynamoModel,
                                                      funName, category.Length > 0
                    ? category
                    : "Custom Nodes", description, cx, cy)
                {
                    WatchChanges = false,
                    FileName     = xmlPath,
                    Zoom         = zoom
                };

                def = new CustomNodeDefinition(Guid.Parse(id))
                {
                    WorkspaceModel = ws,
                    IsBeingLoaded  = true
                };

                // Add custom node definition firstly so that a recursive
                // custom node won't recursively load itself.
                SetFunctionDefinition(def.FunctionId, def);

                XmlNodeList elNodes = xmlDoc.GetElementsByTagName("Elements");
                XmlNodeList cNodes  = xmlDoc.GetElementsByTagName("Connectors");
                XmlNodeList nNodes  = xmlDoc.GetElementsByTagName("Notes");

                if (elNodes.Count == 0)
                {
                    elNodes = xmlDoc.GetElementsByTagName("dynElements");
                }
                if (cNodes.Count == 0)
                {
                    cNodes = xmlDoc.GetElementsByTagName("dynConnectors");
                }
                if (nNodes.Count == 0)
                {
                    nNodes = xmlDoc.GetElementsByTagName("dynNotes");
                }

                XmlNode elNodesList = elNodes[0];
                XmlNode cNodesList  = cNodes[0];
                XmlNode nNodesList  = nNodes[0];

                #region instantiate nodes

                foreach (XmlNode elNode in elNodesList.ChildNodes)
                {
                    XmlAttribute typeAttrib          = elNode.Attributes["type"];
                    XmlAttribute guidAttrib          = elNode.Attributes["guid"];
                    XmlAttribute nicknameAttrib      = elNode.Attributes["nickname"];
                    XmlAttribute xAttrib             = elNode.Attributes["x"];
                    XmlAttribute yAttrib             = elNode.Attributes["y"];
                    XmlAttribute lacingAttrib        = elNode.Attributes["lacing"];
                    XmlAttribute isVisAttrib         = elNode.Attributes["isVisible"];
                    XmlAttribute isUpstreamVisAttrib = elNode.Attributes["isUpstreamVisible"];

                    string typeName = typeAttrib.Value;

                    //test the GUID to confirm that it is non-zero
                    //if it is zero, then we have to fix it
                    //this will break the connectors, but it won't keep
                    //propagating bad GUIDs
                    var guid = new Guid(guidAttrib.Value);
                    if (guid == Guid.Empty)
                    {
                        guid = Guid.NewGuid();
                    }

                    string nickname = nicknameAttrib.Value;

                    double x = double.Parse(xAttrib.Value, CultureInfo.InvariantCulture);
                    double y = double.Parse(yAttrib.Value, CultureInfo.InvariantCulture);

                    bool isVisible = true;
                    if (isVisAttrib != null)
                    {
                        isVisible = isVisAttrib.Value == "true" ? true : false;
                    }

                    bool isUpstreamVisible = true;
                    if (isUpstreamVisAttrib != null)
                    {
                        isUpstreamVisible = isUpstreamVisAttrib.Value == "true" ? true : false;
                    }

                    // Retrieve optional 'function' attribute (only for DSFunction).
                    XmlAttribute signatureAttrib = elNode.Attributes["function"];
                    var          signature       = signatureAttrib == null ? null : signatureAttrib.Value;

                    NodeModel  el           = null;
                    XmlElement dummyElement = null;

                    try
                    {
                        // The attempt to create node instance may fail due to "type" being
                        // something else other than "NodeModel" derived object type. This
                        // is possible since some legacy nodes have been made to derive from
                        // "MigrationNode" object type that is not derived from "NodeModel".
                        //
                        typeName = Nodes.Utilities.PreprocessTypeName(typeName);
                        System.Type type = Nodes.Utilities.ResolveType(this.dynamoModel, typeName);
                        if (type != null)
                        {
                            el = ws.NodeFactory.CreateNodeInstance(type, nickname, signature, guid);
                        }

                        if (el != null)
                        {
                            el.Load(elNode);
                        }
                        else
                        {
                            var e = elNode as XmlElement;
                            dummyElement = MigrationManager.CreateMissingNode(e, 1, 1);
                        }
                    }
                    catch (UnresolvedFunctionException)
                    {
                        // If a given function is not found during file load, then convert the
                        // function node into a dummy node (instead of crashing the workflow).
                        //
                        var e = elNode as XmlElement;
                        dummyElement = MigrationManager.CreateUnresolvedFunctionNode(e);
                    }

                    if (dummyElement != null) // If a dummy node placement is desired.
                    {
                        // The new type representing the dummy node.
                        typeName = dummyElement.GetAttribute("type");
                        System.Type type = Dynamo.Nodes.Utilities.ResolveType(this.dynamoModel, typeName);

                        el = ws.NodeFactory.CreateNodeInstance(type, nickname, string.Empty, guid);
                        el.Load(dummyElement);
                    }

                    ws.Nodes.Add(el);

                    el.X = x;
                    el.Y = y;

                    if (lacingAttrib != null)
                    {
                        LacingStrategy lacing = LacingStrategy.First;
                        Enum.TryParse(lacingAttrib.Value, out lacing);
                        el.ArgumentLacing = lacing;
                    }

                    el.DisableReporting();

                    // This is to fix MAGN-3648. Method reference in CBN that gets
                    // loaded before method definition causes a CBN to be left in
                    // a warning state. This is to clear such warnings and set the
                    // node to "Dead" state (correct value of which will be set
                    // later on with a call to "EnableReporting" below). Please
                    // refer to the defect for details and other possible fixes.
                    //
                    if (el.State == ElementState.Warning && (el is CodeBlockNodeModel))
                    {
                        el.State = ElementState.Dead;
                    }

                    el.IsVisible         = isVisible;
                    el.IsUpstreamVisible = isUpstreamVisible;
                }

                #endregion

                #region instantiate connectors

                foreach (XmlNode connector in cNodesList.ChildNodes)
                {
                    XmlAttribute guidStartAttrib = connector.Attributes[0];
                    XmlAttribute intStartAttrib  = connector.Attributes[1];
                    XmlAttribute guidEndAttrib   = connector.Attributes[2];
                    XmlAttribute intEndAttrib    = connector.Attributes[3];
                    XmlAttribute portTypeAttrib  = connector.Attributes[4];

                    var guidStart  = new Guid(guidStartAttrib.Value);
                    var guidEnd    = new Guid(guidEndAttrib.Value);
                    int startIndex = Convert.ToInt16(intStartAttrib.Value);
                    int endIndex   = Convert.ToInt16(intEndAttrib.Value);
                    var portType   = ((PortType)Convert.ToInt16(portTypeAttrib.Value));

                    //find the elements to connect
                    NodeModel start = null;
                    NodeModel end   = null;

                    foreach (NodeModel e in ws.Nodes)
                    {
                        if (e.GUID == guidStart)
                        {
                            start = e;
                        }
                        else if (e.GUID == guidEnd)
                        {
                            end = e;
                        }
                        if (start != null && end != null)
                        {
                            break;
                        }
                    }

                    try
                    {
                        var newConnector = ws.AddConnection(
                            start, end,
                            startIndex, endIndex,
                            portType);
                    }
                    catch
                    {
                        dynamoModel.WriteToLog(string.Format("ERROR : Could not create connector between {0} and {1}.", start.NickName, end.NickName));
                    }
                }

                #endregion

                #region instantiate notes

                if (nNodesList != null)
                {
                    foreach (XmlNode note in nNodesList.ChildNodes)
                    {
                        XmlAttribute textAttrib = note.Attributes[0];
                        XmlAttribute xAttrib    = note.Attributes[1];
                        XmlAttribute yAttrib    = note.Attributes[2];

                        string text = textAttrib.Value;
                        double x    = Convert.ToDouble(xAttrib.Value, CultureInfo.InvariantCulture);
                        double y    = Convert.ToDouble(yAttrib.Value, CultureInfo.InvariantCulture);

                        ws.AddNote(false, x, y, text, Guid.NewGuid());
                    }
                }

                #endregion

                foreach (var e in ws.Nodes)
                {
                    e.EnableReporting();
                }

                def.IsBeingLoaded = false;

                def.Compile(this.dynamoModel, this.dynamoModel.EngineController);

                SetFunctionDefinition(def.FunctionId, def);

                ws.WatchChanges = true;

                OnGetDefinitionFromPath(def);
            }
            catch (Exception ex)
            {
                dynamoModel.WriteToLog("There was an error opening the workbench.");
                dynamoModel.WriteToLog(ex);

                if (DynamoModel.IsTestMode)
                {
                    throw ex; // Rethrow for NUnit.
                }
                def = null;
                return(false);
            }

            return(true);
        }
Beispiel #33
0
        public static NodeMigrationData Migrate_0630_to_0700(NodeMigrationData data)
        {
            NodeMigrationData migrationData = new NodeMigrationData(data.Document);
            XmlElement        oldNode       = data.MigratedNodes.ElementAt(0);
            string            oldNodeId     = MigrationManager.GetGuidFromXmlElement(oldNode);

            // Create nodes
            XmlElement referencePoint = MigrationManager.CreateFunctionNodeFrom(oldNode);

            MigrationManager.SetFunctionSignature(referencePoint,
                                                  "RevitNodes.dll", "ReferencePoint.ByPoint",
                                                  "ReferencePoint.ByPoint@Point");
            migrationData.AppendNode(referencePoint);
            string referencePointId = MigrationManager.GetGuidFromXmlElement(referencePoint);

            XmlElement pointAtParameter = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 0, "ProtoGeometry.dll",
                "Surface.PointAtParameter", "Surface.PointAtParameter@double,double");

            migrationData.AppendNode(pointAtParameter);
            string pointAtParameterId = MigrationManager.GetGuidFromXmlElement(pointAtParameter);

            XmlElement uvU = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 1, "ProtoGeometry.dll", "UV.U", "UV.U");

            migrationData.AppendNode(uvU);
            string uvUId = MigrationManager.GetGuidFromXmlElement(uvU);

            XmlElement uvV = MigrationManager.CreateFunctionNode(
                data.Document, oldNode, 2, "ProtoGeometry.dll", "UV.V", "UV.V");

            migrationData.AppendNode(uvV);
            string uvVId = MigrationManager.GetGuidFromXmlElement(uvV);

            // Update connectors
            PortId     oldInPort0  = new PortId(oldNodeId, 0, PortType.Input);
            PortId     oldInPort1  = new PortId(oldNodeId, 1, PortType.Input);
            PortId     papInPort0  = new PortId(pointAtParameterId, 0, PortType.Input);
            PortId     uvUInPort0  = new PortId(uvUId, 0, PortType.Input);
            XmlElement connector0  = data.FindFirstConnector(oldInPort0);
            XmlElement connector1  = data.FindFirstConnector(oldInPort1);
            XmlElement connectorUv = null;

            if (connector1 != null)
            {
                connectorUv = MigrationManager.CreateFunctionNodeFrom(connector1);
                data.CreateConnector(connectorUv);
            }

            if (connectorUv != null)
            {
                PortId uvVInPort0 = new PortId(uvVId, 0, PortType.Input);
                data.ReconnectToPort(connectorUv, uvVInPort0);
            }

            data.ReconnectToPort(connector0, papInPort0);
            data.ReconnectToPort(connector1, uvUInPort0);
            data.CreateConnector(uvU, 0, pointAtParameter, 1);
            data.CreateConnector(uvV, 0, pointAtParameter, 2);
            data.CreateConnector(pointAtParameter, 0, referencePoint, 0);

            return(migrationData);
        }
Beispiel #34
0
        /// <summary>
        /// Default constructor for DynamoModel
        /// </summary>
        /// <param name="config">Start configuration</param>
        protected DynamoModel(IStartConfiguration config)
        {
            ClipBoard = new ObservableCollection<ModelBase>();

            pathManager = new PathManager(new PathManagerParams
            {
                CorePath = config.DynamoCorePath,
                HostPath = config.DynamoHostPath,
                PathResolver = config.PathResolver
            });

            // Ensure we have all directories in place.
            var exceptions = new List<Exception>();
            pathManager.EnsureDirectoryExistence(exceptions);

            Context = config.Context;
            IsTestMode = config.StartInTestMode;

            var config2 = config as IStartConfiguration2;
            IsHeadless = (config2 != null) ? config2.IsHeadless : false;

            DebugSettings = new DebugSettings();
            Logger = new DynamoLogger(DebugSettings, pathManager.LogDirectory);

            foreach (var exception in exceptions)
            {
                Logger.Log(exception); // Log all exceptions.
            }

            MigrationManager = new MigrationManager(DisplayFutureFileMessage, DisplayObsoleteFileMessage);
            MigrationManager.MessageLogged += LogMessage;
            MigrationManager.MigrationTargets.Add(typeof(WorkspaceMigrations));

            var thread = config.SchedulerThread ?? new DynamoSchedulerThread();
            Scheduler = new DynamoScheduler(thread, config.ProcessMode);
            Scheduler.TaskStateChanged += OnAsyncTaskStateChanged;

            geometryFactoryPath = config.GeometryFactoryPath;

            IPreferences preferences = CreateOrLoadPreferences(config.Preferences);
            var settings = preferences as PreferenceSettings;
            if (settings != null)
            {
                PreferenceSettings = settings;
                PreferenceSettings.PropertyChanged += PreferenceSettings_PropertyChanged;
            }

            InitializeInstrumentationLogger();

            if (!IsTestMode && PreferenceSettings.IsFirstRun)
            {
                DynamoMigratorBase migrator = null;

                try
                {
                    var dynamoLookup = config.UpdateManager != null && config.UpdateManager.Configuration != null
                        ? config.UpdateManager.Configuration.DynamoLookUp : null;

                    migrator = DynamoMigratorBase.MigrateBetweenDynamoVersions(pathManager, dynamoLookup);
                }
                catch (Exception e)
                {
                    Logger.Log(e.Message);
                }

                if (migrator != null)
                {
                    var isFirstRun = PreferenceSettings.IsFirstRun;
                    PreferenceSettings = migrator.PreferenceSettings;

                    // Preserve the preference settings for IsFirstRun as this needs to be set
                    // only by UsageReportingManager
                    PreferenceSettings.IsFirstRun = isFirstRun;
                }
            }
            InitializePreferences(PreferenceSettings);

            // At this point, pathManager.PackageDirectories only has 1 element which is the directory
            // in AppData. If list of PackageFolders is empty, add the folder in AppData to the list since there
            // is no additional location specified. Otherwise, update pathManager.PackageDirectories to include
            // PackageFolders
            if (PreferenceSettings.CustomPackageFolders.Count == 0)
                PreferenceSettings.CustomPackageFolders = new List<string> {pathManager.UserDataDirectory};

            //Make sure that the default package folder is added in the list if custom packages folder.
            var userDataFolder = pathManager.GetUserDataFolder(); //Get the default user data path
            if (Directory.Exists(userDataFolder) && !PreferenceSettings.CustomPackageFolders.Contains(userDataFolder))
            {
                PreferenceSettings.CustomPackageFolders.Add(userDataFolder);
            }

            pathManager.Preferences = PreferenceSettings;


            SearchModel = new NodeSearchModel();
            SearchModel.ItemProduced +=
                node => ExecuteCommand(new CreateNodeCommand(node, 0, 0, true, true));

            NodeFactory = new NodeFactory();
            NodeFactory.MessageLogged += LogMessage;

            CustomNodeManager = new CustomNodeManager(NodeFactory, MigrationManager);
            InitializeCustomNodeManager();

            extensionManager = new ExtensionManager();
            extensionManager.MessageLogged += LogMessage;
            var extensions = config.Extensions ?? LoadExtensions();

            Loader = new NodeModelAssemblyLoader();
            Loader.MessageLogged += LogMessage;

            // Create a core which is used for parsing code and loading libraries
            var libraryCore = new ProtoCore.Core(new Options());

            libraryCore.Compilers.Add(Language.Associative, new Compiler(libraryCore));
            libraryCore.Compilers.Add(Language.Imperative, new ProtoImperative.Compiler(libraryCore));
            libraryCore.ParsingMode = ParseMode.AllowNonAssignment;

            LibraryServices = new LibraryServices(libraryCore, pathManager, PreferenceSettings);
            LibraryServices.MessageLogged += LogMessage;
            LibraryServices.LibraryLoaded += LibraryLoaded;

            ResetEngineInternal();

            AddHomeWorkspace();

            AuthenticationManager = new AuthenticationManager(config.AuthProvider);

            UpdateManager = config.UpdateManager ?? new DefaultUpdateManager(null);

            // config.UpdateManager has to be cast to IHostUpdateManager in order to extract the HostVersion and HostName
            // see IHostUpdateManager summary for more details 
            var hostUpdateManager = config.UpdateManager as IHostUpdateManager;
          
            if (hostUpdateManager != null)
            {
                HostName = hostUpdateManager.HostName;
                HostVersion = hostUpdateManager.HostVersion == null ? null : hostUpdateManager.HostVersion.ToString();
            }
            else
            {
                HostName = string.Empty;
                HostVersion = null;
            }
            
            UpdateManager.Log += UpdateManager_Log;
            if (!IsTestMode && !IsHeadless)
            {
                DefaultUpdateManager.CheckForProductUpdate(UpdateManager);
            }

            Logger.Log(string.Format("Dynamo -- Build {0}",
                                        Assembly.GetExecutingAssembly().GetName().Version));

            InitializeNodeLibrary(PreferenceSettings);

            if (extensions.Any())
            {
                var startupParams = new StartupParams(config.AuthProvider,
                    pathManager, new ExtensionLibraryLoader(this), CustomNodeManager,
                    GetType().Assembly.GetName().Version, PreferenceSettings);

                foreach (var ext in extensions)
                {
                    var logSource = ext as ILogSource;
                    if (logSource != null)
                        logSource.MessageLogged += LogMessage;

                    try
                    {
                        ext.Startup(startupParams);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(ex.Message);
                    }

                    ExtensionManager.Add(ext);
                }
            }

            LogWarningMessageEvents.LogWarningMessage += LogWarningMessage;

            StartBackupFilesTimer();

            TraceReconciliationProcessor = this;

            foreach (var ext in ExtensionManager.Extensions)
            {
                try
                {
                    ext.Ready(new ReadyParams(this));
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message);
                }
            }
        }
Beispiel #35
0
        static void Main(string[] args)
        {
            //DbManager dbManager = new DbManager();
            MigrationManager migrationManager = new MigrationManager();

            migrationManager.DropTables();
            migrationManager.CreateTables();
            migrationManager.ImportStartValues();



            Menu menu = new Menu();

            menu.MainMenu();



            //migrationManager.DropTables();
            //migrationManager.CreateTables();
            //migrationManager.ImportStartValues();


            //UserFilter userFilter = new UserFilter() { Email = "adasd",  FirstName="asd", HashPassword="******", LastName="asd" };
            //var user = mapper.Map<UserFilter, User> (userFilter);

            //Console.WriteLine(user);
            //dbManager.CommandExecuteNonQuery(@"insert into tblRole (Name) Values ('Admin'), ('Customer');");
            //var reader = dbManager.GetDataReader(@"select Id, Name from tblRole;");

            //while (reader.Read())
            //{
            //    Console.WriteLine("{0}\t{1}", reader.GetInt32(0),
            //                            reader.GetString(1));
            //}


            //UsersRepository usersRepo = new UsersRepository();

            //User entity = new User { FirstName = "Alll", LastName = "PPP", Email = "*****@*****.**", HashPassword = "******", RoleId = 1 };
            //entity = usersRepo.Create(entity);

            //            Console.WriteLine(usersRepo.Update(entity));
            //usersRepo.Delete(new UserFilter() { FirstName = "Alll", Id = 1 });
            //var res = usersRepo.Update(entity, new UserFilter() { Id = 2 });
            //Console.WriteLine(usersRepo.Get(new UserFilter() {  }) );
            //IEnumerable<User> users = usersRepo.GetRange(new UserFilter() {Id  = 0, RoleId = 0 }, new UserFilter() { Id = 4, RoleId = 2 }, new UserFilter() { Email = "*****@*****.**" });


            //IEnumerable<User> users = usersRepo.GetAll();

            //foreach (User el in users)
            //{
            //   Console.WriteLine("==================================");
            //    Console.WriteLine(el);
            //}

            //Console.WriteLine(entity);
            //var _user = usersRepo.Get(0
            //Console.WriteLine(_user.FirstName + _user.LastName);


            //SuppliersRepository suppliersRepository = new SuppliersRepository();
            //Supplier supplier = new Supplier() { Id = 1, Name = "asd" };
            //suppliersRepository.Create(supplier);

            //ProductsRepository productsRepository = new ProductsRepository();
            //Product product = new Product() { Id = 1, Name = "asd", Brand="asd", Price=123, ProducingCountry="asd"};
            //productsRepository.Create(product);
            //var products = productsRepository.GetAll();


            //foreach (Product el in products)
            //{
            //   Console.WriteLine("==================================");
            //   Console.WriteLine(el);
            //}
            //Console.Read();
        }