private HelixWatch3DNodeViewModel(Dynamo.Nodes.Watch3D node, Watch3DViewModelStartupParams parameters):
            base(parameters)
        {
            watchNode = node;
            IsResizable = true;

            RegisterPortEventHandlers(node);

            watchNode.Serialized += SerializeCamera;
            watchNode.Deserialized += watchNode_Deserialized;
        }
 public void Serialize()
 {
     var Serializer = new JsonSerializer();
     dynamic Object = new { A = 5, B = "ASDF" };
     Assert.Equal("{\"A\":5,\"B\":\"ASDF\"}", Serializer.Serialize(Object.GetType(), Object));
     Object = new TestObject { A = 5, B = "ASDF" };
     Assert.Equal("{\"A\":5,\"B\":\"ASDF\"}", Serializer.Serialize(Object.GetType(), Object));
     Object = new ExpandoObject();
     Object.A = 5;
     Object.B = "ASDF";
     Assert.Equal("{\"A\":5,\"B\":\"ASDF\"}", Serializer.Serialize(Object.GetType(), Object));
     Object = new Dynamo();
     Object.A = 5;
     Object.B = "ASDF";
     Assert.Equal("{\"A\":5,\"B\":\"ASDF\"}", Serializer.Serialize(Object.GetType(), Object));
 }
Beispiel #3
0
        public void SetupCustomUIElements(Dynamo.Controls.dynNodeView nodeUI)
        {
            var fileName = "DeprecatedNode.png";
            if (this.NodeNature == Nature.Unresolved)
                fileName = "MissingNode.png";

            var src = @"/DSCoreNodesUI;component/Resources/" + fileName;

            Image dummyNodeImage = new Image()
            {
                Stretch = System.Windows.Media.Stretch.None,
                Source = new BitmapImage(new Uri(src, UriKind.Relative))
            };

            nodeUI.inputGrid.Children.Add(dummyNodeImage);
            this.Warning(GetDescription());
        }
 /// <summary>
 /// Gets the page count for the mapping specified
 /// </summary>
 /// <param name="Version">API version number</param>
 /// <param name="Mapping">Mapping name</param>
 /// <param name="PageSize">Size of the page.</param>
 /// <returns>The resulting items</returns>
 public Dynamo PageCount(int Version, string Mapping, int PageSize)
 {
     try
     {
         IDictionary<string, IAPIMapping> TempMappings = Mappings.GetValue(Version).Mappings;
         if (!TempMappings.ContainsKey(Mapping))
             return new Dynamo(new { PageCount = 0 });
         var ReturnValue = new Dynamo(new { PageCount = TempMappings[Mapping].PageCount(Mappings.GetValue(Version), PageSize) });
         return ReturnValue;
     }
     catch
     {
         return new Dynamo(new { PageCount = 0 });
     }
 }
 /// <summary>
 /// Gets the property as a parameter (for classes, this will return the ID of the property)
 /// </summary>
 /// <param name="Object">Object to get the parameter from</param>
 /// <returns>The parameter version of the property</returns>
 public override object GetParameter(Dynamo Object)
 {
     return(null);
 }
 /// <summary>
 /// Runs the specified service
 /// </summary>
 /// <param name="Version">API version number</param>
 /// <param name="Mapping">Mapping name</param>
 /// <param name="Value">The value.</param>
 /// <returns>The result from running the service</returns>
 public Dynamo CallService(int Version, string Mapping, Dynamo Value)
 {
     try
     {
         if (!WorkflowManager.CreateWorkflow<WorkflowInfo>(Mapping + "_PreService_" + Version).Start(new WorkflowInfo(Mapping, WorkflowType.PreService, Version, Value)).Continue)
             return Error("Error running service");
         IDictionary<string, IService> TempMappings = Services.GetValue(Version).Services;
         if (!TempMappings.ContainsKey(Mapping))
             return Error("Error getting item");
         var ReturnValue = TempMappings[Mapping].Process(Value);
         if (!WorkflowManager.CreateWorkflow<WorkflowInfo>(Mapping + "_PostService_" + Version).Start(new WorkflowInfo(Mapping, WorkflowType.PostService, Version, ReturnValue)).Continue)
             return Error("Error running service");
         return ReturnValue;
     }
     catch
     {
         return Error("Error running service");
     }
 }
