Ejemplo n.º 1
0
        private async void GetReactionsCommand()
        {
            ReactionList.Clear();
            List <ReactionInfo> tmp = new List <ReactionInfo>();

            if (Mode == "my")
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading " + CurrentUser + "'s reaction(s)...", Level = ""
                });
                _logService.Write(this, "Loading " + CurrentUser + "'s reaction(s)...", "debug");
                tmp = await _dbService.GetReactions(Person);
            }
            else
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading all reaction(s)...", Level = ""
                });
                _logService.Write(this, "Loading all reaction(s)...", "debug");
                tmp = await _dbService.GetReactions();
            }
            OutputMessages.Add(new OutputMessage {
                Message = tmp.Count + " reaction(s) loaded!", Level = ""
            });
            _logService.Write(this, tmp.Count + " reaction(s) loaded", "debug");
            foreach (var item in tmp)
            {
                ReactionList.Add(item);
            }
        }
Ejemplo n.º 2
0
        private async void GetProjectsCommand()
        {
            ProjectList.Clear();
            List <Project> tmp = new List <Project>();

            if (Mode == "my")
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading " + CurrentUser + "'s project(s)...", Level = "debug"
                });
                _logService.Write(this, "Loading " + CurrentUser + "'s project(s)...", "debug");
                tmp = await _dbService.GetProjects(Person);
            }
            else
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Loading all project(s)...", Level = "debug"
                });
                _logService.Write(this, "Loading all project(s)...", "debug");
                tmp = await _dbService.GetProjects();
            }
            OutputMessages.Add(new OutputMessage {
                Message = tmp.Count + " project(s) loaded!", Level = "debug"
            });
            _logService.Write(this, tmp.Count + " project(s) loaded", "debug");
            foreach (var item in tmp)
            {
                ProjectList.Add(item);
            }
        }
Ejemplo n.º 3
0
 private void SaveProjectCommand()
 {
     _dbService.UpdateProject(_project.ProjectID, ProjectName, Leader, Goal, Description, NewProjectPlan);
     _logService.Write(this, "Project modified", "debug");
     OutputMessages.Add(new OutputMessage {
         Message = "Project modified!", Level = ""
     });
 }
Ejemplo n.º 4
0
        public override void Spike(int time, double val = 1)
        {
            if (CurrentlyTraining)
            {
                OutputMessages.Add(new OutputMessage(time, new SynapseObject(this, null), val));
            }

            messageHandler.addMessage(new OutputMessage(time + Delay, new SynapseObject(this, null), val));
        }
Ejemplo n.º 5
0
        private void ConfirmUserChangeCommand()
        {
            CurrentUser = SelectedUser;
            var myMessage = new NotificationMessage(SelectedUser);

            Messenger.Default.Send(myMessage);
            OutputMessages.Add(new OutputMessage {
                Message = "Current user set to: " + CurrentUser, Level = "debug"
            });
            _loggerService.Write(this, "Current user set to: " + CurrentUser, "debug");
        }
Ejemplo n.º 6
0
 private void AddProjectCommand()
 {
     if (Validate())
     {
         _dbService.AddProject(_ProjectInfo);
         OutputMessages.Add(new OutputMessage {
             Message = ProjectName + " added!", Level = "debug"
         });
         _logService.Write(this, ProjectName + " added", "debug");
     }
 }
Ejemplo n.º 7
0
        private void SelectObservationImgCommand()
        {
            var resu = _openFileDialogService.ShowOpenFileDialog();

            ObservationImgsFilePaths.Add(resu);
            OutputMessages.Add(new OutputMessage()
            {
                Message = resu + " added as Observation Img", Level = "debug"
            });
            _logService.Write(this, resu + " added as Observation Img", "debug");
        }
