This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SA# | Title | Note | |
---|---|---|---|
SA0027 | Avoid wrapping filtering columns within a function in the WHERE clause | Performance concern | |
SA0081 | Do not use DECIMAL or NUMERIC data types without specifying precision and scale | Logical concern | |
SA0106 | Avoid OR operator in queries | Performance concern | |
SA0168 | Possible division by zero not handled according the practice | Logical concern | |
SA0251 | Subquery used in expression not ensured to return a single value | Logical concern |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Route("api/[controller]")] | |
public class FileController : ControllerBase | |
{ | |
[HttpPost("uploadlarge")] | |
[DisableFormValueModelBinding] | |
public async Task<IActionResult> UploadLargeFileAsync() | |
{ | |
try | |
{ | |
if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// files: suppose we have a list of file paths | |
// subDirectory: the sub-directory structure under root for storing | |
public async Task<HttpResponseMessage> UploadFilesAsync(List<string> files, string subDirectory) | |
{ | |
string boundary = $"--{DateTime.Now.Ticks:x}"; | |
using var content = new MultipartFormDataContent(boundary); | |
content.Headers.Add("ContentType", $"multipart/form-data, boundary={boundary}"); | |
foreach (var filePath in files) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class MonitorServiceTest | |
{ | |
private MonitorService _monitorService; // System under test (SUT) | |
private Mock<MailService> _mockMailService; // Test Double | |
private Mock<IOhterService> _mockOtherService; // Test Double | |
private IOptions<ConfigModel> _configModelOptions; // Configuration | |
[TestInitialize] // Setup | |
public void Initialize() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HttpRequestHelper | |
{ | |
public static async Task<string> PostReturnString(RequestArgs query, string uri) | |
{ | |
using (var httpClient = new HttpClient()) | |
{ | |
var response = await httpClient.PostAsync(new Uri(uri), | |
new StringContent(JsonConvert.SerializeObject(query), Encoding.UTF8, "application/json")); | |
var responseContent = await response.Content.ReadAsStringAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COUNTRY | COUNTRY CODE | |
---|---|---|
Afghanistan | 93 | |
Albania | 355 | |
Algeria | 213 | |
American Samoa | 1-684 | |
Andorra | 376 | |
Angola | 244 | |
Anguilla | 1-264 | |
Antarctica | 672 | |
Antigua and Barbuda | 1-268 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// supposed we have class to monitor request | |
public class RequestMonitor { | |
private readonly Context _context; | |
private readonly IMemoryCache _cache; | |
public RequestMonitor (Context context, IMemoryCache cache) { | |
_context = context; // DI the context of Http request | |
_cache = cache; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// supposed we have class to monitor request | |
public class RequestMonitor { | |
private readonly Context _context; | |
public RequestMonitor (Context context) { | |
_context = context; // DI the context of Http request | |
} | |
public void OnRequested () { | |
// retrieved http request information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ExcelExtension { | |
public static FileInfo Export<T> (string filepath, List<T> data) { | |
ExcelPackage.LicenseContext = LicenseContext.NonCommercial; | |
var output = new FileInfo (filepath); | |
if (output.Exists) output.Delete (); | |
if (!Directory.Exists (Path.GetDirectoryName (filepath))) Directory.CreateDirectory (Path.GetDirectoryName (filepath)); | |
using (var excel = new ExcelPackage (output)) { | |
var ws = excel.Workbook.Worksheets.Add ("Sheet1"); // create sheet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Google.Apis.Auth.OAuth2; | |
using Google.Apis.Services; | |
using Google.Apis.Sheets.v4; | |
using Google.Apis.Sheets.v4.Data; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Text; | |
namespace SheetsQuickstart |
NewerOlder