示例#1
0
 internal void QueueControl(ViewModel.Control Control)
 {
     if (!this.ControlQueue.Contains(Control))
     {
         this.ControlQueue.Add(Control);
     }
 }
        public Models.Response ExecuteCommand(String ID, List <String> Parameters)
        {
            try
            {
                // Get Parameters
                List <ViewModel.Control> viewmodelparameters = new List <ViewModel.Control>();

                if (Parameters != null)
                {
                    foreach (String parameter in Parameters)
                    {
                        Guid parameterviewmodelid          = ViewModel.Utilities.StringToGuid(parameter);
                        ViewModel.Control parametercontrol = this.Session.Control(parameterviewmodelid);
                        viewmodelparameters.Add(parametercontrol);
                    }
                }

                // Run Command
                Guid viewmodelid = ViewModel.Utilities.StringToGuid(ID);
                this.Session.Command(viewmodelid).Execute(viewmodelparameters);

                // Return Response
                return(new Models.Responses.Empty(this.Session));
            }
            catch (Exception e)
            {
                throw this.ProcessException(e);
            }
        }
示例#3
0
        void Control_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            // Add Control to Queue when Property Changes
            ViewModel.Control control = (ViewModel.Control)sender;

            if (control.HasProperty(e.PropertyName))
            {
                this.QueueControl(control);
            }
        }
示例#4
0
        public Control(ViewModel.Manager.Session Session, ViewModel.Control Control)
            : base(Session)
        {
            List <ViewModel.Control> viewmodelcontrols = new List <ViewModel.Control>();

            viewmodelcontrols.Add(Control);
            List <Models.Control> controls = this.QueueControls(Session, viewmodelcontrols);

            this.Value = controls.First();
        }
示例#5
0
 public Models.Responses.Control GetControl(String ID)
 {
     try
     {
         Guid viewmodelid          = ViewModel.Utilities.StringToGuid(ID);
         ViewModel.Control control = this.Session.Control(viewmodelid);
         return(new Models.Responses.Control(this.Session, control));
     }
     catch (Exception e)
     {
         throw this.ProcessException(e);
     }
 }
示例#6
0
        public ViewModel.Control Plugin(ControlType PluginType, String Context)
        {
            // Create Control
            ViewModel.Control plugin = (ViewModel.Control)Activator.CreateInstance(PluginType.Type, new object[1] {
                this
            });

            // Set Context
            ((Aras.ViewModel.Containers.Plugin)plugin).SetBinding(Context);

            // Refresh Plugin
            ((Aras.ViewModel.Containers.Plugin)plugin).Refresh.Execute();

            return(plugin);
        }
示例#7
0
        public Models.Responses.Control GetPlugin(Models.Plugin Plugin)
        {
            try
            {
                // Get Plugin Type
                Manager.ControlType plugintype = this.Session.Database.Server.ControlType(Plugin.Name);

                // Get Plugin Control
                ViewModel.Control plugincontrol = this.Session.Plugin(plugintype, Plugin.Context);

                return(new Models.Responses.Control(this.Session, plugincontrol));
            }
            catch (Exception e)
            {
                throw this.ProcessException(e);
            }
        }
示例#8
0
        internal void CacheControl(ViewModel.Control Control)
        {
            lock (this.ControlCacheLock)
            {
                if (Control != null)
                {
                    if (!this.ControlCache.ContainsKey(Control.ID))
                    {
                        // Add Control to Cache
                        this.ControlCache[Control.ID] = Control;

                        // Queue Control
                        this.QueueControl(Control);

                        // Link to PropertyChanged Event
                        Control.PropertyChanged += Control_PropertyChanged;
                    }
                }
            }
        }
