Skip to content

Instantly share code, notes, and snippets.

View vmandic's full-sized avatar
🤠
chillin'

Vedran Mandić vmandic

🤠
chillin'
View GitHub Profile
@vmandic
vmandic / HzzoExcelDownloader.cs
Last active May 10, 2019 19:33
meds-processor, part/4, snippet #1
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using MedsProcessor.Common.Models;
using static MedsProcessor.Common.Constants;
namespace MedsProcessor.Downloader
{
@vmandic
vmandic / AsyncDisposal.cs
Created April 10, 2019 20:04 — forked from binki/AsyncDisposal.cs
Async disposal
using System;
using System.Threading.Tasks;
class Program
{
static void Main() => new Program().Run().Wait();
async Task Run()
{
Console.WriteLine("Before Using");
await Async.Using(new Test(), t =>
@vmandic
vmandic / extensions.vsext
Created January 9, 2019 21:06
vs2017 extensions
{
"id": "981ebd64-1685-4a11-905e-699dfd2b2adc",
"name": "My Visual Studio extensions",
"description": "A collection of my Visual Studio extensions",
"version": "1.0",
"extensions": [
{
"name": ".NET Compiler Platform SDK",
"vsixId": "3a012d4e-6057-4e7c-8123-6d4be1d4723c"
},
@vmandic
vmandic / AppController.cs
Created October 25, 2018 22:39
meds-processor, p3, s9
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MedsProcessor.Common.Models;
using MedsProcessor.Downloader;
using MedsProcessor.Parser;
using MedsProcessor.Scraper;
using Microsoft.AspNetCore.Mvc;
@vmandic
vmandic / EnumExtensions.cs
Created October 25, 2018 22:30
meds-processor, p3, s8
namespace MedsProcessor.Common.Extensions
{
public static class EnumExtensions
{
public static T2 Parse<T1, T2>(string input) =>
(T2) System.Enum.Parse(typeof(T1), input);
}
}
@vmandic
vmandic / HzzoExcelParser.cs
Created October 25, 2018 22:27
meds-processor, p3, s7
void ParseHzzoExcelDocuments(IEnumerable<HzzoMedsDownloadDto> filteredMeds, DrugListType listType, bool isListStartingWith2014)
{
HzzoMedsDownloadDto latestMed = null;
int latestRow = 0;
int latestCol = 0;
try
{
Parallel.ForEach(filteredMeds, med =>
{
@vmandic
vmandic / HzzoExcelParser.cs
Created October 25, 2018 20:38
meds-processor, p3, s6
static ISheet OpenWorkbookSheetWithNpoi(FileStream stream, HzzoMedsDownloadDto med, HzzoMedsDownloadDto latestMed)
{
ISheet drugListSheet = null;
try
{
if (med.FileName.ToLowerInvariant().EndsWith(".xls"))
{
var hssfWorkbook = new HSSFWorkbook(stream);
drugListSheet = hssfWorkbook.GetSheetAt(0);
@vmandic
vmandic / Enums.cs
Created October 25, 2018 18:46
meds-processor, p3, s5
using System;
namespace MedsProcessor.Parser
{
public enum DrugListType
{
Undefined = 0,
Primary = 1,
Supplementary = 2
}
@vmandic
vmandic / HzzoMedsImportDto.cs
Created October 25, 2018 18:33
meds-processor, p3, s4
public class DrugImportDto
{
public int RowId { get; set; }
public DrugListType ListType { get; set; }
public DateTime ValidFrom { get; set; }
public string AtkCode { get; set; }
public DrugApplicationTypeLimitation ApplicationTypeLimitation { get; set; }
public string GenericName { get; set; }
@vmandic
vmandic / HzzoExcelParser.cs
Created October 25, 2018 18:17
meds-processor, p3, s3
static readonly DateTime filterDtStartWith2014 = new DateTime(2014, 1, 3);
void ParseSupplementaryListsUpTo2014_01(ISet<HzzoMedsDownloadDto> meds) =>
ParseHzzoExcelDocuments(meds.Where(x =>
x.ValidFrom <= filterDtStartWith2014 &&
(
x.FileName.ToLowerInvariant().Contains("dopunska") ||
x.FileName.ToLowerInvariant().Contains("dll")
)), DrugListType.Supplementary, false);