Exemplo n.º 1
0
 protected override void ResetState()
 {
     IsNew       = false;
     IsDirty     = false;
     _Elements   = null;
     _Attributes = null;
     _Template   = null;
     _Categories = null;
     _Parent     = null;
 }
Exemplo n.º 2
0
 private void ResetState()
 {
     _IsNew      = false;
     _IsDirty    = false;
     _IsDeleted  = false;
     _Elements   = null;
     _Attributes = null;
     _Template   = null;
     _Categories = null;
     _Parent     = null;
 }
Exemplo n.º 3
0
        public bool Update(LazyPI.Common.Connection Connection, LazyObjects.AFElement Element)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/elements/{webId}", Method.PATCH);

            request.AddUrlSegment("webId", Element.WebID);

            ResponseModels.AFElement body = DataConversions.Convert(Element);
            request.AddParameter("application/json; charset=utf-8", Newtonsoft.Json.JsonConvert.SerializeObject(body), ParameterType.RequestBody);

            var statusCode = webConnection.Client.Execute(request).StatusCode;

            return((int)statusCode == 204);
        }
Exemplo n.º 4
0
        public void CreateElement()
        {
            AFElement element = new AFElement();

            Console.WriteLine("Test Element Intial Configuration");
            string name = "Test Element 1";
            element.Name = name;
            Assert.Equals(element.Name, name);

            string desc = "Lazy PI Unit Test Element";
            element.Description = desc;
            Assert.Equals(element.Description, desc);

            Console.WriteLine("Test element creation.");
            Assert.IsTrue(elementLoader.CreateChildElement(conn, "", element));
        }
Exemplo n.º 5
0
        public bool Update(LazyPI.Common.Connection Connection, LazyObjects.AFElement Element)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/elements/{webId}", Method.PATCH);

            request.AddUrlSegment("webId", Element.ID);

            ResponseModels.AFElement temp = new ResponseModels.AFElement();
            temp.WebID         = Element.ID;
            temp.Name          = Element.Name;
            temp.Description   = Element.Description;
            temp.Path          = Element.Path;
            temp.CategoryNames = Element.Categories.ToList();
            temp.TemplateName  = Element.Template.Name;

            request.AddBody(temp);

            var statusCode = webConnection.Client.Execute(request).StatusCode;

            return((int)statusCode == 204);
        }
Exemplo n.º 6
0
        public void CreateChild()
        {
            Console.WriteLine("Test adding a child element.");

            AFElement parent = new AFElement();
            parent.Name = "Parent Element";
            parent.Description = "Parent Desciption";

            Assert.IsTrue(elementLoader.CreateChildElement(conn, "", parent));
            parent = elementLoader.Find(conn, parent.Name);

            Assert.IsNotNull(parent.ID);
            Assert.IsNotNull(parent.Path);

            AFElement child = new AFElement();
            child.Name = "Child Element";
            child.Description = "Child Description";

            Assert.IsTrue(elementLoader.CreateChildElement(conn, parent.ID, child));

            child = elementLoader.FindByPath(conn, child.Path);

            Assert.IsNotNull(child.Name);
            Assert.IsNotNull(child.ID);
            Assert.IsNotNull(child.Path);
            Assert.IsNotNull(child.Description);
            Assert.Equals(child.Parent.ID, parent.ID);

            parent = elementLoader.FindByPath(conn, parent.Path);

            Assert.Equals(parent.Children.Count, 1);

            AFElement refChild = parent.Children.First();

            Console.WriteLine("Test that original child and referenced child are identical.");
            Assert.Equals(child.Name, refChild.Name);
            Assert.Equals(child.Path, refChild.Path);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Notifies when developer makes changes to list. This method makes call back to insure PI is up to date.
 /// </summary>
 /// <param name="sender">Object that triggered the change.</param>
 /// <param name="e">Arguments that define the event.</param>
 private void ChildrenChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
     {
         _ElementLoader.CreateChildElement(_Connection, this._ID, (AFElement)sender);
     }
     else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
     {
         AFElement element = (AFElement)sender;
         Delete(_Connection, element._ID);
     }
     else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
     {
         throw new NotImplementedException("Replace is not supported by LazyPI.");
     }
     else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)
     {
         throw new NotImplementedException("Reset is not supported by LazyPI.");
     }
     else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Move)
     {
         throw new NotImplementedException("Move is not supported by LazyPI.");
     }
 }
Exemplo n.º 8
0
 public bool CreateElement(AFElement Element)
 {
     return(_DBController.CreateElement(_Connection, WebID, Element));
 }
Exemplo n.º 9
0
        public bool CreateChildElement(LazyPI.Common.Connection Connection, string ParentID, LazyObjects.AFElement Element)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/elements/{webId}/elements", Method.POST);

            request.AddUrlSegment("webId", ParentID);
            request.AddBody(Element);

            var statusCode = webConnection.Client.Execute(request).StatusCode;

            return((int)statusCode == 201);
        }