Ejemplo n.º 8
0
        private void ExplicitModifyCommand()
        {
            double tmp;

            if (Double.TryParse(ModifyAmount, out tmp))
            {
                if (tmp < 0)
                {
                    OutputMessages.Add(new OutputMessage {
                        Message = "Amount cannot be negative!", Level = "error"
                    });
                    _logService.Write(this, "Amount cannot be negative!", "error");
                }
                else
                {
                    if (Selected.mAvailable.HasValue)
                    {
                        Selected.mAvailable = tmp;
                        RaisePropertyChanged(nameof(Selected));
                        _logService.Write(this, "Update inventory with: " + Selected.CAS + " " + Selected.Location + " " + tmp + " " + null, "debug");

                        _dbService.ModifyMoleculeAvailable(Selected.CAS, Selected.Location, tmp, null);
                        OutputMessages.Add(new OutputMessage {
                            Message = "Inventory updated!", Level = ""
                        });
                        _logService.Write(this, "Inventory updated!", "debug");
                    }
                    else
                    {
                        Selected.VAvailable = tmp;
                        RaisePropertyChanged(nameof(Selected));
                        _logService.Write(this, "Update inventory with: " + Selected.CAS + " " + Selected.Location + " " + null + " " + tmp, "debug");

                        _dbService.ModifyMoleculeAvailable(Selected.CAS, Selected.Location, null, tmp);
                        OutputMessages.Add(new OutputMessage {
                            Message = "Inventory updated!", Level = ""
                        });
                        _logService.Write(this, "Inventory updated!", "debug");
                    }
                }
            }
            else
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Cannot convert given value to number", Level = "error"
                });
                _logService.Write(this, "Cannot convert given value to number", "error");
            }
        }
Ejemplo n.º 9
0
        private async void GetResourcesCommand()
        {
            _logService.Write(this, "Loading project with ID " + _project.ProjectID, "debug");
            var tmplist = await _dbService.GetReactions(_project.ProjectID);

            _logService.Write(this, "Loaded " + _project.ProjectID, "debug");
            foreach (var item in tmplist)
            {
                Reactions.Add(item);
            }
            OutputMessages.Add(new OutputMessage {
                Message = Reactions.Count + " reactions loaded for this project", Level = "debug"
            });
            _logService.Write(this, Reactions.Count + " reactions loaded for this project", "debug");
        }
Ejemplo n.º 10
0
        private async void SaveReactionCommandAsync()
        {
            OutputMessages.Add(new OutputMessage()
            {
                Message = "Saving to database", Level = "debug"
            });
            _logService.Write(this, "Saving to database", "debug");
            await _dbService.FinishSketchReaction(_reactionId, ClosureDate, Procedure, Observation, Yield, ObservationImgsFilePaths.ToList());

            OutputMessages.Add(new OutputMessage()
            {
                Message = "Finished!", Level = "debug"
            });
            _logService.Write(this, "Finished", "debug");
        }
Ejemplo n.º 11
0
        private async void GetResourcesCommand()
        {
            _logService.Write(this, "Loading reaction with ID " + _reactionId, "debug");
            OutputMessages.Add(new OutputMessage()
            {
                Message = "Loading reaction...", Level = "debug"
            });
            _reaction = await _dbService.GetReactionAsync(_reactionId);

            var tmpsm = await _dbService.GetStartingMaterial(_reactionId);

            var tmpr = await _dbService.GetReagents(_reactionId);

            var tmps = await _dbService.GetSolvents(_reactionId);

            var tmpp = await _dbService.GetProducts(_reactionId);

            var tmpobs = await _dbService.GetObsImgs(_reactionId);

            _logService.Write(this, "Loaded " + _reactionId, "debug");

            OutputMessages.Add(new OutputMessage()
            {
                Message = "Loaded", Level = "debug"
            });
            StartingMaterial.Add(tmpsm);
            foreach (var item in tmpr)
            {
                Reagents.Add(item);
            }
            _logService.Write(this, Reagents.Count + " reagents loaded for this reaction", "debug");
            foreach (var item in tmps)
            {
                Solvents.Add(item);
            }
            _logService.Write(this, Solvents.Count + " solvents loaded for this reaction", "debug");
            foreach (var item in tmpp)
            {
                Products.Add(item);
            }
            _logService.Write(this, Products.Count + " products loaded for this reaction", "debug");
            foreach (var item in tmpobs)
            {
                ObservationImgsByteArray.Add(item);
            }
            _logService.Write(this, ObservationImgsByteArray.Count + " observable imgs loaded for this reaction", "debug");
            ConfigureReactionParameter();
        }
