acookook
acookook
CC#
Created by acookook on 11/5/2024 in #help
Cron job "0 */30 15-16 * * ?" in Quartz .NET runs also at 16:30 p. m. Is this correct?
Something I came quickly up
private static List<string> TransformCron(string cronSchedule, string minutes, string hours)
{
var originalCronSchedule = new List<string>() { cronSchedule };

// Both */ (minute interval) and "-" in hour interval need to be present so that we know that the transformation should occur.
if (!hours.Contains("-") && !minutes.Contains("*/"))
return originalCronSchedule;

// Hour string 15-16
var startEndHour = hours.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);

// Only split by '-'
if (startEndHour?.Length < 2)
return originalCronSchedule;

//15
var startHour = int.Parse(startEndHour[0]);
//16
var endHour = int.Parse(startEndHour[1]);
//16 - 15
var difference = endHour - startHour;

var interMediateCronJob = string.Empty;
var lastCronJob = string.Empty;

// Start and end hour are invalid if difference is lower than 0.
if (difference <= 0)
{
return originalCronSchedule;
}

interMediateCronJob = difference == 1 ? $"0 {minutes} {startHour} * * ?" : $"0 {minutes} {startHour}-{endHour - 1} * * ?";

lastCronJob = $"0 0 {endHour} * * ?";

return new List<string>()
{
interMediateCronJob,
lastCronJob
};
}
private static List<string> TransformCron(string cronSchedule, string minutes, string hours)
{
var originalCronSchedule = new List<string>() { cronSchedule };

// Both */ (minute interval) and "-" in hour interval need to be present so that we know that the transformation should occur.
if (!hours.Contains("-") && !minutes.Contains("*/"))
return originalCronSchedule;

// Hour string 15-16
var startEndHour = hours.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);

// Only split by '-'
if (startEndHour?.Length < 2)
return originalCronSchedule;

//15
var startHour = int.Parse(startEndHour[0]);
//16
var endHour = int.Parse(startEndHour[1]);
//16 - 15
var difference = endHour - startHour;

var interMediateCronJob = string.Empty;
var lastCronJob = string.Empty;

// Start and end hour are invalid if difference is lower than 0.
if (difference <= 0)
{
return originalCronSchedule;
}

interMediateCronJob = difference == 1 ? $"0 {minutes} {startHour} * * ?" : $"0 {minutes} {startHour}-{endHour - 1} * * ?";

lastCronJob = $"0 0 {endHour} * * ?";