Beispiel #7
0
 private ObjectType GetCached <ObjectType>(ref Dynamo ReturnValue, string KeyName) where ObjectType : class
 {
     Contract.Requires(this.Cache != null);
     ReturnValue = (Dynamo)Cache[KeyName];
     return(ConvertValue <ObjectType>(ReturnValue));
 }
Beispiel #8
0
 /// <summary>
 /// Gets the property as a parameter (for classes, this will return the ID of the property)
 /// </summary>
 /// <param name="Object">Object to get the parameter from</param>
 /// <returns>The parameter version of the property</returns>
 public override object GetParameter(Dynamo Object)
 {
     return ForeignMapping.IDProperties.FirstOrDefault().GetValue(GetValue(Object));
 }
Beispiel #9
0
        async Task <APIGatewayProxyResponse> CreatePostResponse(JObject input, ILambdaContext context)
        {
            JObject preference = new Preference().preference;

            int statusCode = (input != null) ?
                             (int)HttpStatusCode.OK :
                             (int)HttpStatusCode.InternalServerError;

            Document writeDocument = new Document();

            string sn    = input["sn"].ToString();
            string stage = String.Format("{0}-{1}-{2}", input["code"], input["type"], "simulation");

            writeDocument["sn"]     = sn;
            writeDocument["code"]   = String.Format("{0}-{1}", input["code"], input["type"]);
            writeDocument["status"] = @"start";

            Dynamo.writeDynamoTable(tableRegion: preference["Dynamo"]["Simulation"]["Region"].ToString(),
                                    tableName: preference["Dynamo"]["Simulation"]["Name"].ToString(),
                                    writeDocument: writeDocument).Wait();
            await ProgressWriter.writer(sn : sn, stage : stage, status : "start");

            List <SimulationMeta> metas = JArray.Parse(input["meta"].ToString()).Select(input_meta =>
                                                                                        new SimulationMeta(input_meta as JObject)).ToList();

            context.Logger.LogLine("number of meta data: " + metas.Count);

            if (!input.ContainsKey("size"))
            {
                input["size"] = 1000000;
            }

            string body = "";

            context.Logger.LogLine("Simulation start");
            float[]          results          = Simulation.RunSimulation(metas, Convert.ToInt32(input["size"]));
            SimulationResult simulationResult = new SimulationResult(results);

            writeStreamFromStreamToS3(bucketRegion: preference["S3"]["Simulation"]["Region"].ToString(),
                                      keyName: String.Format("{0}-{1}-{2}.sim", input["sn"], input["code"], input["type"]),
                                      bucketName: preference["S3"]["Simulation"]["Name"].ToString(),
                                      stream: simulationResult.ToStream()).Wait();

            writeDocument["status"] = @"end";

            Dynamo.writeDynamoTable(tableRegion: preference["Dynamo"]["Simulation"]["Region"].ToString(),
                                    tableName: preference["Dynamo"]["Simulation"]["Name"].ToString(),
                                    writeDocument: writeDocument).Wait();
            await ProgressWriter.writer(sn : sn, stage : stage, status : "end");

            var response = new APIGatewayProxyResponse
            {
                StatusCode = statusCode,
                Body       = body,
                Headers    = new Dictionary <string, string>
                {
                    { "Content-Type", "application/json" },
                    { "Access-Control-Allow-Origin", "*" }
                }
            };

            return(response);
        }
