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; }