Ejemplo n.º 12
0
        void BindEvents()
        {
            feDisplay.DataPageReceived += (DataPage page) =>
            {
                Trace.TraceInformation("Received fe data");
                OutputMessages.Add("POW:" + feDisplay.SpecificTrainer.InstantaneousPower);
                OutputMessages.Add("CAD:" + feDisplay.SpecificTrainer.InstantaneousCadence);
            };
            feDisplay.SensorFound += (ushort a, byte b) =>
            {
                Trace.TraceInformation("Found fe sensor");
                _ = SendFEConfigurationAsync();
            };

            bpDisplay.DataPageReceived += (DataPage page) =>
            {
                Trace.TraceInformation("Received bp data");
                OutputMessages.Add("POW:" + bpDisplay.CalculatedPower);
                if (bpDisplay.StandardPowerOnly != null)
                {
                    OutputMessages.Add("CAD:" + bpDisplay.StandardPowerOnly.InstantaneousCadence);
                }
            };

            hrDisplay.DataPageReceived += (DataPage page) =>
            {
                Trace.TraceInformation("Received hr data");
                OutputMessages.Add("HR:" + hrDisplay.HeartRate);
            };

            bcDisplay.DataPageReceived += (DataPage page) =>
            {
                Trace.TraceInformation("Received bc data");
                OutputMessages.Add("CAD:" + bcDisplay.Cadence);
            };

            bscDisplay.DataPageReceived += (DataPage page) =>
            {
                Trace.TraceInformation("Received bsc data");
                OutputMessages.Add("CAD:" + bscDisplay.Cadence);
            };
        }
Ejemplo n.º 13
0
 private void AddNewUserCommand()
 {
     if (Users.Contains(NewUser))
     {
         OutputMessages.Add(new OutputMessage {
             Message = NewUser + " is already registered!", Level = "error"
         });
         _loggerService.Write(this, NewUser + " is already registered!", "error");
     }
     else
     {
         _loggerService.Write(this, "Add started", "debug");
         _dbService.AddUser(NewUser);
         _loggerService.Write(this, NewUser + " added!", "debug");
         OutputMessages.Add(new OutputMessage {
             Message = NewUser + " added!", Level = ""
         });
         Users.Add(NewUser);
     }
 }
Ejemplo n.º 14
0
        private async void ExportExcelFileCommand()
        {
            SaveProgressVisibility = "visible";
            if (String.IsNullOrEmpty(savepath))
            {
                savepath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Inventory.xlsx";
                OutputMessages.Add(new OutputMessage {
                    Message = "Using default save location", Level = "info"
                });
                _logService.Write(this, "Using default save location", "info");
            }
            _logService.Write(this, "Save started", "debug");
            var molecules = await _dbService.GetMoleculesAsync();

            _excelwriterService.ExportExcelAsync(savepath, molecules);
            OutputMessages.Add(new OutputMessage {
                Message = "Excel document saved!", Level = "debug"
            });
            _logService.Write(this, "Excel document saved", "debug");
            SaveProgressVisibility = null;
        }
Ejemplo n.º 15
0
        private void SelectSaveLocationCommand()
        {
            var resu = _openFileDialogService.ShowSaveFileDialog(".xlsx", "Excel Files (*.xlsx)| All files (*.*)");

            if (String.IsNullOrEmpty(resu))
            {
                savepath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Inventory.xlsx";
                OutputMessages.Add(new OutputMessage {
                    Message = "Using default save location", Level = "info"
                });
                _logService.Write(this, "Using default save location", "info");
            }
            else
            {
                savepath = resu;
                OutputMessages.Add(new OutputMessage {
                    Message = savepath + " added as Save Location", Level = "debug"
                });
                _logService.Write(this, savepath + " added as Save Location", "debug");
            }
        }
