public void Setup() { this.serverConnection = Substitute.For <IServerConnection>(); this.innovator = new Innovator(this.serverConnection); this.authManager = new AuthenticationManagerProxy(this.serverConnection, innovator, new InnovatorUser(), Substitute.For <IIOMWrapper>()); this.dialogFactory = Substitute.For <IDialogFactory>(); IProjectConfiguraiton projectConfiguration = Substitute.For <IProjectConfiguraiton>(); this.projectConfigurationManager = Substitute.For <IProjectConfigurationManager>(); projectConfigurationManager.CurrentProjectConfiguraiton.Returns(projectConfiguration); this.messageManager = Substitute.For <MessageManager>(); this.packageManager = new PackageManager(authManager, messageManager); this.arasDataProvider = Substitute.For <IArasDataProvider>(); this.methodInformation = new MethodInfo() { Package = new PackageInfo(string.Empty) }; XmlDocument methodItemTypeXmlDocument = new XmlDocument(); methodItemTypeXmlDocument.Load(Path.Combine(currentPath, @"Dialogs\ViewModels\TestData\MethodItemType.xml")); Item methodItem = this.innovator.newItem(); methodItem.loadAML(methodItemTypeXmlDocument.OuterXml); MethodItemTypeInfo methodItemTypeInfo = new MethodItemTypeInfo(methodItem, messageManager); arasDataProvider.GetMethodItemTypeInfo().Returns(methodItemTypeInfo); List <ConnectionInfo> connectionInfos = new List <ConnectionInfo>() { new ConnectionInfo() { Login = "******", Database = "testDataBase", ServerUrl = "testServerUrl", LastConnection = true } }; projectConfiguration.Connections.Returns(connectionInfos); saveMethodViewModel = new SaveMethodViewModel(this.authManager, this.dialogFactory, this.projectConfigurationManager, this.packageManager, this.arasDataProvider, this.methodInformation, this.messageManager, "methodCode", "projectConfPath", "projectName", "projectFullName"); }
private void EditConnectionInfoCommandClick(object window) { var dialogAdapter = this.dialogFactory.GetLoginView(projectConfigurationManager.CurrentProjectConfiguraiton, projectName, projectFullName); var dialogResult = dialogAdapter.ShowDialog(); if (dialogResult.DialogOperationResult == true) { projectConfigurationManager.Save(projectConfigPath); ConnectionInformation = projectConfigurationManager.CurrentProjectConfiguraiton.Connections.First(c => c.LastConnection); this.methodItemTypeInfo = arasDataProvider.GetMethodItemTypeInfo(); this.MethodNameMaxLength = methodItemTypeInfo.NameStoredLength; this.MethodCommentMaxLength = methodItemTypeInfo.CommentsStoredLength; this.MethodName = this.MethodName; this.MethodComment = this.MethodComment; } }
private void EditConnectionInfoCommandClick(object window) { var loginView = new LoginView(); var loginViewModel = new LoginViewModel(authManager, projectConfiguration, projectName, projectFullName); loginView.DataContext = loginViewModel; loginView.Owner = window as Window; if (loginView.ShowDialog() == true) { projectConfigurationManager.Save(projectConfigPath, projectConfiguration); ConnectionInformation = projectConfiguration.Connections.First(c => c.LastConnection); this.methodItemTypeInfo = arasDataProvider.GetMethodItemTypeInfo(); this.MethodNameMaxLength = methodItemTypeInfo.NameStoredLength; this.MethodCommentMaxLength = methodItemTypeInfo.CommentsStoredLength; this.MethodName = this.MethodName; this.MethodComment = this.MethodComment; } }
public SaveMethodViewModel( IAuthenticationManager authManager, IDialogFactory dialogFactory, IProjectConfigurationManager projectConfigurationManager, PackageManager packageManager, IArasDataProvider arasDataProvider, MethodInfo methodInformation, MessageManager messageManager, string methodCode, string projectConfigPath, string projectName, string projectFullName) { if (authManager == null) { throw new ArgumentNullException(nameof(authManager)); } if (dialogFactory == null) { throw new ArgumentNullException(nameof(dialogFactory)); } if (projectConfigurationManager == null) { throw new ArgumentNullException(nameof(projectConfigurationManager)); } if (packageManager == null) { throw new ArgumentNullException(nameof(packageManager)); } if (arasDataProvider == null) { throw new ArgumentNullException(nameof(arasDataProvider)); } if (methodInformation == null) { throw new ArgumentNullException(nameof(methodInformation)); } if (messageManager == null) { throw new ArgumentNullException(nameof(messageManager)); } this.authManager = authManager; this.dialogFactory = dialogFactory; this.projectConfigurationManager = projectConfigurationManager; this.packageManager = packageManager; this.arasDataProvider = arasDataProvider; this.messageManager = messageManager; this.projectConfigPath = projectConfigPath; this.projectName = projectName; this.projectFullName = projectFullName; this.okCommand = new RelayCommand <object>(OkCommandClick, IsEnabledOkButton); this.closeCommand = new RelayCommand <object>(OnCloseCliked); this.editConnectionInfoCommand = new RelayCommand <object>(EditConnectionInfoCommandClick); this.selectedIdentityCommand = new RelayCommand(SelectedIdentityCommandClick); this.methodItemTypeInfo = arasDataProvider.GetMethodItemTypeInfo(); this.MethodNameMaxLength = methodItemTypeInfo.NameStoredLength; this.MethodCommentMaxLength = methodItemTypeInfo.CommentsStoredLength; this.MethodComment = methodInformation.MethodComment; this.innovatorMethodId = methodInformation.InnovatorMethodId; this.methodCode = methodCode; this.methodType = methodInformation.MethodType; this.methodLanguage = methodInformation.MethodLanguage; this.templateName = methodInformation.TemplateName; this.eventData = methodInformation.EventData.ToString(); this.selectedIdentityKeyedName = methodInformation.ExecutionAllowedToKeyedName; this.selectedIdentityId = methodInformation.ExecutionAllowedToId; this.selectedPackage = methodInformation.Package.Name; this.MethodName = methodInformation.MethodName; this.methodConfigId = methodInformation.InnovatorMethodConfigId; //TODO: How to know current connection? ConnectionInformation = projectConfigurationManager.CurrentProjectConfiguraiton.Connections.First(c => c.LastConnection); }
public SaveToPackageViewModel( IAuthenticationManager authManager, IDialogFactory dialogFactory, IProjectConfiguraiton projectConfiguration, TemplateLoader templateLoader, PackageManager packageManager, ICodeProvider codeProvider, IProjectManager projectManager, IArasDataProvider arasDataProvider, MethodInfo methodInformation, string pathToFileForSave) { if (authManager == null) { throw new ArgumentNullException(nameof(authManager)); } if (dialogFactory == null) { throw new ArgumentNullException(nameof(dialogFactory)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } if (templateLoader == null) { throw new ArgumentNullException(nameof(templateLoader)); } if (packageManager == null) { throw new ArgumentNullException(nameof(packageManager)); } if (codeProvider == null) { throw new ArgumentNullException(nameof(codeProvider)); } if (projectManager == null) { throw new ArgumentNullException(nameof(projectManager)); } if (arasDataProvider == null) { throw new ArgumentNullException(nameof(arasDataProvider)); } if (methodInformation == null) { throw new ArgumentNullException(nameof(methodInformation)); } this.authManager = authManager; this.dialogFactory = dialogFactory; this.projectConfiguration = projectConfiguration; this.templateLoader = templateLoader; this.packageManager = packageManager; this.projectManager = projectManager; this.arasDataProvider = arasDataProvider; this.MethodInformation = methodInformation; this.folderBrowserCommand = new RelayCommand <object>(OnFolderBrowserClick); this.okCommand = new RelayCommand <object>(OkCommandClick, IsEnabledOkButton); this.closeCommand = new RelayCommand <object>(OnCloseCliked); this.selectedIdentityCommand = new RelayCommand(SelectedIdentityCommandClick); string sourceCode = File.ReadAllText(pathToFileForSave, new UTF8Encoding(true)); this.methodItemTypeInfo = arasDataProvider.GetMethodItemTypeInfo(); this.MethodNameMaxLength = methodItemTypeInfo.NameStoredLength; this.MethodCommentMaxLength = methodItemTypeInfo.CommentsStoredLength; MethodComment = MethodInformation.MethodComment; PackagePath = projectConfiguration.LastSelectedDir; MethodName = MethodInformation.MethodName; MethodCode = codeProvider.LoadMethodCode(sourceCode, MethodInformation, projectManager.ServerMethodFolderPath); SelectedPackage = MethodInformation.PackageName; selectedIdentityKeyedName = MethodInformation.ExecutionAllowedToKeyedName; selectedIdentityId = MethodInformation.ExecutionAllowedToId; }
public CreateMethodViewModel( IAuthenticationManager authenticationManager, IDialogFactory dialogFactory, IProjectConfiguraiton projectConfiguration, TemplateLoader templateLoader, PackageManager packageManager, IProjectManager projectManager, IArasDataProvider arasDataProvider, ICodeProvider codeProvider, IGlobalConfiguration userConfiguration, MessageManager messageManager) { if (authenticationManager == null) { throw new ArgumentNullException(nameof(authenticationManager)); } if (dialogFactory == null) { throw new ArgumentNullException(nameof(dialogFactory)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } if (templateLoader == null) { throw new ArgumentNullException(nameof(templateLoader)); } if (packageManager == null) { throw new ArgumentNullException(nameof(packageManager)); } if (projectManager == null) { throw new ArgumentNullException(nameof(projectManager)); } if (arasDataProvider == null) { throw new ArgumentNullException(nameof(arasDataProvider)); } if (codeProvider == null) { throw new ArgumentNullException(nameof(codeProvider)); } if (userConfiguration == null) { throw new ArgumentNullException(nameof(userConfiguration)); } if (messageManager == null) { throw new ArgumentNullException(nameof(messageManager)); } this.authenticationManager = authenticationManager; this.dialogFactory = dialogFactory; this.projectConfiguration = projectConfiguration; this.templateLoader = templateLoader; this.packageManager = packageManager; this.projectManager = projectManager; this.arasDataProvider = arasDataProvider; this.codeProvider = codeProvider; this.globalConfiguration = userConfiguration; this.messageManager = messageManager; this.isUseVSFormattingCode = projectConfiguration.UseVSFormatting; this.UserCodeTemplates = LoadUserCodeTemplates(); this.SelectedUserCodeTemplate = this.userCodeTemplates.First(); this.methodItemTypeInfo = arasDataProvider.GetMethodItemTypeInfo(); this.MethodNameMaxLength = methodItemTypeInfo.NameStoredLength; this.MethodCommentMaxLength = methodItemTypeInfo.CommentsStoredLength; actionLocations = new ObservableCollection <ListInfo>(); foreach (var localtion in Utilities.Utils.GetValueListByName(authenticationManager.InnovatorInstance, "Action Locations")) { string value = localtion.getProperty("value", string.Empty); if (string.Equals(value, "client")) { continue; } actionLocations.Add(new ListInfo(value, localtion.getProperty("label", string.Empty))); } allLanguages = new List <FilteredListInfo>(); foreach (var language in Utilities.Utils.GetFilterValueListByName(authenticationManager.InnovatorInstance, "Method Types")) { string value = language.getProperty("value"); string label = language.getProperty("label"); string filter = language.getProperty("filter"); if (string.Equals(filter, "server", StringComparison.CurrentCultureIgnoreCase) && !string.Equals(value, this.codeProvider.Language, StringComparison.CurrentCultureIgnoreCase)) { continue; } allLanguages.Add(new FilteredListInfo(value, label, filter)); } SelectedActionLocation = actionLocations.First(al => string.Equals(al.Value.ToLowerInvariant(), "server")); okCommand = new RelayCommand <object>(OnOkClick, IsEnabledOkButton); cancelCommand = new RelayCommand <object>(OnCancelClick); closeCommand = new RelayCommand <object>(OnCloseCliked); selectedIdentityCommand = new RelayCommand(SelectedIdentityCommandClick); browseCodeTemplateCommand = new RelayCommand(BrowseCodeTemplateCommandClick); deleteUserCodeTemplateCommand = new RelayCommand <KeyValuePair <string, XmlMethodInfo> >(DeleteUserCodeTemplateCommandClick); SelectedEventSpecificData = EventSpecificData.First(); }
public SaveToPackageViewModel( IAuthenticationManager authManager, IDialogFactory dialogFactory, IProjectConfiguraiton projectConfiguration, TemplateLoader templateLoader, PackageManager packageManager, ICodeProvider codeProvider, IProjectManager projectManager, IArasDataProvider arasDataProvider, IIOWrapper iOWrapper, MessageManager messageManager, MethodInfo methodInformation, string sourceCode) { if (authManager == null) { throw new ArgumentNullException(nameof(authManager)); } if (dialogFactory == null) { throw new ArgumentNullException(nameof(dialogFactory)); } if (projectConfiguration == null) { throw new ArgumentNullException(nameof(projectConfiguration)); } if (templateLoader == null) { throw new ArgumentNullException(nameof(templateLoader)); } if (packageManager == null) { throw new ArgumentNullException(nameof(packageManager)); } if (codeProvider == null) { throw new ArgumentNullException(nameof(codeProvider)); } if (projectManager == null) { throw new ArgumentNullException(nameof(projectManager)); } if (arasDataProvider == null) { throw new ArgumentNullException(nameof(arasDataProvider)); } if (iOWrapper == null) { throw new ArgumentNullException(nameof(iOWrapper)); } if (messageManager == null) { throw new ArgumentNullException(nameof(messageManager)); } if (methodInformation == null) { throw new ArgumentNullException(nameof(methodInformation)); } this.authManager = authManager; this.dialogFactory = dialogFactory; this.projectConfiguration = projectConfiguration; this.templateLoader = templateLoader; this.packageManager = packageManager; this.projectManager = projectManager; this.arasDataProvider = arasDataProvider; this.iOWrapper = iOWrapper; this.messageManager = messageManager; this.MethodInformation = methodInformation; this.folderBrowserCommand = new RelayCommand <object>(OnFolderBrowserClick); this.okCommand = new RelayCommand <object>(OkCommandClick, IsEnabledOkButton); this.closeCommand = new RelayCommand <object>(OnCloseCliked); this.selectedIdentityCommand = new RelayCommand(SelectedIdentityCommandClick); this.methodItemTypeInfo = arasDataProvider.GetMethodItemTypeInfo(); this.MethodNameMaxLength = methodItemTypeInfo.NameStoredLength; this.MethodCommentMaxLength = methodItemTypeInfo.CommentsStoredLength; MethodComment = MethodInformation.MethodComment; PackagePath = projectConfiguration.LastSelectedDir; MethodName = MethodInformation.MethodName; string packageMethodFolderPath = projectConfiguration.UseCommonProjectStructure ? methodInformation.Package.MethodFolderPath : string.Empty; string methodWorkingFolder = Path.Combine(projectManager.ServerMethodFolderPath, packageMethodFolderPath, methodInformation.MethodName); MethodCode = codeProvider.LoadMethodCode(methodWorkingFolder, sourceCode); SelectedPackage = MethodInformation.Package.Name; selectedIdentityKeyedName = MethodInformation.ExecutionAllowedToKeyedName; selectedIdentityId = MethodInformation.ExecutionAllowedToId; }