当前位置: 首页>>代码示例>>C#>>正文


C# ActivityType.ToString方法代码示例

本文整理汇总了C#中ActivityType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ActivityType.ToString方法的具体用法?C# ActivityType.ToString怎么用?C# ActivityType.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActivityType的用法示例。


在下文中一共展示了ActivityType.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetUserActivities

		public ActivitiesResponse GetUserActivities(int page, int count, ActivityType type)
		{
			EnsureIsAuthorized();
			var parameters = BuildPagingParametersWithCount(page, count);
			if (type != ActivityType.All) parameters.Add("type", type.ToString().ToLower());
			return _restTemplate.GetForObject<ActivitiesResponse>(BuildUrl("user/activity", parameters));
		}
开发者ID:coolya,项目名称:CSharp.Geeklist,代码行数:7,代码来源:ActivityTemplate.cs

示例2: IsAccessAllowed

        public static bool IsAccessAllowed(string Controller, string Action, CustomPrincipal User, string IP, ActivityType activity)
        {
            IMenuService menuService = UnityConfigurator.GetConfiguredContainer().Resolve<IMenuService>();

            if (User != null)
            {
                //default controller for all user
                if (Controller.ToLower().Contains("account") || Controller.ToLower().Contains("home"))
                {
                    return true;
                }
                else
                {
                    bool allowed = false;
                    //check if user have access to controller
                    //ensure that 1 form/modul = 1 controller
                    allowed = menuService.isAccessAllowed(Controller, User.RoleId);

                    //if activity type is supplied, check the activity permission too
                    if (activity != ActivityType.None)
                    {
                        allowed = allowed && menuService.isAccessAllowed(Controller, activity.ToString(), User.RoleId);
                    }

                    return allowed;
                }
            }
            else
            {
                return false;
            }
        }
开发者ID:sbudihar,项目名称:SIRIUSrepo,代码行数:32,代码来源:PageAccessManager.cs

示例3: UploadActivityAsync

        /// <summary>
        /// Uploads an activity.
        /// </summary>
        /// <param name="file">The path to the activity file on your local hard disk.</param>
        /// <param name="dataFormat">The format of the file.</param>
        /// <param name="activityType">The type of the activity.</param>
        /// <returns>The status of the upload.</returns>
        public async Task<UploadStatus> UploadActivityAsync(StorageFile file, DataFormat dataFormat, ActivityType activityType = ActivityType.Ride)
        {
            String format = String.Empty;

            switch (dataFormat)
            {
                case DataFormat.Fit:
                    format = "fit";
                    break;
                case DataFormat.FitGZipped:
                    format = "fit.gz";
                    break;
                case DataFormat.Gpx:
                    format = "gpx";
                    break;
                case DataFormat.GpxGZipped:
                    format = "gpx.gz";
                    break;
                case DataFormat.Tcx:
                    format = "tcx";
                    break;
                case DataFormat.TcxGZipped:
                    format = "tcx.gz";
                    break;
            }
           
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Add("Authorization", String.Format("Bearer {0}", Authentication.AccessToken));

            MultipartFormDataContent content = new MultipartFormDataContent();

            byte[] fileBytes = null;
            using (IRandomAccessStreamWithContentType stream = await file.OpenReadAsync())
            {
                fileBytes = new byte[stream.Size];
                using (DataReader reader = new DataReader(stream))
                {
                    await reader.LoadAsync((uint)stream.Size);
                    reader.ReadBytes(fileBytes);
                }
            }

            var byteArrayContent = new ByteArrayContent(fileBytes);

            content.Add(byteArrayContent, "file", file.Name);

            HttpResponseMessage result = await client.PostAsync(
                String.Format("https://www.strava.com/api/v3/uploads?data_type={0}&activity_type={1}",
                format,
                activityType.ToString().ToLower()),
                content);

            String json = await result.Content.ReadAsStringAsync();

            return Unmarshaller<UploadStatus>.Unmarshal(json);
        }
开发者ID:TiBall,项目名称:stravadotnet,代码行数:63,代码来源:UploadClient.cs

示例4: CreateActivityAsync

        /// <summary>
        /// Creates a manual entry on Strava.
        /// </summary>
        /// <param name="name">The name of the activity.</param>
        /// <param name="type">The type of the activity.</param>
        /// <param name="dateTime">The time when the activity was started.</param>
        /// <param name="elapsedSeconds">The elapsed time in seconds.</param>
        /// <param name="description">The description (otpional).</param>
        /// <param name="distance">The distance of the activity (optional).</param>
        public async Task<Activity> CreateActivityAsync(String name, ActivityType type, DateTime dateTime, int elapsedSeconds, String description, float distance = 0f)
        {
            String t = type.ToString().ToLower();
            String timeString = dateTime.ToString("o");

            String postUrl = String.Format("https://www.strava.com/api/v3/activities?name={0}&type={1}&start_date_local={2}&elapsed_time={3}&description={4}&distance={5}&access_token={6}",
                name, t, timeString, elapsedSeconds, description, distance.ToString(CultureInfo.InvariantCulture), Authentication.AccessToken);
            
            String json = await Http.WebRequest.SendPostAsync(new Uri(postUrl));
            return Unmarshaller<Activity>.Unmarshal(json);
        }
开发者ID:neilortoo,项目名称:stravadotnet,代码行数:20,代码来源:ActivityClient.cs

