Пример #1
0
        public void DoWork(InstallModel model)
        {
            var traceListener = new SignalRTraceListener();
            Trace.Listeners.Add(traceListener);

            try
            {
                SetupDb(ConnectionHelper.SqlConnectionString, model.SetupSampleData);
                SendFriendlyMessage("Database successfully created.");
                UpdateIndex(model);
            }
            catch (Exception ex)
            {
                TraceMessageLine(ex.Message);
                Clients.All.failure(ex.Message);
                return;
            }
            finally
            {
                Trace.Listeners.Remove(traceListener);
            }

            Clients.All.success("Database created.");

        }
        public void DoWork(InstallModel model)
        {
            var traceListener = new SignalRTraceListener();

            Trace.Listeners.Add(traceListener);

            try
            {
                SetupDb(ConnectionHelper.SqlConnectionString, model.SetupSampleData);
                SendFriendlyMessage("Database successfully created.");
                UpdateIndex(model);
            }
            catch (Exception ex)
            {
                TraceMessageLine(ex.Message);
                Clients.All.failure(ex.Message);
                return;
            }
            finally
            {
                Trace.Listeners.Remove(traceListener);
            }

            Clients.All.success("Database created.");
        }
Пример #3
0
        public JsonResult Index(InstallModel model)
        {
            CustomValidateModel(model);

            if (!ModelState.IsValid)
            {
                var errorModel =
                       from x in ModelState.Keys
                       where ModelState[x].Errors.Count > 0
                       select new
                       {
                           key = x,
                           errors = ModelState[x].Errors.
                                                  Select(y => y.ErrorMessage).
                                                  ToArray()
                       };

                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return Json(errorModel);
            }

            var traceListener = new SignalRTraceListener();
            Trace.Listeners.Add(traceListener);

            try
            {
                var connectionString = PrepareDb(model);
                SetupWorker.SendFriendlyMessage("Saving database connection string to web.config.");
                //After saving connection string signalR needs some time to recycle iis
                ConnectionHelper.SqlConnectionString = connectionString;

            }
            catch (Exception ex)
            {
                SetupWorker.TraceMessageLine(ex.Message);
                return Json(new { Success = false, ex.Message });
            }
            finally
            {
                Trace.Listeners.Remove(traceListener);
            }

            return Json(new { Success = true });

        }