Exemplo n.º 1
0
        public SchemaDomainObject Update(UpdateSchema command)
        {
            VerifyCreatedAndNotDeleted();

            RaiseEvent(SimpleMapper.Map(command, new SchemaUpdated()));

            return(this);
        }
Exemplo n.º 2
0
        protected Task On(UpdateSchema command, CommandContext context)
        {
            return(handler.UpdateSyncedAsync <SchemaDomainObject>(context, s =>
            {
                GuardSchema.CanUpdate(s.Snapshot.SchemaDef, command);

                s.Update(command);
            }));
        }
Exemplo n.º 3
0
        public SchemaDomainObject Update(UpdateSchema command)
        {
            Guard.Valid(command, nameof(command), () => $"Cannot update schema '{Id}'");

            VerifyCreatedAndNotDeleted();

            RaiseEvent(SimpleMapper.Map(command, new SchemaUpdated()));

            return(this);
        }
        public async Task Should_assign_schema_id_from_id()
        {
            actionContext.RouteData.Values["name"] = schemaId.Name;

            var command = new UpdateSchema();
            var context = new CommandContext(command, commandBus);

            await sut.HandleAsync(context);

            Assert.Equal(schemaId.Id, command.SchemaId);
        }
        public async Task Should_assign_schema_id_from_id()
        {
            httpContext.Features.Set <ISchemaFeature>(new SchemaFeature(schemaId));

            var command = new UpdateSchema();
            var context = Ctx(command);

            await sut.HandleAsync(context);

            Assert.Equal(schemaId, command.SchemaId);
        }
Exemplo n.º 6
0
        public async Task Should_assign_schema_id_from_id()
        {
            SetupApp(out var appId, out _);
            SetupSchema(appId, out var schemaId, out _);

            actionContext.RouteData.Values["name"] = schemaId.ToString();

            var command = new UpdateSchema();
            var context = new CommandContext(command, commandBus);

            await sut.HandleAsync(context);

            Assert.Equal(schemaId, command.SchemaId);
        }
Exemplo n.º 7
0
        public async Task Update_should_create_events_and_update_state()
        {
            var command = new UpdateSchema { Properties = new SchemaProperties() };

            await ExecuteCreateAsync();

            var result = await sut.ExecuteAsync(CreateCommand(command));

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.Equal(command.Properties, sut.Snapshot.SchemaDef.Properties);

            LastEvents
                .ShouldHaveSameEvents(
                    CreateEvent(new SchemaUpdated { Properties = command.Properties })
                );
        }
Exemplo n.º 8
0
        public async Task Should_update_index_with_result_when_schema_is_updated()
        {
            var(schema, schemaGrain) = SetupSchema();

            var command = new UpdateSchema {
                SchemaId = schemaId, AppId = appId
            };

            var context =
                new CommandContext(command, commandBus)
                .Complete(schema);

            await sut.HandleAsync(context);

            A.CallTo(() => schemaGrain.GetStateAsync())
            .MustNotHaveHappened();
        }
Exemplo n.º 9
0
        public async Task Update_should_create_events_and_update_schema_properties()
        {
            var command = new UpdateSchema {
                Properties = new SchemaProperties {
                    Label = "My Properties"
                }
            };

            await ExecuteCreateAsync();

            var result = await PublishIdempotentAsync(command);

            result.ShouldBeEquivalent(sut.Snapshot);

            Assert.Equal(command.Properties, sut.Snapshot.SchemaDef.Properties);

            LastEvents
            .ShouldHaveSameEvents(
                CreateEvent(new SchemaUpdated {
                Properties = command.Properties
            })
                );
        }
Exemplo n.º 10
0
 public void Update(UpdateSchema command)
 {
     RaiseEvent(command, new SchemaUpdated());
 }
 protected Task On(UpdateSchema command, CommandContext context)
 {
     return(handler.UpdateAsync <SchemaDomainObject>(context, s => s.Update(command)));
 }
Exemplo n.º 12
0
 private void Update(UpdateSchema command)
 {
     Raise(command, new SchemaUpdated());
 }
Exemplo n.º 13
0
 public static void CanUpdate(UpdateSchema command)
 {
     Guard.NotNull(command);
 }
Exemplo n.º 14
0
        public UpdateSchema NewUpdatesAvailable()
        {
            Uri updateUri = new Uri(Config.Instance.UpdateLocation + Config.Instance.UpdatesXmlFileName);

            string updateXml = null;

            if (updateUri.IsFile)
            {
                updateXml = System.IO.File.ReadAllText(updateUri.LocalPath);
            }
            else
            {
                HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(updateUri);
                httpRequest.Method  = "GET";
                httpRequest.Timeout = 30000;                 //30 sec

                HttpWebResponse response = null;

                try
                {
                    response = (HttpWebResponse)httpRequest.GetResponse();


                    Stream streamResponse = response.GetResponseStream();

                    try
                    {
                        using (TextReader reader = new StreamReader(streamResponse))
                        {
                            updateXml = reader.ReadToEnd();
                        }
                    }
                    finally
                    {
                        streamResponse.Close();
                    }
                }
                finally
                {
                    // Close response
                    if (response != null)
                    {
                        response.Close();
                    }
                }
            }

            if (updateXml != null)
            {
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(updateXml);

                UpdateSchema updateSchema = new UpdateSchema(xmlDoc);

                if (updateSchema.NewUpdatesAvailable(tangra3Path))
                {
                    return(updateSchema);
                }
            }


            return(null);
        }
Exemplo n.º 15
0
 public static void CanUpdate(Schema schema, UpdateSchema command)
 {
     Guard.NotNull(command, nameof(command));
 }
