Im trying to add viewmodel objects into cookie using angularjs2. I have tried a lot, but didn't worked yet. I
private setCookie(name: string, value: any, expireDays: number, path: string = "") {
let d: Date = new Date();
d.setTime(d.getTime() + expireDays * 24 * 60 * 60 * 1000);
let expires: string = "expires=" + d.toUTCString();
document.cookie = name +`enter code here` "=" + value + "; " + expires + (path.length > 0 ? "; path=" + path : "");
}
I have tried like this,
this.setCookie("CookieConstant", ViewModel, 1);
When I'm checking cookie value in the browser I can see only [Object Object]. Can anyone help me. I'm new to angular 2
I think its not possible in angular 2, you better to set single value in the cookie, based on that value you can generate the results. Cookies is for setting small values, so its better to avoid setting viewmodel objects into cookies. Try to set single value.
Related
To get an event from an Exchange calendar by ICalUId, you can use the FindItem-operation, using the UId base64-encoded as value to the Extended property identified by
DistinguishedPropertySetId=Meeting, PropertyId=3 and PropertyType=Binary.
This works great for events that are created in the Exchange calendar, where ICalUIds look like the following: 040000008200E00074C5B7101A82E00800000000A7C552582821D1010000000000000000100000002550ED442EB2CF4287FD94D10A4F331D
However, this does not work when trying to get the event with a Google Calendar UId, which looks like the following:
tp90m1srk847n1oa4jtp9ofou0#google.com
Not even using the substring before #google.com works, sadly.
Is there a way to get Google Events in the Exchange Calendar with EWS?
The GlobalObjectId is generated from the UID in this case using the formula defined in https://msdn.microsoft.com/en-us/library/ee157690(v=exchg.80).aspx . So if all you have is the UID you will need to generate the GlobalObjectId to search using your own algorithm. eg
String UId = "k5abv4oduaidu8knel4088iq8c#google.com";
String Header = "040000008200E00074C5B7101A82E008";
String Padding = "0000000000000000000000000000000000000000";
String Prefix = "7643616C2D55696401000000";
String DataString = Prefix + BitConverter.ToString(ASCIIEncoding.ASCII.GetBytes(UId)).Replace("-", "") + "00";
String BigEndianlength = (DataString.Length / 2).ToString("X8");
String LittleEndianlength = BigEndianlength.Substring(6, 2) + BigEndianlength.Substring(4, 2) + BigEndianlength.Substring(2, 2) + BigEndianlength.Substring(0, 2);
String GlobalUidHex = Header + Padding + LittleEndianlength + DataString;
If you then conver the HexString to Base64 String that should work.
Cheers
glen
In my long, but simple awesome Gatling simulation, I have few responses that ended with error 500. Is it possible to tell gatling to collect these error responses messages in a file during the simulation?
No in production mode. You only have them when debug logging is enabled.
It is possible to collect what ever you want and save it into simulation.log file. Use extraInfoExtractor method when you define protocol:
val httpProtocol = http
.baseURL(url)
.check(status.is(successStatus))
.extraInfoExtractor { extraInfo => List(getExtraInfo(extraInfo)) }
Then define in your getExtraInfo(extraInfo: ExtraInfo) method whatever criteria you want. Example bellow outputs request and response in case of debug is enables via Java System Property OR response code is not 200 OR status of request is KO (it can be KO if you have setup some max time and this max time gets increased)
private val successStatus: Int = 200
private val isDebug = System.getProperty("debug").toBoolean
private def getExtraInfo(extraInfo: ExtraInfo): String = {
if (isDebug
|| extraInfo.response.statusCode.get != successStatus
|| extraInfo.status.eq(Status.valueOf("KO"))) {
",URL:" + extraInfo.request.getUrl +
" Request: " + extraInfo.request.getStringData +
" Response: " + extraInfo.response.body.string
} else {
""
}
}
I have performance issue on salesforce
I am trying to load table from salesforce into excel cvs, for that used, I tested the ApexDataLoader and found out that to load whole lead table for my organization take around 4~5 min, and have around 60,000 records.
Now I want to do the same with a C# code, for that I write this code:
var user = "xxx";
var password = "xxx";
var token = "xxx";
var sforceService = new SforceService();
var login = sforceService.login(user, String.Concat(password, token));
sforceService.Url = login.serverUrl;
sforceService.SessionHeaderValue = new SessionHeader { sessionId = login.sessionId };
var query = "The full query that I took from ApexDataLoder";
var startTime = DateTime.Now.TimeOfDay;
var firstTime = DateTime.Now.TimeOfDay;
var result = sforceService.query(query);
int i = 0;
while (!result.done)
{
var endTime = DateTime.Now.TimeOfDay;
Debug.Print(endTime.Subtract(startTime) + " " + i * result.records.Count() + " - " + (i + 1) * result.records.Count() +
" Time from start: " + endTime.Subtract(firstTime));
startTime = DateTime.Now.TimeOfDay;
result = sforceService.queryMore(result.queryLocator);
i++;
}
After few lines I saw that I read only 2000 lines in total (out of 60,000) in 2 miniuts.
That's mean that to get the whole table I will need 60 min.
Why there is so big difference between that ApexDataLoader (5 min) to my code? what I am doing wrong?
Thanks for the help!
I found 2 things that really improve performance,
one, set up the EnableDecompression to true
sforceService.EnableDecompression = true;
And the second is based on this thread, it is better to do a query "select Id from Lead" and collect all the id's and then do a multi thread processing to get the data with the retrieve function.
Hope that will help people and if someone have any other improvement tricks, please let me know
I'm currently working on an API controller. This controller should be able to catch any - unknown - parameter and put it in a Map object. Now I'm using this code to catch all parameters and put them in a Map
public String processGetRequest(final #RequestParam Map params)
Now the url I call is as follows:
server/api.json?action=doSaveDeck&Card_IDS[]=1&Card_IDS[]=2&Card_IDS[]=3
Then I print out the parameters, for debugging purposes, with this piece of code:
if (logger.isDebugEnabled()) {
for (Object objKey : params.keySet()) {
logger.debug(objKey.toString() + ": " + params.get(objKey));
}
}
The result of that is:
10:43:01,224 DEBUG ApiRequests:79 - action: doSaveDeck
10:43:01,226 DEBUG ApiRequests:79 - Card_IDS[]: 1
But the expected result should be something like:
10:43:XX DEBUG ApiRequests:79 - action: doSaveDeck
10:43:XX DEBUG ApiRequests:79 - Card_IDS[]: 1
10:43:XX DEBUG ApiRequests:79 - Card_IDS[]: 2
10:43:XX DEBUG ApiRequests:79 - Card_IDS[]: 3
Or atleast tell me that the Card_IDS is an String[] / List<String> and therefore should be casted. I also tried casting the parameter to a List<String> manually but that does not work either:
for (Object objKey : params.keySet()) {
if(objKey.equals(NameConfiguration.PARAM_NAME_CARDIDS)){ //Never reaches this part
List<String> ids = (List<String>)params.get(objKey);
for(String id : ids){
logger.debug("Card: " + id);
}
} else {
logger.debug(objKey + ": " + params.get(objKey));
}
}
Could someone tell me how to get the array Card_IDS - It must be dynamically - from the Map params by using the NameConfiguration.PARAM_NAME_CARDIDS?
When you request a Map annotated with #RequestParam Spring creates a map containing all request parameter name/value pairs. If there are two pairs with the same name, then only one can be in the map. So it's essentially a Map<String, String>
You can access all parameters through a MultiValueMap:
public String processGetRequest(#RequestParam MultiValueMap parameters) {
This map is essentially a Map<String, List<String>>. So parameters with the same name would be in the same list.
I want to implement the data virtualization, but I dont know where to put my real collection of data in this example:
http://blogs.msdn.com/b/ptorr/archive/2010/08/16/virtualizing-data-in-windows-phone-7-silverlight-applications.aspx
Let us say your collection is List where Person is a Custom Class you have defined.
You should read a small subset of data from either a Service or Isolated Storage and set it as below.
In the VirtualizedDataSource.cs file update the getter of "this" property as under
if (itemToReturn == null)
{
if (simpleCache.Count >= CACHE_SIZE)
{
DataItem oldItem = simpleCache.Dequeue();
Debug.WriteLine("Purging\t" + oldItem.Index + "\t" + oldItem.Text);
oldItem.Text = "DEAD ITEM";
}
itemToReturn = **new Person();**
text += "\t" + itemToReturn.Text;
simpleCache.Enqueue(itemToReturn);
}
Hope this helps.