Google Calendar Add multiple events at same time - vb.net

I'm trying to add/update multiples event at same time in Google Calendar, in the example below I've to execute 1 by 1, but I want to use only one .Execute...
Sometimes I've to update 30-50 events at same time and every .Execute takes aprox. 1 second each.
I also tried to make a UpdateRequest list but I couldn't execute them at same time, I had to execute 1 by 1.
Private Sub AddEvents()
Dim newEvent1 As New [Event]() With {
.Summary = "Event1",
.Description = "Desc1",
.Start = New EventDateTime() With {.DateTime = DataHora, .TimeZone = TimeZone},
.End = New EventDateTime() With {.DateTime = DateAdd(DateInterval.Hour, 1, DataHora), .TimeZone = TimeZone},
.Reminders = New [Event].RemindersData() With {.UseDefault = True},
.ColorId = CorEvento
}
Dim newEvent2 As New [Event]() With {
.Summary = "Event2",
.Description = "Desc2",
.Start = New EventDateTime() With {.DateTime = DataHora, .TimeZone = TimeZone},
.End = New EventDateTime() With {.DateTime = DateAdd(DateInterval.Hour, 1, DataHora), .TimeZone = TimeZone},
.Reminders = New [Event].RemindersData() With {.UseDefault = True},
.ColorId = CorEvento
}
Dim request1 As EventsResource.UpdateRequest = service.Events.Update(newEvent1, RetornaCalendario(), EventID1)
request1.Execute()
Dim request2 As EventsResource.UpdateRequest = service.Events.Update(newEvent2, RetornaCalendario(), EventID2)
request2.Execute()
End Sub

Related

Speed up my function - Dynamic button creation vb.net

I have a function that creates button dynamically based on a database table, there are about 250 records inside. Everything is working properly but I'd like to make it faster but I don't know how.
Maybe it's due to the language I don't know.
Actually, on my development machine, it takes about 56 seconds to load. I'm not an experienced developper so maybe I'm missing something.
The problem is that on the client machine, that has only 4Go of RAM, the loading time is much bigger, 2.5 to 3.5 minutes.
Thans you for your help.
This is my code :
Public Sub LoadProducts()
Me.ProgressBar1.Value = 0
Me.ProgressBar1.Visible = True
Dim oSim As New SimFonction
Dim str As String = "SELECT * FROM produits ORDER BY ref;"
Dim oCmd As New MySqlCommand(str, oSim.ConnectDb)
Dim oData As New DataSet
Dim oAdapt As New MySqlDataAdapter With {
.SelectCommand = oCmd
}
oAdapt.Fill(oData)
oSim.conn.Close()
recCount = oData.Tables(0).Rows.Count
Dim btn(recCount) As Button
Dim x, y, j As Integer
oAdapt = Nothing
oCmd = Nothing
str = Nothing
Dim ref As String
x = 0
y = 0
Dim valeurIncr As Integer = 100 / recCount
valeurBar = 0
i = 0
For i = 0 To oData.Tables(0).Rows.Count - 1
If Me.ProgressBar1.Value >= 90 Then
Me.ProgressBar1.Value = 0
End If
If j = 5 Then
y += 90
j = 0
x = 0
End If
x += 90
btn(i) = New Button With {
.Parent = productPanel,
.Location = New Point(x, y),
.Height = 90,
.Width = 90,
.Font = New Font("Microsoft Sans Serif", 14, FontStyle.Bold),
.ForeColor = Color.Orange,
.UseVisualStyleBackColor = True,
.TextAlign = ContentAlignment.BottomCenter
}
ref = oData.Tables(0).Rows(i).Item("ref").ToString
If IsDBNull(oData.Tables(0).Rows(i).Item("photo")) Then
btn(i).Text = oData.Tables(0).Rows(i).Item("ref").ToString
btn(i).Tag = oData.Tables(0).Rows(i).Item("ref").ToString
btn(i).Name = "bt" & ref
Else
Dim photoP As New IO.MemoryStream(CType(oData.Tables(0).Rows(i).Item("photo"), Byte()))
btn(i).BackgroundImage = Image.FromStream(photoP)
btn(i).BackgroundImageLayout = ImageLayout.Stretch
btn(i).Tag = oData.Tables(0).Rows(i).Item("ref").ToString
btn(i).Text = oData.Tables(0).Rows(i).Item("ref").ToString
btn(i).Name = "bt" & ref
photoP = Nothing
End If
If oSim.CheckProduiEnStock(ref) = False Then
btn(i).Enabled = False
End If
AddHandler btn(i).Click, AddressOf ButtonClicked
j += 1
Me.ProgressBar1.Value += 1
btn(i) = Nothing
Next
Me.ProgressBar1.Visible = False
End Sub
You may use the following command:
At the beginning: Me.SuspendLayout() ,and
at the end: Me.ResumeLayout()

