Reply
 
LinkBack Thread Tools Display Modes
Old 04-29-2009, 06:05 PM   #1 (permalink)
CrystalHacker
Guest
 
Posts: n/a
Default How to "Include" an RTF file in a report?

I need to include rich text features in the SOW. Every salesperson currently creates an sow.rtf for each project. I would like to include this file in the report rather than use the SOW plain text in the Project Setup.

Since the sow.rtf will always reside in the same path relative to the project file, would it be possible to automatically include this in the Proposal Report or a separate SOW report?

I'm trying to understand how to access any outside data via the D-Tools AR interface.

-reed
  Reply With Quote
Old 05-21-2009, 07:28 AM   #2 (permalink)
Senior Member
 
Join Date: May 2009
Location: Chennai, India
Posts: 157
nkarthick is on a distinguished road
Default SOW Custom report for RTF

You can achieve this by doing the following steps -
  1. Create a custom report based on Existing report “Scope of Work document”.
  2. Replace the Textbox “txtScopeOfWork” control in detail section of custom report with the RichTextBox control and named it as “txtScopeOfWork”.
    richtextbox control.JPG
  3. Go to Script tab and replace existing script code with the below script code
    Code:
    Private Const fileName As String = "SOW.RTF"
    
    Sub GroupHeader1_Format
    
    	ReportUtilities.SetPresentedToAddress(rpt,"GroupHeader1","txtProjectAddress")
    
    	ReportUtilities.SetPresentedByAddress(rpt,"GroupHeader1","txtCompanyAddress")
    
    End Sub
    Sub GroupHeader1_BeforePrint
    	ReportUtilities.SetCompanyLogo(rpt,"picLogo")
    End Sub
    
    Function ActiveReport_FetchData(ByVal EOF As Boolean) As Boolean
    
    	'get the Xml Data source
     	Dim xmlDS As DataDynamics.ActiveReports.DataSources.XMLDataSource = CType(rpt.DataSource, DataDynamics.ActiveReports.DataSources.XMLDataSource)
    		
    	If xmlDs.EOF Then Return True
    	
    	'Get the Project Folder Node List
        Dim projectFolderNodeIist As System.Xml.XmlNodeList = CType(xmlDS.Field("dtr:ProjectFolder", True), System.Xml.XmlNodeList)
    
         If projectFolderNodeIist.Count > 0 Then
            	
        	Dim filePath As String
        	
    		''Combine the Project Folder path and the Rtf file
             filePath = System.IO.Path.Combine(projectFolderNodeIist(0).InnerText, fileName)
             
             'Load the RTF file
             ReportUtilities.SetRTFControl(rpt,"Detail1","txtScopeofWork",filePath)
                
      	End If
    
    	ActiveReport_FetchData = EOF
    End Function
  4. Publish the report.


Notes –-
- If you want to change the rtf file name, you can change here in the script
Private Const fileName As String = "SOW.RTF"

- If the “SOW.RTF”rtf file not included for a project, then report will show blank scope of work data.

- Make sure while running this custom report, “SOW.RTF” file is not opened manually. If so then report will throw an exception, but it will not crash the navigator.

Hope this helps.

Last edited by nkarthick; 05-21-2009 at 07:31 AM.
nkarthick is offline   Reply With Quote
Old 06-03-2009, 04:26 PM   #3 (permalink)
CrystalHacker
Guest
 
Posts: n/a
Default

Thanks! I look forward to giving this a try. Still trying to get the basic stuff under control...

-ch

Last edited by CrystalHacker; 06-03-2009 at 06:52 PM.
  Reply With Quote
Old 06-04-2009, 02:03 PM   #4 (permalink)
CrystalHacker
Guest
 
Posts: n/a
Default

This also looks like it could possibly be used to add a Signature to the proposal.

I doubt ReportUtilities.SetRTFControl provides the correct behavior. Is there a .SetImageControl or equivalent?

-ch
  Reply With Quote
Old 06-05-2009, 08:05 AM   #5 (permalink)
Senior Member
 
Join Date: May 2009
Location: Chennai, India
Posts: 157
nkarthick is on a distinguished road
Default

See the reply here http://d-tools.us/showthread.php?t=2821
__________________
Narayana Karthik
nkarthick is offline   Reply With Quote
Old 06-14-2009, 06:53 PM   #6 (permalink)
CrystalHacker
Guest
 
