Localized ShallerDBProcessor operations conflicting with IISMainHandler running

main
Inga 🏳‍🌈 15 years ago
parent 5c61ba138c
commit 7164533d7c
  1. 30
      ImportConsole/ShallerDBProcessor.cs

@ -144,6 +144,7 @@ namespace FLocal.ImportConsole {
private readonly static DateTime UNIX = new DateTime(1970, 1, 1, 0, 0, 0); private readonly static DateTime UNIX = new DateTime(1970, 1, 1, 0, 0, 0);
public static void processDB(string filename) { public static void processDB(string filename) {
List<KeyValuePair<int, Action>> inserts = new List<KeyValuePair<int, Action>>();
HashSet<int> discussionsIds = new HashSet<int>(); HashSet<int> discussionsIds = new HashSet<int>();
using(StreamReader reader = new StreamReader(filename)) { using(StreamReader reader = new StreamReader(filename)) {
int i=0; int i=0;
@ -161,6 +162,7 @@ namespace FLocal.ImportConsole {
if(Config.instance.mainConnection.GetCountByConditions(Post.TableSpec.instance, new ComparisonCondition(Post.TableSpec.instance.getIdSpec(), ComparisonType.EQUAL, postId.ToString())) > 0) { if(Config.instance.mainConnection.GetCountByConditions(Post.TableSpec.instance, new ComparisonCondition(Post.TableSpec.instance.getIdSpec(), ComparisonType.EQUAL, postId.ToString())) > 0) {
Console.Write("-"); Console.Write("-");
} else { } else {
inserts.Add(new KeyValuePair<int, Action>(postId, () => {
int localMain = int.Parse(data["Local_Main"]); int localMain = int.Parse(data["Local_Main"]);
int main = int.Parse(data["Main"]); int main = int.Parse(data["Main"]);
int UnixTime; int UnixTime;
@ -236,6 +238,7 @@ namespace FLocal.ImportConsole {
post.Reply(user, title, body, layer, date, postId); post.Reply(user, title, body, layer, date, postId);
} }
Console.Write("+"); Console.Write("+");
}));
} }
} catch(Exception e) { } catch(Exception e) {
Console.Error.WriteLine("Cannot process post #" + postId + ": " + e.GetType().FullName + ": " + e.Message); Console.Error.WriteLine("Cannot process post #" + postId + ": " + e.GetType().FullName + ": " + e.Message);
@ -257,9 +260,36 @@ namespace FLocal.ImportConsole {
} }
Console.WriteLine("Not found discussions:"); Console.WriteLine("Not found discussions:");
int j=0;
foreach(var insert in inserts) {
if(j%1000 == 0) {
Console.Write("[" + (int)(j/1000) + "]");
}
try {
insert.Value();
Console.Write("+");
} catch(Exception e) {
Console.Error.WriteLine("Cannot process post #" + insert.Key + ": " + e.GetType().FullName + ": " + e.Message);
Console.Error.WriteLine(e.StackTrace);
Console.Write("!");
// Console.ReadLine();
} finally {
j++;
if((j%50000)==0) {
Core.RegistryCleaner.CleanRegistry<int, Post>();
Core.RegistryCleaner.CleanRegistry<int, Thread>();
GC.Collect();
Console.Error.WriteLine();
Console.Error.WriteLine("Registry cleaned; garbage collected");
Console.Error.WriteLine();
}
}
}
foreach(int discussionId in discussionsIds.OrderBy(id => id)) { foreach(int discussionId in discussionsIds.OrderBy(id => id)) {
Console.WriteLine(discussionId); Console.WriteLine(discussionId);
} }
} }
} }

Loading…
Cancel
Save