|
|
 |
Delphi 6 SOAP 源码中的BUG修正 |
热 ★★★★ |
|
Delphi 6 SOAP 源码中的BUG修正 |
|
作者:闵涛 文章来源:闵涛的学习笔记 点击数:2831 更新时间:2009/4/23 18:41:03  |
|
|
0 then
begin
DateString := Copy(Value, 1, TimePosition -1);
TimeString := Copy(Value, TimePosition + 1, Length(Value) - TimePosition);
FDateParam.XSToNative(DateString);
FTimeParam.XSToNative(TimeString);
end else
FDateParam.XSToNative(Value);
end;
function TXSDateTime.NativeToXS: WideString;
var
TimeString: WideString;
begin
TimeString := FTimeParam.NativeToXS;
if TimeString <> '''''''' then
Result := FDateParam.NativeToXS + SoapTimePrefix + TimeString
else
Result := FDateParam.NativeToXS;
end;
function TXSDateTime.ValidValue(Value, Subtract, Min, Max: Integer; var Remainder: Integer): Integer;
begin
Result := Value - Subtract;
Remainder := 0;
if Result < Min then
begin
Remainder := 1;
Inc(Result,Max);
end;
end;
function TXSDateTime.CompareDateTimeParam(const Value1, Value2: TXSDateTime): TXSDuration;
var
Remainder, Milliseconds, Seconds: Integer;
begin
Result := TXSDuration.Create;
try
MilliSeconds := ValidValue(Value1.Millisecond, Value2.Millisecond, 0, 1000, Remainder);
Seconds := ValidValue(Value1.Second + Remainder, Value2.Second, 0, 60, Remainder);
Result.DecimalSecond := Seconds + Milliseconds / 1000;
Result.Minute := ValidValue(Value1.Minute + Remainder, Value2.Minute, 0, 60, Remainder);
Result.Hour := ValidValue(Value1.Hour + Remainder, Value2.Hour, 0, 24, Remainder);
Result.Day := ValidValue(Value1.Day + Remainder, Value2.Day, 0, 31, Remainder);
Result.Month := ValidValue(Value1.Month + Remainder, Value2.Month, 0, 12, Remainder);
Result.Year := ValidValue(Value1.Year + Remainder, Value2.Year, -9999, 0, Remainder);
except
Result.Free;
Result := nil;
end;
end;
{ TXSDuration }
constructor TXSDuration.Create;
begin
inherited Create;
FDateParam.MaxDay := 30;
FDateParam.MinDay := 0;
FDateParam.MaxMonth := 11;
FDateParam.MinMonth := 0;
end;
procedure TXSDuration.SetDecimalSecond(const Value: Double);
begin
if Value < 60 then
FDecimalSecond := Value
else
SoapDateTimeErrorFmt(SInvalidFractionSecond, [Value]);
end;
function TXSDuration.GetNumericString(const AParam: string; const AType: string;
const Decimals: Boolean = False): WideString;
var
I, J: Integer;
begin
I := Pos(AType, AParam);
J := I;
while (I > 0) and ((AParam[I-1] in [''''0''''..''''9'''']) or
(Decimals and (AParam[I-1] = ''''.''''))) do
Dec(I);
if J > I then
Result := Copy(AParam, I, J-I)
else
Result := ''''0'''';
end;
function TXSDuration.GetIntegerValue(const AParam: string; const AType: string): Integer;
begin
Result := StrToInt(GetNumericString(AParam, AType));
end;
function TXSDuration.GetDecimalValue(const AParam: string; const AType: string): Double;
begin
Result := StrToFloat(GetNumericString(AParam, AType, True));
end;
procedure TXSDuration.XSToNative(Value: WideString);
var
DateString, TimeString: string;
TimePosition: Integer;
begin
if Value[1] <> XMLDurationStart then
SoapDateTimeErrorFmt(SInvalidDuration, [Value]);
TimePosition := Pos(SoapTimePrefix, Value);
if TimePosition > 0 then
begin
TimeString := Copy(Value, TimePosition + 1, Length(Value) - TimePosition);
DateString := Copy(Value, 1, TimePosition - 1);
end else
DateString := Value;
Year := GetIntegerValue(DateString, XMLDurationYear);
Month := GetIntegerValue(DateString, XMLDurationMonth);
Day := GetIntegerValue(DateString, XMLDurationDay);
if TimePosition > 0 then
begin
Hour := GetIntegerValue(TimeString, XMLDurationHour);
Minute := GetIntegerValue(TimeString, XMLDurationMinute);
DecimalSecond := GetDecimalValue(TimeString, XMLDurationSecond);
end;
end;
{ format is ''''P1Y2M3DT10H30M12.3S'''' }
function TXSDuration.NativeToXS: WideString;
begin
Result := XMLDurationStart +
IntToStr(Year) + XMLDurationYear +
IntToStr(Month) + XMLDurationMonth +
IntToStr(Day) + XMLDurationDay + SoapTimePrefix +
IntToStr(Hour) + XMLDurationHour +
IntToStr(Minute) + XMLDurationMinute +
FloatToStr(DecimalSecond) + XMLDurationSecond;
end;
initialization
RemClassRegistry.RegisterXSClass(TXSDateTime, XMLSchemaNameSpace, ''''dateTime'''', '''''''',True );
RemClassRegistry.RegisterXSClass(TXSTime, XMLSchemaNameSpace, ''''time'''', '''''''', True );
RemClassRegistry.RegisterXSClass(TXSDate, XMLSchemaNameSpace, ''''date'''', '''''''', True );
RemClassRegistry.RegisterXSClass(TXSDuration, XMLSchemaNameSpace, ''''duration'''', '''''''', True );
finalization
RemClassRegistry.UnRegisterXSClass(TXSDateTime);
RemClassRegistry.UnRegisterXSClass(TXSTime);
RemClassRegistry.UnRegisterXSClass(TXSDate);
RemClassRegistry.UnRegisterXSClass(TXSDuration);
end.
上一页 [1] [2] [3] [系统软件]InstallShield Express for delphi制作安装程序定… [系统软件]BCB6 下devexpress 安装手记 [常用软件]InstallShield Express制作Delphi数据库安装程序 [常用软件]Internet Explorer 6 Public Preview 最新出击!! [常用软件]painter 6 手绘实例《油彩篇》 [常用软件]painter 6 手绘实例《粉彩篇》 [常用软件]Painter 6 手绘实例《胶彩篇》 [VB.NET程序]VB.NET实现DirectSound9 (6) 声音特效 [VB.NET程序]Visual Basic 6 逆向工程与反逆向工程 (2) [VB.NET程序]Visual Basic 6 逆向工程与反逆向工程 (1)
|
|
| 教程录入:mintao 责任编辑:mintao |
|
|
上一篇教程: Object TreeView简要说明 下一篇教程: 在Delphi中使用Queued 组件 |
|
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网] |
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!) |
| |
|
|
|
|
|
 |
同类栏目 |
 |
 |
赞助链接 |
 |
|
500 - 内部服务器错误。
|
|
|
|
|
|