Get sales Orders between dates - vb.net

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

Related

Linq from CSV source return empty record on VB.net

I have data extract from csv using vb.net as below code
Dim district As New List(Of tbDistrict)
Dim path As String = AppDomain.CurrentDomain.BaseDirectory & "tb_district.csv"
Dim results = (From line In File.ReadAllLines(path)
Let value = line.Split(";").
Select(Function(x) x)
Select New With {.district_id = value(0),
.district_code = value(1),
.amphur_id = value(2),
.district_name = value(3),
.province_id = value(4)}).ToList()
'Console.WriteLine(results.Count)
For Each item In results
district.Add(New tbDistrict With {
.district_id = item.district_id,
.district_code = item.district_code,
.district_name = item.district_name,
.amphur_id = item.amphur_id,
.province_id = item.province_id
})
Next
I have 2000 records add to list. Then I try to use linq to get some record by using below code
Dim provinceid As String = "1"
Dim amphurid As String = "1"
Dim mystring As String = "test"
Dim searchtabbol As List(Of tbDistrict) = district.Where(Function(x) _
(x.province_id = provinceid) AndAlso
(x.amphur_id = amphurid) AndAlso
(x.district_name.Contains(mystring.Trim()))).ToList()
Console.WriteLine(searchtabbol.Count)
But I get 0 record return although row exist. I'm not sure what's wrong in code?. Appreciated for all advise.

How to fill a DataGridViewComboBoxColumn?

Sorry if this is something that should be obvious, but this is my first project using VB.NET, and some things are still beyond me.
I'm trying to setup a combobox inside a DataGridView but I keep getting
System.ArgumentException: DatagridviewComboBoxCell value not valid
I've been googling this for 2 hours now and to me it seems I'm setting up thing correctly, but probably something is amiss.
Dim imageCol As DataGridViewImageColumn
Dim checkCol As DataGridViewCheckBoxColumn
Dim col As DataGridViewColumn
Dim comboCol As DataGridViewComboBoxColumn
Dim ds As DataSet
Dim som As New SomStructure
Dim somministrazioni() As SomStructure = {}
With dgvListaAttivita
.Columns.Clear()
.AutoGenerateColumns = False
.ReadOnly = False
.EditMode = DataGridViewEditMode.EditOnEnter
.CausesValidation = False
somministrazioni.Clear
ds = getSomministrazioni(codevalue, Today())
If ds IsNot Nothing Then
For Each row As DataRow In ds.Tables(0).Rows
som.idOspite = row(0)
som.nomeOspite = row(1)
som.descrizioneSomministrazione = row(2)
som.idOperatore = row(3)
som.nomeOperatore = row(4)
som.preparata = False
somministrazioni.Add(som)
Next
End If
.DataSource = somministrazioni
imageCol = New DataGridViewImageColumn
imageCol.Width = 25
imageCol.ImageLayout = DataGridViewImageCellLayout.Normal
imageCol.Description = "delete"
imageCol.Image = My.Resources.note
.Columns.Add(imageCol)
col = New DataGridViewColumn
col.DataPropertyName = "descrizioneSomministrazione"
col.HeaderText = "Somministrazione"
col.ValueType = GetType(String)
col.CellTemplate = New DataGridViewTextBoxCell
col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
col.ReadOnly = True
.Columns.Add(col)
comboCol = New DataGridViewComboBoxColumn
Dim dt As DataTable = dsOperatori.Tables(0)
comboCol.DataSource = dt
comboCol.DisplayMember = "display"
comboCol.ValueMember = "idoperatore"
comboCol.DataPropertyName = "idOperatore"
comboCol.HeaderText = "Operatore"
comboCol.ValueType = GetType(Integer)
comboCol.CellTemplate = New DataGridViewComboBoxCell
comboCol.Width = 150
.Columns.Add(comboCol)
checkCol = New DataGridViewCheckBoxColumn
checkCol.DataPropertyName = "preparata"
checkCol.HeaderText = "P."
checkCol.ValueType = GetType(Boolean)
checkCol.CellTemplate = New DataGridViewCheckBoxCell
checkCol.Width = 20
.Columns.Add(checkCol)
End With
As I understand it it should be like this:
comboCol.DataSource = dt
comboCol.DisplayMember = "display"
comboCol.ValueMember = "idoperatore"
specifies the datasource and key/display values of the comboboxes in the column
comboCol.DataPropertyName = "idOperatore"
Is the name of the column linked to both the DataSource of the DataGridView and the ValueMember of the ComboBox, and that should display different selections on different rows.
If I remove the DataPropertyName from the code I don't get the error anymore, but I also get empty comboboxes.
Try commenting out the template line:
comboCol = New DataGridViewComboBoxColumn
Dim dt As DataTable = dsOperatori.Tables(0)
comboCol.DataSource = dt
comboCol.DisplayMember = "display"
comboCol.ValueMember = "idoperatore"
comboCol.DataPropertyName = "idOperatore"
comboCol.HeaderText = "Operatore"
comboCol.ValueType = GetType(Integer)
'comboCol.CellTemplate = New DataGridViewComboBoxCell
comboCol.Width = 150
.Columns.Add(comboCol)

