| 1 |
hi_ |
1.1 |
unit RoundData; |
| 2 |
|
|
|
| 3 |
|
|
interface |
| 4 |
|
|
|
| 5 |
|
|
uses |
| 6 |
|
|
Windows, Messages, SysUtils, Classes, |
| 7 |
|
|
GikoSystem, BoardGroup; |
| 8 |
|
|
|
| 9 |
|
|
type |
| 10 |
|
|
TGikoRoundType = (grtBoard, grtItem); |
| 11 |
|
|
TRoundItem = class; |
| 12 |
|
|
|
| 13 |
|
|
TRoundList = class(TObject) |
| 14 |
|
|
private |
| 15 |
h677 |
1.6 |
FOldFileRead: Boolean; |
| 16 |
hi_ |
1.1 |
FBoardList: TList; |
| 17 |
|
|
FItemList: TList; |
| 18 |
|
|
function GetCount(RoundType: TGikoRoundType): Integer; |
| 19 |
|
|
function GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem; |
| 20 |
h677 |
1.5 |
function ParseRoundBoardLine(Line: string): TRoundItem; |
| 21 |
h677 |
1.8 |
function ParseRoundThreadLine(Line: string): TRoundItem; |
| 22 |
h677 |
1.5 |
function ParseOldRoundBoardLine(Line: string): TRoundItem; |
| 23 |
h677 |
1.8 |
function ParseOldRoundThreadLine(Line: string): TRoundItem; |
| 24 |
hi_ |
1.1 |
public |
| 25 |
|
|
RoundNameList: TStringList; |
| 26 |
|
|
|
| 27 |
|
|
constructor Create; |
| 28 |
|
|
destructor Destroy; override; |
| 29 |
|
|
function Add(Board: TBoard): Integer; overload; |
| 30 |
|
|
function Add(ThreadItem: TThreadItem): Integer; overload; |
| 31 |
|
|
procedure Delete(Board: TBoard); overload; |
| 32 |
|
|
procedure Delete(ThreadItem: TThreadItem); overload; |
| 33 |
h677 |
1.6 |
procedure Delete(URL: string; RoundType: TGikoRoundType); overload; |
| 34 |
hi_ |
1.1 |
procedure Clear; |
| 35 |
|
|
function Find(Board: TBoard): Integer; overload; |
| 36 |
|
|
function Find(ThreadItem: TThreadItem): Integer; overload; |
| 37 |
h677 |
1.6 |
function Find(URL: string; RoundType: TGikoRoundType): Integer; overload; |
| 38 |
hi_ |
1.1 |
property Count[RoundType: TGikoRoundType]: Integer read GetCount; |
| 39 |
h677 |
1.6 |
property OldFileRead: Boolean read FOldFileRead; |
| 40 |
hi_ |
1.1 |
property Items[Index: integer; RoundType: TGikoRoundType]: TRoundItem read GetRoundItem; |
| 41 |
|
|
procedure SetRoundName(Board: TBoard; RoundName: string); overload; |
| 42 |
|
|
procedure SetRoundName(ThreadItem: TThreadItem; RoundName: string); overload; |
| 43 |
|
|
|
| 44 |
h677 |
1.5 |
procedure LoadRoundBoardFile; |
| 45 |
|
|
procedure LoadRoundThreadFile; |
| 46 |
hi_ |
1.1 |
procedure SaveRoundFile; |
| 47 |
h677 |
1.17 |
|
| 48 |
|
|
procedure URLReplace(oldURLs: TStringList; newURLs :TStringList); |
| 49 |
hi_ |
1.1 |
end; |
| 50 |
|
|
|
| 51 |
|
|
TRoundItem = class(TObject) |
| 52 |
|
|
private |
| 53 |
|
|
// FBBSType: TGikoBBSType; |
| 54 |
|
|
FRoundName: string; |
| 55 |
|
|
FRoundType: TGikoRoundType; |
| 56 |
h677 |
1.6 |
//Item : TObject; |
| 57 |
yoffy |
1.3 |
FURL : string; |
| 58 |
hi_ |
1.1 |
FBoardTitle: string; |
| 59 |
|
|
FThreadTitle: string; |
| 60 |
|
|
FFileName: string; |
| 61 |
|
|
FBoolData: Boolean; //鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃緒申 |
| 62 |
|
|
public |
| 63 |
h677 |
1.6 |
|
| 64 |
|
|
constructor Create; |
| 65 |
|
|
//property BBSType: TGikoBBSType read FBBSType write FBBSType; |
| 66 |
hi_ |
1.1 |
property RoundName: string read FRoundName write FRoundName; |
| 67 |
|
|
property RoundType: TGikoRoundType read FRoundType write FRoundType; |
| 68 |
h677 |
1.6 |
//property Item : TObject read FItem write FItem; |
| 69 |
yoffy |
1.3 |
property URL : string read FURL write FURL; |
| 70 |
hi_ |
1.1 |
property BoardTitle: string read FBoardTitle write FBoardTitle; |
| 71 |
|
|
property ThreadTitle: string read FThreadTitle write FThreadTitle; |
| 72 |
|
|
property FileName: string read FFileName write FFileName; |
| 73 |
|
|
property BoolData: Boolean read FBoolData write FBoolData; |
| 74 |
|
|
end; |
| 75 |
|
|
|
| 76 |
|
|
var |
| 77 |
|
|
RoundList: TRoundList; |
| 78 |
|
|
|
| 79 |
|
|
implementation |
| 80 |
|
|
const |
| 81 |
|
|
ROUND_BOARD_FILENAME: string = 'RoundBoard.2ch'; //鐃緒申鐃緒申鐃緒申BoardGroup鐃緒申鐃緒申鐃緒申 |
| 82 |
|
|
ROUND_ITEM_FILENAME: string = 'RoundItem.2ch'; //鐃緒申鐃緒申 |
| 83 |
h677 |
1.5 |
ROUND_INDEX_VERSION: string = '2.00'; |
| 84 |
h677 |
1.7 |
ERROR_BOARD_FILENAME: string = 'ErrorBoard.2ch'; //Error鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 85 |
|
|
ERROR_ITEM_FILENAME: string = 'ErrorItem.2ch'; //Error鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 86 |
h677 |
1.6 |
constructor TRoundItem.Create; |
| 87 |
|
|
begin |
| 88 |
|
|
inherited Create; |
| 89 |
|
|
end; |
| 90 |
hi_ |
1.1 |
constructor TRoundList.Create; |
| 91 |
|
|
begin |
| 92 |
|
|
inherited; |
| 93 |
|
|
FBoardList := TList.Create; |
| 94 |
|
|
FItemList := TList.Create; |
| 95 |
|
|
RoundNameList := TStringList.Create; |
| 96 |
|
|
RoundNameList.Sorted := True; |
| 97 |
|
|
RoundNameList.Duplicates := dupIgnore; |
| 98 |
h677 |
1.6 |
FOldFileRead := false; |
| 99 |
hi_ |
1.1 |
end; |
| 100 |
|
|
|
| 101 |
|
|
destructor TRoundList.Destroy; |
| 102 |
|
|
begin |
| 103 |
|
|
RoundNameList.Free; |
| 104 |
|
|
Clear; |
| 105 |
|
|
FBoardList.Free; |
| 106 |
|
|
FItemList.Free; |
| 107 |
h677 |
1.9 |
//inherited; |
| 108 |
hi_ |
1.1 |
end; |
| 109 |
|
|
|
| 110 |
|
|
function TRoundList.Add(Board: TBoard): Integer; |
| 111 |
|
|
var |
| 112 |
|
|
idx: Integer; |
| 113 |
|
|
Item: TRoundItem; |
| 114 |
|
|
begin |
| 115 |
h677 |
1.2 |
Result := -1; |
| 116 |
hi_ |
1.1 |
idx := Find(Board); |
| 117 |
|
|
if idx = -1 then begin |
| 118 |
|
|
Item := TRoundItem.Create; |
| 119 |
|
|
// Item.BBSType := gbt2ch; //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 120 |
|
|
Item.RoundType := grtBoard; |
| 121 |
h677 |
1.6 |
// Item.Item := Board; |
| 122 |
h677 |
1.5 |
Item.URL := Board.URL; |
| 123 |
hi_ |
1.1 |
Item.BoardTitle := Board.Title; |
| 124 |
|
|
Item.ThreadTitle := ''; |
| 125 |
|
|
Item.FileName := ''; |
| 126 |
|
|
Item.RoundName := Board.RoundName; |
| 127 |
h677 |
1.2 |
Result := FBoardList.Add(Item); |
| 128 |
hi_ |
1.1 |
end; |
| 129 |
|
|
end; |
| 130 |
|
|
|
| 131 |
|
|
function TRoundList.Add(ThreadItem: TThreadItem): Integer; |
| 132 |
|
|
var |
| 133 |
|
|
idx: Integer; |
| 134 |
|
|
Item: TRoundItem; |
| 135 |
|
|
begin |
| 136 |
h677 |
1.2 |
Result := -1; |
| 137 |
hi_ |
1.1 |
idx := Find(ThreadItem); |
| 138 |
|
|
if idx = -1 then begin |
| 139 |
|
|
Item := TRoundItem.Create; |
| 140 |
|
|
// Item.BBSType := gbt2ch; //鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 141 |
|
|
Item.RoundType := grtItem; |
| 142 |
h677 |
1.6 |
// Item.Item := ThreadItem; |
| 143 |
h677 |
1.4 |
Item.URL := Threaditem.URL; |
| 144 |
hi_ |
1.1 |
Item.BoardTitle := ThreadItem.ParentBoard.Title; |
| 145 |
|
|
Item.ThreadTitle := ThreadItem.Title; |
| 146 |
|
|
Item.FileName := ThreadItem.FileName; |
| 147 |
|
|
Item.RoundName := ThreadItem.RoundName; |
| 148 |
h677 |
1.2 |
Result := FItemList.Add(Item); |
| 149 |
hi_ |
1.1 |
end; |
| 150 |
|
|
end; |
| 151 |
|
|
|
| 152 |
|
|
procedure TRoundList.Delete(Board: TBoard); |
| 153 |
|
|
var |
| 154 |
|
|
idx: Integer; |
| 155 |
h677 |
1.12 |
// Item: TRoundItem; |
| 156 |
hi_ |
1.1 |
begin |
| 157 |
|
|
idx := Find(Board); |
| 158 |
|
|
if idx <> -1 then begin |
| 159 |
h677 |
1.8 |
TRoundItem(FBoardList[idx]).Free; |
| 160 |
hi_ |
1.1 |
FBoardList.Delete(idx); |
| 161 |
|
|
end; |
| 162 |
|
|
end; |
| 163 |
|
|
|
| 164 |
|
|
procedure TRoundList.Delete(ThreadItem: TThreadItem); |
| 165 |
|
|
var |
| 166 |
|
|
idx: Integer; |
| 167 |
h677 |
1.12 |
// Item: TRoundItem; |
| 168 |
hi_ |
1.1 |
begin |
| 169 |
|
|
idx := Find(ThreadItem); |
| 170 |
|
|
if idx <> -1 then begin |
| 171 |
h677 |
1.8 |
TRoundItem(FItemList[idx]).Free; |
| 172 |
hi_ |
1.1 |
FItemList.Delete(idx); |
| 173 |
|
|
end; |
| 174 |
|
|
end; |
| 175 |
|
|
|
| 176 |
|
|
procedure TRoundList.Clear; |
| 177 |
|
|
var |
| 178 |
|
|
i: Integer; |
| 179 |
|
|
begin |
| 180 |
h677 |
1.14 |
for i := FBoardList.Count - 1 downto 0 do begin |
| 181 |
h677 |
1.8 |
if FBoardList[i] <> nil then |
| 182 |
|
|
TRoundItem(FBoardList[i]).Free; |
| 183 |
hi_ |
1.1 |
FBoardList.Delete(i); |
| 184 |
|
|
end; |
| 185 |
h677 |
1.16 |
FBoardList.Capacity := FBoardList.Count; |
| 186 |
h677 |
1.14 |
for i := FItemList.Count - 1 downto 0 do begin |
| 187 |
h677 |
1.8 |
if FItemList[i] <> nil then |
| 188 |
|
|
TRoundItem(FItemList[i]).Free; |
| 189 |
hi_ |
1.1 |
FItemList.Delete(i); |
| 190 |
|
|
end; |
| 191 |
h677 |
1.16 |
FItemList.Capacity := FItemList.Count; |
| 192 |
hi_ |
1.1 |
end; |
| 193 |
|
|
|
| 194 |
|
|
function TRoundList.Find(Board: TBoard): Integer; |
| 195 |
|
|
var |
| 196 |
|
|
i: Integer; |
| 197 |
|
|
Item: TRoundItem; |
| 198 |
|
|
begin |
| 199 |
|
|
Result := -1; |
| 200 |
|
|
for i := 0 to FBoardList.Count - 1 do begin |
| 201 |
|
|
Item := TRoundItem(FBoardList[i]); |
| 202 |
|
|
if Item.FRoundType <> grtBoard then Continue; |
| 203 |
h677 |
1.5 |
if Item.FURL = Board.URL then begin |
| 204 |
hi_ |
1.1 |
Result := i; |
| 205 |
|
|
Exit; |
| 206 |
|
|
end; |
| 207 |
|
|
end; |
| 208 |
|
|
end; |
| 209 |
|
|
|
| 210 |
|
|
function TRoundList.Find(ThreadItem: TThreadItem): Integer; |
| 211 |
|
|
var |
| 212 |
|
|
i: Integer; |
| 213 |
|
|
Item: TRoundItem; |
| 214 |
|
|
begin |
| 215 |
|
|
Result := -1; |
| 216 |
|
|
for i := 0 to FItemList.Count - 1 do begin |
| 217 |
|
|
Item := TRoundItem(FItemList[i]); |
| 218 |
|
|
if Item.FRoundType <> grtItem then Continue; |
| 219 |
h677 |
1.5 |
if Item.FURL = ThreadItem.URL then begin |
| 220 |
hi_ |
1.1 |
Result := i; |
| 221 |
|
|
Exit; |
| 222 |
|
|
end; |
| 223 |
|
|
end; |
| 224 |
|
|
end; |
| 225 |
h677 |
1.6 |
function TRoundList.Find(URL: string; RoundType: TGikoRoundType): Integer; |
| 226 |
|
|
var |
| 227 |
|
|
i: Integer; |
| 228 |
|
|
Item: TRoundItem; |
| 229 |
|
|
begin |
| 230 |
|
|
Result := -1; |
| 231 |
h677 |
1.14 |
if RoundType = grtItem then begin |
| 232 |
|
|
for i := 0 to FItemList.Count - 1 do begin |
| 233 |
|
|
Item := TRoundItem(FItemList[i]); |
| 234 |
|
|
if Item.FRoundType <> RoundType then Continue; |
| 235 |
|
|
if Item.FURL = URL then begin |
| 236 |
|
|
Result := i; |
| 237 |
|
|
Exit; |
| 238 |
|
|
end; |
| 239 |
|
|
end; |
| 240 |
|
|
end else begin |
| 241 |
|
|
for i := 0 to FBoardList.Count - 1 do begin |
| 242 |
|
|
Item := TRoundItem(FBoardList[i]); |
| 243 |
|
|
if Item.FRoundType <> RoundType then Continue; |
| 244 |
|
|
if Item.FURL = URL then begin |
| 245 |
|
|
Result := i; |
| 246 |
|
|
Exit; |
| 247 |
|
|
end; |
| 248 |
h677 |
1.6 |
end; |
| 249 |
h677 |
1.14 |
end; |
| 250 |
h677 |
1.6 |
end; |
| 251 |
|
|
procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType); |
| 252 |
|
|
var |
| 253 |
|
|
idx: Integer; |
| 254 |
|
|
Item: TRoundItem; |
| 255 |
|
|
board: TBoard; |
| 256 |
|
|
threadItem: TThreadItem; |
| 257 |
|
|
begin |
| 258 |
|
|
idx := Find(URL, RoundType); |
| 259 |
|
|
if idx <> -1 then begin |
| 260 |
h677 |
1.14 |
|
| 261 |
h677 |
1.6 |
if RoundType = grtBoard then begin |
| 262 |
h677 |
1.14 |
Item := TRoundItem(FBoardList[idx]); |
| 263 |
|
|
Item.Free; |
| 264 |
|
|
FBoardList.Delete(idx); |
| 265 |
h677 |
1.6 |
board := BBSsFindBoardFromURL(URL); |
| 266 |
h677 |
1.14 |
if board <> nil then begin |
| 267 |
|
|
board.Round := False; |
| 268 |
|
|
board.RoundName := ''; |
| 269 |
|
|
end; |
| 270 |
h677 |
1.6 |
end else begin |
| 271 |
h677 |
1.14 |
Item := TRoundItem(FItemList[idx]); |
| 272 |
|
|
Item.Free; |
| 273 |
|
|
FItemList.Delete(idx); |
| 274 |
|
|
|
| 275 |
h677 |
1.6 |
threadItem := BBSsFindThreadFromURL(URL); |
| 276 |
h677 |
1.14 |
if threadItem <> nil then begin |
| 277 |
|
|
threadItem.Round := false; |
| 278 |
|
|
threadItem.RoundName := ''; |
| 279 |
|
|
end; |
| 280 |
h677 |
1.6 |
end; |
| 281 |
|
|
end; |
| 282 |
|
|
end; |
| 283 |
hi_ |
1.1 |
|
| 284 |
|
|
procedure TRoundList.SetRoundName(Board: TBoard; RoundName: string); |
| 285 |
|
|
var |
| 286 |
|
|
idx: Integer; |
| 287 |
|
|
Item: TRoundItem; |
| 288 |
|
|
begin |
| 289 |
|
|
idx := Find(Board); |
| 290 |
|
|
if idx <> -1 then begin |
| 291 |
|
|
Item := TRoundItem(FBoardList[idx]); |
| 292 |
|
|
Item.RoundName := RoundName; |
| 293 |
|
|
end; |
| 294 |
|
|
end; |
| 295 |
|
|
|
| 296 |
|
|
procedure TRoundList.SetRoundName(ThreadItem: TThreadItem; RoundName: string); |
| 297 |
|
|
var |
| 298 |
|
|
idx: Integer; |
| 299 |
|
|
Item: TRoundItem; |
| 300 |
|
|
begin |
| 301 |
|
|
idx := Find(ThreadItem); |
| 302 |
|
|
if idx <> -1 then begin |
| 303 |
|
|
Item := TRoundItem(FItemList[idx]); |
| 304 |
|
|
Item.RoundName := RoundName; |
| 305 |
|
|
end; |
| 306 |
|
|
end; |
| 307 |
|
|
|
| 308 |
|
|
function TRoundList.GetCount(RoundType: TGikoRoundType): Integer; |
| 309 |
|
|
begin |
| 310 |
|
|
Result := 0; |
| 311 |
|
|
if RoundType = grtBoard then |
| 312 |
|
|
Result := FBoardList.Count |
| 313 |
|
|
else if RoundType = grtItem then |
| 314 |
|
|
Result := FItemList.Count; |
| 315 |
|
|
end; |
| 316 |
|
|
|
| 317 |
|
|
function TRoundList.GetRoundItem(Index: Integer; RoundType: TGikoRoundType): TRoundItem; |
| 318 |
|
|
begin |
| 319 |
|
|
Result := nil; |
| 320 |
|
|
if RoundType = grtBoard then begin |
| 321 |
|
|
if (Index >= 0) and (Index < FBoardList.Count) then |
| 322 |
|
|
Result := TRoundItem(FBoardList[Index]); |
| 323 |
|
|
end else if RoundType = grtItem then begin |
| 324 |
|
|
if (Index >= 0) and (Index < FItemList.Count) then |
| 325 |
|
|
Result := TRoundItem(FItemList[Index]); |
| 326 |
|
|
end; |
| 327 |
|
|
end; |
| 328 |
h677 |
1.5 |
procedure TRoundList.LoadRoundBoardFile; |
| 329 |
hi_ |
1.1 |
var |
| 330 |
|
|
i: Integer; |
| 331 |
|
|
sl: TStringList; |
| 332 |
h677 |
1.19 |
FileName, bFileName: string; |
| 333 |
|
|
errorSl: TStringList; |
| 334 |
|
|
errorFileName: string; |
| 335 |
hi_ |
1.1 |
Item: TRoundItem; |
| 336 |
h677 |
1.19 |
delCount: Integer; |
| 337 |
hi_ |
1.1 |
begin |
| 338 |
|
|
sl := TStringList.Create; |
| 339 |
h677 |
1.19 |
errorSl := TStringList.Create; |
| 340 |
h677 |
1.7 |
errorSl.Duplicates := dupIgnore; |
| 341 |
hi_ |
1.1 |
try |
| 342 |
|
|
//鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 343 |
|
|
FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME; |
| 344 |
h677 |
1.19 |
bFileName := GikoSys.GetConfigDir + '~' + ROUND_BOARD_FILENAME; |
| 345 |
|
|
//鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 346 |
|
|
errorFileName := GikoSys.GetConfigDir + ERROR_BOARD_FILENAME; |
| 347 |
|
|
|
| 348 |
hi_ |
1.1 |
if FileExists(FileName) then begin |
| 349 |
|
|
sl.LoadFromFile(FileName); |
| 350 |
h677 |
1.19 |
if FileExists(bFileName) then |
| 351 |
|
|
DeleteFile(bFileName); |
| 352 |
|
|
//鐃?鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 353 |
|
|
sl.SaveToFile(bFileName); |
| 354 |
|
|
if FileExists(errorFileName) then begin |
| 355 |
|
|
try |
| 356 |
h677 |
1.7 |
errorSl.LoadFromFile(errorFileName); |
| 357 |
|
|
except |
| 358 |
|
|
end; |
| 359 |
|
|
end; |
| 360 |
|
|
//Item := TRoundItem.Create; |
| 361 |
h677 |
1.15 |
delCount := 0; |
| 362 |
h677 |
1.5 |
//鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申 |
| 363 |
|
|
if sl[0] = ROUND_INDEX_VERSION then begin |
| 364 |
deux |
1.13 |
for i := 1 to sl.Count - 1 do begin |
| 365 |
h677 |
1.15 |
Item := ParseRoundBoardLine(sl[i - delCount]); |
| 366 |
h677 |
1.7 |
if Item <> nil then begin |
| 367 |
|
|
FBoardList.Add(Item); |
| 368 |
|
|
RoundNameList.Add(Item.RoundName); |
| 369 |
|
|
end else begin |
| 370 |
h677 |
1.15 |
errorSl.Add( sl[i - delCount] ); |
| 371 |
|
|
sl.Delete(i- delCount); |
| 372 |
|
|
Inc(delCount); |
| 373 |
h677 |
1.7 |
end; |
| 374 |
h677 |
1.5 |
end; |
| 375 |
|
|
end else begin |
| 376 |
h677 |
1.6 |
if FOldFileRead then begin //鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 377 |
deux |
1.13 |
for i := 1 to sl.Count - 1 do begin |
| 378 |
h677 |
1.15 |
Item := ParseOldRoundBoardLine(sl[i - delCount]); |
| 379 |
h677 |
1.7 |
if Item <> nil then begin |
| 380 |
|
|
FBoardList.Add(Item); |
| 381 |
|
|
RoundNameList.Add(Item.RoundName); |
| 382 |
|
|
end else begin |
| 383 |
h677 |
1.15 |
errorSl.Add( sl[i- delCount] ); |
| 384 |
|
|
sl.Delete(i- delCount); |
| 385 |
|
|
Inc(delCount); |
| 386 |
h677 |
1.7 |
end; |
| 387 |
h677 |
1.6 |
end; |
| 388 |
|
|
end else |
| 389 |
|
|
FOldFileRead := true; |
| 390 |
h677 |
1.5 |
end; |
| 391 |
hi_ |
1.1 |
end; |
| 392 |
h677 |
1.7 |
if errorSl.Count > 0 then |
| 393 |
|
|
errorSl.SaveToFile(errorFileName); |
| 394 |
h677 |
1.5 |
finally |
| 395 |
h677 |
1.7 |
errorSl.Free; |
| 396 |
h677 |
1.5 |
sl.Free; |
| 397 |
|
|
end; |
| 398 |
|
|
end; |
| 399 |
|
|
procedure TRoundList.LoadRoundThreadFile; |
| 400 |
|
|
var |
| 401 |
|
|
i: Integer; |
| 402 |
h677 |
1.12 |
// j: Integer; |
| 403 |
h677 |
1.5 |
sl: TStringList; |
| 404 |
h677 |
1.19 |
FileName, bFileName: string; |
| 405 |
h677 |
1.7 |
errorSl: TStringList; |
| 406 |
|
|
errorFileName: string; |
| 407 |
h677 |
1.5 |
Item: TRoundItem; |
| 408 |
h677 |
1.15 |
delCount: Integer; |
| 409 |
h677 |
1.8 |
// boardList : TStringList; |
| 410 |
h677 |
1.5 |
begin |
| 411 |
h677 |
1.8 |
// boardList := TStringList.Create; |
| 412 |
|
|
// boardList.Duplicates := dupIgnore; |
| 413 |
h677 |
1.7 |
errorSl := TStringList.Create; |
| 414 |
|
|
errorSl.Duplicates := dupIgnore; |
| 415 |
h677 |
1.5 |
sl := TStringList.Create; |
| 416 |
|
|
try |
| 417 |
hi_ |
1.1 |
//鐃?鐃緒申鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 418 |
|
|
FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME; |
| 419 |
h677 |
1.19 |
bFileName := GikoSys.GetConfigDir + '~' + ROUND_ITEM_FILENAME; |
| 420 |
|
|
//鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申 |
| 421 |
h677 |
1.7 |
errorFileName := GikoSys.GetConfigDir + ERROR_ITEM_FILENAME; |
| 422 |
hi_ |
1.1 |
if FileExists(FileName) then begin |
| 423 |
|
|
sl.LoadFromFile(FileName); |
| 424 |
h677 |
1.19 |
if FileExists(bFileName) then |
| 425 |
|
|
DeleteFile(bFileName); |
| 426 |
|
|
sl.SaveToFile(bFileName); |
| 427 |
|
|
if FileExists(errorFileName) then begin |
| 428 |
h677 |
1.7 |
try |
| 429 |
|
|
errorSl.LoadFromFile(errorFileName); |
| 430 |
|
|
except |
| 431 |
|
|
end; |
| 432 |
|
|
end; |
| 433 |
|
|
//Item := TRoundItem.Create; |
| 434 |
h677 |
1.15 |
delCount := 0; |
| 435 |
h677 |
1.5 |
//鐃?鐃?鐃緒申鐃緒申鐃?鐃?鐃?鐃緒申鐃緒申 |
| 436 |
|
|
if sl[0] = ROUND_INDEX_VERSION then begin |
| 437 |
deux |
1.13 |
for i := 1 to sl.Count - 1 do begin |
| 438 |
h677 |
1.15 |
Item := ParseRoundThreadLine(sl[i - delCount]); |
| 439 |
h677 |
1.7 |
if Item <> nil then begin |
| 440 |
|
|
FItemList.Add(Item); |
| 441 |
|
|
RoundNameList.Add(Item.RoundName); |
| 442 |
|
|
end else begin |
| 443 |
h677 |
1.15 |
errorSl.Add(sl[i - delCount]); |
| 444 |
|
|
sl.Delete(i - delCount); |
| 445 |
|
|
Inc(delCount); |
| 446 |
h677 |
1.7 |
end; |
| 447 |
|
|
end; |
| 448 |
h677 |
1.5 |
end else begin |
| 449 |
h677 |
1.6 |
LoadRoundBoardFile; |
| 450 |
deux |
1.13 |
for i := 1 to sl.Count - 1 do begin |
| 451 |
h677 |
1.15 |
Item := ParseOldRoundThreadLine(sl[i - delCount]); |
| 452 |
h677 |
1.7 |
if Item <> nil then begin |
| 453 |
|
|
FItemList.Add(Item); |
| 454 |
|
|
RoundNameList.Add(Item.RoundName); |
| 455 |
|
|
end else begin |
| 456 |
h677 |
1.15 |
errorSl.Add(sl[i - delCount]); |
| 457 |
|
|
sl.Delete(i - delCount); |
| 458 |
|
|
Inc(delCount); |
| 459 |
h677 |
1.7 |
end; |
| 460 |
h677 |
1.5 |
end; |
| 461 |
|
|
end; |
| 462 |
h677 |
1.8 |
// j := boardList.Count - 1; |
| 463 |
|
|
// while j >= 0 do begin |
| 464 |
|
|
// GikoSys.ReadSubjectFile( BBSsFindBoardFromURL( boardList[j] ) ); |
| 465 |
|
|
// boardList.Delete(j); |
| 466 |
|
|
// Dec(j); |
| 467 |
|
|
// end; |
| 468 |
h677 |
1.7 |
if errorSl.Count > 0 then |
| 469 |
|
|
errorSl.SaveToFile(errorFileName); |
| 470 |
hi_ |
1.1 |
end; |
| 471 |
|
|
finally |
| 472 |
h677 |
1.16 |
errorSl.Free; |
| 473 |
hi_ |
1.1 |
sl.Free; |
| 474 |
h677 |
1.8 |
// boardList.Free; |
| 475 |
hi_ |
1.1 |
end; |
| 476 |
|
|
end; |
| 477 |
|
|
procedure TRoundList.SaveRoundFile; |
| 478 |
|
|
var |
| 479 |
|
|
i: integer; |
| 480 |
|
|
FileName: string; |
| 481 |
|
|
sl: TStringList; |
| 482 |
|
|
s: string; |
| 483 |
|
|
Item: TRoundItem; |
| 484 |
|
|
begin |
| 485 |
|
|
GikoSys.ForceDirectoriesEx(GikoSys.GetConfigDir); |
| 486 |
|
|
|
| 487 |
|
|
sl := TStringList.Create; |
| 488 |
|
|
try |
| 489 |
|
|
FileName := GikoSys.GetConfigDir + ROUND_BOARD_FILENAME; |
| 490 |
|
|
sl.Add(ROUND_INDEX_VERSION); |
| 491 |
deux |
1.13 |
for i := 0 to FBoardList.Count - 1 do begin |
| 492 |
hi_ |
1.1 |
Item := TRoundItem(FBoardList[i]); |
| 493 |
yoffy |
1.3 |
s := Item.URL + #1 |
| 494 |
hi_ |
1.1 |
+ Item.BoardTitle + #1 |
| 495 |
|
|
+ Item.RoundName; |
| 496 |
|
|
sl.Add(s); |
| 497 |
|
|
end; |
| 498 |
|
|
sl.SaveToFile(FileName); |
| 499 |
|
|
sl.Clear; |
| 500 |
|
|
FileName := GikoSys.GetConfigDir + ROUND_ITEM_FILENAME; |
| 501 |
|
|
sl.Add(ROUND_INDEX_VERSION); |
| 502 |
deux |
1.13 |
for i := 0 to FItemList.Count - 1 do begin |
| 503 |
hi_ |
1.1 |
Item := TRoundItem(FItemList[i]); |
| 504 |
yoffy |
1.3 |
s := Item.URL + #1 |
| 505 |
hi_ |
1.1 |
+ Item.BoardTitle + #1 |
| 506 |
|
|
+ Item.FileName + #1 |
| 507 |
|
|
+ Item.ThreadTitle + #1 |
| 508 |
|
|
+ Item.RoundName; |
| 509 |
|
|
sl.Add(s); |
| 510 |
|
|
end; |
| 511 |
|
|
sl.SaveToFile(FileName); |
| 512 |
|
|
finally |
| 513 |
|
|
sl.Free; |
| 514 |
|
|
end; |
| 515 |
|
|
end; |
| 516 |
h677 |
1.5 |
function TRoundList.ParseRoundBoardLine(Line: string): TRoundItem; |
| 517 |
hi_ |
1.1 |
var |
| 518 |
|
|
s: string; |
| 519 |
|
|
i: Integer; |
| 520 |
|
|
begin |
| 521 |
|
|
Result := TRoundItem.Create; |
| 522 |
h677 |
1.5 |
Result.ThreadTitle := ''; |
| 523 |
|
|
Result.FileName := ''; |
| 524 |
|
|
Result.RoundType := grtBoard; |
| 525 |
|
|
for i := 0 to 2 do begin |
| 526 |
|
|
s := GikoSys.GetTokenIndex(Line, #1, i); |
| 527 |
h677 |
1.7 |
try |
| 528 |
|
|
case i of |
| 529 |
h677 |
1.5 |
0: |
| 530 |
h677 |
1.7 |
begin |
| 531 |
|
|
Result.URL := s; |
| 532 |
|
|
end; |
| 533 |
|
|
1: Result.BoardTitle := s; |
| 534 |
|
|
2: Result.RoundName := s; |
| 535 |
|
|
end; |
| 536 |
|
|
except |
| 537 |
|
|
Result := nil; |
| 538 |
|
|
Exit; |
| 539 |
h677 |
1.5 |
end; |
| 540 |
|
|
end; |
| 541 |
hi_ |
1.1 |
end; |
| 542 |
h677 |
1.5 |
|
| 543 |
h677 |
1.8 |
function TRoundList.ParseRoundThreadLine(Line: string): TRoundItem; |
| 544 |
h677 |
1.4 |
var |
| 545 |
h677 |
1.5 |
s: string; |
| 546 |
h677 |
1.4 |
i: Integer; |
| 547 |
h677 |
1.12 |
// threadItem: TThreadItem; |
| 548 |
h677 |
1.4 |
begin |
| 549 |
h677 |
1.5 |
Result := TRoundItem.Create; |
| 550 |
|
|
Result.RoundType := grtItem; |
| 551 |
|
|
for i := 0 to 4 do begin |
| 552 |
|
|
s := GikoSys.GetTokenIndex(Line, #1, i); |
| 553 |
h677 |
1.7 |
try |
| 554 |
|
|
case i of |
| 555 |
|
|
0: |
| 556 |
|
|
begin |
| 557 |
|
|
Result.URL := s; |
| 558 |
h677 |
1.8 |
//threadItem := BBSsFindThreadFromURL( s ); |
| 559 |
|
|
//if threadItem <> nil then begin |
| 560 |
|
|
// BoardList.Add( threadItem.ParentBoard.URL ); |
| 561 |
|
|
//end; |
| 562 |
h677 |
1.5 |
end; |
| 563 |
h677 |
1.7 |
1: Result.BoardTitle := s; |
| 564 |
|
|
2: Result.FileName := s; |
| 565 |
|
|
3: Result.ThreadTitle := s; |
| 566 |
|
|
4: Result.RoundName := s; |
| 567 |
|
|
end; |
| 568 |
|
|
except |
| 569 |
|
|
Result := nil; |
| 570 |
|
|
Exit; |
| 571 |
h677 |
1.5 |
end; |
| 572 |
|
|
end; |
| 573 |
|
|
end; |
| 574 |
h677 |
1.4 |
|
| 575 |
h677 |
1.5 |
function TRoundList.ParseOldRoundBoardLine(Line: string): TRoundItem; |
| 576 |
|
|
var |
| 577 |
|
|
i: Integer; |
| 578 |
h677 |
1.4 |
s: string; |
| 579 |
h677 |
1.5 |
board: TBoard; |
| 580 |
h677 |
1.4 |
begin |
| 581 |
h677 |
1.5 |
Result := TRoundItem.Create; |
| 582 |
|
|
Result.ThreadTitle := ''; |
| 583 |
|
|
Result.FileName := ''; |
| 584 |
|
|
Result.RoundType := grtBoard; |
| 585 |
h677 |
1.6 |
for i := 0 to 2 do begin |
| 586 |
h677 |
1.5 |
s := GikoSys.GetTokenIndex(Line, #1, i); |
| 587 |
h677 |
1.7 |
try |
| 588 |
|
|
case i of |
| 589 |
|
|
0: |
| 590 |
|
|
begin |
| 591 |
|
|
board := BBSs[ 0 ].FindBBSID( s ); |
| 592 |
|
|
if board <> nil then begin |
| 593 |
|
|
Result.URL := board.URL; |
| 594 |
|
|
end else begin |
| 595 |
|
|
raise Exception.Create('鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?鐃緒申鐃緒申鐃?'); |
| 596 |
|
|
end; |
| 597 |
|
|
end; |
| 598 |
|
|
1: Result.FBoardTitle := s; |
| 599 |
|
|
2: Result.RoundName := s; |
| 600 |
|
|
end; |
| 601 |
|
|
except |
| 602 |
|
|
Result := nil; |
| 603 |
|
|
Exit; |
| 604 |
h677 |
1.5 |
end; |
| 605 |
|
|
end; |
| 606 |
|
|
end; |
| 607 |
h677 |
1.4 |
|
| 608 |
h677 |
1.8 |
function TRoundList.ParseOldRoundThreadLine(Line: string): TRoundItem; |
| 609 |
h677 |
1.4 |
var |
| 610 |
|
|
i: Integer; |
| 611 |
|
|
s: string; |
| 612 |
|
|
buf: string; |
| 613 |
|
|
board: TBoard; |
| 614 |
h677 |
1.7 |
// threadItem: TThreadItem; |
| 615 |
h677 |
1.6 |
bbsID: string; |
| 616 |
h677 |
1.4 |
begin |
| 617 |
|
|
Result := TRoundItem.Create; |
| 618 |
h677 |
1.5 |
Result.RoundType := grtItem; |
| 619 |
h677 |
1.6 |
for i := 0 to 4 do begin |
| 620 |
h677 |
1.5 |
s := GikoSys.GetTokenIndex(Line, #1, i); |
| 621 |
h677 |
1.7 |
try |
| 622 |
|
|
case i of |
| 623 |
|
|
0: bbsID := s; |
| 624 |
|
|
1: Result.BoardTitle := s; |
| 625 |
|
|
2: |
| 626 |
|
|
begin |
| 627 |
|
|
Result.FileName := s; |
| 628 |
h677 |
1.10 |
board := BBSs[ 0 ].FindBBSID(bbsID); |
| 629 |
h677 |
1.7 |
if board <> nil then begin |
| 630 |
|
|
buf := Copy(board.GetSendURL,1,LastDelimiter('/', board.GetSendURL)-1); |
| 631 |
|
|
Result.URL := buf + '/read.cgi/'+ board.BBSID+ '/' +ChangeFileExt(s,'') + '/l50'; |
| 632 |
|
|
end else begin |
| 633 |
h677 |
1.10 |
raise Exception.Create('鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申'); |
| 634 |
h677 |
1.7 |
end; |
| 635 |
|
|
end; |
| 636 |
|
|
3: Result.ThreadTitle := s; |
| 637 |
|
|
4: Result.RoundName := s; |
| 638 |
|
|
end; |
| 639 |
|
|
except |
| 640 |
|
|
Result := nil; |
| 641 |
h677 |
1.15 |
break; |
| 642 |
h677 |
1.5 |
end; |
| 643 |
|
|
end; |
| 644 |
h677 |
1.17 |
end; |
| 645 |
|
|
procedure TRoundList.URLReplace(oldURLs: TStringList; newURLs :TStringList); |
| 646 |
|
|
var |
| 647 |
|
|
i: Integer; |
| 648 |
|
|
j: Integer; |
| 649 |
|
|
tempString: string; |
| 650 |
|
|
tmpURL: string; |
| 651 |
|
|
oldHost: string; |
| 652 |
|
|
oldBoardName: string; |
| 653 |
|
|
newHost: string; |
| 654 |
|
|
newBoardName: string; |
| 655 |
|
|
begin |
| 656 |
|
|
if oldURLs.Count <> newURLs.Count then |
| 657 |
|
|
Exit; |
| 658 |
|
|
//鐃緒申鐃緒申鐃緒申鐃緒申鐃?Board鐃緒申URL鐃緒申鐃緒申鐃? |
| 659 |
|
|
for j :=0 to oldURLs.Count - 1 do begin |
| 660 |
|
|
for i :=0 to FBoardList.Count - 1 do begin |
| 661 |
h677 |
1.18 |
if TRoundItem(FBoardList[i]).FURL = oldURLs[j] then |
| 662 |
|
|
TRoundItem(FBoardList[i]).FURL := newURLs[j]; |
| 663 |
h677 |
1.17 |
end; |
| 664 |
|
|
end; |
| 665 |
|
|
//鐃緒申鐃緒申鐃緒申鐃緒申鐃?Board鐃緒申URL鐃緒申鐃緒申鐃? |
| 666 |
|
|
|
| 667 |
|
|
//鐃緒申鐃緒申鐃緒申鐃緒申鐃?Thread鐃緒申URL鐃緒申鐃緒申鐃? |
| 668 |
|
|
//鐃緒申鐃?鐃緒申鐃緒申鐃緒申thread鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申URL鐃緒申鐃?鐃緒申鐃?鐃?鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃緒申鐃? |
| 669 |
|
|
for i := 0 to oldURLs.Count - 1 do begin |
| 670 |
|
|
tmpURL := Copy(oldURLs[i], 1, Length(oldURLs[i]) -1); |
| 671 |
|
|
oldHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) ); |
| 672 |
|
|
oldBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/'; |
| 673 |
|
|
tmpURL := Copy(newURLs[i], 1, Length(newURLs[i]) -1); |
| 674 |
|
|
newHost := Copy(tmpURL, 1, LastDelimiter('/', tmpURL) ); |
| 675 |
|
|
newBoardName := Copy(tmpURL, LastDelimiter('/', tmpURL), Length(tmpURL) ) + '/'; |
| 676 |
|
|
|
| 677 |
|
|
for j := 0 to FItemList.Count - 1 do begin |
| 678 |
|
|
tempString := TRoundItem(FItemList[j]).FURL; |
| 679 |
|
|
if ( AnsiPos(oldBoardName, tempString) <> 0 ) and ( AnsiPos(oldHost, tempString ) <> 0 ) then begin |
| 680 |
|
|
tempString := StringReplace(tempString, oldHost, newHost,[]); |
| 681 |
|
|
TRoundItem(FItemList[j]).FURL := tempString; |
| 682 |
|
|
end; |
| 683 |
|
|
end; |
| 684 |
|
|
end; |
| 685 |
|
|
//鐃緒申鐃緒申鐃緒申鐃緒申鐃?Thread鐃緒申URL鐃緒申鐃緒申鐃? |
| 686 |
|
|
|
| 687 |
h677 |
1.4 |
end; |
| 688 |
hi_ |
1.1 |
|
| 689 |
|
|
end. |