Posts: n/a
Default

Nick,

I'm curious why this function would go in the FetchData routine. If I understand this correctly, this code would execute for EVERY Item in the project.

Is this true?

-ch
  Reply With Quote
Old 06-14-2009, 06:57 PM   #7 (permalink)
CrystalHacker
Guest
 
Posts: n/a
Default

Ah... Never mind. I have my SOW in a header. I will place the code in the Header Format section and see what happens.

-ch
  Reply With Quote
Old 06-25-2009, 05:26 PM   #8 (permalink)
Junior Member
 
Join Date: Jul 2008
Location: San Antonio, TX
Posts: 3
Dominion is on a distinguished road
Default

nkarthick,

The code you posted works for the original Scope of Work document, but I have combined my scope of work with a proposal to print the Scope of Works as page two of my proposals.

I followed the instructions in the following pdf to combine the 2 reports.

http://downloads.d-tools.com/si5/rep...d_Proposal.pdf

I am not a programmer and do not understand what any of the script means. I have attempted to move the pieces where I thought they should work and they don't. I keep getting a blank scope of work page.


How should I modify the code you posted to insert the SOW.RTF in this combined report?



Code:
Private showModel As Boolean
Private showLaborItems As Boolean
Private showItemPrice As Boolean 
Private showPageHeader As Boolean
	
	
Sub ReportHeader1_Format

	ReportUtilities.SetPresentedToAddress(rpt,"ReportHeader1","txtProjectAddress")

	ReportUtilities.SetPresentedByAddress(rpt,"ReportHeader1","txtCompanyAddress")

	ReportUtilities.SetCompanyLogo(rpt,"picLogo")
	
	
	' if we are hiding page headers, then set Visible = false on the
	' following controls.
	If Not showPageHeader Then
	
		ReportUtilities.SetControlVisibility(rpt, "picRptHeader", false)
		ReportUtilities.SetControlVisibility(rpt, "txtRptHeader", false)
		ReportUtilities.SetControlVisibility(rpt, "lblModified", false)
		ReportUtilities.SetControlVisibility(rpt, "lblRevision", false)
		ReportUtilities.SetControlVisibility(rpt, "txtModifiedDate", false)
		ReportUtilities.SetControlVisibility(rpt, "txtRevision", false)
	
	End If

End Sub


Sub grpItemHeader_Format

	' If we are showing the Model #, then set it, otherwise the control will use the default binding
	If showModel Then
		ReportUtilities.SetManufacturerModelTextBox(rpt,"grpItemHeader","txtModel")
	End If
	
	ReportUtilities.SetControlTopPosition(rpt, "grpItemHeader", "txtDescription", "txtModel", .02)
	'ReportUtilities.SetControlTopPosition(rpt, "grpItemHeader", "subProposalItemsLevel2", "txtDescription", .02)
	
	' if showing the item price, then determine whether the "*" is to be shown
	' otherwise set visible to false.
	If showItemPrice Then
	
		' get the current item the report is on...
		' determine if "*" label is being shown
		Dim itm As DTools.SystemIntegrator.Reporting.Item = ReportUtilities.ReturnItem(rpt)
		Dim accessorizedPrice As Boolean = itm.AccessorizedPrice ' false
	
		ReportUtilities.SetControlVisibility(rpt, "lblAccessorized", accessorizedPrice)
	Else
		ReportUtilities.SetControlVisibility(rpt, "lblAccessorized", false)
	
	End If
	
	' control visibility of price field based on parameter
	ReportUtilities.SetControlVisibility(rpt, "txtPrice", showItemPrice)
	
End Sub