How do I set the value for an Invoice custom field using the QuickBooks V3 DataService?

I am attempting to create new invoices in QuickBooks using the V3 API. I have the invoice creation working perfectly, except I cannot set the values for the 3 custom fields.
I need a VB or C# resolution that utilizes the AnyIntuitObject property in this context.
Here is the code that I am attempting to implement:
Dim serviceContext As ServiceContext = getServiceContext(profile)
Dim invoiceDataService As New DataService(serviceContext)
Dim oInvoice As New Invoice()
oInvoice.DocNumber = "8675309"
oInvoice.TxnDate = DateTime.Today.Date
oInvoice.TxnDateSpecified = True
oInvoice.CustomerRef = New ReferenceType() With {.Value = "1885", .name = "QBT"}
Dim cField As New CustomField()
cField.DefinitionId = 1
cField.Name = "MyCustomFieldName"
cField.Type = CustomFieldTypeEnum.StringType
cField.AnyIntuitObject = New String() {"MyCustomFieldValue"}
oInvoice.CustomField = New CustomField() {cField}
Dim invLine As New Line()
invLine.Amount = 999.99D
invLine.AmountSpecified = True
invLine.DetailType = LineDetailTypeEnum.SalesItemLineDetail
invLine.DetailTypeSpecified = True
invLine.AnyIntuitObject = New SalesItemLineDetail With
{
.ItemElementName = ItemChoiceType.UnitPrice,
.AnyIntuitObject = 999.99D,
.Qty = 1D,
.ItemRef = New ReferenceType() With {.name = "Service", .Value = "529"}
}
oInvoice.Line = New Line() {invLine}
Dim invoiceAdded As Invoice = invoiceDataService.Add(Of Invoice)(oInvoice)
I have reviewed every thread I can find pertaining to custom fields and the API and still have not found a resolution.
Any help that can be provided would be greatly appreciated!
Resolved the issue by using the following:
Dim customFieldList As New List(Of CustomField)
Dim cField As New CustomField()
cField.DefinitionId = 2
cField.Name = "Week ending"
cField.Type = CustomFieldTypeEnum.StringType
cField.AnyIntuitObject = inv.WeekEnding.ToString("MM/dd/yyyy")
customFieldList.Add(cField)
oInvoice.CustomField = customFieldList.ToArray

Docusign webservice using vb.net - anchor tags Custom

