public void ProvideValue_returns_instance()
        {
            var converter     = new DateTimeToStringConverter();
            var providedValue = converter.ProvideValue(null);

            Assert.IsType <DateTimeToStringConverter>(providedValue);
        }
Esempio n. 2
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Worksheet worksheet = spreadsheetControl1.Document.Worksheets[0];
            Range     range     = worksheet.Tables[0].Range;
            // Create a data table with column names obtained from the first row in a range.
            // Column data types are obtained from cell value types of cells in the first data row of the worksheet range.
            DataTable dataTable = worksheet.CreateDataTable(range, true);

            // Change the data type of the "As Of" column to text.
            dataTable.Columns["As Of"].DataType = System.Type.GetType("System.String");
            // Create the exporter that obtains data from the specified range,
            //skips header row if required and populates the specified data table.
            DataTableExporter exporter = worksheet.CreateDataTableExporter(range, dataTable, true);
            // Specify a custom converter for the "As Of" column.
            DateTimeToStringConverter toDateStringConverter = new DateTimeToStringConverter();

            exporter.Options.CustomConverters.Add("As Of", toDateStringConverter);
            // Set the export value for empty cell.
            toDateStringConverter.EmptyCellValue = "N/A";
            // Specify that empty cells and cells with errors should be processed.
            exporter.Options.ConvertEmptyCells = true;
            exporter.Options.DefaultCellValueToColumnTypeConverter.SkipErrorValues = false;
            // Perform the export.
            exporter.Export();
            // A custom method that displays the resulting data table.
            ShowResult(dataTable);
        }
