Fixed critical bugs in ShallerDBProcessor

main
Inga 🏳‍🌈 15 years ago
parent 264e809af9
commit abb9e93df7
  1. 23
      ImportConsole/ShallerDBProcessor.cs
  2. 2
      Importer/DictionaryConverter.cs

@ -170,8 +170,29 @@ namespace FLocal.ImportConsole {
}
int postId = int.Parse(data["Number"]);
try {
if(inserts.ContainsKey(postId) || Config.instance.mainConnection.GetCountByConditions(Post.TableSpec.instance, new ComparisonCondition(Post.TableSpec.instance.getIdSpec(), ComparisonType.EQUAL, postId.ToString())) > 0) {
if(inserts.ContainsKey(postId)) {
Console.Write("-");
} else if(Config.instance.mainConnection.GetCountByConditions(Post.TableSpec.instance, new ComparisonCondition(Post.TableSpec.instance.getIdSpec(), ComparisonType.EQUAL, postId.ToString())) > 0) {
Post post = Post.LoadById(postId);
if(post.title.StartsWith("%") || post.body.StartsWith("%")) {
string title = data["Subject"];
string body = data["Body"];
inserts[postId] = () => {
ChangeSetUtil.ApplyChanges(
new UpdateChange(
Post.TableSpec.instance,
new Dictionary<string, AbstractFieldValue> {
{ Post.TableSpec.FIELD_TITLE, new ScalarFieldValue(title) },
{ Post.TableSpec.FIELD_BODY, new ScalarFieldValue(body) },
},
post.id
)
);
};
Console.Write("+");
} else {
Console.Write("-");
}
} else {
int localMain = int.Parse(data["Local_Main"]);
int main = int.Parse(data["Main"]);

@ -16,7 +16,7 @@ namespace FLocal.Importer {
foreach(var str in dump.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)) {// let parts = elem.Split(new char[] { '=' }, 2) select new KeyValuePair<string, string>(HttpUtility.UrlDecode(parts[0], ShallerConnector.encoding), HttpUtility.UrlDecode(parts[1], ShallerConnector.encoding)))) {
string[] parts = str.Split(new char[] { '=' }, 2);
if(parts.Length != 2) throw new ApplicationException("wrong parts count " + parts.Length);
result[parts[0]] = parts[1];
result[HttpUtility.UrlDecode(parts[0], ShallerConnector.encoding)] = HttpUtility.UrlDecode(parts[1], ShallerConnector.encoding);
}
return result;
}

Loading…
Cancel
Save