Ejemplo n.º 16
0
        private bool Validate()
        {
            OutputMessages.Add(new OutputMessage {
                Message = "Validate project inputs", Level = "debug"
            });
            _logService.Write(this, "Validate project inputs", "debug");
            bool result = true;
            List <OutputMessage> tmp = new List <OutputMessage>();

            tmp = _ProjectInfo.Validate(users);

            foreach (var item in tmp)
            {
                if (item.Level == "error")
                {
                    result = false;
                }
                OutputMessages.Add(item);
                _logService.Write(this, item.Message, item.Level);
            }
            return(result);
        }
Ejemplo n.º 17
0
        private bool ValidateMolecule()
        {
            bool result = true;

            OutputMessages.Add(new OutputMessage()
            {
                Message = "Validate molecule inputs", Level = ""
            });
            List <OutputMessage> tmp = _Molecule.Validate(_type);

            foreach (var item in tmp)
            {
                if (item.Level == "error")
                {
                    result = false;
                }
                OutputMessages.Add(item);
                _logService.Write(this, item.Message, item.Level);
            }

            return(result);
        }
Ejemplo n.º 18
0
        private void AddPlanCommand()
        {
            var resu = _openFileDialogService.ShowOpenFileDialog();

            if (resu != null)
            {
                NewProjectPlan = resu;
                OutputMessages.Add(new OutputMessage {
                    Message = resu + " added as New Project Plan", Level = "debug"
                });
                _logService.Write(this, resu + " added as New Project Plan", "debug");
            }


            else
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "No image added as New Project Plan", Level = "debug"
                });
                _logService.Write(this, "No image added as New Project Plan", "debug");
            }
        }
Ejemplo n.º 19
0
        private async void DeleteReactionCommand(ReactionInfo deleteThis)
        {
            try
            {
                OutputMessages.Add(new OutputMessage {
                    Message = "Deleting reaction(s)...", Level = "debug"
                });
                _logService.Write(this, "Deleting reaction(s)...", "debug");
                await _dbService.DeleteReaction(deleteThis.ReactionID);

                Reactions.Remove(deleteThis);
                OutputMessages.Add(new OutputMessage {
                    Message = "Reaction(s) deleted!", Level = "debug"
                });
                _logService.Write(this, "Deleting reaction(s)...", "debug");
            }
            catch (Exception e)
            {
                OutputMessages.Add(new OutputMessage {
                    Message = e.Message, Level = "fatal"
                });
                _logService.Write(this, e.Message, "fatal");
            }
        }
Ejemplo n.º 20
0
        private async void AddMoleculeCommandAsync()
        {
            if (ValidateMolecule())
            {
                try
                {
                    string tmp = await _dbService.AddMolecule(_Molecule);

                    OutputMessages.Add(new OutputMessage()
                    {
                        Message = tmp, Level = "debug"
                    });
                    _logService.Write(this, tmp, "debug");
                }
                catch (Exception e)
                {
                    OutputMessages.Add(new OutputMessage()
                    {
                        Message = "Molecule cannot save to database, read the log file for more info!", Level = "fatal"
                    });
                    _logService.Write(this, e.InnerException.InnerException.Message, "fatal");
                }
            }
        }
 public void WriteLine(string message)
 {
     OutputMessages.Add(message);
 }
