예제 #1
0
        public override void NextBtnCommandAction(Object param)
        {
            switch (CurrentUiStepId)
            {
            case 0:
                CurrentUiStepId = 1;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectDbContextUC == null)
                {
                    SelectDbContextViewModel dataContext = new SelectDbContextViewModel(Dte);
                    dataContext.UiCommandButtonVisibility = Visibility.Collapsed;
                    dataContext.UiCommandCaption3         = "NameSpace: " + (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    string folder = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    if (!string.IsNullOrEmpty(folder))
                    {
                        dataContext.UiCommandCaption3 = dataContext.UiCommandCaption3 + "." + folder.Replace("\\", ".");
                    }
                    SelectDbContextUC = new UserControlSelectSource(dataContext);
                    dataContext.IsReady.IsReadyEvent += CallBack_IsReady;
                }
                (SelectDbContextUC.DataContext as SelectDbContextViewModel).DoAnaliseDbContext();
                this.CurrentUserControl = SelectDbContextUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 1:
                CurrentUiStepId = 2;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (CreateWebApiUC == null)
                {
                    CreateWebApiViewModel dataContext = new CreateWebApiViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent   += CallBack_IsReady;
                    dataContext.DestinationProject      = (InvitationUC.DataContext as InvitationViewModel).DestinationProject;
                    dataContext.DefaultProjectNameSpace = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    dataContext.DestinationFolder       = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    CreateWebApiUC = new UserControlCreateWebApi(dataContext);
                }
                (CreateWebApiUC.DataContext as CreateWebApiViewModel).SelectedDbContext =
                    (SelectDbContextUC.DataContext as SelectDbContextViewModel).SelectedCodeElement;
                (CreateWebApiUC.DataContext as CreateWebApiViewModel).CheckIsReady();
                this.CurrentUserControl = CreateWebApiUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 2:
                CurrentUiStepId = 3;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (T4EditorUC == null)
                {
                    //string templatePath = Path.Combine("Templates", "ViewModel.cs.t4");
                    string            TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    string            templatePath = Path.Combine(TemplatesFld, "WebApiServiceTmplst");
                    T4EditorViewModel dataContext  = new T4EditorViewModel(templatePath);
                    dataContext.IsReady.IsReadyEvent += CallBack_IsReady;
                    T4EditorUC = new UserControlT4Editor(dataContext);
                }
                (T4EditorUC.DataContext as T4EditorViewModel).CheckIsReady();
                this.CurrentUserControl = T4EditorUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 3:
                CurrentUiStepId = 4;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                IVsThreadedWaitDialog2 aDialog = null;
                bool aDialogStarted            = false;
                if (this.DialogFactory != null)
                {
                    this.DialogFactory.CreateInstance(out aDialog);
                    if (aDialog != null)
                    {
                        aDialogStarted = aDialog.StartWaitDialog("Generation started", "VS is Busy", "Please wait", null, "Generation started", 0, false, true) == VSConstants.S_OK;
                    }
                }
                if (GenerateUC == null)
                {
                    GenerateCommonStaffViewModel dataContext = new GenerateCommonStaffViewModel();
                    dataContext.IsReady.IsReadyEvent += GenerateWebApiViewModel_IsReady;
                    GenerateUC = new UserControlGenerate(dataContext);
                }

                (GenerateUC.DataContext as GenerateCommonStaffViewModel).GenText = (T4EditorUC.DataContext as T4EditorViewModel).T4TempateText;

                try
                {
                    (GenerateUC.DataContext as GenerateCommonStaffViewModel)
                    .DoGenerateViewModel(Dte, TextTemplating,
                                         (T4EditorUC.DataContext as T4EditorViewModel).T4TempatePath,
                                         (CreateWebApiUC.DataContext as CreateWebApiViewModel).SerializableDbContext,
                                         (CreateWebApiUC.DataContext as CreateWebApiViewModel).GetSelectedModelShallowCopy());
                    if (aDialogStarted)
                    {
                        int iOut;
                        aDialog.EndWaitDialog(out iOut);
                    }
                }
                catch (Exception e)
                {
                    if (aDialogStarted)
                    {
                        int iOut;
                        aDialog.EndWaitDialog(out iOut);
                    }
                    MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    this.CurrentUserControl = GenerateUC;
                    this.OnPropertyChanged("CurrentUserControl");
                }
                break;

            case 4:
                CurrentUiStepId = 2;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                (CreateWebApiUC.DataContext as CreateWebApiViewModel).CheckIsReady();
                this.CurrentUserControl = CreateWebApiUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            default:
                break;
            }
        }
