I am not able to store data in server side cache for one day - caching

I have around 10 lines of converted text. I want to store that text to a cache for a day. I am using Microsoft translator to convert the text so I don't want to call the Microsoft service for the same text again and again.
my code:
string key = "cachekey"
textConverted = "i am using ";
HttpContext.Current.Cache.Insert(key, textConverted, null, DateTime.Now.AddDays(1), Cache.NoSlidingExpiration);

Related

How to extract the values from a string from slack ruby bot

I am trying to create a slackbot which can save incoming data to a database.
I have used the gem slack-ruby-bot and I'm able to receive my text, but I want to extract specific parts of the text, to save in a database.
Given the following received text:
I worked on 'stackoverflow' for 10 hours.
I must be able to extract the project name, stackoverflow, and the hour, which is 10. Is there someway to do it?
command 'activity', '/^Activity/' do |client, data, match|
client.say(text: "#{data.text}", channel: data.channel)
end
This is just a sample code which gets the command activity.
Wherever you receive the string, you might use the regular expression and String#scan to get the data.
"I worked on 'stackoverflow' for 10 hours.".scan /'[^']+'|\d+/
#⇒ ["'stackoverflow'", "10"]

How to format a value to text in BI publisher

I am trying to create a report in BI. I have created a data model using a sql script and the data type is string. I then created a report using this data model and the sample data is showing as 06185 as shown below.
But when i run the report the output is showing as 6185.0 with decimal places.
I have tried to change the format by double clicking the value. But I cant choose any format except none in the report designer. What I need is the values to be displayed same as the sample data.
06185 is not a number - it's a string. As a number you will never have leading 0s. 6185 is a number.
So first of all you need to find out what your data is really supposed to be. "06185" = string. 6185 = integer. 6185.0 = double.
To be quick simply add ' character next to the number character... Else excel will make your life difficult specially if you have bank account numbers...
SELECT payees.supplier_site_id csupplier_site_id,
payees.org_id c_org_id,
payees.payee_party_id ,
cbbv.bank_name,
max(''''||to_char(ieb.bank_account_num)) as bank_account_num
FROM apps.iby_pmt_instr_uses_all instrument,
apps.iby_account_owners owners,
apps.iby_external_payees_all payees,
apps.iby_ext_bank_accounts ieb,
apps.ap_supplier_sites_all asa,
apps.ap_suppliers asp,
apps.ce_bank_branches_v cbbv
WHERE owners.primary_flag = 'Y'
AND owners.ext_bank_account_id = ieb.ext_bank_account_id
AND owners.ext_bank_account_id = instrument.instrument_id
AND payees.ext_payee_id = instrument.ext_pmt_party_id
AND payees.payee_party_id = owners.account_owner_party_id
AND payees.supplier_site_id = asa.vendor_site_id
AND asa.vendor_id = asp.vendor_id
and bank_party_id(+) = ieb.bank_id
--AND cbbv.branch_party_id(+) = ieb.branch_id
AND (
(INSTRUMENT.END_DATE IS NULL)
OR
( INSTRUMENT.END_DATE >= TO_DATE(SYSDATE) )
)
AND (
(IEB.END_DATE IS NULL)
OR
(IEB.END_DATE >= TO_DATE(SYSDATE))
)
group by payees.supplier_site_id ,
payees.org_id ,
payees.payee_party_id ,
cbbv.bank_name
You may have to edit this with the desktop Microsoft Word add-in. There's limited capabilities with the Oracle BI Publisher Stand-alone running on the server.
You have 100% control if you're editing the template in Word. Unfortunately, there's limited export capability to export your existing template. Oracle BI publisher stand-alone will export an XML file, which to my knowledge is not visually editable in Word. There is an ability to import an RTF file which you created in Word, though. So Install the BI Publisher desktop/Word add-in. Make a new file, save as .rtf format, use the tool to import an example XML file, add a table, and continue editing as you need to. If you need help with this, there's plenty of documentation out there to get you started. Also, there's a Template Viewer application that's also installed that will let you process the XML sample/data file and rtf file into Excel, PDF, or whichever you prefer.

Range values extraction in Kendo spreadsheet changes dates to integers

I am using a Kendo spreadsheet to import data from an Excel file so I can plug it into an SQL Server database using Ajax callbacks. The Ajax callbacks work fine, but I have determined that any Date strings are being converted to an integer offset from a base date of 12/30/1899. I have submitted a support ticket to Telerik, but they do not seem to understand the problem.
The data is displayed in the Kendo spreadsheet appropriately as a date. Kendo converts a date input as "12/1/2015" to "12-1-2015".
I am using the latest version of the ASP.NET MVC 5 wrapper, but the JavaScript code is the 2016-1-226-545 version of the JavaScript. The wrapper version seems to be irrelevant, but later versions of the JavaScript have the gulpfile.js, and this conflicts with the Bundleconfig interface on my ASP.NET MVC 5 project, so I simply work with the last version of the JavaScript that works for my setup.
The spreadsheet I am working with is pretty basic to start:
#(
Html.Kendo().Spreadsheet()
.Name("SiteSlotDataSS")
.Rows(10)
.Columns(4).ColumnWidth(100)
.Sheets(sheets =>
{
sheets.Add()
.Name("Study Data");
}
)
)
I use the import option to pull in an Excel spreadsheet and use a simple button with a click event routine to copy the data to a string array to send to the Ajax callback. I have confirmed that the data being sent to the server controller is the same as it is on the client side before being sent. The Date conversion to an integer occurs when the values are extracted from the range.
The code in question that selects the values is:
values = sheet.range("A" + headerRows.toString() + ":" + endRange + (headerRows + rows).toString()).values();
This produces the correct translation of every other column except for columns containing dates.
I tried the following to brute-force the issue, without success:
for (var x = 0; x <= rows; x++) {
sheet.range("K" + (headerRows + x).toString()).format(kendo.spreadsheet.formatting.date);
}
I could try a date function to convert the date back into the original value, but everyone pretty much knows how Telerik's documentation is a bit skimpy and overall simply a nightmare to find answers to questions with.
What is the solution?
It appears that Kendo Spreadsheet stores the date values as an integer offset from 12/30/1899 in days. I determined the "0" value by entering a date of 1/1/1901 to see what came back, then 1/1/1900. The result of the latter was "2", making the base date 12/30/1899. Taking the data and converting it at the server seems to be the best option. I don't really expect much of a response from Telerik.
I have addressed the storage issue with Telerik, and they have acknowledged there is a bug in the spreadsheet widget.
For now, the solution is to bring the values array one row at a time back to the server and do the data conversion server-side. The integer that is returned in the values array for dates is the way the Kendo Spreadsheet stores the information client-side. Formatting the column simply will not do anything but change the client-side display. It will not change how Kendo returns the values matrix from the spreadsheet range selected.
Firstly, I think you mean 12/31/1899. It makes no sense to refer anything to 12/30/1899.
Excel dates start with 1/1/1900, just as do your Kendo (Japanese: "the way of the sword") dates. If you're getting an integer, forcibly coerce it to the corresponding date on the receiving by merely FORMATTING THE COLUMN. There is no need for a specific function to "convert" days-since-1900 counts to text dates (MM/DD/YYYY), as they are the SAME, differing only in human-readable representation.
Of course, it wasn't clear from your description whether Excel was on the input side or the output side of the problem.

Character length in single line edit filter PowerBuilder

My SQL code gives me over 10 000 rows, each containing client id, name, address and so forth. In my PowerBuilder 10.5 window I've set my DataWindow in which I'm retrieving my SQL code using id as retrieve argument. I have a Single line Edit (sle_id) in which the user can write an id and search by it. What I've figured out is that all of my clients have id's length of 8 characters and starting with either "46XXXXXXXX" or "7052XXXX". So to optimize my retrieve time I want to write a code in the clicked event of my "Start" button that is located in PowerBuilder window that would first check if the id starts with one of does two options: "46..." or "7052...". I assume I'd need to use length of the characters? For example, this is what I'd want...
IF sle_id.text STARTS with 46 or 7052 THEN retrieve
ELSE MessageBox ("INFO", "Your id must have begin with either 32 or 7052")
END IF;
Of course, I need something better then "Starts with". Much oblige for all the help!
there are some string functions in powerbuilder. I think you need this:
If( left(sle_id.text, 2) = "46" or left(sle_id.text, 4) = "7052" ) then
Best Regards
Gábor
I think you're trying to solve the wrong problem. Your database should have an index on client id. If the client id is unique use a unique index.

Visual Basic 6 Command included on String Table

Here is the situation, I have this string table, in a .res file and I have some strings loaded into one of the forms, say Form1. On a form on I want to popup a message box with a message loaded from the string table using LoadResString(1234).
Is it possible that when Resource ID 1234 contains "This is testing vbNewline This is a new line!." that string will be loaded using the said function onto the message box (popup box)?
I've tested it: It will also print out the "vbNewline" command and NOT parse it. Is there any other way to parse the said string making this kind of message ?
This is testing
This is new line!.
I wanted that kind of message to appear.
You are trying to put a VB constant in a String expression so it is treating it like text, you can try using the Replace Function ( I realize this is a .Net link but the signature is the same as the VB6 method) to remove your string and substitute the correct value something like this should work:
MsgBox (Replace(LoadResString(1234), "vbNewLine", vbNewLine))
or create a function like this:
Public Function ParseNewLine(value As String) As String
ParseNewLine = Replace(value, "vbNewLine", vbNewLine)
End Function
and call it like this:
MsgBox (ParseNewLine(LoadResString(1234)))
Why don't you embed the newline sequence into the RES file. If you are using the Resource Add-In, you can press Ctrl+Enter to insert these characters.
In visual Studio's resource editor and a raw resource script, you can use \n.

Resources