|
Hello,
I already have a approved bot account on non english wikipedia. I am having trouble with converting the provided sample codes to C#. Would someone kindly do it? More details can be found at API:Tutorial - MediaWiki[^] and API:Edit - MediaWiki[^] Samples in java, PHP and python can be found at "API:Edit - MediaWiki" link. Here is sample code in java:
var request = require('request').defaults({jar: true}),
url = "https://test.wikipedia.org/w/api.php";
function getLoginToken() {
var params_0 = {
action: "query",
meta: "tokens",
type: "login",
format: "json"
};
request.get({ url: url, qs: params_0 }, function (error, res, body) {
if (error) {
return;
}
var data = JSON.parse(body);
loginRequest(data.query.tokens.logintoken);
});
}
function loginRequest(login_token) {
var params_1 = {
action: "login",
lgname: "bot_username",
lgpassword: "bot_password",
lgtoken: login_token,
format: "json"
};
request.post({ url: url, form: params_1 }, function (error, res, body) {
if (error) {
return;
}
getCsrfToken();
});
}
function getCsrfToken() {
var params_2 = {
action: "query",
meta: "tokens",
format: "json"
};
request.get({ url: url, qs: params_2 }, function(error, res, body) {
if (error) {
return;
}
var data = JSON.parse(body);
editRequest(data.query.tokens.csrftoken);
});
}
function editRequest(csrf_token) {
var params_3 = {
action: "edit",
title: "Project:Sandbox",
appendtext: "test edit",
token: csrf_token,
format: "json"
};
request.post({ url: url, form: params_3 }, function (error, res, body) {
if (error) {
return;
}
console.log(body);
});
}
getLoginToken();
Thanks a lot in advance.
modified 9-Feb-22 12:08pm.
|
|
|
|
|
Pallavi H Shinde wrote: Would someone kindly do it? Sure. As soon as we agree on payment.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I am doing it for free for wikipedia 
|
|
|
|
|
You're not doing it, you're asking me kindly to do it.
I do not do free work, as most here won't.
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
|
I write in Postman this URL for Get method: https://localhost:7033/api/restaurant and I get 404 not found result. I don't know where is the problem. For https://localhostlocalhost:7033 it works, so it must be something wrong with [Route("api/restaurant")]
Here is the Controller code:
[Route("api/restaurant")]
public class RestaurantController : ControllerBase
{
private readonly RestaurantDbContext _dbContext;
public RestaurantController(RestaurantDbContext dbContext)
{
_dbContext = dbContext;
}
[HttpGet]
public ActionResult<ienumerable<restaurant>> GetAll()
{
var restaurants = _dbContext.Restaurants.ToList();
return Ok(restaurants);
}
}
and launchSettings file code:
}
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:8196",
"sslPort": 44311
}
},
"profiles": {
"RestaurantApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7033;http://localhost:5033",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
modified 6-Feb-22 6:56am.
|
|
|
|
|
|
Hello,
when i set three '/' over my Property, i can declare a Comment for Intellisense.
Like this:
Now i have a special custom Attribute on this Proeprty.
I want to includ einformations of this Attribute into the Comment für Intellisense
Sample:
[MyCustomAttribute("ExtendedInformation")]
IPickingOrder Order { get; }
Now i see in intellisense the Text "Zugehöriger Auftrag" but i want to include the Attribute.
Anybody knows how to do that?
Best regard
Armin
|
|
|
|
|
If you're asking how you can automatically add the Attribute to part of the comment, you can't. You have to type it out yourself.
|
|
|
|
|
To add to what Dave has said, there is no way to get Intellisense to recognise your attributes as "Taggable" - the list cannot be customised, but "user defined" tags are allowed so there is nothing stopping you from typing it yourself (and it'll add the closing for you if you do).
The full list of "known tags" that intellisense will type for you is here: Documentation comments - C# language specification | Microsoft Docs[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If it's simply a matter of enhancing the documentation, this may help (when adding the attribute in the first place).
Documentation comments - C# language specification | Microsoft Docs
I add a comment if something needs commenting. If the attribute was important enough (without resorting to "find") I would have added it to the "Summary" in the first place. And what seemed important at the time, becomes the familiar.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Hello! Мaybe someone can help me how to write this project in Visual Studio with C#.Thanks
Menu: (Create menu in C# in console app.)
1. Send email to:
-to who
-text
1.1 Send email? Y / N
1.2 Exit program
2. Create FTP backup
-select local file (provide path)
-enter host
-enter port
-enter UserName
-enter PassW
If FTP finish with success - get email : FTP SUCCESS
Else - get email : FTP FAIL
Which file was successful at which datetime.
|
|
|
|
|
Dijana Deleva wrote: Мaybe someone can help me Certainly, but you need to show some effort first. No one is going to do you entire project for you.
|
|
|
|
|
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.
So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm very new to .Net Core so please bear with me!
I'm working on a project that uses EF Core as a data provider. I have managed to set things up so that any outstanding migrations are applied when the applicaton starts by doing the following:
Snippet from program.cs:
builder.Services.AddDbContext<MyDbContext>
(options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddTransient<IStartupFilter, MigrationStartupFilter<MyDbContext>>();
MigrationStartUpFilter.cs:
using Microsoft.EntityFrameworkCore;
public class MigrationStartupFilter<TContext> : IStartupFilter where TContext : DbContext
{
public Action<IApplicationBuilder> Configure(Action<IApplicationBuilder> next)
{
return app =>
{
using (var scope = app.ApplicationServices.CreateScope())
{
foreach (var context in scope.ServiceProvider.GetServices<TContext>())
{
context.Database.SetCommandTimeout(160);
context.Database.Migrate();
}
}
next(app);
};
}
}
This works fine, using the connection string from appSettings.json.
However - I do not want the SQL account that is used for general data access to have DDL permissions, what I'd like to do is have a different user with the correct privileges that I use just for the migrations.
Is this possible?
|
|
|
|
|
Did you try to create a new/different (not a "DefaultConnection" one) connection string with "different user with the correct privileges" that you need?
|
|
|
|
|
Try setting the connection's ConnectionString property:
context.GetDbConnection().ConnectionString = "...";
context.Database.SetCommandTimeout(160);
context.Database.Migrate();
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
This is precisely what I'd like to do, but I don't want to hard code the connection string in the code, I want to get it from IConfiguration. But I'm unable to inject IConfiguration into my MigrationStartupFilter class because it has to implement IStartupFilter - so I can't add it as a parameter to the constructor for Configure. That's the crux of my issue.
|
|
|
|
|
Just worked it out, I can do
var cfg = scope.ServiceProvider.GetService<IConfiguration>();
to get the configuration service, and from there I can get my connection strings 
|
|
|
|
|
Good morning,
As part of my conduit fill program, I have 8 comboboxes that require the same data filled into each one. They all have the same naming convention, but numerically different.
cbo120VACType_1
cbo120VACType_2
cbo120VACType_3
cbo120VACType_4
cbo120VACType_5
cbo120VACType_6
cbo120VACType_7
cbo120VACType_8
How can I setup the naming to be dynamic in my program, so that it will fill each one, one at a time.
Richard
Disable Vet
Grandfather
Pain in the @ss
|
|
|
|
|
The simplest way is to use an array / List of ComboBox items and preload it with the boxes to be filled.
Then a simple foreach will do what you want.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Is this the same data you were previously considering how to store? A lot depends on how much data, how much the data changes, and in how many places you need the data.
Suppose this one form with the eight combo boxes is the only place where you will need this data. You had mentioned building some kind of calculator or estimator, so it could conceivably consist of just one form. If that's the case, you might consider just manually entering the data in the form designer. Each combo box lets you type in the choices in the list.
A step up from that would be to put the values in an array. Then use that array as the data source to a BindingSource. Then use that binding source as the data source to the first combo box. Repeat the process for the other seven combo boxes. You need one array, but you need a binding source for each combo box. This is because a binding source has only one current position, so if you use the same binding source for more than one combo box, setting one combo box will immediately set all the other combo boxes to the same selected item.
Here's a similar question with code.
c# - Populate a combobox with array information - Stack Overflow[^]
|
|
|
|
|
You should say if you're using Windows Forms or WPF or UWP, etc.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Oops, thanks. I didn't pick up on that.
|
|
|
|
|
You may be right. I thought WPF (probably because I looked at another WPF post first. I hate when I do that).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|