Sub ActiveReport_ReportStart

	'showDetail = False

	' Apply Items Filter
	ReportUtilities.ApplyDataSourceFilter(rpt,1)
	
	
	' detemine whether labor items should be displayed in the report details
	 
	showLaborItems = true
	Dim showLaborItemParam As object = ReportUtilities.ReturnParameterValue("ShowLaborItems") 
		 
	If Not showLaborItemParam Is Nothing Then
		  
		If Not Boolean.TryParse(showLaborItemParam.ToString, showLaborItems) Then
			showLaborItems = true
		End If
	End If
	 
	' if we're not showing labor items, apply the filter
	If Not showLaborItems Then ReportUtilities.ApplyLaborItemFilter(rpt)
	
	
		' show/hide page headers and footers
	 
	showPageHeader = true
	Dim showHeaderParam As object = ReportUtilities.ReturnParameterValue("ShowPageHeader")
	
	If Not showHeaderParam Is Nothing Then
		
		If Not Boolean.TryParse(showHeaderParam.ToString, showPageHeader) Then
			showPageHeader = true
		End If

	End If
	
	'ReportUtilities.SetSectionVisibility(rpt, "PageHeader1", showPageHeader)
	ReportUtilities.SetSectionVisibility(rpt, "PageFooter1", showPageHeader)
	
	If Not showPageHeader Then
		CType(rpt.Sections("grpHeadings"),DataDynamics.ActiveReports.GroupHeader).RepeatStyle = DataDynamics.ActiveReports.RepeatStyle.None

	End If
	
	
	'Determine if the report should show the Model ID
	
	' get the parameter value
	Dim showModelParam As object = ReportUtilities.ReturnParameterValue("ShowModel")
	
	' set the default value
	 showModel = false

	' if the parameter value is not null, then parse it
	If Not showModelParam Is Nothing Then
		
		If Not Boolean.TryParse(showModelParam.ToString, showModel) Then
			showModel = false
		End If

	End If
	
	
	
	' handle whether Detail is being shown or no
	
	' See if parent report has the 'SummarizeAcc' parameter
	Dim  paramValue As Object = ReportUtilities.ReturnParameterValue("SummarizeAcc")

	' if the parameter value exists, then process it, otherwise false
	If Not (paramValue Is Nothing) Then
		
		' if 'None' then show detail for all items
		If paramValue.ToString = "None" Then
			ReportUtilities.SummarizeEquipment = 0 '0 = ItemSummaryEnum.ShowAllDetail
			
		' if use the item setting, then 
		ElseIf paramValue.ToString = "Item" Then
			ReportUtilities.SummarizeEquipment = 1 '1 = ItemSummaryEnum.ItemSetting
		
		Else
			ReportUtilities.SummarizeEquipment = 2 '2 = ItemSummaryEnum.ShowNoDetail
		
		End If
	
	End If
	
	' get the parameter
	Dim summParam As object = ReportUtilities.ReturnParameterValue("SummarizePkg")

	' if nothing, set it to an empty string
	If Not (summParam Is Nothing) Then 
			
		If summParam.ToString = "None" Then
			ReportUtilities.SummarizePackages = 0 '0 = ItemSummaryEnum.ShowAllDetail
		
		ElseIf summParam.ToString = "Item" Then
			ReportUtilities.SummarizePackages = 1 '1 = ItemSummaryEnum.ItemSetting
		
		Else
			ReportUtilities.SummarizePackages = 2 '2 = ItemSummaryEnum.ShowNoDetail
				
		End If
	End If
	
	
	' show/hide line item price field
	showItemPrice = true
	Dim showItemPriceParam As object = ReportUtilities.ReturnParameterValue("ShowItemPrice")
	
	If Not showItemPriceParam Is Nothing Then
		
		If Not Boolean.TryParse(showItemPriceParam.ToString, showItemPrice) Then
			showItemPrice = true
		End If

	End If
	
	

End Sub

Sub GrpDynamicHeader1_Format

	ReportUtilities.SetDescriptionTextBox(rpt,"GrpDynamicHeader1","txtDynamicDesc1")

End Sub

Sub GrpDynamicHeader2_Format

	ReportUtilities.SetDescriptionTextBox(rpt,"GrpDynamicHeader2","txtDynamicDesc2")
	
End Sub

Sub GrpDynamicHeader3_Format

	ReportUtilities.SetDescriptionTextBox(rpt,"GrpDynamicHeader3","txtDynamicDesc3")
	
End Sub

Sub ActiveReport_DataInitialize

	' add calculated field to the data source.
	' this field will equal the integer equivalent of the Summarize Field so the group can keep track
	rpt.CalculatedFields.Add("SummarizeInt")

End Sub

