Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DatabaseUpdate du = new DatabaseUpdate();

            if (!string.IsNullOrEmpty(Request.QueryString["signout"])) {
                FormsAuthentication.SignOut();
            }

            List<DatabaseUpdateMessage> lst = new List<DatabaseUpdateMessage>();

            btnLogin.Visible = false;
            btnCreate.Visible = false;

            if (DatabaseUpdate.LastSQLError != null) {
                du.HandleResponse(lst, DatabaseUpdate.LastSQLError);
                DatabaseUpdate.LastSQLError = null;
            } else {
                bool bUpdate = true;

                if (!du.DoCMSTablesExist()) {
                    bUpdate = false;
                }

                bUpdate = du.DatabaseNeedsUpdate();

                if (bUpdate) {
                    DatabaseUpdateStatus status = du.PerformUpdates();
                    lst = du.MergeMessages(lst, status.Messages);
                } else {
                    DataInfo ver = DatabaseUpdate.GetDbSchemaVersion();
                    du.HandleResponse(lst, "Database up-to-date [" + ver.DataValue + "] ");
                }

                bUpdate = du.DatabaseNeedsUpdate();

                if (!bUpdate && DatabaseUpdate.LastSQLError == null) {
                    if (du.UsersExist) {
                        btnLogin.Visible = true;
                    } else {
                        btnCreate.Visible = true;
                    }
                }
            }

            if (DatabaseUpdate.LastSQLError != null) {
                du.HandleResponse(lst, DatabaseUpdate.LastSQLError);
            }

            if (lst.Where(x => !string.IsNullOrEmpty(x.ExceptionText)).Count() > 0) {
                bOK = false;
            } else {
                bOK = true;
            }

            GeneralUtilities.BindRepeater(rpMessages, lst.OrderBy(x => x.Order));

            using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) {
                cmsHelper.ResetConfigs();
            }
        }
		public ActionResult CalendarDatabase() {
			List<string> lst = new List<string>();

			DatabaseUpdate du = new DatabaseUpdate();
			DatabaseUpdateResponse dbRes = new DatabaseUpdateResponse();

			string sqlUpdate = String.Empty;
			string sqlTest = String.Empty;

			try {
				sqlUpdate = WebHelper.ReadEmbededScript("CarrotCake.CMS.Plugins.CalendarModule.tblCalendar.sql");

				sqlTest = "select * from [INFORMATION_SCHEMA].[COLUMNS] where table_name in('tblCalendar')";
				dbRes = du.ApplyUpdateIfNotFound(sqlTest, sqlUpdate, false);

				if (dbRes.LastException != null && !string.IsNullOrEmpty(dbRes.LastException.Message)) {
					lst.Add(dbRes.LastException.Message);
				} else {
					lst.Add(dbRes.Response);
				}
			} catch (Exception ex) {
				lst.Add(ex.ToString());
			}

			return View(lst);
		}
 protected void Page_Load(object sender, EventArgs e)
 {
     DatabaseUpdate du = new DatabaseUpdate();
     if (du.UsersExist) {
         createWizard.Visible = false;
         lblLogon.Visible = true;
     } else {
         createWizard.Visible = true;
         lblLogon.Visible = false;
     }
 }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DatabaseUpdate du = new DatabaseUpdate();
            divMsg.Visible = false;

            lnkForgot.HRef = SiteFilename.ForgotPasswordURL;

            if (DatabaseUpdate.FailedSQL || du.DatabaseNeedsUpdate() || !du.UsersExist) {
                FormsAuthentication.SignOut();
                Response.Redirect(SiteFilename.DatabaseSetupURL);
            }

            if (Page.User.Identity.IsAuthenticated) {
                Response.Redirect(SiteFilename.DashboardURL);
            }
        }
		protected void Page_Load(object sender, EventArgs e) {
			DatabaseUpdate du = new DatabaseUpdate();
			DatabaseUpdateResponse dbRes = new DatabaseUpdateResponse();
			string sqlUpdate = "";
			string sqlTest = "";
			int iCt = 0;
			litMsg.Text = "";

			sqlUpdate = ReadEmbededScript("Carrotware.CMS.UI.Plugins.EventCalendarModule.carrot_CalendarEvent.sql");
			sqlTest = "select * from information_schema.columns where table_name = 'carrot_CalendarEventProfile' and column_name = 'RecursEvery'";
			dbRes = du.ApplyUpdateIfNotFound(sqlTest, sqlUpdate, false);
			iCt++;

			if (dbRes.LastException != null && !string.IsNullOrEmpty(dbRes.LastException.Message)) {
				litMsg.Text += iCt.ToString() + ")  " + dbRes.LastException.Message + "<br />";
			} else {
				litMsg.Text += iCt.ToString() + ")  " + dbRes.Response + "<br />";
			}
		}
        protected void Page_Load(object sender, EventArgs e)
        {
            DatabaseUpdate du = new DatabaseUpdate();
            DatabaseUpdateResponse dbRes = new DatabaseUpdateResponse();
            string sqlUpdate = "";
            string sqlTest = "";
            int iCt = 0;
            litMsg.Text = "";

            sqlUpdate = ReadEmbededScript("Carrotware.CMS.UI.Plugins.FAQ2Module.carrot_FaqItem.sql");
            sqlTest = "select * from [INFORMATION_SCHEMA].[COLUMNS] where table_name in('carrot_FaqItem')";
            dbRes = du.ApplyUpdateIfNotFound(sqlTest, sqlUpdate, false);
            iCt++;

            if (dbRes.LastException != null && !string.IsNullOrEmpty(dbRes.LastException.Message)) {
                litMsg.Text += iCt.ToString() + ")  " + dbRes.LastException.Message + "<br />";
            } else {
                litMsg.Text += iCt.ToString() + ")  " + dbRes.Response + "<br />";
            }
        }
		protected void Page_Load(object sender, EventArgs e) {
			DatabaseUpdate du = new DatabaseUpdate();
			DatabaseUpdateResponse dbRes = new DatabaseUpdateResponse();
			string sqlUpdate = "";
			string sqlTest = "";
			int iCt = 0;
			litMsg.Text = "";

			sqlUpdate = ReadEmbededScript("Carrotware.CMS.UI.Plugins.PhotoGallery.tblGallery.sql");

			sqlTest = "select * from [information_schema].[columns] where table_name in('tblGalleryImageMeta')";
			dbRes = du.ApplyUpdateIfNotFound(sqlTest, sqlUpdate, false);
			iCt++;

			if (dbRes.LastException != null && !string.IsNullOrEmpty(dbRes.LastException.Message)) {
				litMsg.Text += iCt.ToString() + ")  " + dbRes.LastException.Message + "<br />";
			} else {
				litMsg.Text += iCt.ToString() + ")  " + dbRes.Response + "<br />";
			}

		}
		public ActionResult DatabaseSetup(string signout) {
			DatabaseSetupModel model = new DatabaseSetupModel();

			DatabaseUpdate du = new DatabaseUpdate(true);

			if (!String.IsNullOrEmpty(signout)) {
				SignOut();
			}

			List<DatabaseUpdateMessage> lst = new List<DatabaseUpdateMessage>();
			model.Messages = lst;

			if (DatabaseUpdate.LastSQLError != null) {
				du.HandleResponse(lst, DatabaseUpdate.LastSQLError);
				DatabaseUpdate.LastSQLError = null;
			} else {
				bool bUpdate = true;

				if (!du.DoCMSTablesExist()) {
					bUpdate = false;
				}

				bUpdate = du.DatabaseNeedsUpdate();

				try {
					model.CreateUser = !DatabaseUpdate.UsersExist;
				} catch { }

				if (bUpdate) {
					DatabaseUpdateStatus status = du.PerformUpdates();
					lst = du.MergeMessages(lst, status.Messages);
				} else {
					DataInfo ver = DatabaseUpdate.GetDbSchemaVersion();
					du.HandleResponse(lst, "Database up-to-date [" + ver.DataValue + "] ");
				}

				bUpdate = du.DatabaseNeedsUpdate();

				if (!bUpdate && DatabaseUpdate.LastSQLError == null) {
					model.CreateUser = !DatabaseUpdate.UsersExist;
				}
			}

			if (DatabaseUpdate.LastSQLError != null) {
				du.HandleResponse(lst, DatabaseUpdate.LastSQLError);
			}

			model.HasExceptions = lst.Where(x => !String.IsNullOrEmpty(x.ExceptionText)).Any();
			model.Messages = lst;

			using (CMSConfigHelper cmsHelper = new CMSConfigHelper()) {
				cmsHelper.ResetConfigs();
			}

			return View(model);
		}
        public ActionResult GalleryDatabase()
        {
            List<string> lst = new List<string>();

            DatabaseUpdate du = new DatabaseUpdate();
            DatabaseUpdateResponse dbRes = new DatabaseUpdateResponse();
            string sqlUpdate = "";
            string sqlTest = "";
            try {
                sqlUpdate = GalleryHelper.ReadEmbededScript("CarrotCake.CMS.Plugins.PhotoGallery.tblGallery.sql");

                sqlTest = "select * from [information_schema].[columns] where table_name in('tblGalleryImageMeta')";
                dbRes = du.ApplyUpdateIfNotFound(sqlTest, sqlUpdate, false);

                if (dbRes.LastException != null && !string.IsNullOrEmpty(dbRes.LastException.Message)) {
                    lst.Add(dbRes.LastException.Message);
                } else {
                    lst.Add(dbRes.Response);
                }
            } catch (Exception ex) {
                lst.Add(ex.ToString());
            }

            return View(lst);
        }
		public ActionResult CreateFirstAdmin(RegisterViewModel model) {
			DatabaseUpdate du = new DatabaseUpdate();
			if (du.UsersExist) {
				return RedirectToLocal("Index");
			}

			if (ModelState.IsValid) {
				SecurityData sd = new SecurityData();
				ApplicationUser user = new ApplicationUser { UserName = model.UserName, Email = model.Email };

				ExtendedUserData exUser = null;
				var result = sd.CreateApplicationUser(user, model.Password, out exUser);

				if (result.Succeeded) {
					SecurityData.AddUserToRole(model.UserName, SecurityData.CMSGroup_Admins);
					SecurityData.AddUserToRole(model.UserName, SecurityData.CMSGroup_Users);

					return RedirectToAction("Index");
				}

				AddErrors(result);
			}

			Helper.HandleErrorDict(ModelState);
			return View(model);
		}
		public ActionResult CreateFirstAdmin(string returnUrl) {
			securityHelper.AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

			DatabaseUpdate du = new DatabaseUpdate();
			if (du.UsersExist) {
				return RedirectToLocal("Index");
			}

			RegisterViewModel model = new RegisterViewModel();

			return View(model);
		}