Ejemplo n.º 22
0
        public override bool Validate(PatternSettings settings, OutputMessages output)
        {
            bool hasErrors = false;
            PatternInstanceElement grid = settings.PatternPart.SelectSingleElement("//Grid");
            String customrender = grid.Attributes.GetPropertyValueString(SettingsAttributes.Grid.CustomRender);

            ControlDefinition control = null;

            if (!String.IsNullOrEmpty(customrender))
            {
                control = Controls.getControl(customrender);
            }

            foreach (PatternInstanceElement gridprop in settings.PatternPart.SelectElements("//GridPropertie"))
            {
                if (control == null)
                {
                    output.Add(new OutputError("Invalid CustomRender: ", new PatternElementPosition(gridprop)));
                    hasErrors = true;
                }
                else
                {

                    String nome = gridprop.Attributes.GetPropertyValueString(SettingsAttributes.GridPropertie.Name);
                    String valor = gridprop.Attributes.GetPropertyValueString(SettingsAttributes.GridPropertie.Valor);

                    PropDefinition p = control.GetPropertiesDefinition().GetPropDefinition(nome);
                    if (p != null)
                    {
                        try
                        {
                            p.PropertyConverter.ConvertFrom(valor);
                        }
                        catch (Exception e)
                        {
                            output.Add(new OutputError("Property: " + nome + " - " + e.Message, new PatternElementPosition(gridprop)));
                            hasErrors = true;
                        }
                    }
                }
            }

            if (!hasErrors)
            {
                PatternInstanceElement saction = settings.PatternPart.SelectSingleElement("//StandardActions");
                Object oLegendObject = saction.Attributes.GetPropertyValue(SettingsAttributes.StandardActions.LegendObject);

                PatternInstanceElement actLegend = settings.PatternPart.SelectSingleElement("//StandardActions/Legend");
                Boolean oLegendEnabled = actLegend.Attributes.GetPropertyValue<Boolean>(SettingsAttributes.Action.DefaultMode);
                Boolean oLegendEnabledPrompt = actLegend.Attributes.GetPropertyValue<Boolean>(SettingsAttributes.Action.PromptMode);

                if ((oLegendEnabled || oLegendEnabledPrompt) && oLegendObject == null)
                {
                    output.Add(new OutputError("Legend Object Not Defined: ", new PatternElementPosition(saction)));
                    hasErrors = true;
                }

            }

            if (!hasErrors)
            {
                PatternInstanceElement template = settings.PatternPart.SelectSingleElement("//Template");
                String tabfunction = template.Attributes.GetPropertyValueString(SettingsAttributes.Template.TabFunction);
                tabfunction = Controls.getTabUserControl(tabfunction);

                ControlDefinition controltab = null;

                if (!String.IsNullOrEmpty(tabfunction))
                {
                    controltab = Controls.getControl(tabfunction, null);
                }

                foreach (PatternInstanceElement tabprop in settings.PatternPart.SelectElements("//TabProperty"))
                {
                    if (controltab == null)
                    {
                        output.Add(new OutputError("Invalid UserControl Property: ", new PatternElementPosition(tabprop)));
                        hasErrors = true;
                    }
                    else
                    {

                        String nome = tabprop.Attributes.GetPropertyValueString(SettingsAttributes.TabProperty.Name);
                        String valor = tabprop.Attributes.GetPropertyValueString(SettingsAttributes.TabProperty.Valor);

                        PropDefinition p = controltab.GetPropertiesDefinition().GetPropDefinition(nome);
                        if (p != null)
                        {
                            try
                            {
                                p.PropertyConverter.ConvertFrom(valor);
                            }
                            catch (Exception e)
                            {
                                output.Add(new OutputError("Property: " + nome + " - " + e.Message, new PatternElementPosition(tabprop)));
                                hasErrors = true;
                            }
                        }
                    }
                }

            }

            return !hasErrors;
        }