Esempio n. 3
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            var currentTime = new DateTimeToStringConverter().ConvertToProvider(DateTime.Now);

            migrationBuilder.Sql(
                @$ "
PRAGMA foreign_keys=OFF;

BEGIN TRANSACTION;

CREATE TABLE new_timelines (
    id INTEGER NOT NULL CONSTRAINT PK_timelines PRIMARY KEY AUTOINCREMENT,
	unique_id TEXT NOT NULL DEFAULT (lower(hex(randomblob(16)))),
    name TEXT NULL,
    name_last_modified TEXT NOT NULL,
    description TEXT NULL,
    owner INTEGER NOT NULL,
    visibility INTEGER NOT NULL,
    create_time TEXT NOT NULL,
    last_modified TEXT NOT NULL,
    current_post_local_id INTEGER NOT NULL DEFAULT 0,
    CONSTRAINT FK_timelines_users_owner FOREIGN KEY (owner) REFERENCES users (id) ON DELETE CASCADE
);

INSERT INTO new_timelines (id, unique_id, name, name_last_modified, description, owner, visibility, create_time, last_modified, current_post_local_id)
	SELECT id, unique_id, name, '{currentTime}', description, owner, visibility, create_time, '{currentTime}', current_post_local_id FROM timelines;
Esempio n. 4
0
        private void barButtonItem1_ItemClick(Range range)
        {
            Worksheet worksheet = range.Worksheet;

            // Create a data table with column names obtained from the first row in a range.
            // Column data types are obtained from cell value types of cells in the first data row of the worksheet range.
            DataTable dataTable = worksheet.CreateDataTable(range, true);

            // Change the data type of the "As Of" column to text.
            dataTable.Columns["As Of"].DataType = System.Type.GetType("System.String");
            // Create the exporter that obtains data from the specified range and populates the specified data table.
            DataTableExporter exporter = worksheet.CreateDataTableExporter(range, dataTable, true);

            // Handle value conversion errors.
            exporter.CellValueConversionError += exporter_CellValueConversionError;

            // Specify a custom converter for the "As Of" column.
            DateTimeToStringConverter toDateStringConverter = new DateTimeToStringConverter();

            exporter.Options.CustomConverters.Add("As Of", toDateStringConverter);
            // Set the export value for empty cell.
            toDateStringConverter.EmptyCellValue = "N/A";
            // Specify that empty cells and cells with errors should be processed.
            exporter.Options.ConvertEmptyCells = true;
            exporter.Options.DefaultCellValueToColumnTypeConverter.SkipErrorValues = false;

            // Perform the export.
            exporter.Export();

            // A custom method that displays the resulting data table.
            //ShowResult(dataTable);
        }
        public void ConvertBack(object input, Type targetType, object?parameter, string cultureString, object expectedOutput)
        {
            var converter = new DateTimeToStringConverter();
            var culture   = new CultureInfo(cultureString);
            var output    = converter.ConvertBack(input, targetType, parameter, culture);

            Assert.Equal(expectedOutput, output);
        }
        public void DateTimeToStringConverter_Convert_HasDateTimeValue_StringWithSplitSeconds()
        {
            //------------Setup for test--------------------------
            var dateTimeToStringConverter = new DateTimeToStringConverter();
            var dateTimeToConvert         = new DateTime(2014, 01, 02, 10, 15, 52, 52);
            //------------Execute Test---------------------------
            var convertedValue = dateTimeToStringConverter.Convert(dateTimeToConvert, null, null, null).ToString();

            //------------Assert Results-------------------------
            Assert.IsTrue("2014/01/02 10:15:52.0520 AM" == convertedValue || "02/01/2014 10:15:52.0520 AM" == convertedValue, $"{convertedValue} string does not contain split seconds.");
        }
        public void DateTimeToStringConverter_Convert_ValueNotDateTime_NoStringReturned()
        {
            //------------Setup for test--------------------------
            var dateTimeToStringConverter = new DateTimeToStringConverter();

            //------------Execute Test---------------------------
            var convertedValue = dateTimeToStringConverter.Convert("some data", null, null, null);

            //------------Assert Results-------------------------
            Assert.IsNotInstanceOfType(convertedValue, typeof(string));
        }
        public void DateTimeToStringConverter_Convert_HasDateTimeValue_StringWithSplitSeconds()
        {
            //------------Setup for test--------------------------
            var dateTimeToStringConverter = new DateTimeToStringConverter();
            var dateTimeToConvert         = new DateTime(2014, 01, 02, 10, 15, 52, 52);
            //------------Execute Test---------------------------
            var convertedValue = dateTimeToStringConverter.Convert(dateTimeToConvert, null, null, null);

            //------------Assert Results-------------------------
            Assert.AreEqual("2014/01/02 10:15:52.0520 AM", convertedValue);
        }
        public void ConvertBack_Null_NotNullable()
        {
            // Arrange
            var converter = new DateTimeToStringConverter();

            // Act
            var result = (DateTime)converter.ConvertBack(null, null, null, null);

            // Assert
            Assert.AreEqual(new DateTime(), result);
        }
        public void Convert_NotDateTime()
        {
            // Arrange
            var converter = new DateTimeToStringConverter();

            // Act
            var result = (string)converter.Convert(new object(), null, null, null);

            // Assert
            Assert.AreEqual(string.Empty, result);
        }
        public void ConvertBack_Null_Nullable()
        {
            // Arrange
            var converter = new DateTimeToStringConverter();

            converter.IsDateTimeNullable = true;

            // Act
            var result = converter.ConvertBack(null, null, null, null);

            // Assert
            Assert.IsNull(result);
        }
        public void ConvertBack()
        {
            // Arrange
            var converter = new DateTimeToStringConverter();

            var date = DateTime.Today;

            // Act
            var result = (DateTime)converter.ConvertBack(date.ToString("d"), null, null, null);

            // Assert
            Assert.AreEqual(date, result);
        }
        public void Convert()
        {
            // Arrange
            var converter = new DateTimeToStringConverter();

            var date = DateTime.Now;

            // Act
            var result = (string)converter.Convert(date, null, null, null);

            // Assert
            Assert.AreEqual(date.ToString("d"), result);
        }
        public void DateTimeToStringConverter_Convert_HasFormat_StringUsingProvidedFormat()
        {
            //------------Setup for test--------------------------
            var dateTimeToStringConverter = new DateTimeToStringConverter();

            dateTimeToStringConverter.Format = "dd/MMM/yyyy";
            var dateTimeToConvert = new DateTime(2014, 01, 02, 10, 15, 52, 52);
            //------------Execute Test---------------------------
            var convertedValue = dateTimeToStringConverter.Convert(dateTimeToConvert, null, null, null);

            //------------Assert Results-------------------------
            Assert.AreEqual("02/Jan/2014", convertedValue);
        }
        public void ConvertBack_NotParsable_Nullable()
        {
            // Arrange
            var converter = new DateTimeToStringConverter();

            converter.IsDateTimeNullable = true;

            // Act
            var result = converter.ConvertBack(Guid.NewGuid().ToString(), null, null, null);

            // Assert
            Assert.IsNull(result);
        }
Esempio n. 16
0
        public bool MakeReportByTime(string filename, IEnumerable <Transaction> items)
        {
            try
            {
                var       document = MakeReportHeader(filename, "Отчет за месяц");
                PdfPTable table    = new PdfPTable(5);
                table.HorizontalAlignment = Element.ALIGN_LEFT;
                table.WidthPercentage     = 100;
                table.SetWidths(new[] { 75f, 75f, 75f, 75f, 450f });
                table.AddCell(new PdfPCell(new Phrase("Дата", highlightFont))
                {
                    Colspan = 1
                });
                table.AddCell(new PdfPCell(new Phrase("Сумма", highlightFont))
                {
                    Colspan = 1
                });
                table.AddCell(new PdfPCell(new Phrase("Счет", highlightFont))
                {
                    Colspan = 1
                });
                table.AddCell(new PdfPCell(new Phrase("Тип", highlightFont))
                {
                    Colspan = 1
                });
                table.AddCell(new PdfPCell(new Phrase("Комментарий", highlightFont))
                {
                    Colspan = 1
                });
                var sortingEvents = items.OrderBy(ev => ev.DateTime);
                foreach (var transaction in sortingEvents)
                {
                    table.AddCell(new Phrase(DateTimeToStringConverter.Convert(transaction.DateTime), textFont));
                    table.AddCell(new Phrase(transaction.Amount.ToString(), textFont));
                    table.AddCell(new Phrase(transaction.MoneySource, textFont));
                    table.AddCell(new Phrase(transaction.Type.ToString("G"), textFont));
                    table.AddCell(new Phrase(transaction.Comment, textFont));
                }

                document.Add(table);
                document.Close();
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
Esempio n. 17
0
        public async Task <IEnumerable <ProjectAnalysis> > SearchProjectAnalysesAsync(string project, EventCategories?category = null, int?p = null, int?ps = null, DateTime?from = null, DateTime?to = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(project)]  = project,
                [nameof(category)] = EventCategoriesConverter.ToString(category),
                [nameof(p)]        = p,
                [nameof(ps)]       = ps,
                [nameof(from)]     = DateTimeToStringConverter.ToString(from, "yyyy-MM-dd"),
                [nameof(to)]       = DateTimeToStringConverter.ToString(to, "yyyy-MM-dd")
            };

            return(await GetProjectAnalysesUrl("search")
                   .SetQueryParams(queryParamValues)
                   .GetJsonNamedNodeAsync <IEnumerable <ProjectAnalysis> >("analyses")
                   .ConfigureAwait(false));
        }
Esempio n. 18
0
        public async Task <MeasuresHistory> SearchMeasuresHistoryAsync(string component, string[] metrics, DateTime?from = null, DateTime?to = null, int?p = null, int?ps = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(component)] = component,
                [nameof(metrics)]   = string.Join(",", metrics),
                [nameof(from)]      = DateTimeToStringConverter.ToString(from),
                [nameof(to)]        = DateTimeToStringConverter.ToString(to),
                [nameof(p)]         = p,
                [nameof(ps)]        = ps,
            };

            return(await GetMeasuresUrl("search_history")
                   .SetQueryParams(queryParamValues)
                   .GetJsonAsync <MeasuresHistory>()
                   .ConfigureAwait(false));
        }