示例5: UploadActivityAsync

        /// <summary>
        /// Uploads an activity.
        /// </summary>
        /// <param name="filePath">The path to the activity file on your local hard disk.</param>
        /// <param name="dataFormat">The format of the file.</param>
        /// <param name="activityType">The type of the activity.</param>
        /// <returns>The status of the upload.</returns>
        public async Task<UploadStatus> UploadActivityAsync(String filePath, DataFormat dataFormat, ActivityType activityType = ActivityType.Ride)
        {
            String format = String.Empty;

            switch (dataFormat)
            {
                case DataFormat.Fit:
                    format = "fit";
                    break;
                case DataFormat.FitGZipped:
                    format = "fit.gz";
                    break;
                case DataFormat.Gpx:
                    format = "gpx";
                    break;
                case DataFormat.GpxGZipped:
                    format = "gpx.gz";
                    break;
                case DataFormat.Tcx:
                    format = "tcx";
                    break;
                case DataFormat.TcxGZipped:
                    format = "tcx.gz";
                    break;
            }

            FileInfo info = new FileInfo(filePath);

            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Add("Authorization", String.Format("Bearer {0}", Authentication.AccessToken));

            MultipartFormDataContent content = new MultipartFormDataContent();

            content.Add(new ByteArrayContent(File.ReadAllBytes(info.FullName)), "file", info.Name);

            HttpResponseMessage result = await client.PostAsync(
                String.Format("https://www.strava.com/api/v3/uploads?data_type={0}&activity_type={1}",
                format,
                activityType.ToString().ToLower()),
                content);

            String json = await result.Content.ReadAsStringAsync();

            return Unmarshaller<UploadStatus>.Unmarshal(json);
        }
开发者ID:JohnRuddy,项目名称:stravadotnet,代码行数:52,代码来源:UploadClient.cs

示例6: GetAllActivitiesAsync

		public Task<ActivitiesResponse> GetAllActivitiesAsync(int page, int count, ActivityType type)
		{
			var parameters = BuildPagingParametersWithCount(page, count);
			if (type != ActivityType.All) parameters.Add("type", type.ToString().ToLower());
			return _restTemplate.GetForObjectAsync<ActivitiesResponse>(BuildUrl("activity", parameters));
		}
开发者ID:coolya,项目名称:CSharp.Geeklist,代码行数:6,代码来源:ActivityTemplate.cs

示例7: AccountActivity

        /// <summary>
        /// Used to create a file that contains all of the account activity of a certain type for the specified day.
        /// </summary>
        /// <param name="activityDate">
        /// The date of the activity data to be collected.<see cref="DateTime"/>
        /// </param>
        /// <param name="activityType">
        /// The tyoe of activity to be collected.<see cref="ActivityType"/>
        /// </param>
        /// <returns>
        /// The fully qualified name of the downloaded file (YYYY-MM-DD_activitytype.xml)
        /// </returns>
        public String AccountActivity(DateTime activityDate, ActivityType activityType)
        {
            DateTime now = DateTime.Now;
            // validate that activityDate is not in the future
            if(activityDate > now)
            {
                log.Info("Activity Date cannot be in the future. ActivityDate: " + activityDate + " Date Now: " + now);
                throw new MessageGearsClientException("Parmameter: ActivityDate. Value: " + activityDate + " Error Message: This field cannot be a date in the future.");
            }

            DateTime start = now;
            String fileName = properties.DownloadDirectory + activityDate.Year + "-" + activityDate.Month + "-" + activityDate.Day + "_" + activityType + "_" + properties.MyMessageGearsAccountId + ".xml";
            // build POST data
            StringBuilder data = new StringBuilder ();
            data.Append ("Action=" + HttpUtility.UrlEncode ("AccountActivity"));
            appendCredentials(ref data);
            data.Append("&ActivityDate=" + HttpUtility.UrlEncode (activityDate.Year + "-" + activityDate.Month + "-" + activityDate.Day));
            data.Append ("&ActivityType=" + HttpUtility.UrlEncode (activityType.ToString()));

            // invoke endpoint - either writing the contents to a temporary file or throwing exception if error are encountered
            invokeAccountActivity(data, fileName);
            TimeSpan ts = DateTime.Now - start;
            FileInfo fi = new FileInfo(fileName);
            long mbyte = 1024 * 1024;
            if(fi.Length >= mbyte)
            {
                log.Info(string.Format("Downloaded file {0} of size {1:n} MB in {2:00}:{3:00}:{4:00},{5:000}", fi.Name, (float)fi.Length/mbyte, (int)ts.TotalHours, ts.Minutes, ts.Seconds, ts.Milliseconds));
            }
            else if(fi.Length >= 1024)
            {
                log.Info(string.Format("Downloaded file {0} of size {1:n} KB in {2:00}:{3:00}:{4:00},{5:000}", fi.Name, (float)fi.Length/1024, (int)ts.TotalHours, ts.Minutes, ts.Seconds, ts.Milliseconds));
            }
            else
            {
                log.Info(string.Format("Downloaded file {0} of size {1:##0} Bytes in {2:00}:{3:00}:{4:00},{5:000}", fi.Name, fi.Length, (int)ts.TotalHours, ts.Minutes, ts.Seconds, ts.Milliseconds));
            }
            return fileName;
        }
开发者ID:messagegears,项目名称:messagegears-csharp-sdk,代码行数:50,代码来源:MessageGearsClient.cs


注:本文中的ActivityType.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。