當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。