Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cornea Cristian/L01/Tema.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Un serviciu pe care il folosesc foarte des este Spotify-ul, prin care pot face streaming la muzica.
29 changes: 29 additions & 0 deletions Cornea Cristian/L02/Controllers/StudentsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Repositories;
using Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace L02.Controllers
{
[ApiController]
[Route("[controller]")]
public class StudentsController : ControllerBase
{
public StudentsController()
{
}

public IEnumerable<Students> Get(){
return StudentsRepo.Students;
}

[HttpGet("{id}")]
public Students GetStudent(int id)
{
return StudentsRepo.Students.FirstOrDefault(s=>s.Id == id);
}
}
}
39 changes: 39 additions & 0 deletions Cornea Cristian/L02/Controllers/WeatherForecastController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace L02.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

private readonly ILogger<WeatherForecastController> _logger;

public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}

[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}
8 changes: 8 additions & 0 deletions Cornea Cristian/L02/L02.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>


</Project>
13 changes: 13 additions & 0 deletions Cornea Cristian/L02/Models/Students.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Models
{
public class Students
{
public int Id { get; set; }

public string Faculty { get; set; }

public string Name { get; set; }

public int Year { get; set; }
}
}
26 changes: 26 additions & 0 deletions Cornea Cristian/L02/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace L02
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
30 changes: 30 additions & 0 deletions Cornea Cristian/L02/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:35418",
"sslPort": 44344
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"L02": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
11 changes: 11 additions & 0 deletions Cornea Cristian/L02/Repositories/StudentsRepo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using Models;
namespace Repositories{
public static class StudentsRepo{

public static List<Students> Students = new List<Students>(){
new Students(){Id=1, Faculty="AC", Name = "Bogdan", Year = 4},
new Students(){Id=2, Faculty="ETc", Name = "Alexa", Year = 1}
};
}
}
51 changes: 51 additions & 0 deletions Cornea Cristian/L02/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace L02
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseHttpsRedirection();

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
15 changes: 15 additions & 0 deletions Cornea Cristian/L02/WeatherForecast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace L02
{
public class WeatherForecast
{
public DateTime Date { get; set; }

public int TemperatureC { get; set; }

public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

public string Summary { get; set; }
}
}
9 changes: 9 additions & 0 deletions Cornea Cristian/L02/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
10 changes: 10 additions & 0 deletions Cornea Cristian/L02/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
12 changes: 12 additions & 0 deletions Cornea Cristian/L03/L03.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Apis.Drive.v3" Version="1.55.0.2481" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions Cornea Cristian/L03/L03.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31702.278
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "L03", "L03.csproj", "{2C84BB6A-A07D-4486-B617-E5E02AC1DA76}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2C84BB6A-A07D-4486-B617-E5E02AC1DA76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C84BB6A-A07D-4486-B617-E5E02AC1DA76}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C84BB6A-A07D-4486-B617-E5E02AC1DA76}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C84BB6A-A07D-4486-B617-E5E02AC1DA76}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D9706B27-A7AC-4F49-A7EE-E2AD45A77BDE}
EndGlobalSection
EndGlobal
86 changes: 86 additions & 0 deletions Cornea Cristian/L03/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Drive.v3;
using Google.Apis.Util.Store;
using Newtonsoft.Json.Linq;

namespace L03
{
class Program
{
private static string _token;

static void Main()
{
Initialize();
}

static void Initialize()
{
string[] scopes = new string[]{
DriveService.Scope.Drive,
DriveService.Scope.DriveFile
};
var clientId = "1046461755374-0jeatkchhepp5kf3t922c30jv09lg0rp.apps.googleusercontent.com";
var clientSecret = "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";
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
new ClientSecrets
{
ClientId = clientId,
ClientSecret = clientSecret
},
scopes,
Environment.UserName,
CancellationToken.None,
new FileDataStore("Dainto.GoogleDrive.Auth.Store")
).Result;
_token = credential.Token.AccessToken;
Console.WriteLine(_token);
GetAllFiles();
UploadTxtFile();
}

static void GetAllFiles()
{
var request = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/drive/v3/files?q='root'%20in%20parents");
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + _token);
using var response = request.GetResponse();
using Stream data = response.GetResponseStream();
using var reader = new StreamReader(data);
string text = reader.ReadToEnd();
var myData = JObject.Parse(text);
foreach (var file in myData["files"])
{
if (file["mimeType"].ToString() != "application/vnd.google-apps.folder")
{
Console.WriteLine("File name: " + file["name"]);
}
}
}
static void UploadTxtFile()
{
string path;
byte[] text;
Console.Write("Dati calea fisierului txt pe care doriti sa il incarcati pe drive: ");
path = Console.ReadLine();
text = Encoding.ASCII.GetBytes("--not_so_random_boundary\nContent-Type: application/json; charset = utf-8\nContent-Disposition: form-data; name=\"metadata\"\n\n{\"name\":\""+Path.GetFileName(path)+"\",\"mimeType\":\"text/plain\"}\n--not_so_random_boundary\nContent-Type: text/plain\nContent-Disposition: form-data; name=\"file\"\n\n"+ File.ReadAllText(path) + "\n--not_so_random_boundary--");
var request = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart");
request.Method = WebRequestMethods.Http.Post;
request.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + _token);
request.Headers.Add(HttpRequestHeader.ContentType, "multipart/related; boundary=not_so_random_boundary");
request.Headers.Add(HttpRequestHeader.ContentLength, text.Length.ToString());
Stream body = request.GetRequestStream();
body.Write(text, 0, text.Length);
using var response = request.GetResponse();
using Stream data = response.GetResponseStream();
using var reader = new StreamReader(data);
string info = reader.ReadToEnd();
var myData = JObject.Parse(info);
Console.WriteLine(myData);
}
}
}
1 change: 1 addition & 0 deletions Cornea Cristian/L03/random.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this text is also random
12 changes: 12 additions & 0 deletions Cornea Cristian/L04/L04.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>

</Project>
Loading