Function ActiveReport_FetchData(ByVal EOF As Boolean) As Boolean


	Dim ds As DataDynamics.ActiveReports.Datasources.XMLDatasource = ctype(rpt.Datasource, DataDynamics.ActiveReports.Datasources.XMLDatasource)

	If ds.EOF Then return True
	
	' default the calculated to 0
	rpt.CalculatedFields("SummarizeInt").Value = 0
	
	'ReportUtilities.Spot("FetchData")

	'ReportUtilities.SetCurrentProposalItem(rpt)
	
	' get the current item the report is on...
	Dim itm As DTools.SystemIntegrator.Reporting.Item = ReportUtilities.ReturnItem(rpt)
	
	' If the item is not null, set value of the calculated field 
	If itm IsNot Nothing Then
	
		rpt.CalculatedFields("SummarizeInt").Value = Ctype(itm.Summarize, Integer)
			
	End If


	'ReportUtilities.Spot("FetchData Detail:" & showDetail)


	' Return whether this is the last record.  
	' This Is required Or the report will iterate forever over And never return
	return (ds.NodeList.Count = ds.CurrentPosition)


End Function

Sub grpItemFooter_Format

Dim showDetail As Boolean

	Dim itemSummary As Integer = 0
	
	' Does the group have at least one item that is not set to summarize?
	' The value of the txtItemSummary Textbox is the "Max" value of all items in group
	' This textbox is bound to the calculatedField: SummarizeInt
	' True Boolean values converted to Integer = -1, so if the Max value is 0 then at least one record in the
	' group is flagged to NOT summarize
	try
		itemSummary = ctype(ReportUtilities.ReturnTextBoxValue(rpt,"grpItemFooter","txtItemSummary"),Integer)
	catch
	End Try
	
	
	' Does this group represent a package???
	' If so, the value of the txtPackage textbox will not be null or an empty string
	Dim pkg As String = ""
	
	Try
		pkg = ctype(ReportUtilities.ReturnTextBoxValue(rpt,"grpItemFooter","txtPackage"),String)
	Catch
	End Try
	

	' if item is a package, the package ID will have a value 
	If Not String.IsNullOrEmpty(pkg) Then
		Select Case ReportUtilities.SummarizePackages
		
			Case 0 ' ShowAllDetail
				showDetail = True
		 	Case 1 ' ItemSetting
		 	
		 		' if the itemSummary <> 0 then
				If itemSummary <> 0 Then
					showDetail = False
				Else
					showDetail = True 
				End If
	
			Case 2 ' ShowNoDetail
				showDetail = False
		End Select'

	Else ' this is an equipment Item
		Select Case ReportUtilities.SummarizeEquipment
		
			Case 0 ' ShowAllDetail
		 		showDetail = True
		 			 		
		 	Case 1 ' ItemSetting
				If itemSummary <> 0 Then
					
				Else
					showDetail = True
					
				End If
	
			Case 2 ' ShowNoDetail
				showDetail = False
								
		End Select
	
	
	End If


	If showDetail Then
		Dim itemHash As Integer = 0
		
		' set the current proposal item in the helper class to the item to the item that matches the groups
		' itemHash value.
		try
			itemHash = ctype(ReportUtilities.ReturnTextBoxValue(rpt,"grpItemFooter","txtItemHash"),Integer)
			ReportUtilities.SetCurrentProposalItem(itemHash)
			
		catch 
		End try
		' bind the sub report so it runs
		ReportUtilities.BindSubReport(rpt, "grpItemFooter", "subProposalItemsLevel2")
	Else
		' unbind it to avoid processing time.
		ReportUtilities.UnBindSubReport(rpt, "grpItemFooter", "subProposalItemsLevel2")
	End If
	
	showDetail = False

End Sub

Sub PageFooter1_Format

	Dim dt As new Date

	ReportUtilities.SetTextBoxValue(rpt, "PageFooter1","txtRunDate", dt.Today.ToString("d"))

End Sub



Sub grpMiscCosts_Format

	If ReportUtilities.TotalMiscCosts(rpt) = 0 Then
	
		ReportUtilities.UnbindSubReport(rpt,"grpMiscCosts","subMiscCosts")
		ReportUtilities.SetSectionVisibility(rpt,"grpMiscCosts", false)
	End If

End Sub
Sub PageHeader1_Format

	If showPageHeader = false Then

		ReportUtilities.SetControlVisibility(rpt, "txtPageHeader", false)
		ReportUtilities.SetControlVisibility(rpt, "picPageHeader", false)
			
	
	
	End If

'ReportUtilities.SetSectionVisibility(rpt, "PageHeader1", showPageHeader)



End Sub
Dominion is offline   Reply With Quote
Old 06-26-2009, 10:14 AM   #9 (permalink)
Senior Member
 