Esempio n. 19
0
        public async Task <IssuesList> SearchIssuesAsync(AvailableIssueFields[] additionalFields = null, bool?asc  = null, bool?assigned         = null, string[] assignees = null,
                                                         string[] author            = null, string[] componentKeys = null, DateTime?createdAfter = null, DateTime?createdAt = null, DateTime?createdBefore = null, string createdInLast = null,
                                                         string[] cwe               = null, Facets[] facets = null, string[] issues       = null, string[] languages = null, bool?onComponentsOnly = null, OwaspTop10Types[] owaspTop10 = null,
                                                         int?p                      = null, int?ps = null, IssueResolutions[] resolutions = null, bool?resolved      = null, string[] rules = null, IssueSortFields[] s = null,
                                                         SansTop25Types[] sansTop25 = null, Severities[] severities = null, bool?sinceLeakPeriod = null, SonarSourceSecurityTypes[] sonarSourceSecurity = null,
                                                         IssueStatuses[] statuses   = null, string[] tags           = null, IssueTypes[] types = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(additionalFields)] = additionalFields == null ? null : string.Join(",", additionalFields.Select(AvailableIssueFieldsConverter.ToString)),
                [nameof(asc)]              = BooleanConverter.ToString(asc),
                [nameof(assigned)]         = BooleanConverter.ToString(assigned),
                [nameof(assignees)]        = assignees == null ? null : string.Join(",", assignees),
                [nameof(author)]           = author,
                [nameof(componentKeys)]    = componentKeys == null ? null : string.Join(",", componentKeys),
                [nameof(createdAfter)]     = DateTimeToStringConverter.ToString(createdAfter),
                [nameof(createdAt)]        = DateTimeToStringConverter.ToString(createdAt),
                [nameof(createdBefore)]    = DateTimeToStringConverter.ToString(createdBefore),
                [nameof(createdInLast)]    = createdInLast,
                [nameof(cwe)]              = cwe == null ? null : string.Join(",", cwe),
                [nameof(facets)]           = facets == null ? null : string.Join(",", facets.Select(FacetsConverter.ToString)),
                [nameof(issues)]           = issues == null ? null : string.Join(",", issues),
                [nameof(languages)]        = languages == null ? null : string.Join(",", languages),
                [nameof(onComponentsOnly)] = onComponentsOnly,
                [nameof(owaspTop10)]       = owaspTop10 == null ? null : string.Join(",", owaspTop10.Select(OwaspTop10TypesConverter.ToString)),
                [nameof(p)]                   = p,
                [nameof(ps)]                  = ps,
                [nameof(resolutions)]         = resolutions == null ? null : string.Join(",", resolutions.Select(IssueResolutionsConverter.ToString)),
                [nameof(resolved)]            = BooleanConverter.ToString(resolved),
                [nameof(rules)]               = rules,
                [nameof(s)]                   = s,
                [nameof(sansTop25)]           = sansTop25 == null ? null : string.Join(",", sansTop25.Select(SansTop25TypesConverter.ToString)),
                [nameof(severities)]          = severities == null ? null : string.Join(",", severities.Select(SeveritiesConverter.ToString)),
                [nameof(sinceLeakPeriod)]     = BooleanConverter.ToString(sinceLeakPeriod),
                [nameof(sonarSourceSecurity)] = sonarSourceSecurity == null ? null : string.Join(",", sonarSourceSecurity.Select(SonarSourceSecurityTypesConverter.ToString)),
                [nameof(statuses)]            = statuses == null ? null : string.Join(",", statuses.Select(IssueStatusesConverter.ToString)),
                [nameof(tags)]                = tags,
                [nameof(types)]               = types == null ? null : string.Join(",", types.Select(IssueTypesConverter.ToString))
            };

            return(await GetIssuesUrl("search")
                   .SetQueryParams(queryParamValues)
                   .GetJsonAsync <IssuesList>()
                   .ConfigureAwait(false));
        }
