mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Finished migration
This commit is contained in:
parent
886b36cbf1
commit
77e89e9af4
@ -138,10 +138,9 @@ namespace Teknik.Areas.Profile.Controllers
|
|||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
}
|
}
|
||||||
HttpCookie authcookie = FormsAuthentication.GetAuthCookie(model.Username, model.RememberMe);
|
HttpCookie authcookie = FormsAuthentication.GetAuthCookie(model.Username, model.RememberMe);
|
||||||
authcookie.Domain = string.Format(".{0}", Config.Host);
|
authcookie.Name = ".TeknikAuth";
|
||||||
authcookie.HttpOnly = true;
|
authcookie.Domain = "." + Config.Host;
|
||||||
authcookie.Secure = true;
|
Response.Cookies.Add(authcookie);
|
||||||
Response.AppendCookie(authcookie);
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(model.ReturnUrl))
|
if (string.IsNullOrEmpty(model.ReturnUrl))
|
||||||
{
|
{
|
||||||
|
33
Teknik/Helpers/WebClientExtension.cs
Normal file
33
Teknik/Helpers/WebClientExtension.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace Teknik.Helpers
|
||||||
|
{
|
||||||
|
public class WebDownload : WebClient
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Time in milliseconds
|
||||||
|
/// </summary>
|
||||||
|
public int Timeout { get; set; }
|
||||||
|
|
||||||
|
public WebDownload() : this(60000) { }
|
||||||
|
|
||||||
|
public WebDownload(int timeout)
|
||||||
|
{
|
||||||
|
this.Timeout = timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override WebRequest GetWebRequest(Uri address)
|
||||||
|
{
|
||||||
|
var request = base.GetWebRequest(address);
|
||||||
|
if (request != null)
|
||||||
|
{
|
||||||
|
request.Timeout = this.Timeout;
|
||||||
|
}
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,9 +24,9 @@ namespace Teknik.Migrations
|
|||||||
{
|
{
|
||||||
// Pre-populate with the default stuff
|
// Pre-populate with the default stuff
|
||||||
|
|
||||||
// Create system blog
|
|
||||||
/*
|
/*
|
||||||
Config config = Config.Load();
|
Config config = Config.Load();
|
||||||
|
// Create system blog
|
||||||
Areas.Profile.Models.User systemUser = new Areas.Profile.Models.User();
|
Areas.Profile.Models.User systemUser = new Areas.Profile.Models.User();
|
||||||
systemUser.Username = Constants.SERVERUSER;
|
systemUser.Username = Constants.SERVERUSER;
|
||||||
systemUser.JoinDate = DateTime.Now;
|
systemUser.JoinDate = DateTime.Now;
|
||||||
@ -199,7 +199,6 @@ namespace Teknik.Migrations
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer Blog Comments
|
// Transfer Blog Comments
|
||||||
var commentRet = db.Query("SELECT * FROM `comments` WHERE `service` = {0}", new object[] { "blog" });
|
var commentRet = db.Query("SELECT * FROM `comments` WHERE `service` = {0}", new object[] { "blog" });
|
||||||
foreach (var comment in commentRet)
|
foreach (var comment in commentRet)
|
||||||
@ -244,12 +243,33 @@ namespace Teknik.Migrations
|
|||||||
}
|
}
|
||||||
// Transfer Uploads
|
// Transfer Uploads
|
||||||
var uploadRet = db.Query("SELECT * FROM `uploads`");
|
var uploadRet = db.Query("SELECT * FROM `uploads`");
|
||||||
|
var curUploads = context.Uploads.ToList();
|
||||||
|
if (curUploads == null)
|
||||||
|
curUploads = new List<Areas.Upload.Models.Upload>();
|
||||||
|
int curUpload = 0;
|
||||||
|
int curFinished = 0;
|
||||||
|
//int curDeleted = 0;
|
||||||
foreach (var upload in uploadRet)
|
foreach (var upload in uploadRet)
|
||||||
{
|
{
|
||||||
|
curUpload++;
|
||||||
|
try {
|
||||||
string url = upload["url"].ToString();
|
string url = upload["url"].ToString();
|
||||||
Areas.Upload.Models.Upload upFound = context.Uploads.Where(u => u.Url == url).FirstOrDefault();
|
//Areas.Upload.Models.Upload upFound = curUploads.Find(u => u.Url == url);
|
||||||
if (upFound == null)
|
//if (upFound != null)
|
||||||
{
|
//{
|
||||||
|
// string subDir = upFound.FileName[0].ToString();
|
||||||
|
// string filePath = Path.Combine(config.UploadConfig.UploadDirectory, subDir, upFound.FileName);
|
||||||
|
// if (File.Exists(filePath))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// curDeleted++;
|
||||||
|
// context.Uploads.Remove(upFound);
|
||||||
|
// context.SaveChanges();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
string fileType = upload["type"].ToString();
|
string fileType = upload["type"].ToString();
|
||||||
int contentLength = Int32.Parse(upload["filesize"].ToString());
|
int contentLength = Int32.Parse(upload["filesize"].ToString());
|
||||||
string deleteKey = upload["delete_key"].ToString();
|
string deleteKey = upload["delete_key"].ToString();
|
||||||
@ -257,13 +277,23 @@ namespace Teknik.Migrations
|
|||||||
DateTime uploadDate = DateTime.Parse(upload["upload_date"].ToString());
|
DateTime uploadDate = DateTime.Parse(upload["upload_date"].ToString());
|
||||||
string fullUrl = string.Format("https://u.teknik.io/{0}", url);
|
string fullUrl = string.Format("https://u.teknik.io/{0}", url);
|
||||||
string fileExt = Path.GetExtension(fullUrl);
|
string fileExt = Path.GetExtension(fullUrl);
|
||||||
|
if (!File.Exists(Path.Combine("Z:\\Uploads_Old", upload["filename"].ToString())))
|
||||||
// Download the old file and re-upload it
|
|
||||||
using (WebClient client = new WebClient())
|
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Download the old file and re-upload it
|
||||||
|
using (WebDownload client = new WebDownload(10000))
|
||||||
|
{
|
||||||
|
byte[] fileData;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fileData = client.DownloadData(fullUrl);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
byte[] fileData = client.DownloadData(fullUrl);
|
|
||||||
// Generate key and iv if empty
|
// Generate key and iv if empty
|
||||||
string key = Utility.RandomString(config.UploadConfig.KeySize / 8);
|
string key = Utility.RandomString(config.UploadConfig.KeySize / 8);
|
||||||
string iv = Utility.RandomString(config.UploadConfig.BlockSize / 8);
|
string iv = Utility.RandomString(config.UploadConfig.BlockSize / 8);
|
||||||
@ -279,20 +309,24 @@ namespace Teknik.Migrations
|
|||||||
if (!string.IsNullOrEmpty(deleteKey))
|
if (!string.IsNullOrEmpty(deleteKey))
|
||||||
up.DeleteKey = deleteKey;
|
up.DeleteKey = deleteKey;
|
||||||
up.Url = url;
|
up.Url = url;
|
||||||
context.Uploads.Add(up);
|
context.Entry(up).State = EntityState.Modified;
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
|
curFinished++;
|
||||||
}
|
}
|
||||||
catch { }
|
catch (Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
//}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Db_MysqlErrorEvent(object sender, string e)
|
//private void Db_MysqlErrorEvent(object sender, string e)
|
||||||
{
|
//{
|
||||||
// throw new NotImplementedException();
|
// throw new NotImplementedException();
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,6 +251,9 @@
|
|||||||
<Compile Include="Helpers\RSSFeedResult.cs" />
|
<Compile Include="Helpers\RSSFeedResult.cs" />
|
||||||
<Compile Include="Helpers\UrlExtensions.cs" />
|
<Compile Include="Helpers\UrlExtensions.cs" />
|
||||||
<Compile Include="Helpers\Utility.cs" />
|
<Compile Include="Helpers\Utility.cs" />
|
||||||
|
<Compile Include="Helpers\WebClientExtension.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Migrations\Configuration.cs" />
|
<Compile Include="Migrations\Configuration.cs" />
|
||||||
<Compile Include="Models\TeknikEntities.cs" />
|
<Compile Include="Models\TeknikEntities.cs" />
|
||||||
<Compile Include="Areas\Profile\Models\User.cs" />
|
<Compile Include="Areas\Profile\Models\User.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user