ASP.NET MVC: Download stream without freezing
We use ASP.NET MVC 4 (Presentation), WCF (Logic), Azure Blob Storage
(Storage).
Is it possible to implement stream-downloading (pass through) without
freezing navigation on web-site?
We exactly need "passing through" because custom headers are required
(Content-Disposition etc). It means that FilePathResult and direct link to
Azure are not possible.
Downloading is implemented by this way now:
[HttpGet]
public ActionResult DownloadTemplate(Guid templateId)
{
Response.Clear(); Response.BufferOutput = false;
DownloadResult result = Client.DownloadTemplate(templateId)
Response.AddHeader("Content-Type",
MimeHelper.GetMimeType(result.FileName));
Response.AddHeader("Content-Disposition", "attachment; filename=" +
result.FileName);
byte[] buffer = new byte[4096]; int readed = 0;
while ((readed = result.ContentStream.Read(buffer, 0, buffer.Length))
> 0)
{
if (Response.IsClientConnected)
{
Response.OutputStream.Write(buffer, 0, readed);
Response.Flush();
}
}
return new EmptyResult();
}
Monday, 9 September 2013
Why there are many file shredding methods if one is enough?
Why there are many file shredding methods if one is enough?
If shred software converts all digits of the wiped data to zeros at the
fist step, what does the second step do then? I see that some methods of
shredding rewrites the bits for 7 times! I can't understand how someone
would retrieve a file that all its bits are set to zero (on the fist
time); why this is not secure enough and the operation should be done
several times to insure data are wiped completely?!
Hope I made myself clear : | Thanks in advance to all participants : )
If shred software converts all digits of the wiped data to zeros at the
fist step, what does the second step do then? I see that some methods of
shredding rewrites the bits for 7 times! I can't understand how someone
would retrieve a file that all its bits are set to zero (on the fist
time); why this is not secure enough and the operation should be done
several times to insure data are wiped completely?!
Hope I made myself clear : | Thanks in advance to all participants : )
Android: how to exit the app when user navigate off the app
Android: how to exit the app when user navigate off the app
I just want to exit the app completely when user press home, or switch to
other app. Is there any event I can listen so that I can do the exit code?
I just want to exit the app completely when user press home, or switch to
other app. Is there any event I can listen so that I can do the exit code?
Sunday, 8 September 2013
SQL Create View and using it in Function
SQL Create View and using it in Function
I have the following function and I need to take out the SELECT part and
create a separate view.
CREATE FUNCTION dbo.dbf_get_penalty_points
( @pn_seq_party_id NUMERIC(18),
@pv_penalty_points_code CHAR(1) = 'Y') -- Use 'N' for total
points, otherwise will return Current Penalty Points
RETURNS NUMERIC(18,0)
AS
BEGIN
DECLARE @n_penalty_points NUMERIC(18),
@d_latest_points_date DATETIME
SELECT @d_latest_points_date = dbo.dbf_trunc_date(DateAdd(mm, -
Abs(Convert(NUMERIC(18,0),dbo.dbf_get_sys_param('CMS2', 'PP_MONTHS'))),
GetDate()))
SELECT @n_penalty_points = IsNull(Sum(penalty_points_amount),0)
FROM dbo.ar_penalty_point WITH(NOLOCK)
WHERE seq_party_id = @pn_seq_party_id
AND 1 = CASE
WHEN @pv_penalty_points_code = 'N' THEN 1
WHEN @pv_penalty_points_code = 'Y' AND added_date >=
@d_latest_points_date AND reset_date IS NULL THEN 1
ELSE 0
END
RETURN @n_penalty_points
END
GO
SET QUOTED_IDENTIFIER OFF
GO
GRANT EXECUTE ON dbo.dbf_get_penalty_points TO standard
GO
I have tried and got this,
SELECT SUM(CASE WHEN added_date >=dbo.dbf_trunc_date(DateAdd(mm, -
Abs(Convert(NUMERIC(18,0),dbo.dbf_get_sys_param('CMS2', 'PP_MONTHS'))),
GetDate()))
AND reset_date IS NULL THEN 1
ELSE 0) current_points,
IsNull(Sum(penalty_points_amount),0) total_points,
seq_party_id
FROM dbo.ar_penalty_point WITH(NOLOCK)
GROUP BY seq_party_id
Now I need to get rid of
dbo.dbf_trunc_date(DateAdd(mm, -
Abs(Convert(NUMERIC(18,0),dbo.dbf_get_sys_param('CMS2', 'PP_MONTHS'))),
GetDate()))
From the SELECT part of the query. I am struck is there a better way to
write my view ?
I have the following function and I need to take out the SELECT part and
create a separate view.
CREATE FUNCTION dbo.dbf_get_penalty_points
( @pn_seq_party_id NUMERIC(18),
@pv_penalty_points_code CHAR(1) = 'Y') -- Use 'N' for total
points, otherwise will return Current Penalty Points
RETURNS NUMERIC(18,0)
AS
BEGIN
DECLARE @n_penalty_points NUMERIC(18),
@d_latest_points_date DATETIME
SELECT @d_latest_points_date = dbo.dbf_trunc_date(DateAdd(mm, -
Abs(Convert(NUMERIC(18,0),dbo.dbf_get_sys_param('CMS2', 'PP_MONTHS'))),
GetDate()))
SELECT @n_penalty_points = IsNull(Sum(penalty_points_amount),0)
FROM dbo.ar_penalty_point WITH(NOLOCK)
WHERE seq_party_id = @pn_seq_party_id
AND 1 = CASE
WHEN @pv_penalty_points_code = 'N' THEN 1
WHEN @pv_penalty_points_code = 'Y' AND added_date >=
@d_latest_points_date AND reset_date IS NULL THEN 1
ELSE 0
END
RETURN @n_penalty_points
END
GO
SET QUOTED_IDENTIFIER OFF
GO
GRANT EXECUTE ON dbo.dbf_get_penalty_points TO standard
GO
I have tried and got this,
SELECT SUM(CASE WHEN added_date >=dbo.dbf_trunc_date(DateAdd(mm, -
Abs(Convert(NUMERIC(18,0),dbo.dbf_get_sys_param('CMS2', 'PP_MONTHS'))),
GetDate()))
AND reset_date IS NULL THEN 1
ELSE 0) current_points,
IsNull(Sum(penalty_points_amount),0) total_points,
seq_party_id
FROM dbo.ar_penalty_point WITH(NOLOCK)
GROUP BY seq_party_id
Now I need to get rid of
dbo.dbf_trunc_date(DateAdd(mm, -
Abs(Convert(NUMERIC(18,0),dbo.dbf_get_sys_param('CMS2', 'PP_MONTHS'))),
GetDate()))
From the SELECT part of the query. I am struck is there a better way to
write my view ?
I am trying to remove characters in a string from a defined string. the error comes here: if(s.charAt(x) == punct.charAt(y))
I am trying to remove characters in a string from a defined string. the
error comes here: if(s.charAt(x) == punct.charAt(y))
String dirtyStr = "Who. do yo$u th,ink you are?!";
System.out.println(scrub(dirtyStr));
static String punct = ".,?!:;\"(){}{}<>";
public static String scrub(String s)
{
for(int x = 0; x < s.length(); x++)
{
for(int y = 0; y < punct.length(); y++)
{
if(s.charAt(x) == punct.charAt(y))
{
s = s.replace("" + s.charAt(x), "");
}
}
}
return s;
}
Stack trace
Exception in thread "main" java.lang.StringIndexOutOfBoundsException:
String index out of range: 28
at java.lang.String.charAt(String.java:658)
at StringMethods_7_Gupta.scrub(StringMethods_7_Gupta.java:120)
at StringMethods_7_Gupta.main(StringMethods_7_Gupta.java:95)
error comes here: if(s.charAt(x) == punct.charAt(y))
String dirtyStr = "Who. do yo$u th,ink you are?!";
System.out.println(scrub(dirtyStr));
static String punct = ".,?!:;\"(){}{}<>";
public static String scrub(String s)
{
for(int x = 0; x < s.length(); x++)
{
for(int y = 0; y < punct.length(); y++)
{
if(s.charAt(x) == punct.charAt(y))
{
s = s.replace("" + s.charAt(x), "");
}
}
}
return s;
}
Stack trace
Exception in thread "main" java.lang.StringIndexOutOfBoundsException:
String index out of range: 28
at java.lang.String.charAt(String.java:658)
at StringMethods_7_Gupta.scrub(StringMethods_7_Gupta.java:120)
at StringMethods_7_Gupta.main(StringMethods_7_Gupta.java:95)
can not access JSON object using dot notation
can not access JSON object using dot notation
node v0.10.18 webstorm 6.0.1
I am trying to get the temperature from weather underground. I get the
object using their API and i'm trying to access the actual temperature
using:
<pre>
<code>
request(url+state+"/"+city+format, function (error, response, body) {
if (!error && response.statusCode == 200) {
var objBody = JSON.parse(body);
return objBody.current_observation.temp_f;
}
else if (error) {
console.log('error: ' + err);
}
});
</code>
</pre>
I am getting an error of "unresolved variable" for
objBody.current_observation.temp_f
I also tried using body.current_observation.temp_f directly and get the
same error. I also tried to stringify it and get the same error.
any ideas?
node v0.10.18 webstorm 6.0.1
I am trying to get the temperature from weather underground. I get the
object using their API and i'm trying to access the actual temperature
using:
<pre>
<code>
request(url+state+"/"+city+format, function (error, response, body) {
if (!error && response.statusCode == 200) {
var objBody = JSON.parse(body);
return objBody.current_observation.temp_f;
}
else if (error) {
console.log('error: ' + err);
}
});
</code>
</pre>
I am getting an error of "unresolved variable" for
objBody.current_observation.temp_f
I also tried using body.current_observation.temp_f directly and get the
same error. I also tried to stringify it and get the same error.
any ideas?
"The user to send to could not be found" when using API, using an e-mail identifier
"The user to send to could not be found" when using API, using an e-mail
identifier
for example this query:
curl -H "Content-Type: application/json" \ -d '{"oauth_token":
"...","pin": "....","destinationId":
"reflector@dwolla.com","amount":"0.5","fundsSource":"..."}' \
https://www.dwolla.com/oauth/rest/transactions/send
returns the following error:
{"Success":false,"Message":"The user to send to could not be
found.","Response":null}
I also tried with a confirmed user account. I can send money using a
dwolla number ID, but when using an e-mail I see the "The user to send to
could not be found." error.
Why is this happening?
Thanks in advance
identifier
for example this query:
curl -H "Content-Type: application/json" \ -d '{"oauth_token":
"...","pin": "....","destinationId":
"reflector@dwolla.com","amount":"0.5","fundsSource":"..."}' \
https://www.dwolla.com/oauth/rest/transactions/send
returns the following error:
{"Success":false,"Message":"The user to send to could not be
found.","Response":null}
I also tried with a confirmed user account. I can send money using a
dwolla number ID, but when using an e-mail I see the "The user to send to
could not be found." error.
Why is this happening?
Thanks in advance
Subscribe to:
Posts (Atom)