Esempio n. 20
0
        public async Task <IEnumerable <ProjectComponent> > SearchProjectsAsync(DateTime?analyzedBefore = null, bool?onProvisionedOnly = null, int?p = null, string[] projects = null, int?ps = null, string q = null, ProjectQualifiers[] qualifiers = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(analyzedBefore)]    = DateTimeToStringConverter.ToString(analyzedBefore),
                [nameof(onProvisionedOnly)] = BooleanConverter.ToString(onProvisionedOnly),
                [nameof(p)]          = p,
                [nameof(projects)]   = projects == null ? null : string.Join(",", projects),
                [nameof(ps)]         = ps,
                [nameof(q)]          = q,
                [nameof(qualifiers)] = qualifiers == null ? null : string.Join(",", qualifiers.Select(ProjectQualifiersConverter.ToString)),
            };

            return(await GetProjectsUrl("search")
                   .SetQueryParams(queryParamValues)
                   .GetJsonNamedNodeAsync <IEnumerable <ProjectComponent> >("components")
                   .ConfigureAwait(false));
        }
Esempio n. 21
0
        public async Task <bool> BulkDeleteProjectsAsync(DateTime?analyzedBefore = null, bool?onProvisionedOnly = null, string[] projects = null, string q = null, ProjectQualifiers[] qualifiers = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(analyzedBefore)]    = DateTimeToStringConverter.ToString(analyzedBefore),
                [nameof(onProvisionedOnly)] = onProvisionedOnly,
                [nameof(projects)]          = projects == null ? null : string.Join(",", projects),
                [nameof(q)]          = q,
                [nameof(qualifiers)] = qualifiers == null ? null : string.Join(",", qualifiers.Select(ProjectQualifiersConverter.ToString)),
            };

            var response = await GetProjectsUrl("bulk_delete")
                           .SetQueryParams(queryParamValues)
                           .PostAsync(s_emptyHttpContent)
                           .ConfigureAwait(false);

            return(await HandleResponseAsync(response).ConfigureAwait(false));
        }
