public ModelDesigner(Dictionary<string, string> connectionStrings, DalConfig config)
        {
            this.connectionStrings = connectionStrings;
            this.config = config;

            InitializeComponent();

            CustomizeComponent();

            WireUpEventHandlers();
        }
예제 #2
0
        public void Init(DalConfig config, string fileName, SimpleDataAccessLayerConfigFileEditorPackage package)
        {
            connectionStrings = InitializeConectionStringsCollection(package, fileName);
            this.package = package;
            this.config = config;
            this.fileName = fileName;

            if (config == null)
            {
                HandleInvalidFileFormat();
            }
            else
            {
                InitControls();
            }
        }
 internal void SetStaticData(DalConfig dalConfig)
 {
     this.dalConfig = dalConfig;
     PrepareConfigProceduresCollection();
 }
        /// <summary>
        /// Sets the initial data - existing connection strings and current config
        /// </summary>
        /// <param name="package"></param>
        internal void SetStaticData(Dictionary<string, string> connectionStrings, DalConfig config)
        {
            // this is called after all components of this control are initialized, so it is safe to populate all data
            this.connectionStrings = connectionStrings;
            this.dalConfig = config;

            PopulateFormFields();
        }
예제 #5
0
        private void Edit_Click(object sender, EventArgs e)
        {
            ModelDesigner _modelDesignerDialog = new ModelDesigner(this.connectionStrings, this.config);
            DialogResult _dialogResult = _modelDesignerDialog.ShowDialog();
            if (_dialogResult == DialogResult.OK)
            {
                this.config = _modelDesignerDialog.Config;
                String _connectionStringName = _modelDesignerDialog.ConnectionStringName;
                if (!connectionStrings.ContainsKey(_connectionStringName))
                {
                    connectionStrings.Add(_connectionStringName, _modelDesignerDialog.ConnectionString);
                    //AddConnectionStringToProject(_connectionStringName, _modelDesignerDialog.ConnectionString);
                }
            }

            InitControls();
        }
        internal void SetStaticData(DalConfig config)
        {
            // this is called after all components of this control are initialized, so it is safe to populate all data
            this.dalConfig = config;

            PopulateFormFields();
        }
		/// <summary>
		/// Loads the file content into the textbox
		/// </summary>
		/// <param name="pszFilename">Pointer to the full path name of the file to load</param>
		/// <param name="grfMode">file format mode</param>
		/// <param name="fReadOnly">determines if the file should be opened as read only</param>
		/// <returns>S_OK if the method succeeds</returns>
		int IPersistFileFormat.Load(string pszFilename, uint grfMode, int fReadOnly)
		{
			if (pszFilename == null)
			{
				return VSConstants.E_INVALIDARG;
			}

			loading = true;
			int hr = VSConstants.S_OK;
			try
			{
				// Show the wait cursor while loading the file
				IVsUIShell VsUiShell = (IVsUIShell)GetService(typeof(SVsUIShell));
				if (VsUiShell != null)
				{
					// Note: we don't want to throw or exit if this call fails, so
					// don't check the return code.
					hr = VsUiShell.SetWaitCursor();
				}

				DalConfig _config = null;
				try
				{
					DataContractSerializer _ser = new DataContractSerializer(typeof(DalConfig));
					_config = (DalConfig)_ser.ReadObject(XmlReader.Create(pszFilename));
				}
				catch
				{
					_config = new DalConfig()
					{
						ApplicationConnectionString = "",
						DesignerConnection = new DesignerConnection() { Authentication = new WindowsAuthentication() },
						Enums = new System.Collections.Generic.List<Enum>(),
						Namespace = "",
						Procedures = new System.Collections.Generic.List<Procedure>()
					};
				}
				finally
				{
					editorControl.Init(_config, pszFilename, myPackage);
				}

				isDirty = false;

				//Determine if the file is read only on the file system
				FileAttributes fileAttrs = File.GetAttributes(pszFilename);

				int isReadOnly = (int)fileAttrs & (int)FileAttributes.ReadOnly;

				//Set readonly if either the file is readonly for the user or on the file system
				if (0 == isReadOnly && 0 == fReadOnly)
					SetReadOnly(false);
				else
					SetReadOnly(true);


				// Notify to the property window that some of the selected objects are changed
				ITrackSelection track = TrackSelection;
				if (null != track)
				{
					hr = track.OnSelectChange((ISelectionContainer)selContainer);
					if (ErrorHandler.Failed(hr))
						return hr;
				}

				// Hook up to file change notifications
				if (String.IsNullOrEmpty(fileName) || 0 != String.Compare(fileName, pszFilename, true, CultureInfo.CurrentCulture))
				{
					fileName = pszFilename;
					SetFileChangeNotification(pszFilename, true);

					// Notify the load or reload
					NotifyDocChanged();
				}
			}
			finally
			{
				loading = false;
			}
			return VSConstants.S_OK;
		}
        private void finishButton_Click(object sender, EventArgs e)
        {
            DalConfig _config = new DalConfig()
            {
                ApplicationConnectionString = appConnectionTab.ConnectionStringName,
                DesignerConnection = new DesignerConnection()
                {
                    Authentication = designerInformationTab.WindowsAuthentication ? new WindowsAuthentication() as Authentication : new SqlAuthentication(designerInformationTab.Username, designerInformationTab.Password) as Authentication
                },
                Namespace = designerInformationTab.Namespace,
                Enums = enumsTab.SelectedEnums,
                Procedures = proceduresTab.SelectedProcedures
            };

            this.config = _config;
        }