예제 #2
0
        public override void NextBtnCommandAction(Object param)
        {
            switch (CurrentUiStepId)
            {
            case 0:
                CurrentUiStepId = 1;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectDbContextUC == null)
                {
                    SelectDbContextViewModel dataContext = new SelectDbContextViewModel(Dte);
                    dataContext.UiCommandButtonVisibility = Visibility.Collapsed;
                    dataContext.UiCommandCaption3         = "NameSpace: " + (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    string folder = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    if (!string.IsNullOrEmpty(folder))
                    {
                        dataContext.UiCommandCaption3 = dataContext.UiCommandCaption3 + "." + folder.Replace("\\", ".");
                    }
                    SelectDbContextUC = new UserControlSelectSource(dataContext);
                    dataContext.IsReady.IsReadyEvent += CallBack_IsReady;
                }
                (SelectDbContextUC.DataContext as SelectDbContextViewModel).DoAnaliseDbContext();
                this.CurrentUserControl = SelectDbContextUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 1:
                CurrentUiStepId = 2;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (CreateWebApiUC == null)
                {
                    CreateWebApiViewModel dataContext = new CreateWebApiViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent      += CallBack_IsReady;
                    dataContext.DestinationProject         = (InvitationUC.DataContext as InvitationViewModel).DestinationProject;
                    dataContext.DefaultProjectNameSpace    = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    dataContext.DestinationFolder          = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    dataContext.IsWebServiceEditable       = false;
                    dataContext.UIFormPropertiesVisibility = Visibility.Visible;
                    dataContext.UIListPropertiesVisibility = Visibility.Visible;

                    CreateWebApiUC = new UserControlCreateWebApi(dataContext);
                }
                (CreateWebApiUC.DataContext as CreateWebApiViewModel).SelectedDbContext =
                    (SelectDbContextUC.DataContext as SelectDbContextViewModel).SelectedCodeElement;
                (CreateWebApiUC.DataContext as CreateWebApiViewModel).CheckIsReady();
                this.CurrentUserControl = CreateWebApiUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 2:
                bool   hasUIFormPropertiesError  = false;
                string textUIFormPropertiesError = "";
                foreach (ModelViewUIFormProperty modelViewUIFormProperty in (CreateWebApiUC.DataContext as CreateWebApiViewModel).UIFormProperties)
                {
                    if (
                        ((modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.Combo) ||
                         (modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.SearchDialog) ||
                         (modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.Typeahead)) &&
                        string.IsNullOrEmpty(modelViewUIFormProperty.ForeignKeyNameChain)
                        )
                    {
                        hasUIFormPropertiesError   = true;
                        textUIFormPropertiesError += "\n InputTypeWhenAdd for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                        textUIFormPropertiesError += "\n but ForeignKeyNameChain is empty for this property.";
                        textUIFormPropertiesError += "\n Generators will not work correctly.";
                        textUIFormPropertiesError += "\n ";
                    }
                    if (
                        ((modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.Combo) ||
                         (modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.SearchDialog) ||
                         (modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.Typeahead)) &&
                        string.IsNullOrEmpty(modelViewUIFormProperty.ForeignKeyNameChain)
                        )
                    {
                        hasUIFormPropertiesError   = true;
                        textUIFormPropertiesError += "\n InputTypeWhenUpdate for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                        textUIFormPropertiesError += "\n but ForeignKeyNameChain is empty for this property.";
                        textUIFormPropertiesError += "\n Generators will not work correctly.";
                        textUIFormPropertiesError += "\n ";
                    }
                    if (
                        ((modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.Combo) ||
                         (modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.SearchDialog) ||
                         (modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.Typeahead)) &&
                        string.IsNullOrEmpty(modelViewUIFormProperty.ForeignKeyNameChain)
                        )
                    {
                        hasUIFormPropertiesError   = true;
                        textUIFormPropertiesError += "\n InputTypeWhenUpdate for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                        textUIFormPropertiesError += "\n but ForeignKeyNameChain is empty for this property.";
                        textUIFormPropertiesError += "\n Generators will not work correctly.";
                        textUIFormPropertiesError += "\n ";
                    }


                    if (
                        ((modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.Combo) ||
                         (modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.SearchDialog) ||
                         (modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.Typeahead)) &&
                        (!modelViewUIFormProperty.IsShownInView)
                        )
                    {
                        hasUIFormPropertiesError   = true;
                        textUIFormPropertiesError += "\n InputTypeWhenAdd for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                        textUIFormPropertiesError += "\n but IsShown is not checked.";
                        textUIFormPropertiesError += "\n Generators will not work correctly.";
                        textUIFormPropertiesError += "\n ";
                    }
                    if (
                        ((modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.Combo) ||
                         (modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.SearchDialog) ||
                         (modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.Typeahead)) &&
                        (!modelViewUIFormProperty.IsShownInView)
                        )
                    {
                        hasUIFormPropertiesError   = true;
                        textUIFormPropertiesError += "\n InputTypeWhenUpdate for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                        textUIFormPropertiesError += "\n but IsShown is not checked.";
                        textUIFormPropertiesError += "\n Generators will not work correctly.";
                        textUIFormPropertiesError += "\n ";
                    }
                    if (
                        ((modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.Combo) ||
                         (modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.SearchDialog) ||
                         (modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.Typeahead)) &&
                        (!modelViewUIFormProperty.IsShownInView)
                        )
                    {
                        hasUIFormPropertiesError   = true;
                        textUIFormPropertiesError += "\n InputTypeWhenUpdate for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                        textUIFormPropertiesError += "\n but IsShown is not checked.";
                        textUIFormPropertiesError += "\n Generators will not work correctly.";
                        textUIFormPropertiesError += "\n ";
                    }
                }
                int uIFormPropertiesCount = (CreateWebApiUC.DataContext as CreateWebApiViewModel).UIFormProperties.Count;
                for (int inpTp = 1; inpTp < 4; inpTp++)
                {
                    for (int i = 0; i < uIFormPropertiesCount - 1; i++)
                    {
                        ModelViewUIFormProperty modelViewUIFormProperty =
                            (CreateWebApiUC.DataContext as CreateWebApiViewModel).UIFormProperties[i];
                        if (string.IsNullOrEmpty(modelViewUIFormProperty.ForeignKeyNameChain))
                        {
                            continue;
                        }
                        if (inpTp == 1)
                        {
                            if (!((modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.Combo) ||
                                  (modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.Typeahead) ||
                                  (modelViewUIFormProperty.InputTypeWhenAdd == InputTypeEnum.SearchDialog)))
                            {
                                continue;
                            }
                        }
                        else if (inpTp == 2)
                        {
                            if (!((modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.Combo) ||
                                  (modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.Typeahead) ||
                                  (modelViewUIFormProperty.InputTypeWhenUpdate == InputTypeEnum.SearchDialog)))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (!((modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.Combo) ||
                                  (modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.Typeahead) ||
                                  (modelViewUIFormProperty.InputTypeWhenDelete == InputTypeEnum.SearchDialog)))
                            {
                                continue;
                            }
                        }
                        for (int k = i + 1; k < uIFormPropertiesCount; k++)
                        {
                            ModelViewUIFormProperty modelViewUIFormProperty2 =
                                (CreateWebApiUC.DataContext as CreateWebApiViewModel).UIFormProperties[k];
                            if (string.IsNullOrEmpty(modelViewUIFormProperty2.ForeignKeyNameChain))
                            {
                                continue;
                            }
                            if (modelViewUIFormProperty2.ForeignKeyNameChain != modelViewUIFormProperty.ForeignKeyNameChain)
                            {
                                continue;
                            }
                            if (inpTp == 1)
                            {
                                if ((modelViewUIFormProperty2.InputTypeWhenAdd == InputTypeEnum.Combo) ||
                                    (modelViewUIFormProperty2.InputTypeWhenAdd == InputTypeEnum.Typeahead) ||
                                    (modelViewUIFormProperty2.InputTypeWhenAdd == InputTypeEnum.SearchDialog))
                                {
                                    hasUIFormPropertiesError   = true;
                                    textUIFormPropertiesError += "\n InputTypeWhenAdd for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                                    textUIFormPropertiesError += "\n InputTypeWhenAdd for UIFormProperty named [" + modelViewUIFormProperty2.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                                    textUIFormPropertiesError += "\n Both properties have the same ForeignKeyNameChain =[" + modelViewUIFormProperty.ForeignKeyNameChain + "].";
                                    textUIFormPropertiesError += "\n For InputTypeWhenAdd only one property for each ForeignKeyNameChain can be set to one of the values (Combo, SearchDialog, Typeahead).";
                                    textUIFormPropertiesError += "\n Generators will not work correctly.";
                                    textUIFormPropertiesError += "\n ";
                                }
                            }
                            else if (inpTp == 2)
                            {
                                if ((modelViewUIFormProperty2.InputTypeWhenUpdate == InputTypeEnum.Combo) ||
                                    (modelViewUIFormProperty2.InputTypeWhenUpdate == InputTypeEnum.Typeahead) ||
                                    (modelViewUIFormProperty2.InputTypeWhenUpdate == InputTypeEnum.SearchDialog))
                                {
                                    textUIFormPropertiesError += "\n InputTypeWhenUpdate for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                                    textUIFormPropertiesError += "\n InputTypeWhenUpdate for UIFormProperty named [" + modelViewUIFormProperty2.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                                    textUIFormPropertiesError += "\n Both properties have the same ForeignKeyNameChain =[" + modelViewUIFormProperty.ForeignKeyNameChain + "].";
                                    textUIFormPropertiesError += "\n For InputTypeWhenUpdate only one property for each ForeignKeyNameChain can be set to one of the values (Combo, SearchDialog, Typeahead).";
                                    textUIFormPropertiesError += "\n Generators will not work correctly.";
                                    textUIFormPropertiesError += "\n ";
                                }
                            }
                            else
                            {
                                if ((modelViewUIFormProperty2.InputTypeWhenDelete == InputTypeEnum.Combo) ||
                                    (modelViewUIFormProperty2.InputTypeWhenDelete == InputTypeEnum.Typeahead) ||
                                    (modelViewUIFormProperty2.InputTypeWhenDelete == InputTypeEnum.SearchDialog))
                                {
                                    textUIFormPropertiesError += "\n InputTypeWhenDelete for UIFormProperty named [" + modelViewUIFormProperty.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                                    textUIFormPropertiesError += "\n InputTypeWhenDelete for UIFormProperty named [" + modelViewUIFormProperty2.ViewPropertyName + "] was set to one of the values (Combo, SearchDialog, Typeahead)";
                                    textUIFormPropertiesError += "\n Both properties have the same ForeignKeyNameChain =[" + modelViewUIFormProperty.ForeignKeyNameChain + "].";
                                    textUIFormPropertiesError += "\n For InputTypeWhenDelete only one property for each ForeignKeyNameChain can be set to one of the values (Combo, SearchDialog, Typeahead).";
                                    textUIFormPropertiesError += "\n Generators will not work correctly.";
                                    textUIFormPropertiesError += "\n ";
                                }
                            }
                        }
                    }
                }


                if (hasUIFormPropertiesError)
                {
                    textUIFormPropertiesError += "\n Would you like to continue ?";
                    if (MessageBox.Show(textUIFormPropertiesError, "Error", MessageBoxButton.YesNo, MessageBoxImage.Warning) != MessageBoxResult.Yes)
                    {
                        return;
                    }
                }
                CurrentUiStepId = 3;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (SelectFolderUC == null)
                {
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    SelectFolderViewModel dataContext = new SelectFolderViewModel(Dte, TextTemplating, DialogFactory, (CreateWebApiUC.DataContext as CreateWebApiViewModel).SelectedDbContext, TemplatesFld, "WpfScriptsTmplst", "BatchScriptsTmplst");
                    dataContext.DestinationProjectRootFolder     = (InvitationUC.DataContext as InvitationViewModel).DestinationProjectRootFolder;
                    dataContext.DestinationFolder                = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    dataContext.ContextItemViewName              = (CreateWebApiUC.DataContext as CreateWebApiViewModel).ContextItemViewName;
                    dataContext.DestinationProjectName           = (InvitationUC.DataContext as InvitationViewModel).DestinationProject;
                    dataContext.DestinationProject               = this.DestinationProject;
                    dataContext.DefaultProjectNameSpace          = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    dataContext.IsReady.IsReadyEvent            += CallBack_IsReady;
                    dataContext.OnContextChanged.ContextChanged += OnContextChanged;
                    SelectFolderUC = new UserControlSelectFolder(dataContext);
                }
                (SelectFolderUC.DataContext as SelectFolderViewModel).SerializableDbContext =
                    (CreateWebApiUC.DataContext as CreateWebApiViewModel).SerializableDbContext;
                (SelectFolderUC.DataContext as SelectFolderViewModel).SelectedModel =
                    (CreateWebApiUC.DataContext as CreateWebApiViewModel).SelectedModel;

                (SelectFolderUC.DataContext as SelectFolderViewModel).UIFormProperties = (CreateWebApiUC.DataContext as CreateWebApiViewModel).UIFormProperties;
                (SelectFolderUC.DataContext as SelectFolderViewModel).UIListProperties = (CreateWebApiUC.DataContext as CreateWebApiViewModel).UIListProperties;

                (SelectFolderUC.DataContext as SelectFolderViewModel).CheckIsReady();
                this.CurrentUserControl = SelectFolderUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 3:
                CurrentUiStepId = 4;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (T4EditorUC == null)
                {
                    string            templatePath = Path.Combine((SelectFolderUC.DataContext as SelectFolderViewModel).T4RootFolder, (SelectFolderUC.DataContext as SelectFolderViewModel).T4SelectedFolder);
                    T4EditorViewModel dataContext  = new T4EditorViewModel(templatePath);
                    dataContext.IsReady.IsReadyEvent += CallBack_IsReady;
                    T4EditorUC = new UserControlT4Editor(dataContext);
                }
                (T4EditorUC.DataContext as T4EditorViewModel).T4TemplateFolder =
                    Path.Combine((SelectFolderUC.DataContext as SelectFolderViewModel).T4RootFolder, (SelectFolderUC.DataContext as SelectFolderViewModel).T4SelectedFolder);
                (T4EditorUC.DataContext as T4EditorViewModel).CheckIsReady();
                this.CurrentUserControl = T4EditorUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 4:
                CurrentUiStepId = 5;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                IVsThreadedWaitDialog2 aDialog = null;
                bool aDialogStarted            = false;
                if (this.DialogFactory != null)
                {
                    this.DialogFactory.CreateInstance(out aDialog);
                    if (aDialog != null)
                    {
                        aDialogStarted = aDialog.StartWaitDialog("Generation started", "VS is Busy", "Please wait", null, "Generation started", 0, false, true) == VSConstants.S_OK;
                    }
                }

                if (GenerateUC == null)
                {
                    GenerateCommonStaffViewModel dataContext = new GenerateCommonStaffViewModel();
                    dataContext.IsReady.IsReadyEvent += GenerateWebApiViewModel_IsReady;
                    GenerateUC = new UserControlGenerate(dataContext);
                }

                (GenerateUC.DataContext as GenerateCommonStaffViewModel).GenText = (T4EditorUC.DataContext as T4EditorViewModel).T4TempateText;

                try
                {
                    (GenerateUC.DataContext as GenerateCommonStaffViewModel)
                    .DoGenerateViewModel(Dte, TextTemplating,
                                         (T4EditorUC.DataContext as T4EditorViewModel).T4TempatePath,
                                         (CreateWebApiUC.DataContext as CreateWebApiViewModel).SerializableDbContext,
                                         (CreateWebApiUC.DataContext as CreateWebApiViewModel).GetSelectedModelCommonShallowCopy(
                                             (SelectFolderUC.DataContext as SelectFolderViewModel).T4SelectedFolder,
                                             (SelectFolderUC.DataContext as SelectFolderViewModel).FileName
                                             ),
                                         (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace
                                         );
                    if (aDialogStarted)
                    {
                        int iOut;
                        aDialog.EndWaitDialog(out iOut);
                    }
                }
                catch (Exception e)
                {
                    if (aDialogStarted)
                    {
                        int iOut;
                        aDialog.EndWaitDialog(out iOut);
                    }
                    MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    this.CurrentUserControl = GenerateUC;
                    this.OnPropertyChanged("CurrentUserControl");
                }
                break;

            case 5:
                CurrentUiStepId = 2;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                (CreateWebApiUC.DataContext as CreateWebApiViewModel).CheckIsReady();
                this.CurrentUserControl = CreateWebApiUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            default:
                break;
            }
        }
예제 #3
0
        public override void NextBtnCommandAction(Object param)
        {
            switch (CurrentUiStepId)
            {
            case 0:
                CurrentUiStepId = 1;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectDbContextUC == null)
                {
                    SelectDbContextViewModel dataContext = new SelectDbContextViewModel(Dte);
                    dataContext.UiCommandButtonVisibility = Visibility.Collapsed;
                    dataContext.UiCommandCaption3         = "NameSpace: " + (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    string folder = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    if (!string.IsNullOrEmpty(folder))
                    {
                        dataContext.UiCommandCaption3 = dataContext.UiCommandCaption3 + "." + folder.Replace("\\", ".");
                    }
                    SelectDbContextUC = new UserControlSelectSource(dataContext);
                    dataContext.IsReady.IsReadyEvent += SelectDbContextViewModel_IsReady;
                }
                (SelectDbContextUC.DataContext as SelectDbContextViewModel).DoAnaliseDbContext();
                this.CurrentUserControl = SelectDbContextUC;
                this.OnPropertyChanged("CurrentUserControl");


                break;

            case 1:
                CurrentUiStepId = 2;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectSourceEntityUC == null)
                {
                    SelectEntityForGivenDbContextViewModel dataContext = new SelectEntityForGivenDbContextViewModel(Dte);
                    dataContext.UiCommandButtonVisibility = Visibility.Collapsed;
                    dataContext.IsReady.IsReadyEvent     += SelectEntityForGivenDbContextViewModel_IsReady;
                    SelectSourceEntityUC = new UserControlSelectSource(dataContext);
                }
                (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext =
                    (SelectDbContextUC.DataContext as SelectDbContextViewModel).SelectedCodeElement;
                (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).CheckIsReady();
                OnDbContextChanged();
                this.CurrentUserControl = SelectSourceEntityUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 2:
                CurrentUiStepId = 3;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectExistingUC == null)
                {
                    SelectExistingViewModel dataContext = new SelectExistingViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent += SelectEntityForGivenDbContextViewModel_IsReady;
                    SelectExistingUC = new UserControlSelectExisting(dataContext);
                }
                (SelectExistingUC.DataContext as SelectExistingViewModel).CurrentDbContext = CurrentDbContext;
                (SelectExistingUC.DataContext as SelectExistingViewModel).SelectedEntity   =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;

                (SelectExistingUC.DataContext as SelectExistingViewModel).DestinationProject      = (InvitationUC.DataContext as InvitationViewModel).DestinationProject;
                (SelectExistingUC.DataContext as SelectExistingViewModel).DefaultProjectNameSpace = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                (SelectExistingUC.DataContext as SelectExistingViewModel).DestinationFolder       = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                (SelectExistingUC.DataContext as SelectExistingViewModel).DbSetProppertyName      = (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedProppertyName;

                (SelectExistingUC.DataContext as SelectExistingViewModel).DoAnalize();
                this.CurrentUserControl = SelectExistingUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 3:
                CurrentUiStepId = 4;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                SaveBtnEnabled  = false;
                if (CreateViewUC == null)
                {
                    CreateViewViewModel dataContext = new CreateViewViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent   += SelectEntityForGivenDbContextViewModel_IsReady;
                    dataContext.DestinationProject      = (InvitationUC.DataContext as InvitationViewModel).DestinationProject;
                    dataContext.DefaultProjectNameSpace = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    dataContext.DestinationFolder       = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    CreateViewUC = new UserControlCreateView(dataContext);
                }
                (CreateViewUC.DataContext as CreateViewViewModel).SelectedDbContext =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext;
                (CreateViewUC.DataContext as CreateViewViewModel).SelectedEntity =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;
                (CreateViewUC.DataContext as CreateViewViewModel).CurrentDbContext = CurrentDbContext;
                (CreateViewUC.DataContext as CreateViewViewModel).DestinationDbSetProppertyName =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedProppertyName;
                ModelViewSerializable srcModel = null;
                if ((SelectExistingUC.DataContext as SelectExistingViewModel).IsSelectExisting)
                {
                    srcModel = (SelectExistingUC.DataContext as SelectExistingViewModel).SelectedModel;
                }
                (CreateViewUC.DataContext as CreateViewViewModel).DoAnalize(srcModel);
                this.CurrentUserControl = CreateViewUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 4:
                string checkErrorsText = (CreateViewUC.DataContext as CreateViewViewModel).SelectedModel.CheckCorrect();
                if (!string.IsNullOrEmpty(checkErrorsText))
                {
                    (CreateViewUC.DataContext as CreateViewViewModel).CheckErrorsText = checkErrorsText;
                    return;
                }

                CurrentUiStepId = 5;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                SaveBtnEnabled  = false;
                if (T4EditorUC == null)
                {
                    string            TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    string            templatePath = Path.Combine(TemplatesFld, "ViewModelTmplst");
                    T4EditorViewModel dataContext  = new T4EditorViewModel(templatePath);
                    dataContext.IsReady.IsReadyEvent += T4EditorViewModel_IsReady;
                    T4EditorUC = new UserControlT4Editor(dataContext);
                }
                (T4EditorUC.DataContext as T4EditorViewModel).CheckIsReady();
                this.CurrentUserControl = T4EditorUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 5:
                CurrentUiStepId = 6;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                IVsThreadedWaitDialog2 aDialog = null;
                bool aDialogStarted            = false;
                if (this.DialogFactory != null)
                {
                    this.DialogFactory.CreateInstance(out aDialog);
                    if (aDialog != null)
                    {
                        aDialogStarted = aDialog.StartWaitDialog("Generation started", "VS is Busy", "Please wait", null, "Generation started", 0, false, true) == VSConstants.S_OK;
                    }
                }

                if (GenerateUC == null)
                {
                    GenerateViewModel generateViewModel = new GenerateViewModel();
                    generateViewModel.IsReady.IsReadyEvent += GenerateViewModel_IsReady;
                    GenerateUC = new UserControlGenerate(generateViewModel);
                }
                (GenerateUC.DataContext as GenerateViewModel).GenText = (T4EditorUC.DataContext as T4EditorViewModel).T4TempateText;
                try
                {
                    (CreateViewUC.DataContext as CreateViewViewModel).SelectedModel.RootEntityDbContextPropertyName =
                        (CreateViewUC.DataContext as CreateViewViewModel).DestinationDbSetProppertyName;
                    (GenerateUC.DataContext as GenerateViewModel).DoGenerateViewModel(Dte, TextTemplating, null,
                                                                                      (T4EditorUC.DataContext as T4EditorViewModel).T4TempatePath,
                                                                                      (CreateViewUC.DataContext as CreateViewViewModel).SelectedModel);
                    NextBtnEnabled = true;
                    if (aDialogStarted)
                    {
                        int iOut;
                        aDialog.EndWaitDialog(out iOut);
                    }
                    MessageBox.Show(SuccessNotification, "Done", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch (Exception e)
                {
                    if (aDialogStarted)
                    {
                        int iOut;
                        aDialog.EndWaitDialog(out iOut);
                    }
                    MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    this.CurrentUserControl = GenerateUC;
                    this.OnPropertyChanged("CurrentUserControl");
                }
                break;

            case 6:
                CurrentUiStepId = 7;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                SaveBtnEnabled  = false;
                if (T4EditorPageUC == null)
                {
                    string            TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    string            templatePath = Path.Combine(TemplatesFld, "ViewPageModelTmplst");
                    T4EditorViewModel dataContext  = new T4EditorViewModel(templatePath);
                    dataContext.IsReady.IsReadyEvent += T4EditorViewModel_IsReady;
                    T4EditorPageUC = new UserControlT4Editor(dataContext);
                }
                (T4EditorPageUC.DataContext as T4EditorViewModel).CheckIsReady();
                this.CurrentUserControl = T4EditorPageUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 7:
                CurrentUiStepId = 8;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                IVsThreadedWaitDialog2 aaDialog = null;
                bool aaDialogStarted            = false;
                if (this.DialogFactory != null)
                {
                    this.DialogFactory.CreateInstance(out aaDialog);
                    if (aaDialog != null)
                    {
                        aaDialogStarted = aaDialog.StartWaitDialog("Generation started", "VS is Busy", "Please wait", null, "Generation started", 0, false, true) == VSConstants.S_OK;
                    }
                }
                if (GeneratePageUC == null)
                {
                    GenerateViewPageModel generateViewModel = new GenerateViewPageModel();
                    generateViewModel.IsReady.IsReadyEvent += GenerateViewModel_IsReady;
                    GeneratePageUC = new UserControlGenerate(generateViewModel);
                }
                (GeneratePageUC.DataContext as GenerateViewPageModel).GenText = (T4EditorPageUC.DataContext as T4EditorViewModel).T4TempateText;
                try
                {
                    (GeneratePageUC.DataContext as GenerateViewPageModel).GeneratedModelView =
                        (GenerateUC.DataContext as GenerateViewModel).GeneratedModelView;
                    (GeneratePageUC.DataContext as GenerateViewPageModel).DoGenerateViewPageModel(Dte, TextTemplating, null,
                                                                                                  (T4EditorPageUC.DataContext as T4EditorViewModel).T4TempatePath);
                    if (aaDialogStarted)
                    {
                        int iOut;
                        aaDialog.EndWaitDialog(out iOut);
                    }
                }
                catch (Exception e)
                {
                    if (aaDialogStarted)
                    {
                        int iOut;
                        aaDialog.EndWaitDialog(out iOut);
                    }
                    MessageBox.Show("Error: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                finally
                {
                    this.CurrentUserControl = GeneratePageUC;
                    this.OnPropertyChanged("CurrentUserControl");
                }
                break;

            case 8:
                CurrentUiStepId = 1;
                NextBtnCommandAction(param);
                break;

            default:
                break;
            }
        }
예제 #4
0
        public override void NextBtnCommandAction(Object param)
        {
            switch (CurrentUiStepId)
            {
            case 0:
                CurrentUiStepId = 1;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectDbContextUC == null)
                {
                    SelectDbContextViewModel dataContext = new SelectDbContextViewModel(Dte);
                    dataContext.UiCommandCaption3 = "NameSpace: " + (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                    string folder = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                    if (!string.IsNullOrEmpty(folder))
                    {
                        dataContext.UiCommandCaption3 = dataContext.UiCommandCaption3 + "." + folder.Replace("\\", ".");
                    }
                    SelectDbContextUC = new UserControlSelectSource(dataContext);
                    dataContext.IsReady.IsReadyEvent += SelectDbContextViewModel_IsReady;
                    dataContext.UiCommandButtonClicked.ButtonClickedEvent += SelectDbContextViewModel_ButtonClicked;
                }
                (SelectDbContextUC.DataContext as SelectDbContextViewModel).DoAnaliseDbContext();

                this.CurrentUserControl = SelectDbContextUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 1:
                CurrentUiStepId = 2;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                SaveBtnEnabled  = false;
                if (SelectSourceEntityUC == null)
                {
                    SelectEntityForGivenDbContextViewModel dataContext = new SelectEntityForGivenDbContextViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent += SelectEntityForGivenDbContextViewModel_IsReady;
                    dataContext.UiCommandButtonClicked.ButtonClickedEvent += SelectEntityForGivenDbContextViewModel_ButtonClicked;
                    SelectSourceEntityUC = new UserControlSelectSource(dataContext);
                }
                (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext =
                    (SelectDbContextUC.DataContext as SelectDbContextViewModel).SelectedCodeElement;
                if ((SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement != null)
                {
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).DoAnalize();
                }
                else
                {
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).CheckIsReady();
                }
                this.CurrentUserControl = SelectSourceEntityUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 2:
                CurrentUiStepId = 3;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (SelectForeignKeyUC == null)
                {
                    SelectForeignKeyViewModel dataContext = new SelectForeignKeyViewModel(Dte);
                    dataContext.IsReady.IsReadyEvent += SelectForeignKeyViewModel_IsReady;
                    SelectForeignKeyUC = new UserControlSelectForeignKey(dataContext);
                    dataContext.PrincipalKeyButtonClicked.ButtonClickedEvent += UiBtnCommandPrincipalKey_ButtonClicked;
                    dataContext.ForeignKeyButtonClicked.ButtonClickedEvent   += UiBtnCommandForeignKey_ButtonClicked;
                }
                (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedDbContext =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext;
                (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedEntity =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;
                (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).DoAnaliseEx();
                this.CurrentUserControl = SelectForeignKeyUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 3:
                CurrentUiStepId = 4;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                if (CreateForeignKeyUC == null)
                {
                    CreateForeignKeyViewModel dataContext = new CreateForeignKeyViewModel(Dte, TextTemplating);
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    dataContext.TemplateFolder                = Path.Combine(TemplatesFld, "ForeignKeyTmplts");
                    dataContext.TemplateOneToOneFolder        = Path.Combine(TemplatesFld, "ForeignKeyTmplts", "OneToOne");
                    dataContext.TemplateOneToCollectionFolder = Path.Combine(TemplatesFld, "ForeignKeyTmplts", "OneToCollection");
                    dataContext.IsReady.IsReadyEvent         += SelectForeignKeyViewModel_IsReady;
                    CreateForeignKeyUC = new UserControlCreateForeignKey(dataContext);
                }
                (CreateForeignKeyUC.DataContext as CreateForeignKeyViewModel).SelectedDbContext =
                    (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedDbContext;
                (CreateForeignKeyUC.DataContext as CreateForeignKeyViewModel).SelectedEntity =
                    (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedEntity;

                string navName = null;
                if (param is FluentAPIForeignKey)
                {
                    if ((param as FluentAPIForeignKey) != null)
                    {
                        navName = (param as FluentAPIForeignKey).NavigationName;
                    }
                }
                (CreateForeignKeyUC.DataContext as CreateForeignKeyViewModel).DoAnalise(navName);
                if (string.IsNullOrEmpty(navName))
                {
                    (CreateForeignKeyUC.DataContext as CreateForeignKeyViewModel).SelectedForeignKey =
                        (SelectForeignKeyUC.DataContext as SelectForeignKeyViewModel).SelectedForeignKey;
                }

                this.CurrentUserControl = CreateForeignKeyUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 4:
                CurrentUiStepId = 1;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                NextBtnCommandAction(param);
                break;

            case 100:
                CurrentUiStepId = 101;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (T4SelectTemplateUC == null)
                {
                    Selectt4TemplateViewModel dataContext = new Selectt4TemplateViewModel();
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    dataContext.TemplateFolder        = Path.Combine(TemplatesFld, "DbContextTmplts");
                    dataContext.IsReady.IsReadyEvent += Selectt4TemplateViewModel_IsReady;
                    T4SelectTemplateUC = new UserControlT4SelectTemplate(dataContext);
                }
                (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).DoAnalise();
                this.CurrentUserControl = T4SelectTemplateUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 101:
                CurrentUiStepId = 102;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                string templatePath101 = Path.Combine(
                    (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).TemplateFolder,
                    (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate);
                if (T4Editor == null)
                {
                    T4EditorViewModel dataContext = new T4EditorViewModel((T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).TemplateFolder);
                    dataContext.T4SelectedTemplate = (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate;
                    dataContext.T4TempateCaption   = (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate;
                    T4Editor = new UserControlT4Editor(dataContext);
                }
                else
                {
                    if (!templatePath101.Equals((T4Editor.DataContext as T4EditorViewModel).T4TempatePath, StringComparison.OrdinalIgnoreCase))
                    {
                        (T4Editor.DataContext as T4EditorViewModel).T4SelectedTemplate = (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate;
                        (T4Editor.DataContext as T4EditorViewModel).T4TempateCaption   = (T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).SelectedTemplate;
                        (T4Editor.DataContext as T4EditorViewModel).T4TempatePath      = templatePath101;
                        (T4Editor.DataContext as T4EditorViewModel).ReadTemplate();
                    }
                }
                if (!(T4SelectTemplateUC.DataContext as Selectt4TemplateViewModel).ShowT4Template)
                {
                    NextBtnCommandAction(param);
                    return;
                }
                this.CurrentUserControl = T4Editor;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 102:
                CurrentUiStepId = 103;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = false;
                if (GenerateDbContextUC == null)
                {
                    GenerateDbContextViewModel dataContext = new GenerateDbContextViewModel();
                    dataContext.IsReady.IsReadyEvent += GenerateDbContext_IsReady;
                    GenerateDbContextUC = new UserControlGenerate(dataContext);
                }
                (GenerateDbContextUC.DataContext as GenerateDbContextViewModel).GenText =
                    (T4Editor.DataContext as T4EditorViewModel).T4TempateText;

                string nameSpace102 = (InvitationUC.DataContext as InvitationViewModel).DefaultProjectNameSpace;
                string folder102    = (InvitationUC.DataContext as InvitationViewModel).DestinationFolder;
                if (!string.IsNullOrEmpty(folder102))
                {
                    nameSpace102 = nameSpace102 + "." + folder102.Replace("\\", ".");
                }
                (GenerateDbContextUC.DataContext as GenerateDbContextViewModel).DoGenerateDbContext(Dte, TextTemplating, (T4Editor.DataContext as T4EditorViewModel).T4TempatePath, nameSpace102, (SelectDbContextUC.DataContext as SelectDbContextViewModel).UiCommandProppertyName);
                this.CurrentUserControl = GenerateDbContextUC;
                this.OnPropertyChanged("CurrentUserControl");

                break;

            case 103:
                (SelectDbContextUC.DataContext as SelectDbContextViewModel).CollectProjectClasses((SelectDbContextUC.DataContext as SelectDbContextViewModel).SelectedProject);
                CurrentUiStepId = 0;
                NextBtnCommandAction(param);
                break;

            case 200:
                CurrentUiStepId = 201;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                if (CreatePrimKeyUC == null)
                {
                    CreatePrimaryKeyViewModel dataContext = new CreatePrimaryKeyViewModel(Dte, TextTemplating);
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    dataContext.TemplateFolder = Path.Combine(TemplatesFld, "HasKeyTmplst");
                    CreatePrimKeyUC            = new UserControlCreatePrimKey(dataContext);
                }
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).SelectedDbContext =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext;
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).SelectedEntity =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).DoAnalise();
                this.CurrentUserControl = CreatePrimKeyUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 201:
                CurrentUiStepId = 1;
                NextBtnCommandAction(param);
                break;

            case 300:
                CurrentUiStepId = 301;
                PrevBtnEnabled  = true;
                NextBtnEnabled  = true;
                if (CreatePrimKeyUC == null)
                {
                    CreatePrimaryKeyViewModel dataContext = new CreatePrimaryKeyViewModel(Dte, TextTemplating);
                    string TemplatesFld = TemplatePathHelper.GetTemplatePath();
                    dataContext.TemplateFolder = Path.Combine(TemplatesFld, "HasKeyTmplst");
                    CreatePrimKeyUC            = new UserControlCreatePrimKey(dataContext);
                }
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).SelectedDbContext =
                    (SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedDbContext;
                //(CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).SelectedEntity =
                //(SelectSourceEntityUC.DataContext as SelectEntityForGivenDbContextViewModel).SelectedCodeElement;
                (CreatePrimKeyUC.DataContext as CreatePrimaryKeyViewModel).DoAnalise();
                this.CurrentUserControl = CreatePrimKeyUC;
                this.OnPropertyChanged("CurrentUserControl");
                break;

            case 301:
                CurrentUiStepId = 4;
                PrevBtnCommandAction(param);
                break;


            default:
                break;
            }
        }