Esempio n. 22
0
 static Cvt()
 {
     And        = new AndConverter();
     AndVis     = new AndVisibilityConverter();
     Or         = new OrConverter();
     OrVis      = new OrVisibilityConverter();
     Eq         = new EqualToConverter();
     EqVis      = new EqualToVisibilityConverter();
     Neq        = new NotEqualToConverter();
     NeqVis     = new NotEqualToVisibilityConverter();
     DoNothing  = new DoNothingConverter();
     GridLength = new GridLengthValueConverter();
     IsNull     = new IsNullConverter();
     B2Vis      = new BooleanToVisibilityConverter();
     T2S        = new TimeToStringConverter();
     Dt2S       = new DateTimeToStringConverter();
     D2S        = new DateToStringConverter();
     I2D        = new IntToDoubleConverter();
 }
Esempio n. 23
0
        public async Task <IEnumerable <CeTask> > GetCeActivityAsync(string component = null, DateTime?maxExecutedAt = null, DateTime?minSubmittedAt = null, bool?onlyCurrents = null,
                                                                     int?ps           = null, string q = null, CeTaskStatuses[] status = null, string type = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(component)]      = component,
                [nameof(maxExecutedAt)]  = DateTimeToStringConverter.ToString(maxExecutedAt),
                [nameof(minSubmittedAt)] = DateTimeToStringConverter.ToString(minSubmittedAt),
                [nameof(onlyCurrents)]   = BooleanConverter.ToString(onlyCurrents),
                [nameof(ps)]             = ps,
                [nameof(q)]      = q,
                [nameof(status)] = status == null ? null : string.Join(",", status.Select(CeTaskStatusesConverter.ToString)),
                [nameof(type)]   = type
            };

            return(await GetCeUrl("activity")
                   .SetQueryParams(queryParamValues)
                   .GetJsonFirstNodeAsync <IEnumerable <CeTask> >()
                   .ConfigureAwait(false));
        }