示例#9
0
        public Models.Response UpdateControl(String ID, Models.Control Control)
        {
            try
            {
                Guid viewmodelid          = ViewModel.Utilities.StringToGuid(ID);
                ViewModel.Control control = this.Session.Control(viewmodelid);

                foreach (Models.Property property in Control.Properties)
                {
                    if (!property.ReadOnly)
                    {
                        switch (property.Type)
                        {
                        case ViewModel.Attributes.PropertyTypes.Boolean:
                            control.SetPropertyValue(property.Name, property.Values[0].Equals("1"));
                            break;

                        case ViewModel.Attributes.PropertyTypes.Int32:
                            control.SetPropertyValue(property.Name, Convert.ToInt32(property.Values[0]));
                            break;

                        case ViewModel.Attributes.PropertyTypes.NullableInt32:

                            if (property.Values[0] == null)
                            {
                                control.SetPropertyValue(property.Name, null);
                            }
                            else
                            {
                                control.SetPropertyValue(property.Name, Convert.ToInt32(property.Values[0]));
                            }

                            break;

                        case ViewModel.Attributes.PropertyTypes.String:
                            control.SetPropertyValue(property.Name, property.Values[0]);
                            break;

                        case ViewModel.Attributes.PropertyTypes.Float:
                            control.SetPropertyValue(property.Name, Convert.ToDouble(property.Values[0]));
                            break;

                        case ViewModel.Attributes.PropertyTypes.Control:
                            String id = property.Values[0];

                            if (id != null)
                            {
                                control.SetPropertyValue(property.Name, this.Session.Control(ViewModel.Utilities.StringToGuid(id)));
                            }
                            else
                            {
                                control.SetPropertyValue(property.Name, null);
                            }

                            break;

                        case ViewModel.Attributes.PropertyTypes.ControlList:

                            List <ViewModel.Control> values = new List <ViewModel.Control>();

                            foreach (String thisid in property.Values)
                            {
                                values.Add(this.Session.Control(ViewModel.Utilities.StringToGuid(thisid)));
                            }

                            ((ViewModel.ObservableControlList <ViewModel.Control>)control.GetPropertyValue(property.Name)).Replace(values);

                            break;

                        case ViewModel.Attributes.PropertyTypes.Date:

                            if (property.Values[0] == null)
                            {
                                control.SetPropertyValue(property.Name, null);
                            }
                            else
                            {
                                control.SetPropertyValue(property.Name, Convert.ToDateTime(property.Values[0]));
                            }

                            break;

                        case ViewModel.Attributes.PropertyTypes.Decimal:

                            if (property.Values[0] == null)
                            {
                                control.SetPropertyValue(property.Name, null);
                            }
                            else
                            {
                                control.SetPropertyValue(property.Name, Convert.ToDecimal(property.Values[0]));
                            }

                            break;

                        case ViewModel.Attributes.PropertyTypes.Command:

                            if (property.Values[0] == null)
                            {
                                control.SetPropertyValue(property.Name, null);
                            }
                            else
                            {
                                control.SetPropertyValue(property.Name, this.Session.Command(ViewModel.Utilities.StringToGuid(property.Values[0])));
                            }

                            break;

                        default:
                            throw new NotImplementedException("PropertyType not implemented: " + property.Type);
                        }
                    }
                }

                return(new Models.Responses.Empty(this.Session));
            }
            catch (Exception e)
            {
                throw this.ProcessException(e);
            }
        }
