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


C# Proxy.Get方法代码示例

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


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

示例1: Main

		static void Main(string[] args)
		{
			// TODO: Update the Url, Client Id, Client Secret, Username, & Password values below

			#region Create/configure Proxy
			
			// Create a new Axosoft client object
			var axosoftClient = new Proxy
			{
				// Axosoft instance specific values
				Url = "https://someaccount.axosoft.com/",
				ClientId = "00000000-0000-0000-0000-000000000000",
				ClientSecret = "00000000-0000-0000-0000-000000000000",
			};

			#endregion

			#region Authentication [using username/password in this example]

			// We must authenticate against Axosoft
			axosoftClient.ObtainAccessTokenFromUsernamePassword("admin", "admin", ScopeEnum.ReadWrite);

			// Once authenticated we can query Axosoft
			if (string.IsNullOrWhiteSpace(axosoftClient.AccessToken))
			{
				Console.WriteLine("Unable to authenticate against Axosoft.");

				// Wait for input before closing the console
				Console.WriteLine("Press any key to close the console.");
				Console.ReadKey(true);

				return;
			}
			
			#endregion

			#region Example 1

			// Example 1: we can get all projects
			var projectsResult = axosoftClient.Projects.Get();

			if (!projectsResult.IsSuccessful)
			{
				// Wait for input before closing the console
				Console.WriteLine("Unable to get projects. We're done here!");
				Console.ReadKey(true);

				return;
			}

			Console.WriteLine("Example 1 -> Projects:");

			foreach (var project in projectsResult.Data)
			{
				Console.WriteLine(string.Format("Project Id: {0} - Name: {1}", project.Id, project.Name));
			}

			Console.WriteLine();

			#endregion

			#region Example 2

			// Example 2: we can get a single project by id (this can also be done for items, worklogs, etc.)
			var project1 = projectsResult.Data.FirstOrDefault(x => x.Id.HasValue);

			if (project1 == null)
			{
				// Wait for input before closing the console
				Console.WriteLine("Unable to get one project. We're done here!");
				Console.ReadKey(true);

				return;
			}

			project1 = axosoftClient.Projects.Get(project1.Id.Value).Data;

			Console.WriteLine("Example 2 -> Project by Id:");

			Console.WriteLine(string.Format("Project Id: {0} - Description: {1}", project1.Id, project1.Description));

			Console.WriteLine();

			#endregion

			#region Example 3

			// Example 3: we can get items using filters (all items created today)
			// Additional pre-defined date filter values are: yesterday,last_week,this_week,last10_days,last30_days
			var featuresResult = axosoftClient.Features.Get(new Dictionary<string, object>
			{
				{ "filters", "created_date_time=today" }
			});

			if (!featuresResult.IsSuccessful)
			{
				// Wait for input before closing the console
				Console.WriteLine("Unable to get feature items. We're done here!");
				Console.ReadKey(true);

//.........这里部分代码省略.........
开发者ID:jeremysimmons,项目名称:OnTimeAPIExample,代码行数:101,代码来源:Program.cs


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