Esempio n. 24
0
        public async Task <IEnumerable <Rule> > SearchRulesAsync(bool?activation         = null, Severities[] activeSeverities = null, bool?asc        = null, DateTime?availableSince = null,
                                                                 string[] cwe            = null, AvailableRuleFields[] f       = null, Facets[] facets = null, bool?includeExternal    = null, RuleInheritanceTypes[] inheritance = null, bool?isTemplate = null,
                                                                 string[] languages      = null, OwaspTop10Types[] owaspTop10  = null, int?p           = null, int?ps = null, string q = null, string qprofile = null, string[] repositories = null,
                                                                 string ruleKey          = null, RuleSortFields?s = null, SansTop25Types[] sansTop25   = null, Severities[] severities = null, SonarSourceSecurityTypes[] sonarSourceSecurity = null,
                                                                 RuleStatuses[] statuses = null, string[] tags    = null, string templateKey           = null, IssueTypes[] types      = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(activation)]          = BooleanConverter.ToString(activation),
                ["active_severities"]         = activeSeverities == null ? null : string.Join(",", activeSeverities.Select(SeveritiesConverter.ToString)),
                [nameof(asc)]                 = BooleanConverter.ToString(asc),
                ["available_since"]           = DateTimeToStringConverter.ToString(availableSince, "yyyy-MM-dd"),
                [nameof(cwe)]                 = cwe == null ? null : string.Join(",", cwe),
                [nameof(f)]                   = f == null ? null : string.Join(",", f.Select(AvailableRuleFieldsConverter.ToString)),
                [nameof(facets)]              = facets == null ? null : string.Join(",", facets.Select(FacetsConverter.ToString)),
                ["include_external"]          = BooleanConverter.ToString(includeExternal),
                [nameof(inheritance)]         = inheritance == null ? null : string.Join(",", string.Join(",", inheritance.Select(RuleInheritanceTypesConverter.ToString))),
                ["is_template"]               = BooleanConverter.ToString(isTemplate),
                [nameof(languages)]           = languages == null ? null : string.Join(",", languages),
                [nameof(owaspTop10)]          = owaspTop10 == null ? null : string.Join(",", owaspTop10.Select(OwaspTop10TypesConverter.ToString)),
                [nameof(p)]                   = p,
                [nameof(ps)]                  = ps,
                [nameof(q)]                   = q,
                [nameof(qprofile)]            = qprofile,
                [nameof(repositories)]        = repositories == null ? null : string.Join(",", repositories),
                ["rule_key"]                  = ruleKey,
                [nameof(s)]                   = s == null ? null : RuleSortFieldsConverter.ToString(s),
                [nameof(sansTop25)]           = sansTop25 == null ? null : string.Join(",", sansTop25.Select(SansTop25TypesConverter.ToString)),
                [nameof(severities)]          = severities == null ? null : string.Join(",", severities.Select(SeveritiesConverter.ToString)),
                [nameof(sonarSourceSecurity)] = sonarSourceSecurity == null ? null : string.Join(",", sonarSourceSecurity.Select(SonarSourceSecurityTypesConverter.ToString)),
                [nameof(statuses)]            = statuses == null ? null : string.Join(",", statuses.Select(RuleStatusesConverter.ToString)),
                [nameof(tags)]                = tags == null ? null : string.Join(",", tags),
                ["template_key"]              = templateKey,
                [nameof(types)]               = types == null ? null : string.Join(",", types.Select(IssueTypesConverter.ToString))
            };

            return(await GetRulesUrl("search")
                   .SetQueryParams(queryParamValues)
                   .GetJsonNamedNodeAsync <IEnumerable <Rule> >("rules")
                   .ConfigureAwait(false));
        }