Beispiel #10
0
        private static void CopyOrAdd(List <Dynamo> ReturnValue, IProperty IDProperty, Dynamo Item)
        {
            Contract.Requires <ArgumentNullException>(IDProperty != null);
            if (Item == null)
            {
                return;
            }
            if (ReturnValue == null)
            {
                ReturnValue = new List <Dynamo>();
            }
            var IDValue = IDProperty.GetValue(Item);
            var Value   = ReturnValue.FirstOrDefault(x => IDProperty.GetValue(x).Equals(IDValue));

            if (Value == null)
            {
                ReturnValue.Add(Item);
            }
            else
            {
                Item.CopyTo(Value);
            }
        }
        public void PublishCustomNode(Dynamo.Nodes.Function m)
        {
            CustomNodeInfo currentFunInfo;
            if (DynamoViewModel.Model.CustomNodeManager.TryGetNodeInfo(
                m.Definition.FunctionId,
                out currentFunInfo))
            {
                var termsOfUseCheck = new TermsOfUseHelper(new TermsOfUseHelperParams
                {
                    PackageManagerClient = Model,
                    AuthenticationManager = AuthenticationManager,
                    ResourceProvider = DynamoViewModel.BrandingResourceProvider,
                    AcceptanceCallback = () => ShowNodePublishInfo(new[]
                    {
                        Tuple.Create(currentFunInfo, m.Definition)
                    })
                });

                termsOfUseCheck.Execute();
            }
        }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueryResults"/> class.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <param name="objectType">Type of the object.</param>
 /// <exception cref="ArgumentNullException">query</exception>
 public CachedResult(Dynamo value, Type objectType)
 {
     Value      = value ?? throw new ArgumentNullException(nameof(value));
     ObjectType = objectType;
 }
Beispiel #13
0
 public SymTable(Dynamo _dynamo)
 {
     dynamo = _dynamo;
 }
 /// <summary>
 /// Gets the property as a parameter (for classes, this will return the ID of the property)
 /// </summary>
 /// <param name="Object">Object to get the parameter from</param>
 /// <returns>The parameter version of the property</returns>
 public override object GetParameter(Dynamo Object)
 {
     return(GetValue(Object));
 }
 public static HelixWatch3DNodeViewModel Start(Dynamo.Nodes.Watch3D node, Watch3DViewModelStartupParams parameters)
 {
     var vm = new HelixWatch3DNodeViewModel(node, parameters);
     vm.OnStartup();
     return vm;
 }
Beispiel #16
0
        public void TestCreateDynamo()
        {
            var item = new Dynamo();

            Assert.IsNotNull(item);
        }
Beispiel #17
0
 public Dynamo Process(Dynamo Value)
 {
     return(Value);
 }
 private static IList<dynamic> GetValues(DbDataReader TempReader)
 {
     Contract.Requires<ArgumentNullException>(TempReader != null, "TempReader");
     var ReturnValue = new List<dynamic>();
     string[] FieldNames = new string[TempReader.FieldCount];
     for (int x = 0; x < TempReader.FieldCount; ++x)
     {
         FieldNames[x] = TempReader.GetName(x);
     }
     while (TempReader.Read())
     {
         var Value = new Dynamo();
         for (int x = 0; x < TempReader.FieldCount; ++x)
         {
             Value.Add(FieldNames[x], TempReader[x]);
         }
         ReturnValue.Add(Value);
     }
     return ReturnValue;
 }
 /// <summary>
 /// Gets the property's value from the object sent in
 /// </summary>
 /// <param name="Object">Object to get the value from</param>
 /// <returns>The value of the property</returns>
 public object GetValue(Dynamo Object)
 {
     return(Object[Name]);
 }
 /// <summary>
 /// Gets the property as a parameter (for classes, this will return the ID of the property)
 /// </summary>
 /// <param name="Object">Object to get the parameter from</param>
 /// <returns>The parameter version of the property</returns>
 public abstract object GetParameter(Dynamo Object);