示例#10
0
        private Control QueueControl(ViewModel.Manager.Session Session, ViewModel.Control ViewModelControl)
        {
            // Get Model Control ID
            String id = ViewModel.Utilities.GuidToString(ViewModelControl.ID);

            // Check Queue for Control
            if (!this.QueuedControls.ContainsKey(id))
            {
                // Get Control Type
                Manager.ControlType type = Session.Database.Server.ControlType(ViewModelControl);

                // Create Control
                Control control = new Control(id, type.ClientType);

                // Add Properties to Model Control
                foreach (String name in ViewModelControl.Properties)
                {
                    // Get Type
                    Attributes.PropertyTypes propertytype = ViewModelControl.GetPropertyType(name);

                    // Create Property
                    Property property = new Property(name, propertytype, ViewModelControl.GetPropertyReadOnly(name));
                    control.Properties.Add(property);

                    // Add Value
                    object viewmodelvalue = ViewModelControl.GetPropertyValue(name);

                    switch (propertytype)
                    {
                    case ViewModel.Attributes.PropertyTypes.Boolean:

                        if (viewmodelvalue != null)
                        {
                            if (((Boolean)viewmodelvalue) == true)
                            {
                                property.Values.Add("1");
                            }
                            else
                            {
                                property.Values.Add("0");
                            }
                        }
                        else
                        {
                            property.Values.Add(null);
                        }

                        break;

                    case ViewModel.Attributes.PropertyTypes.Control:

                        if (viewmodelvalue != null)
                        {
                            if (this.QueuedViewModelControls.ContainsKey(((ViewModel.Control)viewmodelvalue).ID))
                            {
                                // Control is in Queue to ensure added first
                                Control propcontrol = this.QueueControl(Session, (ViewModel.Control)viewmodelvalue);

                                property.Values.Add(propcontrol.ID);
                            }
                            else
                            {
                                // Not in Queue to just add ID
                                property.Values.Add(ViewModel.Utilities.GuidToString(((ViewModel.Control)viewmodelvalue).ID));
                            }
                        }
                        else
                        {
                            property.Values.Add(null);
                        }

                        break;

                    case ViewModel.Attributes.PropertyTypes.ControlList:

                        if (viewmodelvalue != null)
                        {
                            IEnumerable <ViewModel.Control> controls = (IEnumerable <ViewModel.Control>)viewmodelvalue;

                            foreach (ViewModel.Control viewmodelcontrol in controls)
                            {
                                if (this.QueuedViewModelControls.ContainsKey(viewmodelcontrol.ID))
                                {
                                    // Control is in Queue to ensure added first
                                    Control propcontrol = this.QueueControl(Session, viewmodelcontrol);

                                    property.Values.Add(propcontrol.ID);
                                }
                                else
                                {
                                    // Not in Queue to just add ID
                                    property.Values.Add(ViewModel.Utilities.GuidToString(viewmodelcontrol.ID));
                                }
                            }
                        }

                        break;

                    case ViewModel.Attributes.PropertyTypes.Int32:
                        property.Values.Add(((System.Int32)viewmodelvalue).ToString());
                        break;

                    case ViewModel.Attributes.PropertyTypes.NullableInt32:

                        if (viewmodelvalue == null)
                        {
                            property.Values.Add(null);
                        }
                        else
                        {
                            property.Values.Add(((System.Int32)viewmodelvalue).ToString());
                        }

                        break;

                    case ViewModel.Attributes.PropertyTypes.String:
                        property.Values.Add((System.String)viewmodelvalue);
                        break;

                    case ViewModel.Attributes.PropertyTypes.Float:
                        property.Values.Add(((System.Double)viewmodelvalue).ToString());
                        break;

                    case ViewModel.Attributes.PropertyTypes.StringList:

                        if (viewmodelvalue != null)
                        {
                            IEnumerable <String> strings = (IEnumerable <String>)viewmodelvalue;

                            foreach (String value in (IEnumerable <String>)viewmodelvalue)
                            {
                                property.Values.Add(value);
                            }
                        }

                        break;

                    case ViewModel.Attributes.PropertyTypes.Date:

                        if (viewmodelvalue != null)
                        {
                            property.Values.Add(((System.DateTime)viewmodelvalue).ToString("yyyy-MM-ddTHH:mm:ssZ"));
                        }
                        else
                        {
                            property.Values.Add(null);
                        }

                        break;

                    case ViewModel.Attributes.PropertyTypes.Decimal:

                        if (viewmodelvalue != null)
                        {
                            property.Values.Add(((System.Decimal)viewmodelvalue).ToString());
                        }
                        else
                        {
                            property.Values.Add(null);
                        }

                        break;

                    case ViewModel.Attributes.PropertyTypes.Command:

                        if (viewmodelvalue != null)
                        {
                            property.Values.Add(ViewModel.Utilities.GuidToString(((ViewModel.Command)viewmodelvalue).ID));
                        }
                        else
                        {
                            property.Values.Add(null);
                        }

                        break;

                    default:
                        throw new NotImplementedException("PropertyType not implemented: " + propertytype.ToString());
                    }
                }

                // Queue Control
                this.ControlQueue.Add(control);
                this.QueuedControls[control.ID] = control;

                return(control);
            }
            else
            {
                return(this.QueuedControls[id]);
            }
        }