From abb9e93df7892c82ba7c71fd2b5f6c086ebc05d8 Mon Sep 17 00:00:00 2001 From: inga-lovinde <52715130+inga-lovinde@users.noreply.github.com> Date: Thu, 8 Jul 2010 08:36:11 +0000 Subject: [PATCH] Fixed critical bugs in ShallerDBProcessor --- ImportConsole/ShallerDBProcessor.cs | 23 ++++++++++++++++++++++- Importer/DictionaryConverter.cs | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ImportConsole/ShallerDBProcessor.cs b/ImportConsole/ShallerDBProcessor.cs index e5cce28..94bd3dd 100644 --- a/ImportConsole/ShallerDBProcessor.cs +++ b/ImportConsole/ShallerDBProcessor.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 { + { 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"]); diff --git a/Importer/DictionaryConverter.cs b/Importer/DictionaryConverter.cs index 7aa57de..d689577 100644 --- a/Importer/DictionaryConverter.cs +++ b/Importer/DictionaryConverter.cs @@ -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(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; }