Here is the problem I am having.
I have a document that I am creating using the DocuSign webservice.
I can create normal fields/tabs on it ie SignHere / SignDate / Initial fields.
However when i wan to use a custom field it just doesn't work. The code runs and the document is sent but all that is in the place of the EXPECTED custom field is just a bisc text box. It's like it's just ignoring the custom field settings.
I have attached the document i am using for reference and my code is below.
Everything works but the parts where the 2 customer fields should be I think is the issue.
Dim DocuSignSoap As New ServiceReference2.DSAPIServiceSoapClient
Dim DocuSignRecipient(0) As ServiceReference2.Recipient
Dim DocuSignRecipientType As ServiceReference2.RecipientTypeCode
Dim DocuSignTabType As ServiceReference2.TabTypeCode
Dim DocuSignCustomTabType As ServiceReference2.CustomTabType
Dim DocuSignEnvelope As New ServiceReference2.Envelope
Dim DocuSignDocument(0) As ServiceReference2.Document
Dim DocuSignTab(7) As ServiceReference2.Tab
Dim DocuSignEnvelopeStatus As ServiceReference2.EnvelopeStatus
Dim DocusignSig1 As New ServiceReference2.AnchorTab
Dim DocusignSig2 As New ServiceReference2.AnchorTab
Dim DocusignDateLOA As New ServiceReference2.AnchorTab
Dim DocusignDDDate As New ServiceReference2.AnchorTab
Dim DocusignFreq1 As New ServiceReference2.AnchorTab
Dim DocusignFreq2 As New ServiceReference2.AnchorTab
Dim DocusignFreq3 As New ServiceReference2.AnchorTab
Dim DocusignFreq4 As New ServiceReference2.AnchorTab
Dim strAuth As String
Dim strDocID As String
strDocID = Format(Now, "ddMMyyyyhhmmss")
Dim Mystream As New FileStream("c:\dantestdocusign.pdf", FileMode.Open)
Dim filesize As Long = Mystream.Length
Dim buffer(filesize) As Byte
Mystream.Read(buffer, 0, filesize)
Mystream.Close()
'Create Recipent
DocuSignRecipient(0) = New ServiceReference2.Recipient
DocuSignRecipient(0).Email = "daniel.rodgers#idebtplan.co.uk"
DocuSignRecipient(0).UserName = "Daniel Rodgers"
DocuSignRecipient(0).SignerName = "Daniel Rodgers"
DocuSignRecipient(0).Type = DocuSignRecipientType.Signer
DocuSignRecipient(0).ID = "1"
DocuSignRecipient(0).RoutingOrder = 1
'Create the envelope content
DocuSignEnvelope.Subject = "Your iDebtPlan Pack"
DocuSignEnvelope.EmailBlurb = "Email content"
DocuSignEnvelope.Recipients = DocuSignRecipient
DocuSignEnvelope.AccountId = "2f447fb0-243a-4a3f-acb5-adefbef43492"
'Create the document
DocuSignDocument(0) = New ServiceReference2.Document
DocuSignDocument(0).ID = strDocID
DocuSignDocument(0).Name = "DAN TESTING DOC"
DocuSignDocument(0).PDFBytes = buffer
' Attach the document(s)
DocuSignEnvelope.Documents = DocuSignDocument
' Create a new signature tab 1
DocuSignTab(0) = New ServiceReference2.Tab
DocuSignTab(0).DocumentID = DocuSignDocument(0).ID
DocuSignTab(0).RecipientID = "1"
DocuSignTab(0).Type = DocuSignTabType.SignHere
DocusignSig1.AnchorTabString = "\s1\"
DocuSignTab(0).AnchorTabItem = DocusignSig1
DocuSignTab(0).TabLabel = "Sig1"
' Create a new signature tab 2
DocuSignTab(1) = New ServiceReference2.Tab
DocuSignTab(1).DocumentID = DocuSignDocument(0).ID
DocuSignTab(1).RecipientID = "1"
DocuSignTab(1).Type = DocuSignTabType.SignHere
DocusignSig2.AnchorTabString = "\s2\"
DocuSignTab(1).AnchorTabItem = DocusignSig2
DocuSignTab(1).TabLabel = "Sig2"
' Create a DateLOA
DocuSignTab(2) = New ServiceReference2.Tab
DocuSignTab(2).DocumentID = DocuSignDocument(0).ID
DocuSignTab(2).RecipientID = "1"
DocuSignTab(2).Type = DocuSignTabType.DateSigned
DocusignDateLOA.AnchorTabString = "\loadate\"
DocuSignTab(2).AnchorTabItem = DocusignDateLOA
DocuSignTab(2).TabLabel = "DateLOA"
'CUSTOM FIELD 1
' Create a DD Date
DocuSignTab(3) = New ServiceReference2.Tab
DocuSignTab(3).DocumentID = DocuSignDocument(0).ID
DocuSignTab(3).RecipientID = "1"
DocuSignTab(3).Type = 11
DocuSignTab(3).CustomTabType = 4 'date
DocuSignTab(3).CustomTabWidth = 100
DocuSignTab(3).CustomTabDisableAutoSize = True
DocuSignTab(3).CustomTabRequired = True
DocuSignTab(3).CustomTabValidationPattern ="(^(?:(?:[12][0-9]|0?[1-9])/0?2|(?:30|[12][0-9]|0?[1-9])/(?:0?[469]|11)|(?:3[01]|[12][0-9]|0?[1-9])/(?:0?[13578]|1[02]))/\d{4}$)"
DocuSignTab(3).MaxLength = 10
DocuSignTab(3).CustomTabValidationMessage = "Your First Payment Date
Must be format dd/mm/yyyy (example: 01/03/2012), and a valid UK Date"
DocusignDDDate.AnchorTabString = "\dddate\"
DocuSignTab(3).AnchorTabItem = DocusignDDDate
DocuSignTab(3).TabLabel = "DDDate"
'CUSTOM FIELD 2
''Create Frequency Radio Buttons
DocuSignTab(4) = New ServiceReference2.Tab
DocuSignTab(4).DocumentID = DocuSignDocument(0).ID
DocuSignTab(4).RecipientID = "1"
DocuSignTab(4).Type = 11
DocuSignTab(4).CustomTabType = 2 'radio
DocuSignTab(4).CustomTabRequired = True
DocuSignTab(4).CustomTabWidth = 100
DocuSignTab(4).CustomTabDisableAutoSize = True
DocuSignTab(4).CustomTabRadioGroupName = "Frequency"
DocuSignTab(4).TabLabel = "Frequency"
DocuSignTab(4).Value = ""
DocusignFreq1.AnchorTabString = "\ow\"
DocuSignTab(4).AnchorTabItem = DocusignFreq1
DocuSignEnvelope.Tabs = DocuSignTab
strAuth = "<DocuSignCredentials<Usernameinfo#idebtplan.co.uk<mailto:info#idebtplan.co.uk</Username<Passwordjemima79</Password<IntegratorKeyIDEB-8ce296aa-0dff-4347-8ece-b62836a6a94e</IntegratorKey</DocuSignCredentials"
Dim x As New OperationContextScope(DocuSignSoap.InnerChannel)
Dim httpRequest As New System.ServiceModel.Channels.HttpRequestMessageProperty
httpRequest.Headers.Add("X-DocuSign-Authentication", strAuth)
OperationContext.Current.OutgoingMessageProperties(httpRequest.Name) = httpRequest
' Create the envelope on the account -- it will be a draft
DocuSignEnvelopeStatus = DocuSignSoap.CreateAndSendEnvelope(DocuSignEnvelope)
buffer = Nothing
Mystream = Nothing
httpRequest = Nothing
I would suggest the following:
Try adding your custom fields without the use of anchor tabs (i.e. use absolute positioning)
Compare how you are configuring your custom fields with the sample code from the SOAP SDK up on GitHub.
Create the envelope using the newer REST API from DocuSign.