How to add Name field in Docusing envelope?

Currently i can create envelope with signers dynamically, now i want to add Name field above the signer, i using below code to set Auto search Text.
' Document
Dim doc1 As Document = New Document With {
.DocumentBase64 = doc1DocxBytes,
.Name = ext1(0),
.FileExtension = ext1(1),
.DocumentId = "1"
}
env.Documents = New List(Of Document) From {
doc1
}
'Signer1
Dim signer1 As Signer = New Signer With {
.Email = signerEmail,
.Name = signerName,
.RecipientId = "1",
.RoutingOrder = "1"
}
Dim signHere212 As SignHere = New SignHere With {
.AnchorString = "For and on behalf of the vendor",
.AnchorUnits = "pixels",
.AnchorYOffset = "70",
.AnchorXOffset = "20"
}
Dim fullName212 As FullName = New FullName With {
.AnchorString = "For and on behalf of the vendor",
.AnchorUnits = "pixels",
.AnchorYOffset = "100",
.AnchorXOffset = "20"
}
Dim signer1Tabs As Tabs = New Tabs With {
.SignHereTabs = New List(Of SignHere) From {
signHere212
},
.FullNameTabs = New List(Of FullName) From {
fullName212
}
}
signer1.Tabs = signer1Tabs
Dim recipients As Recipients = New Recipients With {
.Signers = New List(Of Signer) From {
signer1
}
}
env.Recipients = recipients
env.Status = "sent"
Dim envelopeEvents = New List(Of EnvelopeEvent)()
envelopeEvents.Add(New EnvelopeEvent With {
.EnvelopeEventStatusCode = "completed",
.IncludeDocuments = "true"
})
eventNotification.EnvelopeEvents = envelope
From above code i placed sign on the top of "For and on behalf of the vendor", now i want Name field to add Name when signer sign the document.Please provide piece of code.
Dim fullName212 As FullName = New FullName With {
.AnchorString = "For and on behalf of the vendor",
.AnchorUnits = "pixels",
.AnchorYOffset = "70",
.AnchorXOffset = "20"
}
Dim signer1Tabs As Tabs = New Tabs With {
.SignHereTabs = New List(Of SignHere) From {
signHere1
},
.FullNameTabs = New List(Of FullName) From {
fullName212
}
signer1.Tabs = signer1Tabs
Dim recipients As Recipients = New Recipients With {
.Signers = New List(Of Signer) From {
signer1
}
}

Mail is not being delivered

I am sending mail using SmtpClient. while attempting to send any-mail, I am getting success response. But mail is not getting delivered.
Dim mMailMessage As New Net.Mail.MailMessage
Dim client As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient("domain", 587)
client.EnableSsl = True
client.Timeout = 100000
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network
client.UseDefaultCredentials = False
client.Credentials = New NetworkCredential("username***", "password")
Dim msg As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
mMailMessage.[To].Add(pstrToMailid)
mMailMessage.From = New System.Net.Mail.MailAddress("frommailid")
mMailMessage.Subject = pstrSubject
mMailMessage.IsBodyHtml = True
mMailMessage.Body = text
If Not pstrfilenames Is Nothing Then
Dim lint As Integer
Dim larrattachment() As String
larrattachment = Split(pstrfilenames, ",")
For lint = 0 To larrattachment.Length - 2
attachment = New Net.Mail.Attachment(larrattachment(lint))
mMailMessage.Attachments.Add(attachment)
Next
End If
client.Send(mMailMessage)

How to format axis in highchart

I am creating a simple chart using the HighCharts .Net API:
Dim sFontFamily As String = "fontFamily: 'inherit'"
Dim oChart As DotNet.Highcharts.Highcharts = New DotNet.Highcharts.Highcharts("SearchCount")
With oChart
.InitChart(New DotNet.Highcharts.Options.Chart With {.Style = sFontFamily, .Height = 250, .DefaultSeriesType = DotNet.Highcharts.Enums.ChartTypes.Line})
.SetOptions(New GlobalOptions With {.Global = New DotNet.Highcharts.Options.Global With {.UseUTC = False}})
.SetTitle(New Title With {.Style = sFontFamily, .Text = "Search Count"})
.SetXAxis(New XAxis With {.Labels = New XAxisLabels With {.Style = sFontFamily}, .Title = New XAxisTitle With {.Style = sFontFamily, .Text = "Month"}})
.SetYAxis(New YAxis With {.Labels = New XAxisLabels With {.Style = sFontFamily}, .Title = New YAxisTitle With {.Style = sFontFamily, .Text = "Searches"}})
.SetCredits(New Credits With {.Enabled = False})
.SetTooltip(New Tooltip With {.Style = sFontFamily})
.SetSeries(New Series() With {.Name = "this year", .Data = New Data(oData)})
'display a legend so user knows what graphs represent
.SetLegend(New Legend With {.Style = sFontFamily, .Enabled = True})
litHighChartSearchCount.Text = oChart.ToHtmlString()
End With
For convenience here is the rendered result: https://jsfiddle.net/d063mhoL/
And the data passed to the Series looks like this:
If you check the Fiddle you will see the data on the Y-Axis is numeric, when I want it to be a string of the month name, can anyone help?
I needed to set the categories for the axis, like so:
.SetXAxis(New XAxis With {.Categories = sCategories.ToArray, .Labels = New XAxisLabels With {.Style = sFontFamily}, .Title = New XAxisTitle With {.Style = sFontFamily, .Text = "Month"}, .Type = AxisTypes.Datetime})
sCategories is a list(of string) containing the months

Get sales Orders between dates

How can I make a call to the Magento SOAP API v2 to get all of the sales orders between a set of dates in vb.net?
Here is what I have tried so far, but it returns 0 sales orders despite the fact that they are present.
Dim ae As associativeEntity = New associativeEntity()
ae.key = "status"
ae.value = "processing"
Dim params As filters = New filters
Dim dateFilter As complexFilter
dateFilter = New complexFilter()
dateFilter.key = "created_at"
Dim nestedFilterFrom As associativeMultiEntity = New associativeMultiEntity()
nestedFilterFrom.key = "gteq"
nestedFilterFrom.value = New String() {DateTime.Parse(fromDate).ToUniversalTime.ToString()}
dateFilter.value = nestedFilterFrom
Dim dateToFilter As complexFilter = New complexFilter()
Dim nestedFilterTo As associativeMultiEntity = New associativeMultiEntity()
nestedFilterTo.key = "lteq"
nestedFilterTo.value = New String() {DateTime.Parse(toDate).ToUniversalTime.ToString()}
dateToFilter.key = "created_at"
dateToFilter.value = nestedFilterTo
params.complex_filter = New complexFilter() {dateFilter, dateToFilter}
magentoWS.salesOrderList(sessionID, params)
I have been able to get the same code to work matching on status, like below.
Dim ae As associativeEntity = New associativeEntity
Dim params As filters = New filters()
ae.key = "status"
ae.value = "processing"
params.filter = New associativeEntity() {ae}
magentoWS.salesOrderList(sessionID, params)
The date format must be the following for the filters to work.
YYYY-MM-DD
I only discovered this, because that is how it was in Magento's SOAP "v2" XML Request example. It would have been nice to specify this in the documentation or in their response, but se la vie. In case anyone is interested, here is the code.
Dim ae As associativeEntity = New associativeEntity With { .key = "status", .value = "processing" }
Dim params As filters = New filters
Const createdAt As String = "created_at"
Const magentoDateTimeFormat As String = "yyyy-MM-dd"
Dim nestedFilterFrom As associativeMultiEntity =
New associativeMultiEntity With {.key = "from", .value = New String() {fromDate.ToString(magentoDateTimeFormat)}}
Dim dateFromFilter As complexFilter = New complexFilter With {.key = createdAt, .value = nestedFilterFrom}
Dim nestedFilterTo As associativeMultiEntity =
New associativeMultiEntity With {.key = "to", .value = New String() {toDate.ToString(magentoDateTimeFormat)}}
Dim dateToFilter As complexFilter = New complexFilter With {.key = createdAt, .value = nestedFilterFrom}
params.complex_filter = New complexFilter() {dateFromFilter, dateToFilter}
magentoWS.salesOrderList(sessionID, params)
It should be noted that in this case, the from and to filters are equivalent to the lteq and gteq. I found from and to to make more sense in this context but results are the same.
Public Function getMageOrdersListByFilter(ByVal fromDate As DateTime, ByVal toDate As DateTime) As MagentoService.salesOrderListEntity()
GetMageSessionId()
Dim f As MagentoService.filters = New MagentoService.filters
Const createdAt As String = "created_at"
Dim magentoDateTimeFormat As String = "yyyy-MM-dd"
magentoDateTimeFormat = "yyyy-MM-dd HH:mm:ss"
Dim cpf(2) As MagentoService.complexFilter
cpf(0) = New MagentoService.complexFilter With {.key = createdAt, .value = New MagentoService.associativeEntity With {.key = "from", .value = New String(fromDate.ToString(magentoDateTimeFormat))}}
'HACK FIX: http://www.magentocommerce.com/bug-tracking/issue?issue=8073
cpf(1) = New MagentoService.complexFilter With {.key = "/*fake*/created_at", .value = New MagentoService.associativeEntity With {.key = "to", .value = New String(toDate.ToString(magentoDateTimeFormat))}}
f.complex_filter = cpf
Dim oList() As MagentoService.salesOrderListEntity = Nothing
Try
oList = mage.salesOrderList(sessionId, f)
Catch ex As Exception
End Try
Return oList
End Function