Esempio n. 25
0
        public async Task <bool> ActivateQualityProfileRulesAsync(string targetKey, bool?activation = null, Severities[] activeSeverities = null, bool?asc          = null,
                                                                  DateTime?availableSince           = null, string[] cwe = null, RuleInheritanceTypes[] inheritance = null, bool?isTemplate = null, string[] languages = null,
                                                                  OwaspTop10Types[] owaspTop10      = null, string q     = null, string qprofile = null, string[] repositories              = null, string ruleKey = null, RuleSortFields?s = null,
                                                                  SansTop25Types[] sansTop25        = null, Severities[] severities = null, SonarSourceSecurityTypes[] sonarSourceSecurity = null, RuleStatuses[] statuses = null,
                                                                  string[] tags = null, Severities?targetSeverity                   = null, string templateKey = null, IssueTypes[] types = null)
        {
            var queryParamValues = new Dictionary <string, object>
            {
                [nameof(targetKey)]           = targetKey,
                [nameof(activation)]          = BooleanConverter.ToString(activation),
                ["active_severities"]         = activeSeverities,
                [nameof(asc)]                 = BooleanConverter.ToString(asc),
                ["available_since"]           = DateTimeToStringConverter.ToString(availableSince, "yyyy-MM-dd"),
                [nameof(cwe)]                 = cwe == null ? null : string.Join(",", cwe),
                [nameof(inheritance)]         = inheritance == null ? null : string.Join(",", inheritance.Select(RuleInheritanceTypesConverter.ToString)),
                ["is_template"]               = BooleanConverter.ToString(isTemplate),
                [nameof(languages)]           = languages == null ? null : string.Join(",", languages),
                [nameof(owaspTop10)]          = owaspTop10 == null ? null : string.Join(",", owaspTop10.Select(OwaspTop10TypesConverter.ToString)),
                [nameof(q)]                   = q,
                [nameof(qprofile)]            = qprofile,
                [nameof(repositories)]        = repositories == null ? null : string.Join(",", repositories),
                ["rule_key"]                  = ruleKey,
                [nameof(s)]                   = s == null ? null : string.Join(",", s),
                [nameof(sansTop25)]           = sansTop25 == null ? null : string.Join(",", sansTop25.Select(SansTop25TypesConverter.ToString)),
                [nameof(severities)]          = severities == null ? null : string.Join(",", severities.Select(SeveritiesConverter.ToString)),
                [nameof(sonarSourceSecurity)] = sonarSourceSecurity == null ? null : string.Join(",", sonarSourceSecurity.Select(SonarSourceSecurityTypesConverter.ToString)),
                [nameof(statuses)]            = statuses == null ? null : string.Join(",", statuses.Select(RuleStatusesConverter.ToString)),
                [nameof(tags)]                = tags == null ? null : string.Join(",", tags),
                [nameof(targetSeverity)]      = SeveritiesConverter.ToString(targetSeverity),
                ["template_key"]              = templateKey,
                [nameof(types)]               = types == null ? null : string.Join(",", types.Select(IssueTypesConverter.ToString))
            };

            var response = await GetQualityProfilesUrl("activate_rules")
                           .SetQueryParams(queryParamValues)
                           .PostAsync(s_emptyHttpContent)
                           .ConfigureAwait(false);

            return(await HandleResponseAsync(response).ConfigureAwait(false));
        }
        public DebugOutputFilterStrategy()
        {
            if (Application.Current != null)
            {
                _timeSpanToStringConverter = Application.Current.Resources["TimeSpanToStringConverter"] as TimeSpanToStringConverter;
                _dateTimeToStringConverter = Application.Current.Resources["DateTimeToStringConverter"] as DateTimeToStringConverter;
                _enumToStringConverter     = Application.Current.Resources["EnumToStringConverter"] as EnumToStringConverter;
            }

            if (_timeSpanToStringConverter == null)
            {
                _timeSpanToStringConverter = new TimeSpanToStringConverter();
            }

            if (_dateTimeToStringConverter == null)
            {
                _dateTimeToStringConverter = new DateTimeToStringConverter();
            }

            if (_enumToStringConverter == null)
            {
                _enumToStringConverter = new EnumToStringConverter();
            }
        }