Beispiel #21
0
        /// <summary>
        /// Gets all items of the mapped type
        /// </summary>
        /// <param name="Mappings">The mapping holder</param>
        /// <param name="PageSize">Size of the page.</param>
        /// <param name="Page">The page specified</param>
        /// <param name="OrderBy">The order by clause</param>
        /// <param name="EmbeddedProperties">Properties to embed</param>
        /// <returns>All items of the mapped type</returns>
        public IEnumerable <Dynamo> Paged(MappingHolder Mappings, int PageSize, int Page, string[] OrderBy, string[] EmbeddedProperties)
        {
            if (OrderBy == null)
            {
                OrderBy = new string[0];
            }
            string OrderByClauseFinal = "";
            string Splitter           = "";

            foreach (string OrderByClause in OrderBy)
            {
                string[] SplitValues = OrderByClause.Split(' ');
                if (SplitValues.Length > 0)
                {
                    if (Properties.Where(x => x is IReference || x is IID).Any(x => string.Equals(x.Name, SplitValues[0], StringComparison.InvariantCulture)))
                    {
                        OrderByClauseFinal += Splitter + SplitValues[0];
                        if (SplitValues.Length > 1)
                        {
                            SplitValues[1]      = SplitValues[1].Equals("DESC", StringComparison.InvariantCultureIgnoreCase) ? "DESC" : "ASC";
                            OrderByClauseFinal += " " + SplitValues[1];
                        }
                        Splitter = ",";
                    }
                }
            }
            IEnumerable <ClassType> Objects = PagedFunc(PageSize, Page, OrderByClauseFinal);

            if (Objects == null)
            {
                Objects = new List <ClassType>();
            }
            var ReturnValue = new List <Dynamo>();

            foreach (ClassType Object in Objects)
            {
                if (CanGetFunc(Object))
                {
                    var    TempItem   = new Dynamo(Object);
                    Dynamo ReturnItem = TempItem.SubSet(Properties.Where(x => x is IReference || x is IID)
                                                        .Select(x => x.Name)
                                                        .ToArray());
                    string AbsoluteUri = HttpContext.Current != null?HttpContext.Current.Request.Url.AbsoluteUri.Left(HttpContext.Current.Request.Url.AbsoluteUri.IndexOf('?')) : "";

                    AbsoluteUri = AbsoluteUri.Check("");
                    if (!AbsoluteUri.EndsWith("/", StringComparison.Ordinal))
                    {
                        AbsoluteUri += "/";
                    }
                    AbsoluteUri += Properties.FirstOrDefault(x => x is IID).GetValue(Mappings, Object).ToString() + "/";
                    foreach (IAPIProperty Property in Properties.Where(x => x is IMap))
                    {
                        ReturnItem[Property.Name] = EmbeddedProperties.Contains(Property.Name) ?
                                                    (object)Property.GetValue(Mappings, TempItem) :
                                                    (object)(AbsoluteUri + Property.Name);
                    }
                    ReturnValue.Add(ReturnItem);
                }
            }
            return(ReturnValue);
        }
 public bool CanPublishCustomNode(Dynamo.Nodes.Function m)
 {
     return AuthenticationManager.HasAuthProvider && m != null;
 }
 /// <summary>
 /// Executes the commands and returns the results
 /// </summary>
 /// <returns>
 /// The results of the batched commands
 /// </returns>
 public IList<IList<dynamic>> Execute()
 {
     var ReturnValue = new List<IList<dynamic>>();
     if (Commands.Count == 0)
     {
         ReturnValue.Add(new List<dynamic>());
         return ReturnValue;
     }
     using (DirectoryEntry Entry = new DirectoryEntry(Source.Server, Source.UserName, Source.Password, AuthenticationTypes.Secure))
     {
         using (DirectorySearcher Searcher = new DirectorySearcher(Entry))
         {
             Searcher.PageSize = 1000;
             foreach (Command Command in Commands)
             {
                 Searcher.Filter = Command.SQLCommand;
                 using (SearchResultCollection Results = Searcher.FindAll())
                 {
                     var ReturnValues = new List<dynamic>();
                     foreach (SearchResult Result in Results)
                     {
                         var TempValue = new Dynamo();
                         foreach (PropertyValueCollection Property in Result.GetDirectoryEntry().Properties)
                         {
                             TempValue[Property.PropertyName] = Property.Value;
                             ReturnValues.Add(TempValue);
                         }
                     }
                     ReturnValue.Add(ReturnValues);
                 }
             }
         }
         Entry.Close();
     }
     for (int x = 0; x < Commands.Count(); ++x)
     {
         Commands[x].Finalize(ReturnValue[x]);
     }
     return ReturnValue;
 }