Exemplo n.º 1
0
        public override async Task InitializeAsync(CancellationToken cancellationToken = default)
        {
            var body = await _deserializer.DeserializeAsync <QueryResultData>(ResponseStream, cancellationToken);

            MetaData = new QueryMetaData
            {
                RequestId       = body.requestID.ToString(),
                ClientContextId = body.clientContextID,
                Signature       = body.signature,
                Profile         = body.profile,
                Metrics         = body.metrics?.ToMetrics()
            };

            if (Enum.TryParse(body.status, true, out QueryStatus status))
            {
                MetaData.Status = status;
                Success         = status == QueryStatus.Success;
            }

            PreparedPlanName = body.prepared;

            if (body.warnings != null)
            {
                MetaData.Warnings.AddRange(body.warnings.Select(p => p.ToWarning()));
            }
            if (body.errors != null)
            {
                Errors.AddRange(body.errors.Select(p => p.ToError()));
            }

            _rows = body.results ?? Enumerable.Empty <T>();
        }
Exemplo n.º 2
0
 public void MergeResults(Result result, bool clearOnOk = false)
 {
     if (result == null)
     {
         return;
     }
     OK = OK && result.OK;
     if (!string.IsNullOrEmpty(result.Id))
     {
         Id = result.Id;
     }
     if (Errors == null)
     {
         Errors = new List <string>();
     }
     if (!OK)
     {
         if (result.Errors != null)
         {
             Errors.AddRange(result.Errors);
         }
     }
     else if (clearOnOk)
     {
         Errors.Clear();
     }
 }
