tazarvmmr
چهارشنبه 14 آبان 1393, 15:13 عصر
سلام دوستان
من از 4.11.4 Fast Report در دلفی 2010 استفاده میکنم، بانک اطلاعاتیم هم SQL Server 2008 هستش، یک SP دارم که مشکلی از نظر سرعت نداره یعنی وقتی اجراش میکنم خیلی سریع اجرا میشه از همین SP در FastReport استفاده کردم ولی اونقدر طول میکشه که تا حالا حوصله نکردم زمان رو اندازه بگیرم فکر میکنم اگر رهاش کنم یک ساعتی طول بکشه تا ریپورت رو کامل باز کنه.
این کد SP که البته سرعتش خوبه:
ALTER Procedure [dbo].[sp_GetUserAllProjectsnp]
@UserCode int = 8 ,
@Keyword nvarchar(100) = null
As
if @keyword is null set @keyword='';
SELECT
RequestedProjects.RequestProjectName,
RequestedProjects.Id AS RequestId,
RequestedProjects.Allowed,
RequestedProjects.RequestDate,
RequestedProjects.AllowDate,
ProjectNames.ProjectStartDate,
ISNULL(ProjectIndexes.IndexCaption, '') AS IndexCaption,
ISNULL(ProjectSteps.ProjectStepCaption, '') AS ProjectStepCaption,
ISNULL(ProjectReasons.ReasonCaption, '') AS ReasonCaption,
ISNULL(Users_1.UserName, '') AS NextUserName,
ProjectNames.Id AS ProjectId,
ISNULL(ProjectNames.ProjectNextUserCode, - 1) AS NextUserCode,
RequestedProjects.ProjectIsWaitingToConfirm,
RequestedProjects.ProjectIsStartedByUser,
ISNULL(Contacts.ContactDate, '') AS ProjectLastContactDate,
Users.UserName AS RequestedUserName,
ISNULL(ProjectNames.ProjectHasAttachment, 0) AS ProjectHasAttachment,
ProjectTypes.ProjectType,
ProjectTypes.BelongsTo
FROM
ProjectTypes RIGHT OUTER JOIN
RequestedProjects ON ProjectTypes.Id = RequestedProjects.ProjectTypeId LEFT OUTER JOIN
Users ON RequestedProjects.RequestedUserCode = Users.Id LEFT OUTER JOIN
ProjectSteps RIGHT OUTER JOIN
Contacts RIGHT OUTER JOIN
ProjectNames ON Contacts.Id = ProjectNames.ProjectLastContactId LEFT OUTER JOIN
Users AS Users_1 ON ProjectNames.ProjectNextUserCode = Users_1.Id LEFT OUTER JOIN
ProjectReasons ON ProjectNames.ProjectReasonId = ProjectReasons.Id ON ProjectSteps.Id = ProjectNames.ProjectStepId LEFT OUTER JOIN
ProjectIndexes ON ProjectNames.ProjectIndexId = ProjectIndexes.Id ON RequestedProjects.Id = ProjectNames.RequestId
WHERE
(ProjectNames.Id in (Select ProjectId From UserProjects Where (ProjectId = ProjectNames.Id) and (UserId = @UserCode) and (UserRight = 1))) AND
(RequestedProjects.ProjectIsWaitingToConfirm = 0) AND
(RequestedProjects.Allowed = 1) AND
(RequestedProjects.ProjectIsStartedByUser = 1) AND
(REPLACE(RequestedProjects.RequestProjectName, ' ', '') LIKE N'%' + REPLACE(@keyWord, ' ', '') + '%') OR (RequestedProjects.ProjectIsWaitingToConfirm = 0) AND
(RequestedProjects.Allowed = 1) AND
(RequestedProjects.ProjectIsStartedByUser = 1) AND
(REPLACE(RequestedProjects.RequestProjectName, ' ', '') LIKE N'%' + REPLACE(@keyWord, ' ', '') + '%') AND (RequestedProjects.RequestedUserCode = @UserCode)
return @@RowCount
اینجا هم کدی هست که FastReport رو توی دلفی باهاش صدا میزنم:
procedure ShowFastReport(ReportParam: TReportParams; ReportName, QueryStr: string);
var
VIdx,
Count: integer;
tmpComponent: TfrxComponent;
Database : TfrxADODatabase;
Query: TfrxADOQuery;
Variable: TfrxVariable;
begin
frmWaiting.ShowWaitingForm(GetMessageBody(541), GetMessageBody(141));
frmReport.frxReport1.LoadFromFile(ReportName);
for Count := 1 to 100 do
begin
if ReportParam[Count, 1] <> 'nil' then
begin
VIdx := frmReport.frxReport1.Variables.IndexOf(ReportParam[Count, 1]);
if VIdx <> -1 then
begin
Variable := frmReport.frxReport1.Variables.Items[VIdx];
Variable.Value := QuotedStr(ReportParam[Count, 2]) ;
end;
// frmReport.frxReport1.Variables.Variables[ReportParam[Count, 1]] := ReportParam[Count, 2];
end;
end;
tmpComponent := frmReport.frxReport1.FindObject('ADODatabase1');
Database := (tmpComponent as TfrxADODatabase);
Database.Connected := false;
Database.DatabaseName := frmLogin.CRMstr;
Database.Connected := true;
tmpComponent := frmReport.frxReport1.FindObject('ADOQuery1');
Query := (tmpComponent as TfrxADOQuery);
Query.Close;
Query.SQL.Clear;
Query.SQL.Text := QueryStr;
query.Open;
frmReport.frxReport1.ShowReport();
frmWaiting.HideWaitingForm;
end;
وقتی SP رو از طریق خود SQL اجرا میکنم در کمتر از 1 ثانیه 1065 ردیف رو برمیگردونه، همین SP توی FastReport حدودا 2 دقیقه طول میکشه که صفحه اول رو نمایش بده!
روی نوار MasterData خصوصیت PrintIfDetailEmpty رو هم برابر True قرار دادم که وقتی صرف اینکار نشه!
کسی با این مشکل مواجه شده؟ من اینترنت رو زیرو رو کردم سوالاتی پیدا کردم که در همین مورد پرسیده شده بود ولی جوابی پیدا نکردم!
ممنون
من از 4.11.4 Fast Report در دلفی 2010 استفاده میکنم، بانک اطلاعاتیم هم SQL Server 2008 هستش، یک SP دارم که مشکلی از نظر سرعت نداره یعنی وقتی اجراش میکنم خیلی سریع اجرا میشه از همین SP در FastReport استفاده کردم ولی اونقدر طول میکشه که تا حالا حوصله نکردم زمان رو اندازه بگیرم فکر میکنم اگر رهاش کنم یک ساعتی طول بکشه تا ریپورت رو کامل باز کنه.
این کد SP که البته سرعتش خوبه:
ALTER Procedure [dbo].[sp_GetUserAllProjectsnp]
@UserCode int = 8 ,
@Keyword nvarchar(100) = null
As
if @keyword is null set @keyword='';
SELECT
RequestedProjects.RequestProjectName,
RequestedProjects.Id AS RequestId,
RequestedProjects.Allowed,
RequestedProjects.RequestDate,
RequestedProjects.AllowDate,
ProjectNames.ProjectStartDate,
ISNULL(ProjectIndexes.IndexCaption, '') AS IndexCaption,
ISNULL(ProjectSteps.ProjectStepCaption, '') AS ProjectStepCaption,
ISNULL(ProjectReasons.ReasonCaption, '') AS ReasonCaption,
ISNULL(Users_1.UserName, '') AS NextUserName,
ProjectNames.Id AS ProjectId,
ISNULL(ProjectNames.ProjectNextUserCode, - 1) AS NextUserCode,
RequestedProjects.ProjectIsWaitingToConfirm,
RequestedProjects.ProjectIsStartedByUser,
ISNULL(Contacts.ContactDate, '') AS ProjectLastContactDate,
Users.UserName AS RequestedUserName,
ISNULL(ProjectNames.ProjectHasAttachment, 0) AS ProjectHasAttachment,
ProjectTypes.ProjectType,
ProjectTypes.BelongsTo
FROM
ProjectTypes RIGHT OUTER JOIN
RequestedProjects ON ProjectTypes.Id = RequestedProjects.ProjectTypeId LEFT OUTER JOIN
Users ON RequestedProjects.RequestedUserCode = Users.Id LEFT OUTER JOIN
ProjectSteps RIGHT OUTER JOIN
Contacts RIGHT OUTER JOIN
ProjectNames ON Contacts.Id = ProjectNames.ProjectLastContactId LEFT OUTER JOIN
Users AS Users_1 ON ProjectNames.ProjectNextUserCode = Users_1.Id LEFT OUTER JOIN
ProjectReasons ON ProjectNames.ProjectReasonId = ProjectReasons.Id ON ProjectSteps.Id = ProjectNames.ProjectStepId LEFT OUTER JOIN
ProjectIndexes ON ProjectNames.ProjectIndexId = ProjectIndexes.Id ON RequestedProjects.Id = ProjectNames.RequestId
WHERE
(ProjectNames.Id in (Select ProjectId From UserProjects Where (ProjectId = ProjectNames.Id) and (UserId = @UserCode) and (UserRight = 1))) AND
(RequestedProjects.ProjectIsWaitingToConfirm = 0) AND
(RequestedProjects.Allowed = 1) AND
(RequestedProjects.ProjectIsStartedByUser = 1) AND
(REPLACE(RequestedProjects.RequestProjectName, ' ', '') LIKE N'%' + REPLACE(@keyWord, ' ', '') + '%') OR (RequestedProjects.ProjectIsWaitingToConfirm = 0) AND
(RequestedProjects.Allowed = 1) AND
(RequestedProjects.ProjectIsStartedByUser = 1) AND
(REPLACE(RequestedProjects.RequestProjectName, ' ', '') LIKE N'%' + REPLACE(@keyWord, ' ', '') + '%') AND (RequestedProjects.RequestedUserCode = @UserCode)
return @@RowCount
اینجا هم کدی هست که FastReport رو توی دلفی باهاش صدا میزنم:
procedure ShowFastReport(ReportParam: TReportParams; ReportName, QueryStr: string);
var
VIdx,
Count: integer;
tmpComponent: TfrxComponent;
Database : TfrxADODatabase;
Query: TfrxADOQuery;
Variable: TfrxVariable;
begin
frmWaiting.ShowWaitingForm(GetMessageBody(541), GetMessageBody(141));
frmReport.frxReport1.LoadFromFile(ReportName);
for Count := 1 to 100 do
begin
if ReportParam[Count, 1] <> 'nil' then
begin
VIdx := frmReport.frxReport1.Variables.IndexOf(ReportParam[Count, 1]);
if VIdx <> -1 then
begin
Variable := frmReport.frxReport1.Variables.Items[VIdx];
Variable.Value := QuotedStr(ReportParam[Count, 2]) ;
end;
// frmReport.frxReport1.Variables.Variables[ReportParam[Count, 1]] := ReportParam[Count, 2];
end;
end;
tmpComponent := frmReport.frxReport1.FindObject('ADODatabase1');
Database := (tmpComponent as TfrxADODatabase);
Database.Connected := false;
Database.DatabaseName := frmLogin.CRMstr;
Database.Connected := true;
tmpComponent := frmReport.frxReport1.FindObject('ADOQuery1');
Query := (tmpComponent as TfrxADOQuery);
Query.Close;
Query.SQL.Clear;
Query.SQL.Text := QueryStr;
query.Open;
frmReport.frxReport1.ShowReport();
frmWaiting.HideWaitingForm;
end;
وقتی SP رو از طریق خود SQL اجرا میکنم در کمتر از 1 ثانیه 1065 ردیف رو برمیگردونه، همین SP توی FastReport حدودا 2 دقیقه طول میکشه که صفحه اول رو نمایش بده!
روی نوار MasterData خصوصیت PrintIfDetailEmpty رو هم برابر True قرار دادم که وقتی صرف اینکار نشه!
کسی با این مشکل مواجه شده؟ من اینترنت رو زیرو رو کردم سوالاتی پیدا کردم که در همین مورد پرسیده شده بود ولی جوابی پیدا نکردم!
ممنون