Im trying to get a resource usage of specific resource in specific day.
I tryed to use Resource.TimeScaleData but it always returns 0 items.
While in debug mode, the Resource.TimephasedData ArrayList has 6118 items.
Maybe, there is a sample code for getting resource usage?
Can someone direct me, how to approach these?
Try this:
Set tsv = ActiveProject.Resources("your resource").TimeScaleData(#6/6/2013#, #6/6/2013#)
amt = tsv(1)
This will give you the amount of forecast work for the resource for the given day, expressed in minutes. If you want baseline work, you'll need to add the third argument (e.g. pjResourceTimescaledBaselineWork).
Related
I am trying to get the latest value/rate for a given pair using the Kraken API, but I cannot really figure it out.
Is there anyone that knows how to do it?
I am using the C# code provided on Git (https://github.com/trenki2/KrakenApi) and thought using the following function was the way to go:
client.GetRecentTrades("XETHZEUR",ID)
I however don't want to use an ID, which seems to be optional according to Kraken Website.
I just want to know what is the current value, nothing more.
I have also used GetTicker to get the last trade, but this does not come with a Time stamp and will not give the actual currency pair value.
Cheers
Both GetTicker and GetRecentTrades will give you the value of the last trade. You can use either depending on what other data you need. I guess there could be some difference because most likely Kraken caches the results.
Of the two methods above only GetRecentTrades will provide a timestamp.
Alternatively instead of getting the last trade you can call GetOrderBook and calculate the average between the lowest Ask price and highest Bid price.
The workfront API isn't returning the same results as our web report:
On our web front-end on workfront one of the reports has a date range from $$TODAYbw to $$TODAYe+6m and it returned about ~500 rows.
I tried the same query on the API like so (formatted for easier reading)
/v7.0/RSALLO/search
?fields=DE:project:Probability,allocationDate,scheduledHours,project:name,project:status,roleID,project:status,role:name
&allocationDate_Mod=between
&allocationDate=$$TODAYbw
&allocationDate_Range=$$TODAYe+6m
&AND:0:project:status_Mod=notin
&AND:0:project:status=CPL
&AND:0:project:status=DED
&AND:0:project:status=REJ
&AND:0:project:status=UZF
&AND:0:project:status=IDA
&AND:0:roleID_Mod=in
&AND:0:roleID=55cb58b8001cc9bc1bd9767e080f6c10
&AND:0:roleID=55cb58b8001cc9bd9fc0f8b03a581493
&AND:0:roleID=55cb58b8001cc9bfaa01243cd6024b6d
&AND:0:roleID=55cb58b8001cc9c0afa399dece405efd
&$$LIMIT=1000
which returned barely any results. Notice the &allocationDate_Range=$$TODAYe+6m line. If I change it to read =$$TODAY+6m without the end of day modifier the API returns ~500 rows.
I went through every filter criteria and it's only the allocationDate range that is going wrong. I found this resource for the date modifiers and in it there is no e+6m example, yet it works on our web front-end report.
Is the API flawed or is the web report doing something extra in the background?
I don't have an exact solution for your problem, but I can confirm that the API does have some difficulty parsing wildcards like you're trying to use and they don't always come up the way we expect. Furthermore, the API doesn't parse things the same way as text mode reporting, so a query that looks great in the latter might return something different in the former.
If I may propose a different solution, since you're already coding this up outside of Workfront then I suggest you simply perform the date calculations on your own and pass explicit datetime objects to Workfront instead of allowing it to use its own logic. I know this doesn't answer the question of "what is a query that will return exactly what I want" but it should give you the correct end result.
For what it's worth, I spent about 15 minutes trying to get an example working on my end and I gave up after it kept returning values which should have been outside of my own date range.
I was wondering if there was anyway to get a date range of data from Fitbit, such as the detailed Activity and detailed sleep data as we get for one single day. The application I am working on may need to grab data for a long time period for a user. Is there anything in the Fitbit API where I could grab this information for a range of days in just one query to the server?
Later edit: as far as i know you cannot grab all resources for a specified date range.
I think you're searching for Activity Time Series.
You can retrieve activity time series filtered for a specified date range, but you can find them only by resource-path.
There are two acceptable formats for retrieving activity time series data:
GET /1/user/[user-id]/[resource-path]/date/[date]/[period].json
GET /1/user/[user-id]/[resource-path]/date/[base-date]/[end-date].json
Resource Path Options are the following:
activities/calories
activities/caloriesBMR
activities/steps
activities/distance
activities/floors
activities/elevation
activities/minutesSedentary
activities/minutesLightlyActive
activities/minutesFairlyActive
activities/minutesVeryActive
activities/activityCalories
And you have the same for sleep, Sleep Time Series.
GET https://api.fitbit.com/1/user/[user-id]/[resource-path]/date/[date]/[period].json
GET https://api.fitbit.com/1/user/[user-id]/[resource-path]/date/[base-date]/[end-date].json
Resource path options are the following:
sleep/startTime
sleep/timeInBed
sleep/minutesAsleep
sleep/awakeningsCount
sleep/minutesAwake
sleep/minutesToFallAsleep
sleep/minutesAfterWakeup
sleep/efficiency
Example request:
GET https://api.fitbit.com/1/user/28H22H/sleep/minutesAsleep/date/2014-09-01/today.json
It will give you the minutesAsleep between 2014-09-01 and today.
What is the best method to cache the following? I am creating an intranet web application template that will display the message, e.g., Good Morning, Justin Satyr! near the top of my master page header. Obviously, I will have to determine whether to show Morning, Afternoon or Evening. For clarity, my code is below:
string partOfDay;
var hours = DateTime.Now.Hour;
if (hours > 16)
{
partOfDay = "evening";
}
else if (hours > 11)
{
partOfDay = "afternoon";
}
else
{
partOfDay = "morning";
}
I do not want to re-determine this on each page load because that seems moderately redundant and because I have to poll a SQL server to retrieve the user's full name. What is the best way to cache this information? If I cache it for the length of the session, then if the user begins using the application at 11:00 AM and finishes at 3:00 PM, it will still say Good Morning.
Is the best thing to do simply re-determine the M/A/E word each page load and cache the person's full name for the session? Or is there a better way?
I would just keep the user name in the Session object, the rest honestly is not worth caching and checking if it is out of date etc., just re-run it on each page - provided you put the implementation into a common library /class so you keep your code DRY.
In my opinion there is absolutely no need to cache the part of day. User information can be made available in the Session.
If you are talking in ASP.NET MVC context, you can use System.Web.Helpers namespace, where you can find WebCache helper. Than you need to calculate minutes to time of day_time will be changed and call WebCache.Set method with paramters: value="your string", minutesToCache=calculated_value.
Old, I know, but I don't cache mine, due to the obvious reason that the users time may change during the session. I store their calculated time in my session (calculates based on their timezone), and then use this code at the top of all pages:
<strong>#string.Format("Good {0}, ", SessionManager.GetUserCurrentDate().Hour > 16 ? "Evening" : SessionManager.GetUserCurrentDate().Hour > 11 ? "Afternoon" : "Morning") + SessionManager.GetDisplayName())</strong>
Works well for me!
Can anyone find a constant in the .NET framework that defines the number of days in a week (7)?
DateTime.DaysInAWeek // Something like this???
Of course I can define my own, but I'd rather not if it's somewhere in there already.
Update:
I am looking for this because I need to allow the user to select a week (by date, rather than week number) from a list in a DropDownList.
You could probably use System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames.Length.
I think it's ok to harcode this one. I don't think it will change any soon.
Edit: I depends where you want to use this constant. Inside the some calendar related algorithm it is obvious what 7 means. On the other hand sometimes named constant make code much more readable.
Try this:
Enum.GetNames(System.DayOfWeek).Length
If you look at the IL code for Calendar.AddWeeks you will see that Microsoft itself uses a hardcoded 7 in the code.
Also the rotor source uses a hardcoded 7.
Still, I would suggest to use a const.
I used this:
public static readonly int WeekNumberOfDays = Enum.GetNames(typeof(DayOfWeek)).Length;
I don't believe there is one. TimeSpan defines constants for the number of ticks per milli/second/minute/hour/day, but nothing at the level of a week.
I ran a query across the standard libraries for symbols (methods/constants/fields/etc) containing the word 'Week'. Nothing came back. FYI, I ran this query using ReSharper.
I'm not sure what exactly you're looking for, but you can try DateHelper (CODE.MSDN). It's a library I put together for typical date needs. You might be able to use the week methods or the List methods. method list
Edit - no more MSDN code, not on GitHub as part of lib: https://github.com/tbasallo/toolshed
Do you mean calendar weeks or just common weeks?
Obviously, there are calendar weeks that might be shortrer than seven days. The last calendar week of the year is usually shorter, and depending on your definition of calendar week, the first week might be shorter as well.
In that case, I'm afraid you will have to roll out your own week length function. It's not really hard to do with the DateTime class, I did it before, if you need more help let me know.
GregorianCalendar has AddWeeks(1) which will add 7 days to a date.