Add a Parameter Value in SSRS

I have a report already setup on the ReportServer. And its subscription as well. What I'm trying to do is add the ParameterValue "CC" and some email addresses then send the email out. It doesn't seem to work.
My code:
Dim emailReader As SqlDataReader = selCount.ExecuteReader
Dim emailsTest As List(Of String) = New List(Of String)
emailsTest.Add("test1#pen.com")
emailsTest.Add("test2#pen.com")
emailsTest.Add("test3#pen.com")
emailsTest.Add("test4#pen.com")
If emailReader.HasRows() Then 'checks to see if there any quotes in query
For Each subscrp As rs.Subscription In subscr
Dim allValues = subscrp.DeliverySettings.ParameterValues
Dim allValuesList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = allValues.ToList()
Dim CCParameter As ReportTriggerTemplate1.rs.ParameterValue = New ReportTriggerTemplate1.rs.ParameterValue()
CCParameter.Name = "CC"
CCParameter.Value = String.Empty
allValuesList.Add(CCParameter)
Dim toValue = CType(allValuesList.Item(7), ReportTriggerTemplate1.rs.ParameterValue)
For Each testEmail As String In emailsTest
Dim ownerEmail As String = testEmail
If toValue.Value.Contains(ownerEmail) Then
'skip
ElseIf toValue.Value = String.Empty Then
toValue.Value += ownerEmail
Else
toValue.Value += "; " & ownerEmail
End If
Next
subscrp.DeliverySettings.ParameterValues = allValuesList.ToArray()
Dim hello As String = "hi"
tr.FireEvent(EventType, subscrp.SubscriptionID) 'forces subscription to be sent
Next
What I'm adding to toValue.Value doesn't seem to be adding to the report's CC subscription field at all. So what am I missing?
http://msdn.microsoft.com/en-us/library/ms154020%28v=SQL.100%29.aspx
http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.getsubscriptionproperties.aspx
http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.setsubscriptionproperties%28v=SQL.105%29.aspx
Try
tr = New rs.ReportingService2005
Dim extSettings As ExtensionSettings = Nothing
Dim desc As String = Nothing
Dim active As ActiveState = Nothing
Dim status As String = Nothing
Dim matchData As String = Nothing
Dim values As ParameterValue() = Nothing
Dim extensionParams As ParameterValueOrFieldReference() = Nothing
Dim mainLogin As System.Net.NetworkCredential = New System.Net.NetworkCredential("ADUser", "Password", "NetworkName")
If mainLogin Is Nothing Then
tr.Credentials = System.Net.CredentialCache.DefaultCredentials
Else
tr.Credentials = mainLogin
End If
'skip to relevant code
For Each subscrp As rs.Subscription In subscr
Dim allValues = subscrp.DeliverySettings.ParameterValues
Dim allValuesList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = allValues.ToList()
If CType(allValuesList.Item(0), ReportTriggerTemplate1.rs.ParameterValue).Value = "test#pen.com" Then
Dim subsID = subscrp.SubscriptionID
'important code just below
tr.GetSubscriptionProperties(subsID, extSettings, desc, active, status, EventType, matchData, extensionParams)
''''add change to CC here
Dim extSettingsList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = extSettings.ParameterValues.ToList()
If CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Name = "CC" Then
If CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value = String.Empty Then
CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value = emailsTest.Item(0) & ";" & emailsTest.Item(1)
Else
CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value += ";" & emailsTest.Item(0) & ";" & emailsTest.Item(1)
End If
Else
Dim CCParameter As ReportTriggerTemplate1.rs.ParameterValue = New ReportTriggerTemplate1.rs.ParameterValue()
CCParameter.Name = "CC"
CCParameter.Value = emailsTest.Item(0) & ";" & emailsTest.Item(1)
extSettingsList.Insert(1, CCParameter)
extSettings.ParameterValues = extSettingsList.ToArray
End If
'important code just below
tr.SetSubscriptionProperties(subsID, extSettings, desc, EventType, matchData, extensionParams)
tr.FireEvent(EventType, subscrp.SubscriptionID) 'forces subscription to be sent
Else
End If
Next