• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

iSightを使ってBooklog,MediaMarkerインポート用CSVファイルを生成するアプリ


Commit MetaInfo

Révision51917f07f6a13303b7b54c84e74c07500fe2782f (tree)
l'heure2011-03-01 21:18:18
Auteurmasakih <masakih@user...>
Commitermasakih

Message de Log

[New] booklog形式でのエクスポートに対応。

Change Summary

Modification

--- a/BEBooklogBooksExporter.m
+++ b/BEBooklogBooksExporter.m
@@ -7,8 +7,82 @@
77 //
88
99 #import "BEBooklogBooksExporter.h"
10-#import "MyBookInformation.h"
10+#import "BEBookInformation.h"
1111
1212
1313 @implementation BEBooklogBooksExporter
14+NSString *normalizeString(NSString *string)
15+{
16+ if(!string) return @"";
17+ if([string isKindOfClass:[NSAttributedString class]]) {
18+ string = [(NSAttributedString *)string string];
19+ }
20+ return string;
21+}
22+- (NSString *)statusNameWithBook:(BEBookInformation *)book
23+{
24+ NSString *result = nil;
25+ switch([book.status intValue]) {
26+ case 0:
27+ result = @"-";
28+ break;
29+ case 1:
30+ result = NSLocalizedString(@"Want read", @"Want read");
31+ break;
32+ case 2:
33+ result = NSLocalizedString(@"Now reading", @"Now reading");
34+ break;
35+ case 3:
36+ result = NSLocalizedString(@"Already read", @"Already read");
37+ break;
38+ case 4:
39+ result = NSLocalizedString(@"Stack", @"Stack");
40+ break;
41+ default:
42+ return @"";
43+ }
44+ return result;
45+}
46+- (BOOL)exportToURL:(NSURL *)url
47+{
48+ NSMutableArray *array = [NSMutableArray array];
49+ NSDateFormatter *dateFormatter01 = [[[NSDateFormatter alloc] init] autorelease];
50+ [dateFormatter01 setDateFormat:@"YYYY-MM-dd' 'HH':'mm':'ss"];
51+ NSDateFormatter *dateFormatter02 = [[[NSDateFormatter alloc] init] autorelease];
52+ [dateFormatter02 setDateFormat:@"YYYY"];
53+ for(BEBookInformation *book in books) {
54+ NSString *line = [NSString stringWithFormat:
55+ @"%@\t%@\t%@\t%@\t%@\t%@\t%@\t%@\t%@\t%@\t%@\t%@\t%@",
56+ normalizeString(book.asin),
57+ normalizeString(book.isbn),
58+ normalizeString(book.title),
59+ normalizeString(book.author),
60+ normalizeString(book.manufacturer),
61+ normalizeString([dateFormatter02 stringFromDate:book.publicationDate]),
62+ normalizeString(@"Books"),
63+ normalizeString(book.category),
64+ normalizeString([book.rating stringValue]),
65+ normalizeString(book.review),
66+ normalizeString([self statusNameWithBook:book]),
67+ normalizeString([dateFormatter01 stringFromDate:book.readDate]),
68+ normalizeString([dateFormatter01 stringFromDate:book.registerDate])];
69+ [array addObject:line];
70+ }
71+ if([array count] == 0) return NO;
72+
73+ NSString *lines = [array componentsJoinedByString:@"\r\n"];
74+ NSError *error = nil;
75+ BOOL isOK = NO;
76+ isOK = [lines writeToURL:url atomically:YES encoding:NSShiftJISStringEncoding error:&error];
77+ if(!isOK) {
78+ NSString *errorString = nil;
79+ if(error) {
80+ errorString = [error localizedDescription];
81+ }
82+ NSLog(@"Error exporting -> %@", errorString);
83+ return NO;
84+ }
85+ return YES;
86+}
87+
1488 @end
--- a/BEBooksExporter.m
+++ b/BEBooksExporter.m
@@ -9,6 +9,7 @@
99 #import "BEBooksExporter.h"
1010
1111 #import "BEBooklogBooksExporter.h"
12+#import "BEMediaMarkerBooksExporter.h"
1213
1314
1415 @implementation BEBooksExporter
@@ -21,6 +22,9 @@
2122 case 0:
2223 createClass = [BEBooklogBooksExporter class];
2324 break;
25+ case 1:
26+ createClass = [BEMediaMarkerBooksExporter class];
27+ break;
2428 }
2529
2630 if(!createClass) return nil;
--- a/BooksExporter.xcodeproj/project.pbxproj
+++ b/BooksExporter.xcodeproj/project.pbxproj
@@ -317,8 +317,6 @@
317317 children = (
318318 F44EEB4A131A7E0F00CAA969 /* Base64EncDec.h */,
319319 F44EEB4B131A7E0F00CAA969 /* Base64EncDec.m */,
320- F44EEAD3131A5ECE00CAA969 /* BEAmazonLookup.h */,
321- F44EEAD4131A5ECE00CAA969 /* BEAmazonLookup.m */,
322320 05B708550D12DA11004E1545 /* MyBarcodeScanner.h */,
323321 05B708560D12DA11004E1545 /* MyBarcodeScanner.m */,
324322 05B708530D12D9F3004E1545 /* SampleCIView.h */,
@@ -330,6 +328,8 @@
330328 05FC63710DF401F80087B320 /* Old Sequence Grabber */,
331329 05D5F68A0AFB9AF7005A12B0 /* MyGraphView.h */,
332330 05D5F68B0AFB9AF7005A12B0 /* MyGraphView.m */,
331+ F44EEAD3131A5ECE00CAA969 /* BEAmazonLookup.h */,
332+ F44EEAD4131A5ECE00CAA969 /* BEAmazonLookup.m */,
333333 F44EEAB2131A562F00CAA969 /* BEBookInformation.h */,
334334 F44EEAB3131A562F00CAA969 /* BEBookInformation.m */,
335335 F44EEB17131A752500CAA969 /* BEAmazonSignatureGenerator.h */,