Esempio n. 27
0
        protected async override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            this.abibAddFav = new ApplicationBarIconButton()
            {
                Text = "favourite", IconUri = new Uri("/Images/appbar.favs.addto.rest.png", UriKind.Relative)
            };
            this.abibAddFav.Click += this.btnFavourite_Click;

            this.abibRemFav = new ApplicationBarIconButton()
            {
                Text = "unfavourite", IconUri = new Uri("/Images/appbar.favs.rem.rest.png", UriKind.Relative)
            };
            this.abibRemFav.Click += this.btnUnfavourite_Click;

            this.abibPin = new ApplicationBarIconButton()
            {
                Text = "pin", IconUri = new Uri("/Images/appbar.pin.png", UriKind.Relative)
            };
            this.abibPin.Click += this.btnPinSecondary_Click;

            this.abibDirections = new ApplicationBarIconButton()
            {
                Text = "drive", IconUri = new Uri("/Images/route.png", UriKind.Relative)
            };
            this.abibDirections.Click += this.btnDrive_Click;

            this.abibTrailer = new ApplicationBarIconButton()
            {
                Text = "trailer", IconUri = new Uri("/Images/appbar.transport.play.rest.png", UriKind.Relative)
            };
            this.abibTrailer.Click += this.btnViewTrailer_Click;

            this.abibShare = new ApplicationBarIconButton()
            {
                Text = "share", IconUri = new Uri("/Images/appbar.share03.png", UriKind.Relative)
            };
            this.abibShare.Click += this.btnShare_Click;

            this.abibSoundTrack = new ApplicationBarIconButton()
            {
                IconUri = new Uri("/Images/appbar.notes.rest.png", UriKind.Relative), Text = "sounds track"
            };
            this.abibSoundTrack.Click += this.abibSoundTrack_Click;

            this.ApplicationBar.Buttons.Clear();

            if (!Config.ShowCleanBackground && SelectedFilm.BackdropUrl != null)
            {
                this.pMain.Background = new ImageBrush()
                {
                    ImageSource = new BitmapImage(SelectedFilm.BackdropUrl),
                    Opacity     = 0.2,
                    Stretch     = Stretch.UniformToFill
                };
            }

            this.pMain.Title = String.Format("{0} at Cineworld {1}", SelectedFilm.TitleWithClassification, SelectedCinema.Name);

            bool bError = false;

            try
            {
                this.DataContext = this;

                if (ShowCinemaDetails)
                {
                    await this.LoadCinemaDetails();
                }

                if (ShowFilmDetails)
                {
                    this.LoadFilmDetails();
                }

                var query = from item in SelectedFilm.Performances
                            orderby((PerformanceInfo)item).PerformanceTS
                            group item by((PerformanceInfo)item).PerformanceTS.Date into g
                            select new Group <PerformanceInfo>(DateTimeToStringConverter.ConvertData(g.Key.Date), g);

                List <Group <PerformanceInfo> > shows = new List <Group <PerformanceInfo> >(query);
                this.lbPerformances.ItemsSource = shows;
            }
            catch
            {
                bError = true;
            }

            if (bError)
            {
                MessageBox.Show("Error downloading showtime data");
            }
        }
        private static string GenerateShareMessage(object sender)
        {
            MenuItem mi = sender as MenuItem;

            if (mi != null)
            {
                ContextMenu cm = mi.Parent as ContextMenu;

                PerformanceInfo pi = (PerformanceInfo)cm.Tag;

                return(String.Format("Shall we go and see \"{0}\" at Cineworld {1} on {2} at {3}? Book here {4}", (string)pi.FilmTitle, SelectedCinema.Name, DateTimeToStringConverter.ConvertData(pi.PerformanceTS), pi.TimeString, (pi.BookUrl).ToString()));
            }

            return(String.Empty);
        }