Please!
I'm getting tweets from LinqToTwitter, and some tweets seem to have the text truncated, with part of the text following with an ellipsis. In some cases, the search criteria are not returned in the text, as it appears to be in the unearned part of the message. That's right? Is there a way to get this missing part of the message? I have already looked at other posts, but I could not understand which parameter allows the full text to be obtained. I'm using linqToTwitter version 4.1.0.
Thank you
Dim twitterCtx As TwitterContext = New TwitterContext(twAuth)
Dim Response As Search = Await (From search In twitterCtx.Search()
Where search.Type = SearchType.Search _
AndAlso search.SearchLanguage = "pt" _
AndAlso search.Query = "Coronavirus").SingleOrDefaultAsync()
Dim tweets As List(Of Status) = Response.Statuses()
If Response IsNot Nothing AndAlso Response.Statuses IsNot Nothing Then
For Each str As Status In tweets
Console.WriteLine(str.StatusID.ToString() + " " + str.Text)
Next
End If
When Twitter extended tweets from 140 to 280 characters, they needed to add support in the API. This is called Extended Mode and you need to add a new filter to your LINQ query, like this:
Dim Response As Search = Await (From search In twitterCtx.Search()
Where search.Type = SearchType.Search _
AndAlso search.SearchLanguage = "pt" _
AndAlso search.TweetMode = TweetMode.Extended _
AndAlso search.Query = "Coronavirus").SingleOrDefaultAsync()
Notice the search.TweetMode property. I assigned the TweetMode.Extended enum to it, which means you now get the full 280 characters.
Having done that, you might view the Text property and be surprised to see Nothing. That's because now the tweet text is in the FullText property and you can read it like this:
Dim tweets As List(Of Status) = Response.Statuses()
If Response IsNot Nothing AndAlso Response.Statuses IsNot Nothing Then
For Each str As Status In tweets
Console.WriteLine(str.StatusID.ToString() + " " + str.FullText)
Next
End If
Related
How I can do to retrieve, from, to, subject, etc. from a message with this code ? Actually I can retrive list of message in a folder (label) but i want to retrieve fron, to, sender, etc. to display in a grid
Private Sub LoadMailGrid(ByVal FolderName As String)
Dim request As Google.Apis.Gmail.v1.UsersResource.MessagesResource.ListRequest = myGMailService.Users.Messages.List("xxxxxxx#gmail.com")
request.Q = "label: " + folderName
Dim messagesList As ListMessagesResponse = request.Execute()
Dim SubjectList As List(Of GMailMessageSummary) = New List(Of GMailMessageSummary)
Dim mail As GMailMessageSummary
For Each Message In messagesList.Messages
mail = New GMailMessageSummary
mail.MessageID = Message.Id
**mail.From = Message.**
mail.Subject = "Courriel " + x.ToString
mail.Received = Today
SubjectList.Add(mail)
Next
grdGMail.DataSource = SubjectList
grdGMail.DataBind()
End Sub
List message just returns the message Ids and thread ids, not the full content (since that could be an entire email which could be huge like 25MB). So if you want certain info on all of them then call messages.get() in the loop. If you only want headers like To, From, Subject then you can call messages.get(format=METADATA), or however it looks in the language you're using.
https://developers.google.com/gmail/api/v1/reference/users/messages/get
I'm building insert statements based on a list of data and a tab name. I have 4 tabs, the last 2 get data inserted successfully, the first 2 do not.
I commented out inserting into all tabs but one. The size of the excel file increases, but the rows are still blank. Any ideas?
Edit: For some reason, the Excel file I was using as a "blank template" had "empty" values in rows of the first 2 sheets. First one had "empty values" in the first 100K rows, seconds had empty values in the first 700-some rows. The data was being inserted after these rows, which explains why the file size was increasing. Now I'm getting "Operation must use an updateable query" when trying to insert.
Public Sub BuildReport(Of T)(tabName As String, dataList As IEnumerable(Of T))
'// Setup the connectionstring for Excel 2007+ XML format
'// http://www.connectionstrings.com/ace-oledb-12-0/
If ((tabName.EndsWith("$") = True AndAlso m_TabList.Contains(tabName) = False) OrElse m_TabList.Contains(tabName & "$") = False) Then
Throw New Exception(String.Format("The specified tab does not exist in the Excel spreadsheet: {0}", tabName))
End If
Using excelConn As New OleDbConnection(m_ConnectionString)
excelConn.Open()
Dim insertStatementList As IEnumerable(Of String) = BuildInsertStatement(Of T)(tabName, dataList)
Using excelCommand As New OleDbCommand()
excelCommand.CommandType = CommandType.Text
excelCommand.Connection = excelConn
For Each insertStatement In insertStatementList
excelCommand.CommandText = insertStatement
excelCommand.ExecuteNonQuery()
Next
End Using
End Using
End Sub
Private Function BuildInsertStatement(Of T)(tabName As String, dataList As IEnumerable(Of T)) As IEnumerable(Of String)
Dim insertStatementList As New List(Of String)
Dim insertStatement As New StringBuilder()
For Each dataItem As T In dataList
Dim props As PropertyInfo() = GetType(T).GetProperties()
insertStatement.Clear()
insertStatement.AppendFormat("INSERT INTO [{0}$] ", tabName)
Dim nameValueDictionary As New Dictionary(Of String, String)
For Each prop As PropertyInfo In props
Dim excelColumn As ExcelColumnAttribute = CType(prop.GetCustomAttributes(GetType(ExcelColumnAttribute), False).FirstOrDefault(), ExcelColumnAttribute)
If (excelColumn IsNot Nothing) Then
Dim value As Object = prop.GetValue(dataItem, Nothing)
If (value IsNot Nothing AndAlso value.GetType() <> GetType(Integer) _
AndAlso value.GetType() <> GetType(Double) _
AndAlso value.GetType() <> GetType(Decimal) _
AndAlso value.GetType() <> GetType(Boolean)) Then
value = String.Format("""{0}""", value)
ElseIf (value Is Nothing) Then
value = "NULL"
End If
nameValueDictionary.Add(excelColumn.ColumnName, value)
End If
Next
Dim columList As String = String.Join(",", nameValueDictionary.Keys)
Dim valueList As String = String.Join(",", nameValueDictionary.Select(Function(x) x.Value))
insertStatement.AppendFormat("({0}) ", columList)
insertStatement.AppendFormat("VALUES ({0})", valueList)
insertStatementList.Add(insertStatement.ToString())
Next
Return insertStatementList
End Function
For some reason, the Excel file I was using as a "blank template" had "empty" values in rows of the first 2 sheets. First one had "empty values" in the first 100K rows, second one had empty values in the first 700-some rows. The data was being inserted after these rows, which explains why the file size was increasing. Now I'm getting "Operation must use an updateable query" when trying to insert.
I found the answer to the second problem here: Operation must use an updateable query when updating excel sheet
Just needed to remove the "IMEX=1" from the extended properties of the connection string which I added in trying to troubleshoot the issue.
Is it possible to add a menu item to Quickbooks using the QBSDK?
I have found a couple of old examples that I can't make work.
I have created a custom application for my company and am trying to simplify it by making a menu item in Quickbooks.
Any help would be greatly appreciated.
Here is what I have tried so far, but I get an error message at the subAdd.SubscriberID.SetValue(Me.appGUID.ToString).
The error is: * Invalid GUID format. Must use zero for Custom Fields, or a GUID generated with GuidGen.exe for private data extensions.*
{
Dim subRq As ISubscriptionMsgSetRequest
subRq = MySessionManager.CreateSubscriptionMsgSetRequest(4, 0)
' Add a UIExtension subscription to our request
Dim subAdd As IUIExtensionSubscriptionAdd
subAdd = subRq.AppendUIExtensionSubscriptionAddRq
'
' set up the subscription request with the required information, we're adding to
' the file menu in this case, and just for fun, we're making it a cascading menu
subAdd.SubscriberID.SetValue(Me.appGUID.ToString) "<-----error happens here
subAdd.COMCallbackInfo.AppName.SetValue(Me.appName)
subAdd.COMCallbackInfo.ORProgCLSID.ProgID.SetValue("MenuEventContext.QBMenuListener")
subAdd.MenuExtensionSubscription.AddToMenu.SetValue("atmFile")
'
' For the cascade fun, we're just going to add items to the cascade menu...
Dim subMenu As IMenuItem
For i = 1 To 5
subMenu = subAdd.MenuExtensionSubscription.ORMenuSubmenu.Submenu.MenuItemList.Append
'
' this is the text that the user will see in QuickBooks:
subMenu.MenuText.SetValue("Sub Item " & i)
'
' this is the tag we'll get in our event handler to know which menu item was
' selected:
subMenu.EventTag.SetValue("SubMenu" & i)
Next i
'
' Send the request and get the response, since we're sending only one request there
' will be only one response in the response list
Dim subRs As ISubscriptionMsgSetResponse
subRs = MySessionManager.DoSubscriptionRequests(subRq)
Dim resp As IResponse
'
' Check the response and display an appropriate message to the user.
resp = subRs.ResponseList.GetAt(0)
If (resp.StatusCode = 0) Then
MsgBox("Successfully added to QuickBooks File menu, restart QuickBooks to see results")
Else
MsgBox("Could not add to QuickBooks menu: " & resp.StatusMessage)
End If
MySessionManager.CloseConnection()
MySessionManager = Nothing
Exit Sub
handleError:
MsgBox("Encountered error subscribing: " & Err.Description)
If Not MySessionManager Is Nothing Then
MySessionManager.CloseConnection()
End If
End Sub
The answer is yes.
The only purpose of UIExtensionSubscription is to add menu items to the top menus. Clicking the menus will then start your app, if it isn't already running, and pass it information about the current focused Quickbooks window.
Your application must be com accessible and registered.
As for your sample make sure you are passing { } around your GUID. I don't use function call unsure if you might need to cast to a string first or not.
There is a sample console app in C# in the current QBPOSSDK download from Intuit. I would thoroughly read the programmers guide and look at that sample.
One of my working requests, pretty close to the intuit sample:
Private Shared Function GetUIExtensionSubscriptionAddXML(ByVal strMenuName As String, ByVal strMainMenuName As String) As String
'strMainMenuName would be "Company" for example
'Create the qbXML request
Dim requestXMLDoc As New XmlDocument()
requestXMLDoc.AppendChild(requestXMLDoc.CreateXmlDeclaration("1.0", Nothing, Nothing))
requestXMLDoc.AppendChild(requestXMLDoc.CreateProcessingInstruction("qbxml", "version=""5.0"""))
Dim qbXML As XmlElement = requestXMLDoc.CreateElement("QBXML")
requestXMLDoc.AppendChild(qbXML)
'subscription Message request
Dim qbXMLMsgsRq As XmlElement = requestXMLDoc.CreateElement("QBXMLSubscriptionMsgsRq")
qbXML.AppendChild(qbXMLMsgsRq)
'UI Extension Subscription ADD request
Dim uiExtSubscriptionAddRq As XmlElement = requestXMLDoc.CreateElement("UIExtensionSubscriptionAddRq")
qbXMLMsgsRq.AppendChild(uiExtSubscriptionAddRq)
'UI Extension Subscription ADD
Dim uiExtEventSubscriptionAdd As XmlElement = requestXMLDoc.CreateElement("UIExtensionSubscriptionAdd")
uiExtSubscriptionAddRq.AppendChild(uiExtEventSubscriptionAdd)
'Add Subscription ID
uiExtEventSubscriptionAdd.AppendChild(requestXMLDoc.CreateElement("SubscriberID")).InnerText = MySubscriberGUID
'Add COM CallbackInfo
Dim comCallbackInfo As XmlElement = requestXMLDoc.CreateElement("COMCallbackInfo")
uiExtEventSubscriptionAdd.AppendChild(comCallbackInfo)
'Appname and CLSID
comCallbackInfo.AppendChild(requestXMLDoc.CreateElement("AppName")).InnerText = App_Name
comCallbackInfo.AppendChild(requestXMLDoc.CreateElement("CLSID")).InnerText = MyCLSID
' MenuEventSubscription
Dim menuExtensionSubscription As XmlElement = requestXMLDoc.CreateElement("MenuExtensionSubscription")
uiExtEventSubscriptionAdd.AppendChild(menuExtensionSubscription)
'Add To menu
menuExtensionSubscription.AppendChild(requestXMLDoc.CreateElement("AddToMenu")).InnerText = strMainMenuName
Dim menuItem As XmlElement = requestXMLDoc.CreateElement("MenuItem")
menuExtensionSubscription.AppendChild(menuItem)
'Add Menu Name
menuItem.AppendChild(requestXMLDoc.CreateElement("MenuText")).InnerText = strMenuName
menuItem.AppendChild(requestXMLDoc.CreateElement("EventTag")).InnerText = "menu_" & strMenuName.Replace(" ", "_")
Dim displayCondition As XmlElement = requestXMLDoc.CreateElement("DisplayCondition")
menuItem.AppendChild(displayCondition)
displayCondition.AppendChild(requestXMLDoc.CreateElement("VisibleIf")).InnerText = "InventoryEnabled"
displayCondition.AppendChild(requestXMLDoc.CreateElement("EnabledIf")).InnerText = "InventoryEnabled"
Dim strRetString As String = requestXMLDoc.OuterXml
WriteLocalLog("GetUIExtensionSubscriptionAddXML: " & strRetString)
Return strRetString
End Function
I'm trying to concatenate two fields in LINQ so that I can then filter with a keyword. I found a question posted here that I thought was my answer, but I'm getting 0 records back for some reason. This is supposed to return a JSON result for an autocomplete textbox (it works when I don't concatenate fields).
Here's my code:
Function CostCodeList(ByVal term As String) As ActionResult
Dim results = From c In db.ORG_CHART_V
Let Fullname = CStr(c.COSTCTR_CD & " - " & c.BREADCRUMB)
Where Fullname.ToUpper.Contains(CStr(term).ToUpper)
Order By Fullname
Select New With {.label = Fullname, .id = c.ORG_NODE_ID}
Return Json(results.ToArray, JsonRequestBehavior.AllowGet)
End Function
I'm also getting this error on the Return:
Public member 'ToArray' on type 'DbQuery(Of VB$AnonymousType_3(Of
String,Integer))' not found.
Before trying to concatenate the two fields I was searching on them separately, successfully. But when I concatenate them, it seems like everything I try either gets me an error and/or zero records.
Here is a different function that does work:
Function RoleList(ByVal term As String) As ActionResult
Dim list As New ArrayList
Dim results As IQueryable(Of JOB_ROLE)
If IsNumeric(term) Then
results = From c In db.JOB_ROLE
Where CStr(c.JBROLE_NO).StartsWith(term)
Else
results = From c In db.JOB_ROLE
Where c.JOB_ROLE_NAME.ToUpper.Contains(CStr(term).ToUpper)
End If
results = results.OrderBy(Function(e) e.JOB_ROLE_NAME)
For Each item In results
list.Add(New With {.label = item.JOB_ROLE_NAME, .id = item.JOB_ROLE_ID})
Next
Return Json(list.ToArray, JsonRequestBehavior.AllowGet)
End Function
Here is the new function that works as intended:
Function CostCodeList(ByVal term As String) As ActionResult
Dim list As New ArrayList
Dim results = db.ORG_CHART_V.Where(Function(e) (CStr(e.COSTCTR_CD) + " - " + e.BREADCRUMB).Contains(CStr(term).ToUpper)).OrderBy(Function(o) o.COSTCTR_CD)
For Each item In results
list.Add(New With {.label = item.COSTCTR_CD & " - " & item.BREADCRUMB, .id = item.ORG_NODE_ID})
Next
Return Json(list.ToArray, JsonRequestBehavior.AllowGet)
End Function
i'm trying to set a cookie to store a selected department in. The cookie is set with a small form which has a select-dropdown with departments. This is posted using AJAX.
This is how I store the cookie:
<AcceptVerbs(HttpVerbs.Post)> _
Function ChangeDepartment(ByVal FormValues As FormCollection) As ActionResult
If Response.Cookies("department") IsNot Nothing Then
Response.Cookies("department").Value = FormValues("department")
Else
Dim c As New HttpCookie("department")
c.Value = FormValues("department")
c.Expires = Now.AddDays(7)
Response.Cookies.Add(c)
End If
Return Json(New With {.newDepartment = Response.Cookies("department").Value})
End Function
The .newDepartment variable is returned correctly with the correct value.
This is how I retrieve the cookie and build the select-dropdown:
<% Ajax.BeginRouteForm("ChangeDepartment", New AjaxOptions With {.LoadingElementId = "loading", .HttpMethod = "post", .OnSuccess = "function(request) {ajaxMessage('Department change', 'Department changed to: ' + request.get_response().get_object().newDepartment);}"})%>
<select name="department">
<option>Default</option>
<option<%If Request.Cookies("department") Isnot Nothing andAlso Request.Cookies("department").Value = "Supervisor" Then Response.Write (" selected=""selected""") %>>Supervisor</option>
<option<%If Request.Cookies("department") Isnot Nothing andAlso Request.Cookies("department").Value = "Purchasing" Then Response.Write (" selected=""selected""") %>>Purchasing</option>
<option<%If Request.Cookies("department") Isnot Nothing andAlso Request.Cookies("department").Value = "Engineering" Then Response.Write (" selected=""selected""") %>>Engineering</option>
</select>
<input type="submit" value="Change department" />
<% Html.EndForm%>
The cookie isn't stored, because the select-dropdown keeps going back to Default. Am I doing something wrong?
You could try to use http debugger like Fiddler for IE and HttpFox for FireFox.
Check if the cookie is really send with the server response and if the browser sends it back with further requests.
From there you are probably going to track the problem and see what is going wrong. If you still have problems you could post the http traffic here.