Appframe Knowledge Base


50 hits
9

Loading data asynchronous in Appframe

In release Appframe 430 there are support for loading data, forms, reports and executing procedures asynchronously. The framework takes care of loading forms, opening reports and loading data in child datasource. But when it comes to dataobjects that doesn't have a master object, dataobjects that you would like to manually, procedures or fetching data outside dataobject, there are some changes required in order to load async.

'Example 1: Loading dataobject async
aviw_Testing_Async.refreshDataSourceAsync()


'Example 2: Loading dataobject async and working with data
Private Async Sub LoadTestData()
     Dim vTask = aviw_Testing_Async.refreshDataSourceAsync()
     Await vTask
     'do your stuff
End Sub


'Example 3: Executing procedure
Private Async Sub ExecuteTestProcedure()
     Dim vProc = new afProcedureCall("astp_Teting_Async")
     vProc.Parameters.Add("Test","Test")
     Dim vDataSet as DataSet = Await vProc.ExecuteAsync()
     'do your stuff
End Sub



'Example 4: Executing procedure
Private Async Sub LoadTestData()
     Dim vRec= new afRecordSource("aviw_Testing_Async")
     vRec.MaxRecords = -1
     vRec.SelectColumns.Add("Test")
     Dim vDataTable as DataTable = Await vRec.GetDataAsync()
     'do your stuff
End Sub


'Adding status in statusbar for tasks
 Dim vTask = aviw_Testing_Async.refreshDataSourceAsync()
CR3.AddStatus("Loading data",vTask)
' or
CR3.AddStatus(CR3.TaskType.Data,vTask)

'Locking form using a task
Dim vProc as new afProcedureCall("astp_CRM_Test");
Dim vTask = vPro.ExecuteAsync();
Me.Lock(vTask);



win · Perma link post comment Posted by: Peter Øren (02-sep-2014)

Tomas Dambrauskas :
A step forward... (12-sep-2014)
2

Passing Filers to Subreports

'
' This snippet goes into the parent report.
' It copies the parent's filter into the subreport's Tag member
' Tag member will be automatically assigned as FilterString
Private Sub xtraReport1_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
	arpt_ModuleFoo_Subreport.Tag = CType(xtraReport1, Appframe3.Reporting.afReport).Filter
End Sub

reporting win · Perma link post comment Posted by: Kevin Francis Becker (29-apr-2013)

Karl Stroud :
This does not appear to have any affect on filtering of subreports? (20-jun-2016)
Kevin Francis Becker :
Sorry this doesn't seem to do anything--I presume it did at one time. (24-jun-2016)
2

VB.NET Naming Conventions - Windows Forms

''' <summary>
''' This class demonstrates the naming conventions to be followed when writing
''' Windows GUI applications
''' </summary>
''' <remarks>
''' Forms should always have meaningful names, and should never have names
''' like Form1 or Dialog1!
''' 
''' For cases not covered by the example and the general naming convention guideline
''' on this site, refer to the official .NET Guidelines for Names found at
''' http://msdn.microsoft.com/en-us/library/ms229002.aspx
''' </remarks>
Public Class ManagePeople

    Private gEditor As CustomEditorControl

    Public Sub New()

        InitializeComponent()

        ' Controls and components created using the visual designer should
        ' use a c prefix for names
        cEditButton.Enabled = False

		' Controls and components created in code should follow general naming
		' conventions for variable names
        gEditor = New CustomEditorControl()
        Controls.Add(gEditor)

    End Sub

    Private Sub ManagePeople_Load(pSender As Object, pArgs As EventArgs) Handles MyBase.Load

        ' Names of data objects should always match the view name
        atbv_FancyCRMApp_People.RefreshDataSource()

        ' If you have multiple data objects referencing the same view,
        ' use a meaningful suffix but be careful of collisions with
		' names of actual database object!
        atbv_FancyCRMApp_Messages_Unread.RefreshDataSource()
        atbv_FancyCRMApp_Messages_All.RefreshDataSource()

    End Sub

End Class

win · Perma link post comment Posted by: Jarl Erik Schmidt (08-mar-2012)

2

VB.NET Naming Conventions - General

''' <summary>
''' This class demonstrates the naming conventions to be followed when writing Appframe
''' libraries and applications
''' </summary>
''' <remarks>
''' For cases not covered by the example, refer to the official .NET Guidelines for Names
''' found at http://msdn.microsoft.com/en-us/library/ms229002.aspx
''' </remarks>
Public Class Person
    Inherits DomainObject

    ' No prefix on constants
    Private Const FormatNameMask As String = "{1}, {0}"

    ' g prefix on class-level static variables
    Private Shared gDatabaseTable As String = "Persons"

    ' Also g prefix on class-level instance variables
    Private gFirstName, gLastName As String

    ' p prefix on parameters
    Public Sub New(ByVal pFirstName As String, ByVal pLastName As String)

        ' v prefix on local variables
        Dim vIsNameValid = String.IsNullOrEmpty(pFirstName) AndAlso Not String.IsNullOrEmpty(pLastName)

        gFirstName = pFirstName
        gLastName = pLastName

        AddHandler MyBase.AfterDataUpdated, AddressOf HandleSomeEvent

    End Sub

    ' Event handlers are technically functions, thus best practice is to rename
    ' the parameters to follow naming conventions. Leaving them as "sender" and "e"
    ' is permissable if they are not referenced within the method body
    Private Sub HandleSomeEvent(ByVal pSender As Object, ByVal pArgs As EventArgs)
        ' TODO: Add some important logic here
    End Sub

    ' We also capitalize the first letter of private method names
    Private Sub DoSomethingRisky()
        Try
            Dim vMagicValue As Integer = Integer.Parse("FortyTwo")
        Catch ex As Exception ' Use ex as exception names
            Console.WriteLine("Something blew up: {0}", ex.Message)
        End Try
    End Sub

    Public Function FirstNameIsInList(ByVal pNames As List(Of String)) As Boolean

        ' One letter variable names is ok for indexers, but should be reconsidered
		' if there are several nested for-loops
        For i As Integer = 0 To pNames.Count - 1
            If pNames(i) = gFirstName Then 
				Return True
			End If
        Next
		
		' One-letter variable names is ok for lambda expression parameters
		Dim vUnused = pNames.Where(Function(n) n.StartsWith("p"))

        Return False

    End Function

    Public Overrides Function ToString() As String
        Return String.Format(FormatNameMask, gFirstName, gLastName)
    End Function

