コード例 #1
0
ファイル: GreyFoxRoleEditor.cs プロジェクト: rahodges/Amns
        protected void ok_Click(object sender, EventArgs e)
        {
            if (greyFoxRoleID == 0)
            {
                obj = new GreyFoxRole();
            }
            else
            {
                obj = new GreyFoxRole(greyFoxRoleID);
            }

            obj.Name        = tbName.Text;
            obj.Description = tbDescription.Text;
            obj.IsDisabled  = cbIsDisabled.Checked;

            if (editOnAdd)
            {
                greyFoxRoleID = obj.Save();
            }
            else
            {
                obj.Save();
            }

            if (resetOnAdd)
            {
                tbName.Text          = string.Empty;
                tbDescription.Text   = string.Empty;
                cbIsDisabled.Checked = false;
            }

            OnUpdated(EventArgs.Empty);
        }
コード例 #2
0
        /// <summary>
        /// Initializes the database with the necissary tables to support the content
        /// manager as well as creating a default content catalog and associated roles
        /// in the Amns.GreyFox user's database.
        /// </summary>
        /// <returns></returns>
        public void Install()
        {
            OleDbConnection  dbConnection = new OleDbConnection(dbConnectionString);
            OleDbCommand     dbCommand    = new OleDbCommand();
            OleDbTransaction dbTransaction;

            dbCommand.Connection = dbConnection;

            // Try to open database
            try
            {
                dbConnection.Open();
                dbTransaction = dbConnection.BeginTransaction();
            }
            catch (OleDbException e)
            {
                throw(new ContentManagerException(e.Message, e.ErrorCode));
            }

            // Try to create table to hold catalogs
            try
            {
                //
                dbCommand.CommandText = createCatalogTable;
                dbCommand.Transaction = dbTransaction;
                dbCommand.ExecuteNonQuery();

                GreyFoxRole authorRole = new GreyFoxRole(dbConnectionString);
                authorRole.Name        = "CMS/Author";
                authorRole.Description = "Default Author";
                authorRole.IsDisabled  = false;
                authorRole.Save();

                GreyFoxRole reviewerRole = new GreyFoxRole(dbConnectionString);
                reviewerRole.Name        = "CMS/Reviewer";
                reviewerRole.Description = "Default Reviewer";
                reviewerRole.IsDisabled  = false;
                reviewerRole.Save();

                GreyFoxRole editorRole = new GreyFoxRole(dbConnectionString);
                editorRole.Name        = "CMS/Editor";
                editorRole.Description = "Default CMS Editor";
                editorRole.IsDisabled  = false;
                editorRole.Save();

                GreyFoxRole publisherRole = new GreyFoxRole(dbConnectionString);
                publisherRole.Name        = "CMS/Publisher";
                publisherRole.Description = "Default CMS Publisher";
                publisherRole.IsDisabled  = false;

                GreyFoxRole adminRole = new GreyFoxRole(dbConnectionString);
                adminRole.Name        = "CMS/Admin";
                adminRole.Description = "Default CMS Administrator";
                adminRole.IsDisabled  = false;
                adminRole.Save();

                iD = createCatalog(dbCommand);

                dbTransaction.Commit();
                sync = true;
            }
            catch (OleDbException e)
            {
                iD = 0;
                dbTransaction.Rollback();
                throw(new ContentManagerException(e.Message + " SQL: " + sqlStatement, e.ErrorCode));
            }
            finally
            {
                dbConnection.Close();
            }

            Log.InsertGenericEvent(DateTime.Now.ToUniversalTime(), ContentLogEntryType.CatalogCreateSuccess, iD);
        }