Exemplo n.º 1
0
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            var msg        = new ExecuteMessage();
            var serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save Resource Service", GlobalConstants.WarewolfInfo);

                values.TryGetValue("ServerSettings", out StringBuilder resourceDefinition);

                var updatedServerSettings = serializer.Deserialize <ServerSettingsData>(resourceDefinition);

                var sourceFilePath = Config.Server.AuditFilePath;

                var auditsFilePath = updatedServerSettings.AuditFilePath;

                if (sourceFilePath != auditsFilePath)
                {
                    var   source = Path.Combine(sourceFilePath, "auditDB.db");
                    IFile _file  = new FileWrapper();
                    if (_file.Exists(source))
                    {
                        var destination = Path.Combine(auditsFilePath, "auditDB.db");
                        CreateIfNotExists(auditsFilePath);
                        _file.Move(source, destination);
                        Config.Server.AuditFilePath = auditsFilePath;
                        msg.Message = new StringBuilder("Moved");
                    }
                }
                else
                {
                    msg.Message = new StringBuilder();
                }
                msg.HasError = false;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err, GlobalConstants.WarewolfError);
            }
            return(serializer.SerializeToBuilder(msg));
        }