Join Date: May 2009
Location: Chennai, India
Posts: 157
nkarthick is on a distinguished road
Default Try this

Can you try the below steps to create your custom report: -

  1. Create a custom report based on existing report “Scope of Work Document” and name it as “Scope of Work RTF”.
  2. Replace the Textbox “txtScopeOfWork” control in detail section of custom report with the RichTextBox control and name it as “txtScopeOfWork”.
  3. Go to Script tab and replace existing script code with the below code (updated code).

    Code:
    Private Const fileName As String = "SOW.RTF"
    
    Sub GroupHeader1_Format
    
    	ReportUtilities.SetPresentedToAddress(rpt,"GroupHeader1","txtProjectAddress")
    
    	ReportUtilities.SetPresentedByAddress(rpt,"GroupHeader1","txtCompanyAddress")
    
    End Sub
    Sub GroupHeader1_BeforePrint
    	ReportUtilities.SetCompanyLogo(rpt,"picLogo")
    End Sub
    
    Function ActiveReport_FetchData(ByVal EOF As Boolean) As Boolean
    
    	'get the Xml Data source
     	Dim xmlDS As DataDynamics.ActiveReports.DataSources.XMLDataSource = CType(rpt.DataSource, DataDynamics.ActiveReports.DataSources.XMLDataSource)
    		
    	If xmlDs.EOF Then Return True
    	
    	'Get the Project Folder Node List
        Dim projectFolderNodeIist As System.Xml.XmlNodeList = CType(xmlDS.Field("dtr:ProjectFolder", True), System.Xml.XmlNodeList)
    
         If projectFolderNodeIist.Count > 0 Then
            	
        	Dim filePath As String
        	
    		''Combine the Project Folder path and the Rtf file
             filePath = System.IO.Path.Combine(projectFolderNodeIist(0).InnerText, fileName)
             
              Dim fileDetail As System.IO.FileInfo = My.Computer.FileSystem.GetFileInfo(filePath)
    
            If (fileDetail.IsReadOnly  AndAlso System.IO.File.Exists(filePath)) Then
               	System.IO.File.SetAttributes(filePath, System.IO.FileAttributes.Normal)
            End If
    
        
             'Load the RTF file
             ReportUtilities.SetRTFControl(rpt,"Detail1","txtScopeofWork",filePath)
                
      	End If
    
    	ActiveReport_FetchData = EOF
    End Function
  4. Publish the report.
  5. Create a another report based on exiting “Proposals” report and named it as “Proposal with SOW”
  6. In the GroupHeader2 section set Visible = “True” and NewPage = “After” in the Properties window for this section as shown in fig.


    Groupheader2 Property.JPG

  7. Add SubReport control into the GroupHeader2 section, right click on the Sub report and click “Bind To D-Tools Report” it will open a “Select Report to Bind” dialog, there select the “Scope of Work RTF” report as shown in below fig.

    select report dialog.JPG
  8. Publish the “Proposal with SOW” report. Now it’s ready to run.

Note: Make sure you add the “SOW.RTF” rtf file into the project folder before running the “Proposal with SOW” report.

Hope it helps.
__________________
Narayana Karthik

Last edited by nkarthick; 06-26-2009 at 11:12 AM.
nkarthick is offline   Reply With Quote
Old 06-26-2009, 12:34 PM   #10 (permalink)
CrystalHacker
Guest
 
Posts: n/a
Default

For "preview" purposes while testing your report, place the sow.rtf file in the
C:\Program Files\D-Tools\SI 5\Reports
directory. This keeps you from having to Publish to run a test.

You can also copy and rename any *.dtl file to "SampleData.xml" and drop it in this folder to allow preview to run on you own data. You may wish to rename the originals before blowing them away.

-ch
  Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Custom Report and Dynamic grouping bcharnz Reports and Reporting Center 4 12-03-2009 10:00 PM
OpenDNS and unable to find LanSync Padwerx Installation & Setup 2 10-25-2009 05:13 AM
sub-report force groupings grichards Reports and Reporting Center 4 08-07-2009 06:23 AM
SetRTFControl Throws Exception when RTF File is ReadOnly CrystalHacker Reports and Reporting Center 3 06-24-2009 10:49 PM
Same Man & Model, Different Description jpol Reports and Reporting Center 4 10-11-2007 03:31 PM


All times are GMT. The time now is 08:35 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0
D-Tools, Inc.