Exemplo n.º 16
0
 public void Update(UpdateSchema command)
 {
     RaiseEvent(SimpleMapper.Map(command, new SchemaUpdated()));
 }
Exemplo n.º 17
0
        private void updateTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                updateTimer.Enabled = false;

                UpdateSchema schema = updater.NewUpdatesAvailable();
                if (schema != null)
                {
                    List <UpdateObject> modulesToUpdate = new List <UpdateObject>();

                    #region Get all modules to update and refresh the information in the UI about thse updates
                    foreach (UpdateObject module in schema.AllUpdateObjects)
                    {
                        if (!module.NewUpdatesAvailable(tangra3Path))
                        {
                            continue;
                        }

                        if (!(module is Schema.SoftwareUpdate))
                        {
                            modulesToUpdate.Add(module);
                        }
                    }

                    if (modulesToUpdate.Count > 0)
                    {
                        lbModulesToUpdate.Items.Clear();
                        foreach (UpdateObject module in modulesToUpdate)
                        {
                            if (module is Schema.SoftwareMainUpdate)
                            {
                                lbModulesToUpdate.Items.Add(SharedUpdateConstants.MAIN_PROGRAM_NAME);
                            }
                            else if (module is Schema.ModuleUpdate)
                            {
                                lbModulesToUpdate.Items.Add((module as Schema.ModuleUpdate).ModuleName);
                            }
                        }

                        if (modulesToUpdate.Count > 1)
                        {
                            // We only show a list of updates if there is more than one component to update
                            SetMaxiLayout();
                        }
                    }
                    #endregion

                    if (schema.AutoUpdate != null &&
                        schema.AutoUpdate.NewUpdatesAvailable(tangra3Path))
                    {
                        // Update the AutoUpdate. Will need to start another process to finish this
                        // and store the assembly for this other process as a resource

                        schema.AutoUpdate.Update(updater, tangra3Path, acceptBetaUpdates, this);
                        if (m_Abort)
                        {
                            return;
                        }
                    }

                    #region Setup the Progress Bar and compute the files to be updated
                    m_allFilesToUpdate = 0;
                    m_CurrentFileIndex = 0;
                    foreach (UpdateObject module in modulesToUpdate)
                    {
                        if (module.NewUpdatesAvailable(tangra3Path))
                        {
                            m_allFilesToUpdate += module.AllFiles.Count;
                        }
                    }

                    pbUpdate.Maximum = m_allFilesToUpdate + 2;
                    pbUpdate.Value   = 1;
                    pbUpdate.Style   = ProgressBarStyle.Continuous;
                    #endregion

                    #region Prepare: Kill running instances of Tangra3
                    lblStatus.Text = "Preparing to update ...";
                    pbUpdate.Update();
                    lblStatus.Update();


                    //NOTE: Delete the OWSelfUpdate.exe file if the key presents in the registry
                    //      then set the key value to an empty string.
                    if (!string.IsNullOrEmpty(Config.Instance.SelfUpdateFileNameToDelete))
                    {
                        try
                        {
                            if (System.IO.File.Exists(Config.Instance.SelfUpdateFileNameToDelete))
                            {
                                System.IO.File.Delete(Config.Instance.SelfUpdateFileNameToDelete);
                            }

                            Config.Instance.ResetSelfUpdateFileName();
                        }
                        catch (Exception)
                        { }
                    }

                    pbUpdate.Value = 1;
                    pbUpdate.Update();
                    updater.PrepareToUpdate();
                    #endregion

                    lblStatus.Text = "Downloading ...";
                    pbUpdate.Value = 2;
                    pbUpdate.Update();
                    lblStatus.Update();

                    foreach (UpdateObject module in modulesToUpdate)
                    {
                        if (module.NewUpdatesAvailable(tangra3Path))
                        {
                            lblInfo.Text = string.Format("Updating {0} to {3}version {1} released on {2}", module.ModuleName, module.VersionString, module.ReleaseDate, acceptBetaUpdates ? "beta " : "");
                            lblInfo.Update();

                            Thread thr = new Thread(new ParameterizedThreadStart(UpdateWorkerThread));
                            thr.Start(new KeyValuePair <UpdateObject, IProgressUpdate>(module, this));

                            while (thr.IsAlive)
                            {
                                Update();
                                Application.DoEvents();
                                Thread.Sleep(250);
                            }

                            thr = null;
                            if (m_Abort)
                            {
                                return;
                            }
                        }
                    }

                    lblStatus.Text = "Restarting " + SharedUpdateConstants.MAIN_PROGRAM_NAME + " ...";
                    pbUpdate.Value = pbUpdate.Maximum;
                    pbUpdate.Update();
                    lblStatus.Update();

                    System.Threading.Thread.Sleep(1000);

                    if (System.IO.File.Exists(Config.Instance.Tangra3ExePath(tangra3Path)))
                    {
                        Process.Start(Config.Instance.Tangra3ExePath(tangra3Path));
                    }

                    this.Close();
                    Application.Exit();
                }
                else
                {
                    // No new updates
                    lblStatus.Text = string.Format("There are no new {0}updates available", acceptBetaUpdates ? "beta " : "");
                    int currVer = Config.Instance.CurrentlyInstalledTangra3Version(tangra3Path);
                    lblInfo.Text     = string.Format("Your version {0} is the latest", Config.Instance.VersionToVersionString(currVer));
                    pbUpdate.Maximum = 10;
                    pbUpdate.Value   = 10;
                    pbUpdate.Style   = ProgressBarStyle.Continuous;
                }
            }
            catch (Exception ex)
            {
                s_Error = ex;
                Close();
            }
        }