return new List<string>()
{
interMediateCronJob,
lastCronJob
};
}
2 replies
CC#
Created by acookook on 2/28/2024 in #help
Running gRPC service inside a docker container on a kubernetes cluster
public List<Ad> GetUsersAdsByRPC(int userId)
{
var channel = GrpcChannel.ForAddress("http://kubernetes-ingress:80/ads/api/grpc/{userID}}" + userId);
var client = new AdProto.AdProtoClient(channel);

var reply = client.GetAdsByUserId(new AdByIdUserIdRequest { UserId = userId });
if (!reply.Ads.Any())
return Enumerable.Empty<Ad>().ToList();
var ads = new List<Ad>();
foreach (var adItem in reply.Ads)
{
var ad = new Ad()
{
ID = adItem.Id,
Category = adItem.Category,
Thing = adItem.Thing,
Price = adItem.Price,
UserId = userId,
PostTime = DateTime.ParseExact(adItem.PublishDate, "MM/dd/yyyy HH:mm:ss", new CultureInfo("si-SI"))
};
ads.Add(ad);
}
return ads;
}
}
public List<Ad> GetUsersAdsByRPC(int userId)
{
var channel = GrpcChannel.ForAddress("http://kubernetes-ingress:80/ads/api/grpc/{userID}}" + userId);
var client = new AdProto.AdProtoClient(channel);

var reply = client.GetAdsByUserId(new AdByIdUserIdRequest { UserId = userId });
if (!reply.Ads.Any())
return Enumerable.Empty<Ad>().ToList();
var ads = new List<Ad>();
foreach (var adItem in reply.Ads)
{
var ad = new Ad()
{
ID = adItem.Id,
Category = adItem.Category,
Thing = adItem.Thing,
Price = adItem.Price,
UserId = userId,
PostTime = DateTime.ParseExact(adItem.PublishDate, "MM/dd/yyyy HH:mm:ss", new CultureInfo("si-SI"))
};
ads.Add(ad);
}
return ads;
}
}
2 replies
CC#
Created by Denis on 6/16/2023 in #help
✅ How to deploy gRPC Server + Client via docker
Yeah, thought so. Okay, i'll Just open a new thread.
107 replies
CC#
Created by Denis on 6/16/2023 in #help
✅ How to deploy gRPC Server + Client via docker
No description
107 replies
CC#
Created by ANewDeveloper on 6/14/2023 in #help
❔ GraphQL for ASP.NET 7 subscription service
With currently giving a try myself, I just find it confusing just to everything set up, not to mention that I do not understand how to wire this up the unitofwork and repository pattern. I have no code to show, since I am wiggleing around installing different graph ql packages like HotChocolate and trying various options shown @ medium, with even the basic examples failing at the first lines, like:
//var inputs = query.Variables.ToInputs();
//var inputs = query.Variables.ToInputs();
3 replies
CC#
Created by Denis on 3/19/2023 in #help
❔ GraphQL + EF Core
I mostly read through https://medium.com/shemseddine-on-code/setup-a-graphql-api-using-asp-net-core-79f1b88f6ad8 but a I am cofused how I should user the context. Maybe via DI?
9 replies
CC#
Created by Denis on 3/19/2023 in #help
❔ GraphQL + EF Core
I am facing the same issue. I am trying to implement some GraphQL library but do not know to get it to work it the unitOfWork pattern with a Business Logic Layer in between.
9 replies
CC#
Created by acookook on 6/5/2023 in #help
✅ Attachment upload to Jira through a custom application using AJAX and ASP .NET Core 6 - Rest Sharp
$codegif
14 replies
CC#
Created by acookook on 6/5/2023 in #help
✅ Attachment upload to Jira through a custom application using AJAX and ASP .NET Core 6 - Rest Sharp
private RestRequest GenerateRequestForFileUpload(IFormFile file)
{
//Tell Jira what content type should the file be.
var fileExtension = Path.GetExtension(file.FileName).ToLower();
var sourceContentType = _jiraConfiguration.ExtensionToContentType[fileExtension];

// Create a POST request using your favourite library
var request = new RestRequest
{
Authenticator = new HttpBasicAuthenticator("userName","token"),
Method = Method.Post,
AlwaysMultipartFormData = true
};
request.AddHeader("X-Atlassian-Token", "no-check");
request.AddFile("file", GetFileBytes(file), file.FileName, sourceContentType);

return request;
}
private RestRequest GenerateRequestForFileUpload(IFormFile file)
{
//Tell Jira what content type should the file be.
var fileExtension = Path.GetExtension(file.FileName).ToLower();
var sourceContentType = _jiraConfiguration.ExtensionToContentType[fileExtension];

// Create a POST request using your favourite library
var request = new RestRequest
{
Authenticator = new HttpBasicAuthenticator("userName","token"),
Method = Method.Post,
AlwaysMultipartFormData = true
};
request.AddHeader("X-Atlassian-Token", "no-check");
request.AddFile("file", GetFileBytes(file), file.FileName, sourceContentType);

return request;
}
14 replies
CC#
Created by acookook on 6/5/2023 in #help
✅ Attachment upload to Jira through a custom application using AJAX and ASP .NET Core 6 - Rest Sharp
ok, so the code which does function is the following. The point is simply to get the correct Content (MIME) type.
14 replies
CC#
Created by MrScautHD on 6/5/2023 in #help
❔ I looking for Game Engine / Framework!
The most accessible engine which also supports C# is definitely Unity, but you can alo try Godot. Afaik Cry Engine also supports it, but good luck with obtaining that.
7 replies
CC#
Created by acookook on 6/5/2023 in #help
✅ Attachment upload to Jira through a custom application using AJAX and ASP .NET Core 6 - Rest Sharp
I would like to be able to send any file(s) - of course within the known limits.
14 replies
CC#
Created by acookook on 6/5/2023 in #help
✅ Attachment upload to Jira through a custom application using AJAX and ASP .NET Core 6 - Rest Sharp
14 replies
CC#
Created by acookook on 3/28/2023 in #help
❔ Problem with including C DLL in a C# console app project.
Apparently it is the last file that is being processed and the last data structure in this file.
86 replies
CC#
Created by acookook on 3/28/2023 in #help
❔ Problem with including C DLL in a C# console app project.
First I thought a file was corrupt, but then I tried out a new, independent set of files
86 replies
CC#
Created by acookook on 3/28/2023 in #help
❔ Problem with including C DLL in a C# console app project.
Because I can easily process a few files without any issues
86 replies
CC#
Created by acookook on 3/28/2023 in #help
❔ Problem with including C DLL in a C# console app project.
86 replies