End Class

win · Perma link post comment Posted by: Jarl Erik Schmidt (08-mar-2012)

2

How to execute a stored procedure

Try
	Dim myProc As New afProcedureCall("astp_CRM_SearchForCandidates")
	myProc.Parameters.Add("SearchCategory", Me.cSearchCategory.EditValue)
	myProc.Parameters.Add("SearchText", Me.cSearchText.EditValue)
	Dim vDataSet as DataSet = afAccessLayer.ExecProcedure(myProc)
Catch ex As Exception
	CR3.HandleException(ex)
End Try

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

2

Windows client progress indicator

In old times to indicate something is being loaded one could use CR3.SetStatus(String, Boolean, Boolean) and CR3.ClearStatus() to remove indicator. Those do not work well with asynchronous paradigm. That is why ClientExtensions.AddStatus(Task, String) and afForm.SetIsLoading(Object, Boolean) have been introduced. AddStatus can be used directly on task because it is extension method.

Adding progress indication when refreshing data object:

Await stbv_WinClient_ProjectsVersions.RefreshDataSourceAsync.AddStatus(CR3.TaskType.Data)

The result:

loading indicator

    loading indicator invoked with AddStatus

Similarly one can await result from task, adding progress indication at the same time:

Dim sp = New afProcedureCall("sstp_WinClient_WhatsUp")
Dim dataSet = Await sp.ExecuteAsync.AddStatus("What is up ...")

The result:

loding indicator

    loading indicator invoked for stored procedure execution

Former example does not spin loading indicator in the MDI form tab. How come refreshing data object did spin it?..

That is because refreshing any afDataObject will spin that loading indicator automatically.

To spin it by your self you have to use afForm.SetIsLoading.

Dim t = Task.Delay(3000).AddStatus("аккордеон ...")
SetIsLoading(t, True)
Try
    Await t
Finally
    SetIsLoading(t, False)
End Try

The result after calling above code 3 times slightly one after another:

loading indicator

    loading and spining indicator invoked for delay task

When using SetIsLoading be sure to call SetIsLoading(t, False) in Finally block. That way it is going to be called no matter what happens in Try block.

AddStatus and CR3.SetStatus do not interact with each other, so CR3.ClearStatus will not affect any loading indicators invoked using other means.

progress win · Perma link post comment Posted by: Tomas Dambrauskas (26-feb-2016)

Vadim Narožnij :
Moving GIFs in the middle of a text are horrible, looks like a boiling soup. It distracts from reading. Also names like "Formidigus, Uogenojus and аккордеон" are not funny - they are confusing. Please try to keep texts also in examples in English. (24-mar-2016)
1

Export report to PDF and save to filestore

Dim vReport As New AppFrame3.Reporting.afReport(vReportID, vFilter)
vReport.LoadLayoutAndData()

Dim vMemoryStream As System.IO.MemoryStream = New System.IO.MemoryStream()
vReport.ExportToPdf(vMemoryStream)

vMemoryStream.Seek(0, System.IO.SeekOrigin.Begin)
Dim vFileStoreLayer As New AppFrame3.Common.Data.afFileStoreLayer
vFileStoreLayer.InsertFile(vMemoryStream, vFileName, vViewName, vPrimKey)

vMemoryStream.Close()

reporting win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

Kevin Francis Becker :
I needed to prepare a new row in the filestore table as per Trong's post https://www.pims.no/teamdoc?8088/151517/post-811237 (17-okt-2017)
Kevin Francis Becker :
Dim vTable As DataTable = CType(pFilestoreTableView.DataSource, DataTable) Dim vNewRow As DataRow = vTable.NewRow() vTable.Rows.Add(vNewRow) Dim vPrimKey = vNewRow("PrimKey").ToString() Dim vViewName = pFilestoreTableView.DataSource.ToString() (17-okt-2017)
1

How to insert data using afAccessLayer

Dim vList As New List(Of KeyValuePair(Of String, Object))
vList.Add(New KeyValuePair(Of String, Object)("Title", "Testing1233"))
vList.Add(New KeyValuePair(Of String, Object)("Status", "Open"))
 
Dim vColumnsToRetreive As New Appframe3.Common.Data.Columns.afSelectColumnCollection()
vColumnsToRetreive.Add("Primkey")
vColumnsToRetreive.Add("RiskID")
 
Dim vData As DataTable
vData = Appframe3.Common.Data.afAccessLayer.AddData("atbv_RiskMgmt_Risks", vList, vColumnsToRetreive, "atbv_RiskMgmt_Risks")

win · Perma link post comment Posted by: Peter Øren (12-jan-2012)

1

How to update data using afAccessLayer

Dim lstList As New List(Of KeyValuePair(Of String, Object))
lstList.Add(New KeyValuePair(Of String, Object)("UseRBS", IIf(Me.RadioGroup1.SelectedIndex = 0, True, False)))
lstList.Add(New KeyValuePair(Of String, Object)("Level1Title", Me.txtLevel1.Text))
lstList.Add(New KeyValuePair(Of String, Object)("Level2Title", Me.txtLevel2.Text))
lstList.Add(New KeyValuePair(Of String, Object)("Level3Title", Me.txtLevel3.Text))
 
Dim objColumnsToRetreive As New Appframe3.Common.Data.Columns.afSelectColumnCollection
objColumnsToRetreive.Add("Primkey")
 
Dim dt As DataTable
dt = Appframe3.Common.Data.afAccessLayer.PutData("atbv_RiskMgmt_Constants", lstList, Me.atbv_RiskMgmt_Constants.CurrentRow("Primkey").ToString, "", objColumnsToRetreive, "atbv_RiskMgmt_Constants")

win · Perma link post comment Posted by: Peter Øren (12-jan-2012)

1

How to toggle insert, save and delete buttons on the afDataNavigatorControl

' The buttons will be automatically enabled or disabled based on the state of
' the associated afDataObject and does not need to be modified directly.
'
' Examples:

atbv_Testing_MyStuff.AllowNew = True ' Enables the New button
atbv_Testing_MyStuff.AllowUpdate = False ' Disables the Save button
atbv_Testing_MyStuff.AllowDelete = False ' Disables the Delete button

win · Perma link post comment Posted by: Jarl Erik Schmidt (25-apr-2012)

1

Guidelines for creating afDataObject in code

' It is recommended that you only create afDataObject instances
' through the Windows Forms designer. If you for some reason have to
' do it programatically, it is important that it is disposed correctly.
' Otherwise it will remain identifitely in memory and cause various
' performance issues in the client. Two ways to do this:

' 1. Add the data object to the form's components collection. This will
'    dispose it automatically when the form is closed (recommended):

Public Sub New()
    InitializeComponent();
    gDataObj = New afDataObject();
	components.Add(gDataObj);
End Sub

' 2. Handle the .Disposed event of the enclosing form/control and dispose
'    the data object manually (not recommended):

Private Sub MyForm_OnDisposed(pSender As Object, pArgs As EventArgs) Handles Me.Disposed
    If gDataObj IsNot Nothing Then
        gDataObj.Dispose()
    End If
End Sub

' If the instance is only used within the scope of a single function,
' always enclose it in a Using block like the following:

Using vDataObj As New afDataObject()
    ' Insert code here...
End Using

dataobject win · Perma link post comment Posted by: Jarl Erik Schmidt (08-jun-2012)

1

Summary of percent field in pivots

        If e.DataField Is fieldExternalShare Then
            Dim vDS As PivotDrillDownDataSource = e.CreateDrillDownDataSource
            For i = 0 To vDS.RowCount - 1
                vTotal = vTotal + CDec(vDS.GetValue(i, fieldTotal)) 
                vExternal = vExternal + CDec(vDS.GetValue(i, fieldExternalManhours))
            Next
            If vTotal > 0 Then
                e.CustomValue = vExternal / vTotal
            Else
                e.CustomValue = Nothing
            End If
        End If

win · Perma link post comment Posted by: Johnny Vik (27-nov-2013)

0

How to change the Globalization of a field in a report by script

Private Sub label3_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
      Dim culture as System.Globalization.CultureInfo = new System.Globalization.CultureInfo("en-GB")
      sender.Text = String.Format(culture, "{0:dd MMM yyyy }", GetCurrentColumnValue("CutOff"))
End Sub

reporting win · Perma link post comment Posted by: Peter Øren (08-jun-2015)

0

Build MSI packages for you Pims client

You can now build installer packages for your Pims Client via Login builder project.

  • Open Login builder project ("Appframe->Login Builder").
  • Configure your project or create new one.
  • In toolbar navigate and press "Build->Installer package..."
  • Supply comments for your build and press "Build".

Worth Noting:

  • You should open login builder where you usually build your "ClickOnce". Recommendation is to build it from our terminal servers.
  • Installer package underlying technology (windows installer) uses strict version number policy, only 3 part version numbering is actually used and there is limit for each version number [major].[minor].[build] to [0..255].[0..255].[0..65535].
  • You do not have to care about [build] version part. It will be incremented with every build of installer package.
  • Any number can reside in last part of version number (last number is sometimes called [revision] or [private]).

Installer Login Win · Perma link post comment Posted by: Tomas Dambrauskas (24-sep-2014)

Luke Simcock :
Thanks for this. I couldn't get it to work until i made the first box in the ‘Last Version’ a 0. For my clients I have been using 4.30.1.0 to start my versioning and it seems to be working fine. (15-jan-2015)
0

afGridLookup vs afGridLookupEdit vs afLookupEdit

<u>afGridLookup (Preferred):</u> <ul> <li>RecordSource in Lookup / onDemand</li> <li>DevExpress Grid Functionality</li> </ul> <u>afGridLookupEdit:</u> <ul> <li>DevExpress Grid functionality</li> <li>RecordSource bound in application</li> </ul> <u>afLookupEdit</u> <ul> <li>Standard Lookup without DevExpress grid functionality</li> <li>RecordSource bound in application</li> </ul>

components win · Perma link post comment Posted by: Jan Christian Brataas (09-okt-2013)

0

How to update single cell in dataobject

atbv_Gruppe1_Records.CurrentRow("CategoryID") = e.Value("CategoryID").ToString()

dataobject win · Perma link post comment Posted by: Torbjørn Mevik (01-okt-2013)

0

Reporting GetCurrentRow Method

Private Sub XtraReport_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
	If GetCurrentRow() IsNot Nothing AndAlso GetCurrentColumnValue("VatPercent").ToString() = "" Then
		cLabelVat.Visible = False
	End If

End Sub

win · Perma link post comment Posted by: Torgeir Fredriksen (05-sep-2013)

0

How to get data using afAccessLayer and afRecordSource

Import Appframe3.Common.Data							


'Table to retrieve data from
Dim vRs As New afRecordSource("atbv_LessonsLearned_LessonCategory")		

'Columns of interest
vRs.SelectColumns.AddRange(New String() {"Category", "Lesson"})	

'Where-clause
vRs.Whereclause="Lesson like '%learned%'"			

'Result is returned as datatable
Dim vLessonCategories as DataTable = afAccessLayer.GetData(rs)			

win · Perma link post comment Posted by: Torbjørn Mevik (08-jul-2013)

Karl Stroud :
Pretty sure it's "Imports Appframe3.Common.Data" with an (s). (05-jun-2017)
Andrew Wooding :
This would be a lot easier to find if mentioned the word "filter". Hopefully my comment here will make it easier for the next person. (25-jun-2019)
0

Upper case letters mask (TextEdit and MemoEdit)

Dim vMaskProps As New DevExpress.XtraEditors.Mask.MaskProperties()
vMaskProps.MaskType = Mask.MaskType.RegEx
vMaskProps.UseMaskAsDisplayFormat = True
vMaskProps.EditMask = "(\p{Lu}|[0-9]|\W)+"

'For TextEdit:
vTextEdit.Properties.Mask.Assign(vMaskProps)

'For MemoEdit:
vMemoEdit.MaskBox.Mask.Assign(vMaskProperties)

'TextEdit mask can be set in design time, not the case with MemoEdit.

win · Perma link post comment Posted by: Tomas Dambrauskas (08-mar-2013)

0

How to use report parameters through code

' Step 1:
' -------
' Create report parameters in the designer with default values*. Make sure that the
' "Show in the parameters panel" box is unchecked.
'
' * see: http://documentation.devexpress.com/#XtraReports/CustomDocument9998/Creating
'
' Step 2:
' -------
' Create the applicable *ReportArgs object in your form, pass parameters through the
' AddParameter method:

Dim vArgs As New OpenReportArgs("arpt_Demo_MyReportWithParameters")
vArgs.AddParameter("Foo",           ' Name
                   GetType(String), ' Type
                   "Bar") '         ' Value

CR3.OpenReport(vArgs)

' Step 3:
' -------
' To consume the parameters in your report, use the Parameters property. Example:

Private Sub XtraReport_BeforePrint(
	ByVal sender As Object,
	ByVal e As System.Drawing.Printing.PrintEventArgs)

	Dim vFoo = Parameters("Foo")

	cFooLabel.Text = Parameters("Foo").Value

End Sub

reporting win · Perma link post comment Posted by: Jarl Erik Schmidt (12-feb-2013)

0

Sub for applying filesize formatting to controls [afFileGrid]

    Private Sub ApplyFileSizeFormatting(ByRef FSGridColumn As Appframe3.Win.Controls.Utils.afGrid.afGridColumn)
        FSGridColumn.DisplayFormat.Format = New Appframe3.Win.afFileGrid.Utils.afFileGridFileSizeFormat()
        FSGridColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom
        FSGridColumn.DisplayFormat.FormatString = "FileSize"
    End Sub

components win · Perma link post comment Posted by: Aleksander Hansen Birkeland (12-sep-2012)

0

How to locate a control bound to a specific fieldname

Private Shared Function FindBoundControl(ByVal fieldName As String, ByVal ctrl As Control) As Control
        If ctrl.DataBindings.Count > 0 AndAlso ctrl.DataBindings(0).BindingMemberInfo.BindingField = fieldName Then
            Return ctrl
        End If
        For Each child As Control In ctrl.Controls
            If child.DataBindings.Count > 0 AndAlso child.DataBindings(0).BindingMemberInfo.BindingField = fieldName Then
                Return child
            End If
            Dim childResult As Control = FindBoundControl(fieldName, child)
            If childResult IsNot Nothing Then
                Return childResult
            End If
        Next
        Return Nothing
    End Function

common win · Perma link post comment Posted by: Stian Gundersen Skjerveggen (22-aug-2012)

0

How to set defaultvalues on afDataobject

CType(Me.atbv_ProjectSetup_Persons.DataSource, DataTable).Columns("Department").DefaultValue = "3A"

win · Perma link post comment Posted by: Øystein Berge-Olsen (08-aug-2012)

0

How to hide bands with only one record

	Try
	
		Dim vReport As DevExpress.XtraReports.UI.XtraReport = sender.Report
	
		Dim vPrevValue As String = vReport.GetPreviousColumnValue("GroupField")
		Dim vCurrValue As String = vReport.GetCurrentColumnValue("GroupField")
		Dim vNextValue As String = vReport.GetNextColumnValue("GroupField")

		If vCurrValue <> vNextValue AndAlso vCurrValue <> vPrevValue Then
			e.Cancel = True
		End If

	Catch ex As Exception

	End Try

reporting win · Perma link post comment Posted by: Håvard Ravatn (19-jun-2012)

0

How to open report launcher with prefilled values

Dim vArgs As New OpenReportArgs("arpt_MyModule_ProjectStatus")

vArgs.AddParameter("ProjectName", GetType(String), "Installation Step 3")
vArgs.AddParameter("Milestone", GetType(Integer), "40")

vArgs.HeaderText = "Status  for milestone 40"
vArgs.FooterText = "Status report prepared by department 4"

vArgs.HideFilterString = True

CR3.OpenReportLauncher(vArgs)

win · Perma link post comment Posted by: Jarl Erik Schmidt (08-mai-2012)

0

How to open form while passing optional values

' Sometimes you might want to accept optional values in a CR4 form. The
' assembly loader provides a facility to pass constructor arguments, but
' this may be too rigid. The OpenProperty facility allows you to pass
' and read optional values of any type without depending on constructor
' signatures.

' The following code shows how to open a form while passing values to it:

Public Sub cOpenSetup_Click(pSender As Object, pArgs As EventArgs) handles cOpenSetup.Click

	Dim vProjectName = cProject.SelectedValue

	Dim vArgs As New OpenFormArgs("App.Example.ProjectManagement", "ProjectSetup")
	vArgs.AddProperty("ProjectName", vProjectName)
	vArgs.AddProperty("SummaryVisible", False)

	CR3.OpenForm(vArgs)

End Sub

' The following code shows how to access the passed values in the newly
' opened form defined in another project:

Private Sub MyForm_Load(ByVal pSender As Object, ByVal pArgs As EventArgs) Handles Me.Load

    If HasOpenProperty(Of String)("ProjectName") Then
        cProjectChooser.EditValue = GetOpenProperty(Of String)("ProjectName")
    End If

    If HasOpenProperty(Of Boolean)("SummaryVisible") Then
        cSummaryPanel.Visible = GetOpenProperty(Of Boolean)("SumamryVisible")
    End If

End Sub

win · Perma link post comment Posted by: Jarl Erik Schmidt (08-mai-2012)

0

Concatenating reports

Try
	Dim vCollection As Appframe3.Reporting.afReport
    Dim vDataTable As DataTable = afAccessLayer.GetData(vRecordSource)

    For Each vRow As DataRow In vDataTable.Rows
        Dim vReport As New Appframe3.Reporting.afReport("arpt_CRM_Test", "TestId = " + vRow("TestId").ToString())
        vReport.LoadLayoutAndData()
        vReport.CreateDocument()

        If vCollection Is Nothing Then
            vCollection = vReport
        Else
            vCollection.Pages.AddRange(vReport.Pages)
        End If
    Next

    Dim vMemoryStream As System.IO.MemoryStream = New System.IO.MemoryStream()
    vCollection.ExportToPdf(vMemoryStream)
    vMemoryStream.Seek(0, System.IO.SeekOrigin.Begin)
    Dim vFileStoreLayer As New Appframe3.Common.Data.afFileStoreLayer
    vFileStoreLayer.InsertFile(vMemoryStream, "test.pdf", "atbv_CRM_Tests", pPrimKey)
    Me.atbv_CRM_ProduksjonerFiles.RefreshDataSource()
Catch ex As Exception
    Throw
End Try

reporting win · Perma link post comment Posted by: Peter Øren (08-mai-2012)

0

How to connect to exchange via webservice

'List of functions: http://www.independentsoft.de/exchangewebservices/tutorial/index.html

Public ReadOnly Property ExService As ExchangeService
        Get
            If gExService Is Nothing Then
                gExService = New ExchangeService(ExchangeVersion.Exchange2010_SP1)
                gExService.Timeout = 10000
                gExService.Url = New Uri("https://.../EWS/Exchange.asmx")
                gExService.Credentials = New WebCredentials("", "")
            End If

            Return gExService
        End Get
    End Property

    <Serializable()>
    Public Class InboxItem
        Public Property UniqueID As String
        Public Property ChangeKey As String
        Public Property Subject As String
        Public Property Body As String
        Public Property FromName As String
        Public Property Received As DateTime
        Public Property ReceivedString As String
        Public Property IsRead As Boolean
    End Class

    Public Function GetMessageList(pMaxRecords As Integer, pFolder As String) As List(Of InboxItem)
        Dim vItemsList As New List(Of InboxItem)
        Dim vFolder As WellKnownFolderName
        Dim vMessage As EmailMessage
        Dim vItemIndex As Integer = 0

        Select Case pFolder.ToUpper()
            Case "INBOX"
                vFolder = WellKnownFolderName.Inbox
            Case "SENT ITEMS"
                vFolder = WellKnownFolderName.SentItems
            Case Else
                Throw New Exception("Invalid Folder")
        End Select

        Dim vResults As FindItemsResults(Of Item) = ExService.FindItems(vFolder, New ItemView(pMaxRecords))

        If vResults.Items.Count = 0 Then
            Return vItemsList
        End If

        Dim vPropertySet As New PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, EmailMessageSchema.From, EmailMessageSchema.DateTimeCreated, EmailMessageSchema.IsRead)
        Dim vResponses As ServiceResponseCollection(Of ServiceResponse) = ExService.LoadPropertiesForItems(vResults, vPropertySet)

        For Each vResponse As ServiceResponse In vResponses
            If vResponse.Result = ServiceResult.Success AndAlso TypeOf vResults.Items(vItemIndex) Is EmailMessage Then
                vMessage = DirectCast(vResults.Items(vItemIndex), EmailMessage)

                vItemsList.Add(New InboxItem With {.UniqueID = vMessage.Id.UniqueId,
                                                   .ChangeKey = vMessage.Id.ChangeKey,
                                                   .Subject = vMessage.Subject,
                                                   .FromName = vMessage.From.Name,
                                                   .Received = vMessage.DateTimeCreated,
                                                   .ReceivedString = vMessage.DateTimeCreated.ToShortDateString(),
                                                   .IsRead = vMessage.IsRead})
            End If
            vItemIndex += 1
        Next
        Return vItemsList
    End Function

win · Perma link post comment Posted by: Peter Øren (26-mar-2012)

0

How to set the datanavigator to active tab page grid

#Region "Set datanavigator datasource and custom tabspecific whereclause"
    Private Sub cMainTab_SelectedPageChanged(ByVal sender As System.Object, ByVal e As DevExpress.XtraTab.TabPageChangedEventArgs) Handles cMainTab.SelectedPageChanged
        ' Find and select the grid:
        For Each ctrl As Control In Me.cMainTab.SelectedTabPage.Controls
            If TypeOf ctrl Is Appframe3.Win.Controls.afGrid Then
                Dim vWhereclause As String = ""
                DataNavigator.DataSource = CType(ctrl, Appframe3.Win.Controls.afGrid).DataSource
                DataNavigator.cDataNavigator.DataSource = CType(ctrl, Appframe3.Win.Controls.afGrid).DataSource
                Try
                    DataNavigator.afReloadData()
                Catch ex As Exception
                    CR3.HandleException(ex)
                End Try
            End If
        Next
        If cMainTab.SelectedTabPage.Name = cTabStart.Name Then
            DataNavigator.Visible = False
        Else
            DataNavigator.Visible = True
        End If
    End Sub
#End Region

win · Perma link post comment Posted by: Werner Waage (21-feb-2012)

0

How to get afSendMail to connect to multiple databases

Duplicate the <dbconnection> item in MailSettings.xml

<config>
	<afSendMail>
		<dbconnection>
			<PIMS_DEV>Server=127.0.0.1;Database=PIMS1;User ID=af_mail;Password=Pwd</PIMS_DEV>
		</dbconnection>
		<dbconnection>
			<PIMS_TEST>Server=127.0.0.1;Database=PIMS2;User ID=af_mail;Password=Pwd</PIMS_TEST>
		</dbconnection>
		<dbconnection>
			<PIMS_PROD>Server=127.0.0.1;Database=PIMS3;User ID=af_mail;Password=Pwd</PIMS_PROD>
		</dbconnection>
		<smtp>
			<server>255.255.255.255</server>
			<port>25</port>
		</smtp>
		<debug>
			<port>1002</port>
			<sessiontimeout>30</sessiontimeout>
			<logfiledirectory>c:\Appframe\Services\LogFiles\afSendMail</logfiledirectory>
		</debug>
	</afSendMail>
	...
</config>	

win · Perma link post comment Posted by: Nils Arne Ramsvik (02-feb-2012)

0

How to copy a row in afDataObject

' Copy all items from the current row into an array
Dim vItems As Object = MyDataObject.CurrentRow.ItemArray

' Adds a new item to the dataobject
MyDataObject.AddNew()

' Saves the PrimKey value from the newly added row
Dim vPrimKey As String = MyDataObject.CurrentRow("PrimKey").ToString()

' Moves all items to the new row
MyDataObject.CurrentRow.ItemArray = vItems

' Makes sure the PrimKey isn't duplicated and sets the stored PK reference
MyDataObject.CurrentRow("PrimKey") = vPrimKey

' For each column you don't want to include in the new row remove it by setting DBNull.Value
MyDataObject.CurrentRow("Updated") = DBNull.Value
MyDataObject.CurrentRow("UpdatedBy") = DBNull.Value
MyDataObject.CurrentRow("Created") = DBNull.Value
MyDataObject.CurrentRow("CreatedBy") = DBNull.Value

' Finally save the new row
MyDataObject.EndEdit()

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

Preserve Window Size And Position (Only applicable to dialogs)

Add this line in the Form_Load event

afForms:
AppFrame3.Win.Helpers.FormLayoutHelper.PreserveLayout(Me, PositionSizeAndWindowState)

Non-afForms:
AppFrame3.Win.Helpers.FormLayoutHelper.PreserveLayout(Me, "CR3ProjectName", PositionSizeAndWindowState)

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to add image to a button

Step-by-step instruction 1. Add "ImageList" component from Toolbox section "All Windows Forms" to your form. 2. Download images from AppFrame R3 TeamDocument. They are in Ico.zip file. 3. Add needed Images to this component. 4. Set the "Images" property of the BarManager component. 5. Set the "ImageIndex" property of your button. 6. Set "PaintStyle" property to "CaptionGlyph" of your button.

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to export a report to PDF

Dim vFileName as String = Nothing
Dim vViewName as String = Nothing
Dim vPrimKey as String = Nothing

Dim vReport As New AppFrame3.Reporting.afReport(vReportID, vFilter)
vReport.LoadLayoutAndData()

Dim vMemoryStream As System.IO.MemoryStream = New System.IO.MemoryStream()
vReport.ExportToPdf(vMemoryStream)
vMemoryStream.Seek(0, System.IO.SeekOrigin.Begin)

Dim vFileStoreLayer As New AppFrame3.Common.Data.afFileStoreLayer
vFileStoreLayer.InsertFile(vMemoryStream, vFileName, vViewName, vPrimKey)

vMemoryStream.Close()

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

Kevin Francis Becker :
I needed to prepare a new row in the filestore table as per Trong's post https://www.pims.no/teamdoc?8088/151517/post-811237 (17-okt-2017)
Kevin Francis Becker :
Dim vTable As DataTable = CType(pFilestoreTableView.DataSource, DataTable) Dim vNewRow As DataRow = vTable.NewRow() vTable.Rows.Add(vNewRow) Dim vPrimKey = vNewRow("PrimKey").ToString() Dim vViewName = pFilestoreTableView.DataSource.ToString() (17-okt-2017)
0

How to handle exceptions

Try
'Your Code here
Catch ex As Exception
CR3.HandleException(ex)
End Try

or

Try
'Your Code here
Catch ex As Exception
CR3.HandleException("Errormessage", "App.CRM.Persons")
End Try

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to open a project

CR3.OpenProject("App.Development.janleonDemo")   'Will launch the projects default form

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

Open Mail Message fra CR3 (application object)

CR3.OpenMailMessage(MessageRef, mode)
'mode-enum=Open/Reply/ReplyAll/Forward + en overload uten noen argument som bare åpner en tom (ny melding).

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to open report

CR3.OpenReport("arpt_Torgeir_Test", "myFilter")

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to insert new record through code

Dim vSource As AppFrame3.Win.Data.afDataObject = DirectCast(dbgRelated.DataSource, AppFrame3.Win.Data.afDataObject)  'GetCurrent DataSource for datagrid
Dim vCurrent As DataRow = vSource.CurrentRow            'Get Current Selected Row
Dim vNewRow As DataRow = vCurrent.Table.NewRow()  'Create new Row object inheriting from existing table row
vNewRow.Item("DocDwgID") = "DocDwgID"
vNewRow.Item("Title") = "Title"
vNewRow.Item("CurrentRev") = "Rev"
vNewRow.Item("RevDate") = "2007.01.01"
vCurrent.Table.Rows.Add(vNewRow) 'Post Data to dataSource

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

Marquee progressbar and LoadingDialog in the main client

Try
	AppFrame3.Win.CR3.SetStatus(String.Format("Loading {0}...", ProjectName), False, True)
Catch
	...
Finally
	AppFrame3.Win.CR3.ClearStatus()
End try

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to save main record and refresh sub data(grid)

Private Sub cSearchCategory_EditValueChanged(....) Handles cSearchCategory.EditValueChanged
  Try
     Me.DataNavigator.DataSource.EndEdit()
     Me.aviw_CRM_SearchForCandidates.RefreshDataSource()
  Catch ex As Exception
      MessageBox.Show("Error saving/refreshing : " + ex.Message)
  End Try
End Sub

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to customise Print/Preview for chart, grid etc.

Imports DevExpress.XtraPrinting

Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton1.Click
	Dim vPrintingSystem As PrintingSystem = New PrintingSystem()
	Dim vLink As PrintableComponentLink = New PrintableComponentLink(vPrintingSystem)
	vLink.Component = Me.ChartControl1 ' Set to your chart / grid control
	vLink.Landscape = True
	Me.ChartControl1.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Zoom
	vLink.ShowPreview()
End Sub

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to send mail message without showing the window to user

Imports AppFrame3.Win.Common.Mail

Dim vMessage As New Message() 
vMessage.Recipients.Add(pMessageRow("ToName").ToString(), pMessageRow("ToEmail").ToString(), RecipientType.MailTo) 
vMessage.Recipients.Add(pMessageRow("FromName").ToString(), pMessageRow("FromEmail").ToString(), RecipientType.MailFrom)
vMessage.Subject = "Test" 
vMessage.InsertHTML = "Blabla"
vMessage.Attachments.Add(vFilePath)
vMessage.DoSendMessage(True, True)

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to use 2 layer remoting (web.config)

Add this appsetting to the external server's web.config:
&lt;system.runtime.remoting&gt;
    &lt;application&gt;
      &lt;service&gt;
        &lt;wellknown mode="SingleCall" objectUri="afRemotingLoader.rem" type="AppFrame3.Common.RemotingLoader.afRemotingLoader, AppFrame3.Common.RemotingLoader" /&gt;
        &lt;wellknown mode="SingleCall" objectUri="afFileRemotingLoader.rem" type="AppFrame3.Common.RemotingLoader.afFileRemotingLoader, AppFrame3.Common.RemotingLoader" /&gt;
      &lt;/service&gt;
      &lt;channels&gt;
        &lt;channel ref="http" /&gt;
      &lt;/channels&gt;
    &lt;/application&gt;
  &lt;/system.runtime.remoting&gt;

&lt;appSettings&gt;
      &lt;add key="InternalRemotingHost" value="http://test3.teamdocuments.com/"/&gt;
  &lt;/appSettings&gt;

Copy this file to the external remoting server's bin folder:
AppFrame3.Common.Data.dll
AppFrame3.Common.RemotingLoader.dll
AppFrame3.Common.Remoting.dll
AppFrame3.Common.Remoting2.dll

Add this to the internal remoting server's web.config:
&lt;system.runtime.remoting&gt;
    &lt;application&gt;
      &lt;service&gt;
        &lt;wellknown mode="SingleCall" objectUri="afRemoteSqlAccessLayer.rem" type="AppFrame3.Common.Remoting.afRemoteSqlAccessLayer, AppFrame3.Common.Remoting" /&gt;
        &lt;wellknown mode="SingleCall" objectUri="afRemoteFileStoreLayer.rem" type="AppFrame3.Common.Remoting.afRemoteFileStoreLayer, AppFrame3.Common.Remoting" /&gt;
      &lt;/service&gt;
      &lt;channels&gt;
        &lt;channel ref="http" /&gt;
      &lt;/channels&gt;
    &lt;/application&gt;
  &lt;/system.runtime.remoting&gt;

Copy these files to the internal remoting server's bin folder:
AppFrame3.Common.Data.dll
AppFrame3.Common.RemotingLoader.dll
AppFrame3.Common.Remoting.dll
AppFrame3.Common.Remoting2.dll

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to use 1 layer remoting (Web.config)

Add this section to the web.config:
&lt;system.runtime.remoting&gt;
    &lt;application&gt;
      &lt;service&gt;
        &lt;wellknown mode="SingleCall" objectUri="afRemotingLoader.rem" type="AppFrame3.Common.RemotingLoader.afRemotingLoader, AppFrame3.Common.RemotingLoader" /&gt;
        &lt;wellknown mode="SingleCall" objectUri="afFileRemotingLoader.rem" type="AppFrame3.Common.RemotingLoader.afFileRemotingLoader, AppFrame3.Common.RemotingLoader" /&gt;
      &lt;/service&gt;
      &lt;channels&gt;
        &lt;channel ref="http" /&gt;
      &lt;/channels&gt;
    &lt;/application&gt;
  &lt;/system.runtime.remoting&gt;


Copy these files to the bin folder of you web site:
AppFrame3.Common.Data.dll
AppFrame3.Common.RemotingLoader.dll
AppFrame3.Common.Remoting.dll
AppFrame3.Common.Remoting2.dll

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to use tag-replacement in where clause

Using controls as replacement tag (ex:DevExpress.XtraEditors.TextEdit):

[PersonID]='<%cTextEdit1%>'

Using afGrid as replacement:

[PersonID]='<%cAfGrid1.PersonID%>' (refering to DataTable column name in the grids datasource)

PS: When using replacement in a grid where the parent control is another column, you need to refer to the field name in the grid's datasource

Following controls are supported as parent controls when using tag-replacement:
 - Controls inheriting from DevExpress.XtraEditors.BaseEdit
 - afGrid having afDataObject as DataSource

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to upload multiple files

Dim vFileTransferDialog As New afFileTransferDialog(FileMode.Upload, "stbv_SourceControl_Files")
vFileTransferDialog.Files.Add("0e3d1a1d-e4c6-4702-a728-7540287a550a", "C:\Documents and Settings\Jan Leon\Desktop\New Folder (7)\DXperience-7.3.6.exe")
vFileTransferDialog.Files.Add("0e3d1a1d-e4c6-4702-a728-7540287a550a", "C:\Documents and Settings\Jan Leon\Desktop\New Folder (7)\newfilename.exe")
vFileTransferDialog.Show()

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

Karl Stroud :
I think .Show() should be .ShowDialog() (10-apr-2019)
0

Up/download without dialog

Dim vFileTransferDialog As New afFileTransferDialog("C:\Documents and Settings\Jan Leon\Desktop\New Folder (7)\New Folder", "", "stbv_SourceControl_Files", "0e3d1a1d-e4c6-4702-a728-7540287a550a")
vFileTransferDialog.ShowInTaskbar = False
vFileTransferDialog.Visible = False
vFileTransferDialog.Show()

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to upload single file using afFileTransferDialog

Dim vFileTransferDialog As New afFileTransferDialog("C:\Documents and Settings\Jan Leon\Desktop\New Folder (7)\DXperience-7.3.6.exe", "stbv_SourceControl_Files", "0e3d1a1d-e4c6-4702-a728-7540287a550a")
vFileTransferDialog.Show()

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)

0

How to download single file using afFileTransferDialog

Dim vFileTransferDialog As New afFileTransferDialog("C:\Documents and Settings\Jan Leon\Desktop\New Folder (7)\New Folder", "", "stbv_SourceControl_Files", "0e3d1a1d-e4c6-4702-a728-7540287a550a")

'Property for open after download
vFileTransferDialog.OpenAfterDownload = True

vFileTransferDialog.Show()

win · Perma link post comment Posted by: Peter Øren (13-jan-2012)