Example #1
0
        public void ValidatorsTest()
        {
            NodeRpcClient    nodeRpcClient = new NodeRpcClient(endpoint);
            ResultValidators result        = nodeRpcClient.Validators(10779111);

            Assert.NotNull(result.Validators[0].Address);
        }
Example #2
0
        public void CopyWithLinks(
            Context context,
            SiteSettings ss,
            string columnName,
            long from,
            long to)
        {
            var column = ss.GetColumn(
                context: context,
                columnName: columnName);

            if (column == null)
            {
                return;
            }
            if (View == null)
            {
                View = new View();
            }
            if (View.ColumnFilterHash == null)
            {
                View.ColumnFilterHash = new Dictionary <string, string>();
            }
            View.GridColumns = new List <string>()
            {
                Rds.IdColumn(ss.ReferenceType),
                columnName
            };
            View.ColumnFilterHash.AddOrUpdate(columnName, $"[\"{from}\"]");
            if (View.ColumnSorterHash == null)
            {
                View.ColumnSorterHash = new Dictionary <string, SqlOrderBy.Types>();
            }
            View.ColumnSorterHash.AddOrUpdate("CreatedTime", SqlOrderBy.Types.asc);
            var dataRows = new GridData(
                context: context,
                ss: ss,
                view: View,
                count: false)
                           .DataRows;

            switch (ss.ReferenceType)
            {
            case "Issues":
                dataRows.ForEach(dataRow =>
                {
                    var issueId = dataRow.Long("IssueId");
                    var data    = GetData(
                        dataRow: dataRow,
                        column: column,
                        from: from,
                        to: to);
                    var formData = new Dictionary <string, string>()
                    {
                        { $"Issues_{columnName}", data }
                    };
                    if (!context.ContractSettings.ItemsLimit(
                            context: context,
                            siteId: ss.SiteId))
                    {
                        var issueModel = new IssueModel(
                            context: context,
                            ss: ss,
                            issueId: issueId,
                            formData: formData);
                        var invalid = IssueValidators.OnCreating(
                            context: context,
                            ss: ss,
                            issueModel: issueModel);
                        switch (invalid.Type)
                        {
                        case Error.Types.None:
                            issueModel.IssueId      = 0;
                            issueModel.Ver          = 1;
                            issueModel.Title.Value += CharToAddWhenCopying ?? ss.CharToAddWhenCopying;
                            if (CopyWithComments != true)
                            {
                                issueModel.Comments.Clear();
                            }
                            issueModel.SetCopyDefault(
                                context: context,
                                ss: ss);
                            var errorData = issueModel.Create(
                                context: context,
                                ss: ss,
                                copyFrom: issueModel.SavedIssueId,
                                forceSynchronizeSourceSummary: true,
                                notice: false,
                                otherInitValue: true);
                            break;
                        }
                    }
                });
                break;

            case "Results":
                dataRows.ForEach(dataRow =>
                {
                    var resultId = dataRow.Long("ResultId");
                    var data     = GetData(
                        dataRow: dataRow,
                        column: column,
                        from: from,
                        to: to);
                    var formData = new Dictionary <string, string>()
                    {
                        { $"Results_{columnName}", data }
                    };
                    if (!context.ContractSettings.ItemsLimit(
                            context: context,
                            siteId: ss.SiteId))
                    {
                        var resultModel = new ResultModel(
                            context: context,
                            ss: ss,
                            resultId: resultId,
                            formData: formData);
                        var invalid = ResultValidators.OnCreating(
                            context: context,
                            ss: ss,
                            resultModel: resultModel);
                        switch (invalid.Type)
                        {
                        case Error.Types.None:
                            resultModel.ResultId     = 0;
                            resultModel.Ver          = 1;
                            resultModel.Title.Value += CharToAddWhenCopying ?? ss.CharToAddWhenCopying;
                            if (CopyWithComments != true)
                            {
                                resultModel.Comments.Clear();
                            }
                            resultModel.SetCopyDefault(
                                context: context,
                                ss: ss);
                            var errorData = resultModel.Create(
                                context: context,
                                ss: ss,
                                copyFrom: resultModel.SavedResultId,
                                forceSynchronizeSourceSummary: true,
                                notice: false,
                                otherInitValue: true);
                            break;
                        }
                    }
                });
                break;
            }
        }
Example #3
0
 public ExtendedListBuilder <TResult> WithValidation(Func <TResult, bool> fn, string errorMessage)
 {
     ResultValidators.Add(fn, errorMessage);
     return(this);
 }
Example #4
0
 public ListBuilder <TResult> WithValidation(Func <TResult, bool> fn, Func <TResult, string> errorMessageFn)
 {
     ResultValidators.Add(fn, errorMessageFn);
     return(this);
 }