Exemplo n.º 3
0
        private RepositoryResponse <bool> SaveRelatedPost(int id, MixCmsContext _context, IDbContextTransaction _transaction)
        {
            var result = new RepositoryResponse <bool>()
            {
                IsSucceed = true
            };

            foreach (var navPost in PostNavs)
            {
                navPost.SourceId       = id;
                navPost.Status         = MixEnums.MixContentStatus.Published;
                navPost.Specificulture = Specificulture;
                if (navPost.IsActived)
                {
                    var saveResult = navPost.SaveModel(false, _context, _transaction);
                    result.IsSucceed = saveResult.IsSucceed;
                    if (!result.IsSucceed)
                    {
                        result.Exception = saveResult.Exception;
                        Errors.AddRange(saveResult.Errors);
                    }
                }
                else
                {
                    var saveResult = navPost.RemoveModel(false, _context, _transaction);
                    result.IsSucceed = saveResult.IsSucceed;
                    if (!result.IsSucceed)
                    {
                        result.Exception = saveResult.Exception;
                        Errors.AddRange(saveResult.Errors);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        ///		Ejecuta un script de powershell
        /// </summary>
        private async Task ExecuteContentAsync(BlockLogModel block, string content, NormalizedDictionary <object> parameters, ExecuteScriptSentence sentence)
        {
            PowerShellManager manager = new PowerShellManager();

            // Carga el script en memoria
            manager.LoadScript(content);
            // Asigna los parámetros
            if (!AddParameters(manager, parameters, sentence, out string error))
            {
                Errors.Add(error);
            }
            else
            {
                // Ejecuta
                await manager.ExecuteAsync();

                // Comprueba los errores
                if (manager.Errors.Count > 0)
                {
                    Errors.AddRange(manager.Errors);
                }
                else if (manager.OutputItems.Count > 0)
                {
                    foreach (object output in manager.OutputItems)
                    {
                        block.Info($"{manager.OutputItems.IndexOf(output).ToString()}: {output?.ToString()}");
                    }
                }
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Основная функция, выполняющая все проверки
 /// </summary>
 /// <returns></returns>
 private void Validate()
 {
     try
     {
         Errors.Clear();
         // 1) конроль рекурсии (отсутствие циклических связей is_a и is_instance)
         Errors.AddRange(CheckRecursion());
         // 2) отсутствие экземпляров экземпляров, т.е. A -#is_instance-> B -#is_instance-> C
         Errors.AddRange(CheckInstancesOfInstances());
         // 3) контроль метазнаний: имена вершин метазнаний не должны совпадать с именами зарезервированных дуг
         Errors.AddRange(CheckMetadata());
         // 4) из именованной вершины не должно выходить дуг
         Errors.AddRange(CheckNamedNodes());
         // 5) в именованную вершину может входить только дуга с именем #Name
         Errors.AddRange(CheckArcToNamedNodes());
         // 6) В именованную вершину должна входить хотя бы одна дуга с именем #Name
         Errors.AddRange(CheckIfNamedNodeHasUnnamedObject());
         // 7) Нельзя, чтобы из неименованной вершины выходило несколько дуг с именем #is_instance, #is_a и #Name
         Errors.AddRange(CheckUniqueArcs(new List <string> {
             "#is_instance", "#is_a", "#Name"
         }));
         OnValidationFinished(Errors.Count);
         _semaphore.Release();
     }
     catch {}
 }
Exemplo n.º 6
0
 public Response(T data, string msg, IEnumerable <string> errors)
     : this()
 {
     Data    = data;
     Message = msg;
     Errors.AddRange(errors);
 }
 internal TableEntriesSnapshot(AccessibilityResult result)
 {
     _dte         = (DTE2)Package.GetGlobalService(typeof(DTE));
     _projectName = result.Project;
     Errors.AddRange(result.Violations);
     Url = result.Url;
 }
        public override async Task InitializeAsync(CancellationToken cancellationToken = default)
        {
            var body = await _deserializer.DeserializeAsync <AnalyticsResultData>(ResponseStream, cancellationToken);

            MetaData = new AnalyticsMetaData
            {
                RequestId       = body.requestID,
                ClientContextId = body.clientContextID,
                Signature       = body.signature,
                Metrics         = body.metrics?.ToMetrics() ?? new AnalyticsMetrics()
            };

            if (Enum.TryParse(body.status, true, out AnalyticsStatus status))
            {
                MetaData.Status = status;
            }

            if (body.warnings != null)
            {
                MetaData.Warnings.AddRange(body.warnings.Select(p => p.ToWarning()));
            }
            if (body.errors != null)
            {
                Errors.AddRange(body.errors.Select(p => p.ToError()));
            }

            _rows = body.results ?? Enumerable.Empty <T>();
        }
Exemplo n.º 9
0
 protected virtual void JointsOutOfRange()
 {
     var outofRangeErrors = mechanism.Joints
     .Where(x => !x.Range.IncludesParameter(Joints[x.Index]))
     .Select(x => $"Axis {x.Number + 1} is outside the permited range.");
     Errors.AddRange(outofRangeErrors);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Adds another LoaderInfo to the current result set.
 /// </summary>
 /// <param name="info">Additional LoaderInfo</param>
 public void AddRange(LoaderInfo info)
 {
     Campaigns.AddRange(info.Campaigns);
     Errors.AddRange(info.Errors);
     Levels.AddRange(info.Levels);
     Players.AddRange(info.Players);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Merges the current list with another error list.
 /// </summary>
 /// <param name="otherList">Another error list to merge the current list with.</param>
 public void MergeWith(ErrorList otherList)
 {
     if (otherList != null && otherList != this)
     {
         Errors.AddRange(otherList.Errors);
     }
 }
Exemplo n.º 12
0
        /// <summary>
        ///		Ejecuta un script de SQL
        /// </summary>
        internal async Task ExecuteAsync(IDbProvider dbProvider, string query, ArgumentListModel arguments, TimeSpan timeout, CancellationToken cancellationToken)
        {
            using (BlockLogModel block = Manager.Logger.Default.CreateBlock(LogModel.LogType.Info, "Start script execution"))
            {
                SqlScriptExecutor    executor    = new SqlScriptExecutor(Manager, dbProvider, arguments, timeout);
                DbScriptsInterpreter interpreter = new DbScriptsInterpreter(executor, Manager.Logger);

                // Ejecuta el archivo
                await interpreter.ExecuteAsync(query, null, cancellationToken);

                // Recopila los errores
                Errors.AddRange(interpreter.Errors);
                // y los pasa al log
                if (Errors.Count == 0)
                {
                    block.Info("End script execution");
                }
                else
                {
                    string error = string.Empty;

                    // Agrega los errores
                    foreach (string inner in Errors)
                    {
                        error += inner + Environment.NewLine;
                    }
                    // log
                    block.Error($"Error when execute sql script: {Environment.NewLine}{error}");
                }
            }
        }
Exemplo n.º 13
0
 internal TableEntriesSnapshot(ValidationResult result)
 {
     _dte         = (DTE2)Package.GetGlobalService(typeof(DTE));
     _projectName = result.Project;
     Errors.AddRange(result.Errors);
     Url = result.Url;
 }
Exemplo n.º 14
0
 public void AddErrorMessage(IEnumerable <string> messages, object value1, object value2, object value3)
 {
     if (Errors == null)
     {
         Errors = new List <string>();
     }
     Errors.AddRange(messages.Select(r => string.Format(r, value1, value2, value3)));
 }
Exemplo n.º 15
0
 public void AddErrorMessage(IEnumerable <string> messages, params object[] values)
 {
     if (Errors == null)
     {
         Errors = new List <string>();
     }
     Errors.AddRange(messages.Select(r => string.Format(r, values)));
 }
Exemplo n.º 16
0
 public void AddErrorMessage(IEnumerable <string> messages)
 {
     if (Errors == null)
     {
         Errors = new List <string>();
     }
     Errors.AddRange(messages);
 }
Exemplo n.º 17
0
 /// <summary>
 /// A configurable HubActionResponse.
 /// </summary>
 /// <param name="isSuccessful">Whether the action was successful.</param>
 /// <param name="errors">A list of any errors encountered.
 /// Defaults to null.</param>
 public HubResponse(bool isSuccessful, IEnumerable <string>?errors = null)
 {
     IsSuccessful = isSuccessful;
     if (errors != null)
     {
         Errors.AddRange(errors);
     }
 }
Exemplo n.º 18
0
 public DbFluentResult AddError(params string[] errors)
 {
     if (errors != null)
     {
         Errors.AddRange(errors);
     }
     return(this);
 }
 public ProcessException(string message,
                         HttpStatusCode httpStatusCode,
                         params Error[] errors)
     : this(message)
 {
     HttpStatusCode = httpStatusCode;
     Errors.AddRange(errors);
 }
Exemplo n.º 20
0
 public bool Validate()
 {
     Properties.Values.ForEach(p => p.Errors.Clear());
     Validator?.Invoke(this);
     Errors.AddRange(Properties.Values.SelectMany(x => x.Errors), true);
     RaisePropertyChanged(nameof(IsValid));
     return(IsValid);
 }
Exemplo n.º 21
0
 public void AddResponseStatus(ResponseStatus status)
 {
     Errors.AddRange(status.Errors);
     if (status.Errors.Any())
     {
         Message = ResponseStatusMessage.Unsuccessful;
     }
 }
Exemplo n.º 22
0
 /// <summary>
 /// Compose two distinct <see cref="ValidationResult"/> objects.
 /// </summary>
 /// <param name="res">The res.</param>
 public void Compose(ValidationResult res)
 {
     if (!res.Success)
     {
         Success = false;
         Errors.AddRange(res.Errors);
     }
 }
Exemplo n.º 23
0
 public AjaxResultModel(string statusCode, List <string> errors)
     : this(statusCode)
 {
     if (errors != null && errors.Count > 0)
     {
         Errors.AddRange(errors);
     }
 }
        /// ------------------------------------------------------------------------------------
        public bool GetIsValid(SearchQuery query)
        {
            try
            {
                Errors.Clear();

                VerifyMatchingSymbolPairs(query.Pattern);

                var pattern = query.SearchItem + "/" + query.PrecedingEnvironment + "_" + query.FollowingEnvironment;
                if (!VerifyGeneralPatternStructure(pattern))
                {
                    var error = new SearchQueryValidationError(GetPatternSyntaxErrorMsg());
                    Errors.Add(error);
                }

                VerifySearchItem(query.SearchItem);
                VerifyPrecedingEnvironment(query.PrecedingEnvironment);
                VerifyFollowingEnvironment(query.FollowingEnvironment);
                VerifyPhonesAndSymbols(query);

                foreach (var item in new[] { query.SearchItem, query.PrecedingEnvironment, query.FollowingEnvironment })
                {
                    VerifyTextInSquareBrackets(item);
                    VerifyTextInAngleBrackets(item);
                    VerifyDiacriticPlaceholders(item);
                    VerifyOneDiacriticPlaceholderPerAndGroup(item);

                    VerifyNoEmptyTextBetweenOpenAndCloseSymbols(item, PatternParser.FindInnerMostSquareBracketPairs,
                                                                string.Format(LocalizationManager.GetString("PhoneticSearchingMessages.EmptySquareBracketsMsg",
                                                                                                            "The pattern '{0}' contains at least one set of empty square brackets."), item));

                    VerifyNoEmptyTextBetweenOpenAndCloseSymbols(item, PatternParser.FindInnerMostBracesPair,
                                                                string.Format(LocalizationManager.GetString("PhoneticSearchingMessages.EmptyBracesMsg",
                                                                                                            "The pattern '{0}' contains at least one set of empty braces."), item));

                    VerifyNoEmptyTextBetweenOpenAndCloseSymbols(item, PatternParser.FindInnerAngleBracketPairs,
                                                                string.Format(LocalizationManager.GetString("PhoneticSearchingMessages.EmptyAngleBracketsMsg",
                                                                                                            "The pattern '{0}' contains at least one set of empty angle brackets."), item));

                    VerifyMatchingSymbolPairs(item);
                    ValidateOrGroups(item);

                    var andGroupValidator = new AndGroupValidator(_project);
                    andGroupValidator.Verify(item);
                    if (andGroupValidator.HasErrors)
                    {
                        Errors.AddRange(andGroupValidator.Errors);
                    }
                }
            }
            catch (Exception e)
            {
                Errors.Add(SearchQueryValidationError.MakeErrorFromException(e, query.Pattern));
            }

            query.Errors.AddRange(Errors);
            return(!HasErrors);
        }
        public void AddErrors(List <ErrorDetail> errors)
        {
            if (errors == null)
            {
                throw new ArgumentNullException(nameof(errors));
            }

            Errors.AddRange(errors);
        }
Exemplo n.º 26
0
        public void Join(Message message)
        {
            Errors.AddRange(message.Errors);
            Success.AddRange(message.Success);
            Warnings.AddRange(message.Warnings);
            Info.AddRange(message.Info);

            refreshType();
        }
Exemplo n.º 27
0
        async Task <RepositoryResponse <bool> > HandlePermission(SioPortalPages.UpdateRolePermissionViewModel item, SioCmsContext context, IDbContextTransaction transaction)
        {
            var result = new RepositoryResponse <bool>()
            {
                IsSucceed = true
            };

            if (item.NavPermission.IsActived)
            {
                item.NavPermission.CreatedBy = item.CreatedBy;
                var saveResult = await item.NavPermission.SaveModelAsync(false, context, transaction);

                result.IsSucceed = saveResult.IsSucceed;

                /* skip child nav
                 * if (result.IsSucceed)
                 * {
                 *  foreach (var child in item.ChildPages)
                 *  {
                 *      result = await HandlePermission(child.Page, context, transaction);
                 *      if (!result.IsSucceed)
                 *      {
                 *          break;
                 *      }
                 *  }
                 * }*/

                if (!result.IsSucceed)
                {
                    result.Exception = saveResult.Exception;
                    Errors.AddRange(saveResult.Errors);
                }
            }
            else
            {
                var saveResult = await item.NavPermission.RemoveModelAsync(false, context, transaction);

                /* skip child nav */
                result.IsSucceed = saveResult.IsSucceed;
                if (result.IsSucceed)
                {
                    foreach (var child in item.ChildPages)
                    {
                        child.Page.NavPermission.IsActived = false;
                        result = await HandlePermission(child.Page, context, transaction);
                    }
                }

                if (!result.IsSucceed)
                {
                    result.Exception = saveResult.Exception;
                    Errors.AddRange(saveResult.Errors);
                }
            }

            return(result);
        }
Exemplo n.º 28
0
        public void CopyFrom(ErrorBucket donor)
        {
            // copy the normal errors...
            Errors.Clear();
            Errors.AddRange(donor.Errors);

            // copy the fatal error...
            Fatal = donor.Fatal;
        }
Exemplo n.º 29
0
        public override async Task Initialize()
        {
            EstatesCount = await DBConn.SelectCountAsync <Model.Estate>();

            Errors.AddRange(DBConn.Errors);
            EstatesInSaleCount = await DBConn.SelectCountAsync <Model.Transaction>(
                t => !t.TransactionDone);

            Errors.AddRange(DBConn.Errors);
        }
Exemplo n.º 30
0
        public void Set(List <BusinessError> businessErrors)
        {
            var isFirstSet = businessErrors.Any() && !Errors.Any();

            Errors.AddRange(businessErrors);
            if (isFirstSet)
            {
                SetExecutionOrder(nameof(Errors));
            }
        }