Last active
August 29, 2015 13:57
-
-
Save billzhuang/9363557 to your computer and use it in GitHub Desktop.
dotnet PK asp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Start"); | |
var aspRedirect = File.ReadLines(@"d:\yyy\asp.txt") | |
.Where(s => !s.Contains("webus")) | |
.GroupBy(s => LogEntity.Parse(s)) | |
.ToDictionary(g => g.Key); | |
if (File.Exists(@"d:\yyy\result.txt")) | |
{ | |
File.Delete(@"d:\yyy\result.txt"); | |
} | |
var dotnetRedirect = File.ReadLines(@"d:\yyy\dotnet.txt") | |
.Where(s => !s.Contains("webus")) | |
.GroupBy(s => LogEntity.Parse(s)) | |
.ToDictionary(g => g.Key, g => g.FirstOrDefault()); | |
using (var destFile = File.AppendText(@"d:\yyy\result.txt")) | |
{ | |
foreach (var item in dotnetRedirect.Keys) | |
{ | |
if (!aspRedirect.ContainsKey(item)) | |
{ | |
destFile.WriteLine(dotnetRedirect[item]); | |
} | |
} | |
} | |
Console.WriteLine("Finish"); | |
} | |
} | |
struct LogEntity | |
{ | |
public String RequestUrl { get; set; } | |
public String Partner { get; set; } | |
public String Locale { get; set; } | |
//public String Member_id { get; set; } | |
public String RedirectUrl { get; set; } | |
public static LogEntity Parse(String line) | |
{ | |
var arr = line.Split(','); | |
var entity = new LogEntity(); | |
entity.RequestUrl = arr[0].Trim().ToLowerInvariant() | |
.Replace("aspx", "asp"); | |
entity.Partner = arr[1].Trim().ToLowerInvariant(); | |
entity.Locale = TreatLocale(arr[2]); | |
//entity.Member_id = TreatMember_id(arr[3]); | |
entity.RedirectUrl = arr[5].Trim().ToLowerInvariant(); | |
return entity; | |
} | |
public static String TreatLocale(String locale) | |
{ | |
locale = locale.Trim().ToLowerInvariant(); | |
if (locale.Contains("_")) | |
{ | |
return locale.Split('_')[0]; | |
} | |
return locale; | |
} | |
public static String TreatMember_id(String member_id) | |
{ | |
if (String.IsNullOrWhiteSpace(member_id)) | |
{ | |
return "-1"; | |
} | |
if (member_id != "-1") | |
{ | |
return "1"; // magic number, handle all login as same student | |
} | |
return "-1"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment