logo
Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
bart  
#1 Posted : Thursday, January 21, 2010 4:24:27 PM(UTC)
bart

Rank: Administration

Reputation:

Groups: Administration
Joined: 10/8/2008(UTC)
Posts: 190
Man

Was thanked: 1 time(s) in 1 post(s)
Here is an easy implementation to use viewcontrols(Control 42) in the shopmaillayout.

Just add the code below in the "UserEscape overrule mail 0"

Code:

Imports microsoft.visualbasic
==>END IMPORTS
Try
Dim Cid as string = pbw.get_cid_currentdomain
Dim Newmail as string = ""
Dim Orgineletekst as string = Mailtext
'
Dim CTeller, Labelteller As Integer
        Labelteller = -1
        Dim b As String() = Split(Orgineletekst, "{!$")
        Dim arraysize As Integer = b.Length * 3

        Dim Lbar(arraysize) As String
        Dim LbarType(arraysize) As String
        While Orgineletekst.IndexOf("{!$") >= 0
            'Neem eerste deel tekst en plaats in label array voorbeeld: {!$Control.05$!}
            Dim Ctrlpos, Ctrllen As Integer
            Ctrlpos = Orgineletekst.IndexOf("{!$")
            Ctrllen = Orgineletekst.IndexOf("$!}") + 1 - Ctrlpos
            Dim TekstdeelI As String = Orgineletekst.Substring(0, Ctrlpos)
            Dim Controlnaam As String = Orgineletekst.Substring(Ctrlpos + 1, Ctrllen)
            Controlnaam = Controlnaam.Substring(2, Controlnaam.Length - 4)
            Dim TekstdeelII As String = Orgineletekst.Substring(Ctrlpos + Ctrllen + 2, Orgineletekst.Length - Ctrlpos - Ctrllen - 2)
            'Voeg items toe aan array
            Labelteller = Labelteller + 1
            Lbar(Labelteller) = TekstdeelI
            LbarType(Labelteller) = "LB"
            Labelteller = Labelteller + 1
            Lbar(Labelteller) = Controlnaam
            LbarType(Labelteller) = "UC"
            'Orginele tekst wordt de rest van de string
            Orgineletekst = TekstdeelII
            Dim ViewId as string= controlnaam.split(".")(2)
            Dim Queryoverrule as string = controlnaam.split(".")(3)
            Queryoverrule = Queryoverrule.replace("|",".")
            dim result as string = pbw.Create_View(0,0,"/",0,httpContext.Current.Server,"","","","",httpContext.Current.Session,httpContext.Current.Response,httpContext.Current.Request,0,"",-1,"","","",0.0,-1,2,0,0,0,0,0,0,1,Queryoverrule,0,"",0,"",0,Cint(ViewId),Cid,100,"",Constring)
            Newmail &= TekstdeelI & Result
        End While
                'Kijk of er nog tekst is overgebleven
          Newmail &= Orgineletekst 

Mailtext=Newmail
catch ex as exception
mailtext &= ex.tostring
end try


Notice that this only works for viewcontrols and not for other controls. this is because a viewcontrol can return a string. Most other controls return a label which is not possible in a mail.

Edited by user Friday, April 15, 2011 12:05:32 PM(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your Sienn Forum forum account. New Registrations are disabled.

bart  
#2 Posted : Wednesday, February 3, 2010 5:03:33 PM(UTC)
bart

Rank: Administration

Reputation:

Groups: Administration
Joined: 10/8/2008(UTC)
Posts: 190
Man

Was thanked: 1 time(s) in 1 post(s)
Or even better

Code:
Imports microsoft.visualbasic
==>END IMPORTS
Try
Dim Cid as string = pbw.get_cid_currentdomain
Dim Newmail as string = ""
Dim Orgineletekst as string = Mailtext

Dim CTeller, Labelteller As Integer
        Labelteller = -1
        Dim b As String() = Split(Orgineletekst, "{!$")
        Dim arraysize As Integer = b.Length * 3

        Dim Lbar(arraysize) As String
        Dim LbarType(arraysize) As String
        While Orgineletekst.IndexOf("{!$") >= 0
            'Neem eerste deel tekst en plaats in label array voorbeeld: {!$Control.05$!}
            Dim Ctrlpos, Ctrllen As Integer
            Ctrlpos = Orgineletekst.IndexOf("{!$")
            Ctrllen = Orgineletekst.IndexOf("$!}") + 1 - Ctrlpos
            Dim TekstdeelI As String = Orgineletekst.Substring(0, Ctrlpos)
            Dim Controlnaam As String = Orgineletekst.Substring(Ctrlpos + 1, Ctrllen)
            Controlnaam = Controlnaam.Substring(2, Controlnaam.Length - 4)
            Dim TekstdeelII As String = Orgineletekst.Substring(Ctrlpos + Ctrllen + 2, Orgineletekst.Length - Ctrlpos - Ctrllen - 2)
            'Voeg items toe aan array
            Labelteller = Labelteller + 1
            Lbar(Labelteller) = TekstdeelI
            LbarType(Labelteller) = "LB"
            Labelteller = Labelteller + 1
            Lbar(Labelteller) = Controlnaam
            LbarType(Labelteller) = "UC"
            'Orginele tekst wordt de rest van de string
            Orgineletekst = TekstdeelII
			Dim ControlId as string = controlnaam.split(".")(1)
			Select Case ControlId
			  Case 36
			    Dim OpenControlId as string= controlnaam.split(".")(2)
				Select Case OpenControlId
				  Case 25
				    dim result as string = ""
				    Dim prefix as string = Cid & "U_"
				    Dim whereQuery as string = controlnaam.split(".")(3)
				    dim count as integer = 0
				    using Con As New SqlConnection(constring)
        				    Try
            				    Dim strQuery As String = ""
            				    strQuery &= " Select count(*) "
            				    strQuery &= " from " & prefix & "cursisttemp "
            				    strQuery &= whereQuery
				                
            				    Dim Com As New SqlCommand(strQuery, Con)
				    
            				    con.open
            				    Dim Reader As SqlDataReader = Com.ExecuteReader()
            				    while Reader.Read()
                				    count = reader(0)
            				    End While
        				    Catch ex As Exception
        				    Finally
            				    con.close
        				    End Try
				    end using
				    If count >0 then
  				    result &= "<table style=""border-left: gray 1px solid;background: #ddebeb; border-top: gray 1px solid; border-right: gray 1px solid"" border=""0"" cellspacing=""2"" cellpadding=""2"" width=""500"">"
  				    result &= " <tr> "
  				    result &= "      <td>Ingeschreven cursisten voor de cursus</td>"
  				    result &= "  </tr>"
  				    result &= "</table>"
				    end if
					Newmail &= TekstdeelI & Result
				end Select		  

			  Case 42
			    Dim ViewId as string= controlnaam.split(".")(2)
                	    Dim Queryoverrule as string = controlnaam.split(".")(3)
                	    Queryoverrule = Queryoverrule.replace("|",".")
                	    dim result as string = pbw.Create_View(0,0,"/",0,httpContext.Current.Server,"","","","",httpContext.Current.Session,httpContext.Current.Response,httpContext.Current.Request,0,"",-1,"","","",0.0,-1,2,0,0,0,0,0,0,1,Queryoverrule,0,"",0,"",0,Cint(ViewId),Cid,100,"",Constring)
                	    Newmail &= TekstdeelI & Result
		    end Select 
        End While
                'Kijk of er nog tekst is overgebleven
        Newmail &= Orgineletekst 

Mailtext=Newmail
catch ex as exception
mailtext &= ex.tostring
end try


Now you can also use Opencontrols. The only thing is that you have to copy the compete opencontrol source to create a string
and "Par(0)" should be replaced by "controlnaam.split(".")(3)" and so on.

For the viewcontrol, If you like to use startpos you can use
Code:

Dim startpos as string = controlnaam.split(".")(4)

for example.
bart  
#3 Posted : Friday, April 15, 2011 11:03:28 AM(UTC)
bart

Rank: Administration

Reputation:

Groups: Administration
Joined: 10/8/2008(UTC)
Posts: 190
Man

Was thanked: 1 time(s) in 1 post(s)
For this overrule mail part, I created something which overrules every open Control without Copying the code

Code:
Imports microsoft.visualbasic
==>END IMPORTS
Try
Dim Cid as string = pbw.get_cid_currentdomain
Dim Newmail as string = ""
Dim Orgineletekst as string = Mailtext

Dim CTeller, Labelteller As Integer
        Labelteller = -1
        Dim b As String() = Split(Orgineletekst, "{!$")
        Dim arraysize As Integer = b.Length * 3

        Dim Lbar(arraysize) As String
        Dim LbarType(arraysize) As String
        While Orgineletekst.IndexOf("{!$") >= 0
            'Neem eerste deel tekst en plaats in label array voorbeeld: {!$Control.05$!}
            Dim Ctrlpos, Ctrllen As Integer
            Ctrlpos = Orgineletekst.IndexOf("{!$")
            Ctrllen = Orgineletekst.IndexOf("$!}") + 1 - Ctrlpos
            Dim TekstdeelI As String = Orgineletekst.Substring(0, Ctrlpos)
            Dim Controlnaam As String = Orgineletekst.Substring(Ctrlpos + 1, Ctrllen)
            Controlnaam = Controlnaam.Substring(2, Controlnaam.Length - 4)
            Dim TekstdeelII As String = Orgineletekst.Substring(Ctrlpos + Ctrllen + 2, Orgineletekst.Length - Ctrlpos - Ctrllen - 2)
            'Voeg items toe aan array
            Labelteller = Labelteller + 1
            Lbar(Labelteller) = TekstdeelI
            LbarType(Labelteller) = "LB"
            Labelteller = Labelteller + 1
            Lbar(Labelteller) = Controlnaam
            LbarType(Labelteller) = "UC"
            'Orginele tekst wordt de rest van de string
            Orgineletekst = TekstdeelII
            Dim ControlId as string = controlnaam.split(".")(1)
            Select Case ControlId
              Case 36
                try
                  Dim SourceVolgnummer as string= controlnaam.split(".")(2)
                  Dim key As String = "SOURCEFORMCT"
                  If SourceVolgnummer.Length = 1 Then
                    SourceVolgnummer = "0" & SourceVolgnummer
                  End If
                  key &= SourceVolgnummer
                  dim Parvulling as integer = controlnaam.split(".").Length - 3
                  Dim par(20) As String
                  For I as integer = 0 to Parvulling -1
                    par(I) = controlnaam.split(".")(I+3)
                  next
                  Dim Controlplace as new System.Web.UI.HtmlControls.HtmlGenericControl
                  Controlplace.Id = "Controlplace"
                  Dim MyForm2 As new SiennEngine.OpenControl
                  pbw.Run_OpenControl(key, Cid, False, pbw.Get_RunSource_CreateAssembly, pbw.Get_RunSource_RunFromAssembly(), MyForm2, "", httpContext.Current.Server, httpContext.Current.Request, httpContext.Current.Session, httpContext.Current.Response, pbw.Get_Constring, par, parvulling, "", "", Controlplace)
                  Dim Result as string = ""
                  Dim ControlCount as integer = Controlplace.Controls.Count
                  If controlCount > 0 then
                    For I as integer = 0 to ControlCount -1
                      If Controlplace.Controls(I).Tostring= "System.Web.UI.LiteralControl" then
                        Dim litControl as literalControl = Controlplace.Controls(I)
                        Result &= litControl.text
                      end if
                    next
                  else
                    Result = Controlplace.InnerHTML
                  end if
                  Newmail &= TekstdeelI & Result
                catch ex as exception
                  Newmail &= TekstdeelI & ex.tostring
                end try
              Case 42
                Dim ViewId as string= controlnaam.split(".")(2)
                        Dim Queryoverrule as string = controlnaam.split(".")(3)
                        Queryoverrule = Queryoverrule.replace("|",".")
                        dim result as string = pbw.Create_View(0,0,"/",0,httpContext.Current.Server,"","","","",httpContext.Current.Session,httpContext.Current.Response,httpContext.Current.Request,0,"",-1,"","","",0.0,-1,2,0,0,0,0,0,0,1,Queryoverrule,0,"",0,"",0,Cint(ViewId),Cid,100,"",Constring)
                        Newmail &= TekstdeelI & Result
            end Select
        End While
                'Kijk of er nog tekst is overgebleven
        Newmail &= Orgineletekst

Mailtext=Newmail
catch ex as exception
mailtext &= ex.tostring
end try


This currently only works if you use only literalcontrols.
If you also use other control you can remark this code
Code:
                  'Dim Result as string = ""
                  'Dim ControlCount as integer = Controlplace.Controls.Count
                  'For I as integer = 0 to ControlCount -1
                  '  If Controlplace.Controls(I).Tostring= "System.Web.UI.LiteralControl" then
                  '    Dim litControl as literalControl = Controlplace.Controls(I)
                  '    Result &= litControl.text
                  '  end if
                  'next

And Include your own handling for other controls.

I hope this will help someone out.

Edit 20120829: I changed the controplace part so it automaticcaly detects innerHTML or controlplace. In some cases it won't work correct if you do this the wrong way.

Edited by user Wednesday, August 29, 2012 11:06:04 AM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.