Ejemplo n.º 23
0
        public override bool Validate(PatternInstance instance, OutputMessages output)
        {
            bool hasErrors = false;
            foreach (PatternInstanceElement actionElement in instance.PatternPart.SelectElements("//actions/action"))
            {
                PatternInstanceElement container = actionElement.Parent.Parent;
                Debug.Assert(container != null && (container.Type == InstanceElements.Transaction || container.Type == InstanceElements.Selection || container.Type == InstanceElements.Tab || container.Type == InstanceElements.WebPanelRoot || container.Type == InstanceElements.Prompt));

                if (container != null)
                {
                    bool cannotHaveInGrid = (container.Type == InstanceElements.Tab && container.Attributes.GetPropertyValue<string>(InstanceAttributes.Tab.Type) == TabElement.TypeValue.Tabular);
                    bool isInGrid = actionElement.Attributes.GetPropertyValue<bool>(InstanceAttributes.Action.InGrid);

                    if (isInGrid && cannotHaveInGrid)
                    {
                        output.Add(new OutputError(Messages.FormatValidationErrorActionCannotBeInGrid(actionElement.ToString()), new PatternElementPosition(actionElement)));
                        hasErrors = true;
                    }
                }
            }
            if (!hasErrors)
            {
                if (instance.Parent is Transaction)
                {
                    if (instance.PatternPart.SelectSingleElement("instance/transaction") == null)
                    {
                        output.Add(new OutputError("Não é permitido excluir o nó Transaction"));
                        hasErrors = true;
                    } else if (instance.PatternPart.SelectSingleElement("instance/webPanelRoot") != null)
                    {
                        output.Add(new OutputError("Não é permitido o nó WebPanel na Transação"));
                        hasErrors = true;
                    }
                }
            }
            if (!hasErrors)
            {
                if (instance.Parent is WebPanel)
                {
                    if (instance.PatternPart.SelectSingleElement("instance/webPanelRoot") == null)
                    {
                        output.Add(new OutputError("Não é permitido excluir o nó WebPanel"));
                        hasErrors = true;
                    }
                    else if (instance.PatternPart.SelectSingleElement("instance/transaction") != null)
                    {
                        output.Add(new OutputError("Não é permitido o nó Transaction no WebPanel"));
                        hasErrors = true;
                    }
                }
            }

            if (!hasErrors)
            {
                foreach (PatternInstanceElement tabElement in instance.PatternPart.SelectElements("tab"))
                {
                    string nome = tabElement.Attributes.GetPropertyValueString(InstanceAttributes.TabForm.Name);
                    string desc = tabElement.Attributes.GetPropertyValueString(InstanceAttributes.TabForm.Description);
                    if (!Variable.IsValidName(nome))
                    {
                        output.Add(new OutputError(String.Format("Caracter inválido no nome da Aba: '{0}', Descrição: {1} ",nome,desc)));
                        hasErrors = true;
                    }
                }
            }

            if (!hasErrors)
            {
                foreach (PatternInstanceElement gridprop in instance.PatternPart.SelectElements("//GridPropertie"))
                {
                    String nome = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridPropertie.Name);
                    String valor = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridPropertie.Valor);

                    String nomeControl = Controls.getCustomRender(gridprop);
                    ControlDefinition control = Controls.getControl(nomeControl);

                    if (control == null)
                    {
                        output.Add(new OutputError("Invalid CustomRender: ", new PatternElementPosition(gridprop)));
                        hasErrors = true;
                    }
                    else
                    {

                        PropDefinition p = control.GetPropertiesDefinition().GetPropDefinition(nome);
                        if (p != null)
                        {
                            try
                            {
                                p.PropertyConverter.ConvertFrom(valor);
                            }
                            catch (Exception e)
                            {
                                output.Add(new OutputError("Property: " + nome + " - " + e.Message, new PatternElementPosition(gridprop)));
                                hasErrors = true;
                            }
                        }
                    }
                }
            }

            if (!hasErrors)
            {

                foreach (PatternInstanceElement gridprop in instance.PatternPart.SelectElements("//GridColumnPropertie"))
                {
                    String nome = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridColumnPropertie.Name);
                    String valor = gridprop.Attributes.GetPropertyValueString(InstanceAttributes.GridColumnPropertie.Valor);

                    String nomeControl = Controls.getCustomRender(gridprop);
                    ControlDefinition control = Controls.getControl(nomeControl);

                    if (control == null)
                    {

                        output.Add(new OutputError("Invalid CustomRender: ", new PatternElementPosition(gridprop)));
                        hasErrors = true;
                    }
                    else
                    {

                        PropDefinition p = control.GetColumnPropertiesDefinition().GetPropDefinition(nome);
                        if (p != null)
                        {
                            try
                            {
                                p.PropertyConverter.ConvertFrom(valor);
                            }
                            catch (Exception e)
                            {
                                output.Add(new OutputError("Column Property: " + nome + " - " + e.Message, new PatternElementPosition(gridprop)));
                                hasErrors = true;
                            }
                        }
                    }
                }
            }

            // TODO não permtir textblock no form com o nome internalname duplicado

            return !hasErrors;
        }
Ejemplo n.º 24
0
 public void LogMessageLine(string message) => OutputMessages.Add(message);
Ejemplo n.º 25
0
 public void Output(string message)
 {
     OutputMessages.Add(message);
 }