Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

c sharp example

  • Loading branch information...
commit b2fe31d927cf2fc6a6b02e3d61a11da529a9eff0 1 parent 69dd5a4
@kywon kywon authored
Showing with 2,048 additions and 1 deletion.
  1. +1 −1  README.md
  2. +29 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample.sln
  3. BIN  examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample.suo
  4. +446 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/MainForm.Designer.cs
  5. +519 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/MainForm.cs
  6. +126 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/MainForm.resx
  7. +36 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Program.cs
  8. +36 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/AssemblyInfo.cs
  9. +63 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/Resources.Designer.cs
  10. +117 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/Resources.resx
  11. +26 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/Settings.Designer.cs
  12. +7 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/Settings.settings
  13. +97 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/TeamPlatformAPIExample.csproj
  14. +3 −0  examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/app.config
  15. BIN  examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.exe
  16. +3 −0  ...ples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.exe.config
  17. BIN  examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.pdb
  18. BIN  ...ples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.vshost.exe
  19. +3 −0  ... example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.vshost.exe.config
  20. +11 −0 ...xample/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.vshost.exe.manifest
  21. +112 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/tpAPI/tpModels.cs
  22. +392 −0 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/tpAPI/tpOAuth2.cs
  23. +11 −0 examples/c# example/c-sharp.md
  24. +10 −0 examples/examples.md
View
2  README.md
@@ -61,4 +61,4 @@ Help us make it better
Please tell us how we can make the API better. If you have a specific feature request or if you found a bug, please use GitHub issues.
-This documentation is inspired by 37signals's [bcx-api](https://github.com/vispower/teamplatform-api)
+This documentation is inspired by 37signals's [bcx-api](https://github.com/37signals/bcx-api)
View
29 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample.sln
@@ -0,0 +1,29 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamPlatformAPIExample", "TeamPlatformAPIExample\TeamPlatformAPIExample.csproj", "{9977A1E1-1A7B-4DC8-A133-6339D4790709}"
+EndProject
+Global
+ GlobalSection(TeamFoundationVersionControl) = preSolution
+ SccNumberOfProjects = 2
+ SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
+ SccTeamFoundationServer = http://vispower-pc:8080/tfs/defaultcollection
+ SccLocalPath0 = .
+ SccProjectUniqueName1 = TeamPlatformAPIExample\\TeamPlatformAPIExample.csproj
+ SccProjectName1 = TeamPlatformAPIExample
+ SccLocalPath1 = TeamPlatformAPIExample
+ EndGlobalSection
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {9977A1E1-1A7B-4DC8-A133-6339D4790709}.Debug|x86.ActiveCfg = Debug|x86
+ {9977A1E1-1A7B-4DC8-A133-6339D4790709}.Debug|x86.Build.0 = Debug|x86
+ {9977A1E1-1A7B-4DC8-A133-6339D4790709}.Release|x86.ActiveCfg = Release|x86
+ {9977A1E1-1A7B-4DC8-A133-6339D4790709}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
BIN  examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample.suo
Binary file not shown
View
446 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/MainForm.Designer.cs
@@ -0,0 +1,446 @@
+namespace TeamPlatformAPIExample
+{
+ partial class MainForm
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
+ this.signin_Box = new System.Windows.Forms.GroupBox();
+ this.profile_image = new System.Windows.Forms.PictureBox();
+ this.label3 = new System.Windows.Forms.Label();
+ this.profile_box = new System.Windows.Forms.ListBox();
+ this.signout_btn = new System.Windows.Forms.Button();
+ this.signin_btn = new System.Windows.Forms.Button();
+ this.label2 = new System.Windows.Forms.Label();
+ this.label1 = new System.Windows.Forms.Label();
+ this.pwd_text = new System.Windows.Forms.TextBox();
+ this.email_text = new System.Windows.Forms.TextBox();
+ this.help_label1 = new System.Windows.Forms.LinkLabel();
+ this.client_secret_text = new System.Windows.Forms.TextBox();
+ this.client_id_text = new System.Windows.Forms.TextBox();
+ this.label5 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.ouput_box = new System.Windows.Forms.GroupBox();
+ this.label7 = new System.Windows.Forms.Label();
+ this.api_task_btn = new System.Windows.Forms.Button();
+ this.api_file_btn = new System.Windows.Forms.Button();
+ this.tp_datagridview = new System.Windows.Forms.DataGridView();
+ this.api_ws_btn = new System.Windows.Forms.Button();
+ this.help_label2 = new System.Windows.Forms.LinkLabel();
+ this.status_strip = new System.Windows.Forms.StatusStrip();
+ this.msg_box = new System.Windows.Forms.ToolStripStatusLabel();
+ this.client_box = new System.Windows.Forms.GroupBox();
+ this.label6 = new System.Windows.Forms.Label();
+ this.label9 = new System.Windows.Forms.Label();
+ this.label10 = new System.Windows.Forms.Label();
+ this.signin_Box.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.profile_image)).BeginInit();
+ this.ouput_box.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.tp_datagridview)).BeginInit();
+ this.status_strip.SuspendLayout();
+ this.client_box.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // signin_Box
+ //
+ this.signin_Box.Controls.Add(this.profile_image);
+ this.signin_Box.Controls.Add(this.label3);
+ this.signin_Box.Controls.Add(this.profile_box);
+ this.signin_Box.Controls.Add(this.signout_btn);
+ this.signin_Box.Controls.Add(this.signin_btn);
+ this.signin_Box.Controls.Add(this.label2);
+ this.signin_Box.Controls.Add(this.label1);
+ this.signin_Box.Controls.Add(this.pwd_text);
+ this.signin_Box.Controls.Add(this.email_text);
+ this.signin_Box.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.signin_Box.Location = new System.Drawing.Point(375, 33);
+ this.signin_Box.Name = "signin_Box";
+ this.signin_Box.Size = new System.Drawing.Size(346, 185);
+ this.signin_Box.TabIndex = 0;
+ this.signin_Box.TabStop = false;
+ this.signin_Box.Text = "Step 2 - Sign in";
+ //
+ // profile_image
+ //
+ this.profile_image.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
+ this.profile_image.Location = new System.Drawing.Point(15, 119);
+ this.profile_image.Name = "profile_image";
+ this.profile_image.Size = new System.Drawing.Size(60, 60);
+ this.profile_image.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
+ this.profile_image.TabIndex = 14;
+ this.profile_image.TabStop = false;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label3.Location = new System.Drawing.Point(13, 104);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(305, 13);
+ this.label3.TabIndex = 8;
+ this.label3.Text = "Account info will be displayed below, when sign-in is successful";
+ //
+ // profile_box
+ //
+ this.profile_box.BackColor = System.Drawing.SystemColors.Window;
+ this.profile_box.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.profile_box.FormattingEnabled = true;
+ this.profile_box.Location = new System.Drawing.Point(81, 121);
+ this.profile_box.Name = "profile_box";
+ this.profile_box.Size = new System.Drawing.Size(248, 56);
+ this.profile_box.TabIndex = 7;
+ //
+ // signout_btn
+ //
+ this.signout_btn.Enabled = false;
+ this.signout_btn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.signout_btn.Location = new System.Drawing.Point(269, 74);
+ this.signout_btn.Name = "signout_btn";
+ this.signout_btn.Size = new System.Drawing.Size(64, 25);
+ this.signout_btn.TabIndex = 5;
+ this.signout_btn.Text = "Sign Out";
+ this.signout_btn.UseVisualStyleBackColor = true;
+ this.signout_btn.Click += new System.EventHandler(this.signout_btn_Click);
+ //
+ // signin_btn
+ //
+ this.signin_btn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.signin_btn.Location = new System.Drawing.Point(199, 74);
+ this.signin_btn.Name = "signin_btn";
+ this.signin_btn.Size = new System.Drawing.Size(64, 25);
+ this.signin_btn.TabIndex = 4;
+ this.signin_btn.Text = "Sign In";
+ this.signin_btn.UseVisualStyleBackColor = true;
+ this.signin_btn.Click += new System.EventHandler(this.signin_btn_Click);
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label2.Location = new System.Drawing.Point(19, 53);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(56, 13);
+ this.label2.TabIndex = 3;
+ this.label2.Text = "Password:";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Location = new System.Drawing.Point(40, 26);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(35, 13);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "Email:";
+ //
+ // pwd_text
+ //
+ this.pwd_text.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.pwd_text.Location = new System.Drawing.Point(83, 49);
+ this.pwd_text.Name = "pwd_text";
+ this.pwd_text.PasswordChar = '*';
+ this.pwd_text.Size = new System.Drawing.Size(250, 20);
+ this.pwd_text.TabIndex = 3;
+ //
+ // email_text
+ //
+ this.email_text.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.email_text.Location = new System.Drawing.Point(83, 22);
+ this.email_text.Name = "email_text";
+ this.email_text.Size = new System.Drawing.Size(250, 20);
+ this.email_text.TabIndex = 2;
+ //
+ // help_label1
+ //
+ this.help_label1.AutoSize = true;
+ this.help_label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.help_label1.Location = new System.Drawing.Point(526, 16);
+ this.help_label1.Name = "help_label1";
+ this.help_label1.Size = new System.Drawing.Size(172, 13);
+ this.help_label1.TabIndex = 17;
+ this.help_label1.TabStop = true;
+ this.help_label1.Tag = "";
+ this.help_label1.Text = "TeamPlatform API Documentations";
+ this.help_label1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.help_label1_LinkClicked);
+ //
+ // client_secret_text
+ //
+ this.client_secret_text.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.client_secret_text.Location = new System.Drawing.Point(87, 49);
+ this.client_secret_text.Name = "client_secret_text";
+ this.client_secret_text.Size = new System.Drawing.Size(250, 20);
+ this.client_secret_text.TabIndex = 1;
+ //
+ // client_id_text
+ //
+ this.client_id_text.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.client_id_text.Location = new System.Drawing.Point(87, 22);
+ this.client_id_text.Name = "client_id_text";
+ this.client_id_text.Size = new System.Drawing.Size(250, 20);
+ this.client_id_text.TabIndex = 0;
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label5.Location = new System.Drawing.Point(9, 53);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(70, 13);
+ this.label5.TabIndex = 10;
+ this.label5.Text = "Client Secret:";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label4.Location = new System.Drawing.Point(29, 26);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(50, 13);
+ this.label4.TabIndex = 9;
+ this.label4.Text = "Client ID:";
+ //
+ // ouput_box
+ //
+ this.ouput_box.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.ouput_box.Controls.Add(this.label7);
+ this.ouput_box.Controls.Add(this.help_label1);
+ this.ouput_box.Controls.Add(this.api_task_btn);
+ this.ouput_box.Controls.Add(this.api_file_btn);
+ this.ouput_box.Controls.Add(this.tp_datagridview);
+ this.ouput_box.Controls.Add(this.api_ws_btn);
+ this.ouput_box.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.ouput_box.Location = new System.Drawing.Point(10, 234);
+ this.ouput_box.Name = "ouput_box";
+ this.ouput_box.Size = new System.Drawing.Size(711, 372);
+ this.ouput_box.TabIndex = 1;
+ this.ouput_box.TabStop = false;
+ this.ouput_box.Text = "Step 3 - Call Sample API functions";
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label7.Location = new System.Drawing.Point(8, 24);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(211, 13);
+ this.label7.TabIndex = 6;
+ this.label7.Text = "Each API call fetches up to recent 30 items";
+ //
+ // api_task_btn
+ //
+ this.api_task_btn.Enabled = false;
+ this.api_task_btn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.api_task_btn.Location = new System.Drawing.Point(350, 43);
+ this.api_task_btn.Name = "api_task_btn";
+ this.api_task_btn.Size = new System.Drawing.Size(151, 25);
+ this.api_task_btn.TabIndex = 5;
+ this.api_task_btn.Text = "List Finished Tasks";
+ this.api_task_btn.UseVisualStyleBackColor = true;
+ this.api_task_btn.Click += new System.EventHandler(this.api_task_btn_Click);
+ //
+ // api_file_btn
+ //
+ this.api_file_btn.Enabled = false;
+ this.api_file_btn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.api_file_btn.Location = new System.Drawing.Point(179, 43);
+ this.api_file_btn.Name = "api_file_btn";
+ this.api_file_btn.Size = new System.Drawing.Size(151, 25);
+ this.api_file_btn.TabIndex = 3;
+ this.api_file_btn.Text = "List Recent Files";
+ this.api_file_btn.UseVisualStyleBackColor = true;
+ this.api_file_btn.Click += new System.EventHandler(this.api_file_btn_Click);
+ //
+ // tp_datagridview
+ //
+ this.tp_datagridview.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.tp_datagridview.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+ dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Window;
+ dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.ControlText;
+ dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+ dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+ this.tp_datagridview.DefaultCellStyle = dataGridViewCellStyle4;
+ this.tp_datagridview.Location = new System.Drawing.Point(9, 74);
+ this.tp_datagridview.Name = "tp_datagridview";
+ this.tp_datagridview.RowTemplate.Height = 23;
+ this.tp_datagridview.Size = new System.Drawing.Size(689, 291);
+ this.tp_datagridview.TabIndex = 2;
+ //
+ // api_ws_btn
+ //
+ this.api_ws_btn.Enabled = false;
+ this.api_ws_btn.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.api_ws_btn.Location = new System.Drawing.Point(8, 43);
+ this.api_ws_btn.Name = "api_ws_btn";
+ this.api_ws_btn.Size = new System.Drawing.Size(151, 25);
+ this.api_ws_btn.TabIndex = 0;
+ this.api_ws_btn.Text = "List Active Workspaces";
+ this.api_ws_btn.UseVisualStyleBackColor = true;
+ this.api_ws_btn.Click += new System.EventHandler(this.api_ws_btn_Click);
+ //
+ // help_label2
+ //
+ this.help_label2.AutoSize = true;
+ this.help_label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.help_label2.Location = new System.Drawing.Point(11, 141);
+ this.help_label2.Name = "help_label2";
+ this.help_label2.Size = new System.Drawing.Size(323, 13);
+ this.help_label2.TabIndex = 18;
+ this.help_label2.TabStop = true;
+ this.help_label2.Text = "2. Click here or go to Settings->API tab to register a new client app.";
+ this.help_label2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.help_label2_LinkClicked);
+ //
+ // status_strip
+ //
+ this.status_strip.BackColor = System.Drawing.Color.LightYellow;
+ this.status_strip.Dock = System.Windows.Forms.DockStyle.Top;
+ this.status_strip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.msg_box});
+ this.status_strip.Location = new System.Drawing.Point(0, 0);
+ this.status_strip.Name = "status_strip";
+ this.status_strip.Size = new System.Drawing.Size(729, 22);
+ this.status_strip.TabIndex = 2;
+ //
+ // msg_box
+ //
+ this.msg_box.Name = "msg_box";
+ this.msg_box.Size = new System.Drawing.Size(87, 17);
+ this.msg_box.Text = "Pleasae sign in.";
+ //
+ // client_box
+ //
+ this.client_box.Controls.Add(this.label10);
+ this.client_box.Controls.Add(this.label9);
+ this.client_box.Controls.Add(this.label6);
+ this.client_box.Controls.Add(this.label4);
+ this.client_box.Controls.Add(this.client_id_text);
+ this.client_box.Controls.Add(this.help_label2);
+ this.client_box.Controls.Add(this.label5);
+ this.client_box.Controls.Add(this.client_secret_text);
+ this.client_box.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.client_box.Location = new System.Drawing.Point(10, 33);
+ this.client_box.Name = "client_box";
+ this.client_box.Size = new System.Drawing.Size(346, 185);
+ this.client_box.TabIndex = 19;
+ this.client_box.TabStop = false;
+ this.client_box.Text = "Step 1 - Enter OAuth2 Client App Info";
+ //
+ // label6
+ //
+ this.label6.AutoSize = true;
+ this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label6.Location = new System.Drawing.Point(11, 125);
+ this.label6.Name = "label6";
+ this.label6.Size = new System.Drawing.Size(258, 13);
+ this.label6.TabIndex = 19;
+ this.label6.Text = "1. Sign in to your TeamPlatform account on the Web.";
+ //
+ // label9
+ //
+ this.label9.AutoSize = true;
+ this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label9.Location = new System.Drawing.Point(11, 106);
+ this.label9.Name = "label9";
+ this.label9.Size = new System.Drawing.Size(250, 13);
+ this.label9.TabIndex = 20;
+ this.label9.Text = "No Cliente ID Yet? Follow the steps below.";
+ //
+ // label10
+ //
+ this.label10.AutoSize = true;
+ this.label10.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label10.Location = new System.Drawing.Point(11, 159);
+ this.label10.Name = "label10";
+ this.label10.Size = new System.Drawing.Size(287, 13);
+ this.label10.TabIndex = 21;
+ this.label10.Text = "3. Copy and paste client ID/Secret in the text boxes above.";
+ //
+ // MainForm
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(729, 619);
+ this.Controls.Add(this.client_box);
+ this.Controls.Add(this.status_strip);
+ this.Controls.Add(this.ouput_box);
+ this.Controls.Add(this.signin_Box);
+ this.Name = "MainForm";
+ this.Text = "TeamPlatform API Sample";
+ this.signin_Box.ResumeLayout(false);
+ this.signin_Box.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.profile_image)).EndInit();
+ this.ouput_box.ResumeLayout(false);
+ this.ouput_box.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.tp_datagridview)).EndInit();
+ this.status_strip.ResumeLayout(false);
+ this.status_strip.PerformLayout();
+ this.client_box.ResumeLayout(false);
+ this.client_box.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox signin_Box;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.TextBox pwd_text;
+ private System.Windows.Forms.TextBox email_text;
+ private System.Windows.Forms.Button signout_btn;
+ private System.Windows.Forms.Button signin_btn;
+ private System.Windows.Forms.GroupBox ouput_box;
+ private System.Windows.Forms.Button api_ws_btn;
+ private System.Windows.Forms.ListBox profile_box;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.TextBox client_secret_text;
+ private System.Windows.Forms.TextBox client_id_text;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.PictureBox profile_image;
+ private System.Windows.Forms.DataGridView tp_datagridview;
+ private System.Windows.Forms.Button api_file_btn;
+ private System.Windows.Forms.LinkLabel help_label1;
+ private System.Windows.Forms.Button api_task_btn;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.LinkLabel help_label2;
+ private System.Windows.Forms.StatusStrip status_strip;
+ private System.Windows.Forms.ToolStripStatusLabel msg_box;
+ private System.Windows.Forms.GroupBox client_box;
+ private System.Windows.Forms.Label label6;
+ private System.Windows.Forms.Label label10;
+ private System.Windows.Forms.Label label9;
+ }
+}
+
View
519 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/MainForm.cs
@@ -0,0 +1,519 @@
+/*
+ * Copyright © 2012 VISPOWER TECHNOLOGY, INC.
+ * All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
+ * You may freely redistribute and use this sample code, with or without modification, provided you include the original copyright notice and use restrictions.
+ *
+ * Disclaimer:
+ * THE SAMPLE CODE IS PROVIDED "AS IS," AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
+ * IN NO EVENT SHALL VISPOWER TECHNOLOGY, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT, ARISING IN ANY WAY OUT OF THE USE OF THIS SAMPLE CODE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * For additional information, contact
+ * support@teamplatform.com
+ *
+ * Oct. 22nd, 2012
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Net;
+using System.Windows.Forms;
+
+namespace TeamPlatformAPIExample
+{
+ public partial class MainForm : Form
+ {
+ DataGridViewCellStyle defaultCellStyle, oddRawCellStyle;
+
+ public MainForm()
+ {
+ InitializeComponent();
+ defaultCellStyle = new DataGridViewCellStyle();
+ defaultCellStyle.Font = new Font("Verdana", 8, FontStyle.Regular);
+ defaultCellStyle.WrapMode = DataGridViewTriState.True;
+
+ oddRawCellStyle = new DataGridViewCellStyle();
+ oddRawCellStyle.Font = new Font("Verdana", 8, FontStyle.Regular);
+ oddRawCellStyle.BackColor = Color.LightGray;
+ oddRawCellStyle.WrapMode = DataGridViewTriState.True;
+ }
+
+ private tpOAuth2 _oauth = null;
+
+ //
+ // Sign in to TeamPlatform and get the user profile
+ //
+ private void signin_btn_Click(object sender, EventArgs e)
+ {
+ string client_id = this.client_id_text.Text;
+ string client_secret = this.client_secret_text.Text;
+ string email = this.email_text.Text;
+ string pwd = this.pwd_text.Text;
+
+ //
+ // OAuth2 Client ID and Secret.
+ //
+ // If don't have a client ID/Secret, you need to register a new client app
+ //
+ // (1) Please sing into TeamPlatform account on the Web and go to Settings->API tab
+ // https://teamplatform.com/settings#tab-api-s
+ //
+ // (2) Register a new client. Application URL and Redirect URI should have full addresses staring with http:// or https://
+ //
+ // (3) Copy and paste newly generated client ID/Secret in the form or the code below.
+ //
+ //client_id = "";
+ //client_secret = "";
+ //
+
+ string error_msg = null;
+
+ showMessage("Connecting ...");
+
+ //
+ // Authorizing - password method
+ //
+ if (is_blank(client_id) || is_blank(client_secret) || is_blank(email) || is_blank(pwd))
+ {
+ showMessage("Failed to sign in - info missing.");
+ return;
+ }
+ _oauth = new tpOAuth2();
+ bool authorized = _oauth.tpGetAuthorization(client_id, client_secret, email, pwd, out error_msg);
+ if (!authorized)
+ {
+ showMessage(error_msg);
+ return;
+ }
+ showMessage("Successfully signed in.");
+
+ //
+ // Get the user profile
+ //
+ bool getUser = _oauth.tpGetProfile(out error_msg);
+ if (!getUser)
+ {
+ showMessage(error_msg);
+ return;
+ }
+ this.profile_box.Items.Clear();
+ this.profile_box.Items.AddRange(_oauth.User.user_info_arr());
+ this.profile_image.ImageLocation = _oauth.User.picture;
+
+ // Update button status
+ this.signin_btn.Enabled = false;
+ this.signout_btn.Enabled = true;
+ this.api_ws_btn.Enabled = true;
+ this.api_file_btn.Enabled = true;
+ this.api_task_btn.Enabled = true;
+ }
+
+ //
+ // Sign out and clear fields and table
+ //
+ private void signout_btn_Click(object sender, EventArgs e)
+ {
+ _oauth = null;
+ this.client_id_text.Text = null;
+ this.client_secret_text.Text = null;
+ this.email_text.Text = null;
+ this.pwd_text.Text = null;
+ this.profile_box.Items.Clear();
+ this.profile_image.ImageLocation = null;
+ this.signin_btn.Enabled = true;
+ this.signout_btn.Enabled = false;
+ this.api_ws_btn.Enabled = false;
+ this.api_file_btn.Enabled = false;
+ this.api_task_btn.Enabled = false;
+ this.tp_datagridview.Columns.Clear();
+ this.tp_datagridview.Refresh();
+ showMessage("Please sign in.");
+ }
+
+ //
+ // Get the list of recent workspaces
+ //
+ private void api_ws_btn_Click(object sender, EventArgs e)
+ {
+ this.tp_datagridview.Columns.Clear();
+ this.tp_datagridview.Refresh();
+ string error_msg = null;
+ List<tpModels.Workspace> workspaces = null;
+
+ showMessage("Connecting ...");
+
+ //
+ // Visit https://github.com/vispower/teamplatform-api for more options
+ //
+ // Following codes fetches recently updated active workspaces.
+ // The number of workspaces retrieved at each call is 30
+ //
+ List<QueryParameter> options = new List<QueryParameter>();
+ options.Add(new QueryParameter("status", "active"));
+ options.Add(new QueryParameter("deleted", "false"));
+
+ //
+ // If you need to get next 30 more active workspaces,
+ // use 'page' option ('page' is the shortform of the 'pagination')
+ //
+ // options.Add(new QueryParameter("page", "2"));
+ // options.Add(new QueryParameter("page", "3"));
+ //
+
+ if (!_oauth.tpGetWorkspaces(options, out error_msg, out workspaces))
+ {
+ showMessage(error_msg);
+ return;
+ }
+ showMessage(workspaces.Count.ToString() + " workspaces found.");
+
+ //
+ //Add workspaces data to the grid view
+ //
+ try
+ {
+ setupWSViewTable(this.tp_datagridview);
+ foreach (tpModels.Workspace ws in workspaces)
+ {
+ bool ws_deleted = !is_blank(ws.deleted_at);
+ string ws_content = truncate(ws.description, 100) + "\n"
+ + "Comments:" + ws.comments_count
+ + ", Files:" + ws.files_count
+ + ", Pages:" + ws.pages_count
+ + ", Tasks:" + ws.tasks_count
+ + ", Members:" + ws.members_count;
+ string ws_state = ws.status + " " + (ws_deleted ? "deleted" : "") + "\n"
+ + convertDateTime(ws.updated_at) + "\n" + convertDateTime(ws.created_at);
+ string[] row = { ws.owner.name, ws.title, ws_content, ws_state };
+ this.tp_datagridview.Rows.Add(row);
+ DataGridViewRow lastRow = this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2];
+
+ //
+ // Workspace link
+ //
+ DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
+ linkCell.Value = _oauth.APIHost + "/workspaces/" + ws.id + "#tab-overview-s";
+ linkCell.ToolTipText = "Open the workspace in a web browser";
+ lastRow.Cells[4] = linkCell;
+ if (ws_deleted || ws.status == "archived")
+ this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2].DefaultCellStyle.ForeColor = Color.DarkGray;
+ }
+
+ //
+ // Clicking a cell opens the workspace in a Web browser
+ //
+ this.tp_datagridview.CellContentClick += new DataGridViewCellEventHandler(tp_datagridview_CellContentClick);
+ }
+ catch (Exception err)
+ {
+ showMessage("Error while fetching the list of workspaces.");
+ return;
+ }
+ }
+
+ //
+ // Get the list of recent files
+ //
+ private void api_file_btn_Click(object sender, EventArgs e)
+ {
+ this.tp_datagridview.Columns.Clear();
+ this.tp_datagridview.Refresh();
+ string error_msg = null;
+ List<tpModels.File> files = null;
+
+ showMessage("Connecting ...");
+
+
+ //
+ // Visit https://github.com/vispower/teamplatform-api for more options
+ //
+ // Following codes fetches recently updated files excluding folderes.
+ // The number of files retrieved at each call is 30
+ //
+ List<QueryParameter> options = new List<QueryParameter>();
+ options.Add(new QueryParameter("ftype", "file"));
+
+ //
+ // If you need to get next 30 more files,
+ // use 'page' option ('page' is the shortform of the 'pagination')
+ //
+ // options.Add(new QueryParameter("page", "2"));
+ //
+
+ if (!_oauth.tpGetFiles(options, out error_msg, out files))
+ {
+ showMessage(error_msg);
+ return;
+ }
+ showMessage(files.Count.ToString() + " recent files found.");
+
+ //
+ //Add files data to the grid view
+ //
+ try
+ {
+ setupFileViewTable(this.tp_datagridview);
+ foreach (tpModels.File file in files)
+ {
+ bool file_deleted = !is_blank(file.deleted_at);
+ string desc = "";
+ if (file.workspace_id != null) desc = "Workspace:" + file.key.Split('/').First();
+ else desc = "Attached to a discussion";
+
+ string file_content = desc + "\n"
+ + "Owner:" + file.owner.name + ", Comments:" + file.comments_count;
+ string file_state = convertDateTime(file.updated_at) + "\n" + convertDateTime(file.created_at);
+ string[] row = { null, file.filename, file_content, file_state };
+ this.tp_datagridview.Rows.Add(row);
+ DataGridViewRow lastRow = this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2];
+
+ //
+ // Get thumbnail images from the TeamPlatform images storage
+ //
+ if (!is_blank(file.small))
+ {
+ try
+ {
+ DataGridViewImageCell imageCell = new DataGridViewImageCell();
+ HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(file.small.ToString());
+ myRequest.Method = "GET";
+ HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
+ Bitmap bmp = new System.Drawing.Bitmap(myResponse.GetResponseStream());
+ Bitmap resized = new Bitmap(bmp, new Size(100, 100));
+ myResponse.Close();
+ imageCell.Value = resized;
+ lastRow.Cells[0] = imageCell;
+ }
+ catch { }
+ }
+
+ //
+ // Clicking a cell opens the file data in a Web browser
+ //
+ if (file.workspace_id != null)
+ {
+ DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
+ linkCell.Value = _oauth.APIHost + "/workspaces/" + file.workspace_id + "#tab-files-" + file.id + "-s";
+ linkCell.ToolTipText = "Open the file in a web browser";
+ lastRow.Cells[4] = linkCell;
+ }
+
+ if (file_deleted)
+ this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2].DefaultCellStyle.ForeColor = Color.DarkGray;
+ }
+ //bind cell click to open in browser
+ this.tp_datagridview.CellContentClick += new DataGridViewCellEventHandler(tp_datagridview_CellContentClick);
+ }
+ catch (Exception err)
+ {
+ showMessage("Error while fetching the list of files.");
+ return;
+ }
+ }
+
+ //
+ // Get the list of recent tasks
+ //
+ private void api_task_btn_Click(object sender, EventArgs e)
+ {
+ this.tp_datagridview.Columns.Clear();
+ this.tp_datagridview.Refresh();
+ string error_msg = null;
+ List<tpModels.Task> tasks = null;
+
+ showMessage("Connecting ...");
+
+ //
+ // Visit https://github.com/vispower/teamplatform-api for more options
+ //
+ // Following codes fetches recently finished tasks.
+ // The number of tasks retrieved at each call is 30
+ //
+
+ List<QueryParameter> options = new List<QueryParameter>();
+ options.Add(new QueryParameter("state", "finished"));
+
+ if (!_oauth.tpGetTasks(options, out error_msg, out tasks))
+ {
+ showMessage(error_msg);
+ return;
+ }
+ showMessage(tasks.Count.ToString() + " finished tasks found.");
+
+ //
+ // Add tasks data to the grid view
+ //
+ try
+ {
+ setupTaskViewTable(this.tp_datagridview);
+ foreach (tpModels.Task task in tasks)
+ {
+ bool task_finished = (task.state == "finished") ? true : false;
+ string task_content = task.description + "\n" + truncate(task.details, 100);
+ string task_users = task.assigner.name + "\n" + ((task.assignee == null) ? "" : task.assignee.name);
+ string[] row = { task_content, task_users, convertDateTime(task.due), task.state };
+ this.tp_datagridview.Rows.Add(row);
+ DataGridViewRow lastRow = this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2];
+
+ //
+ // Workspace hyper link
+ //
+ DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
+ linkCell.Value = _oauth.APIHost + "/workspaces/" + task.workspace_id + "#tab-tasks-s";
+ linkCell.ToolTipText = "Open Workspace in web browser";
+ lastRow.Cells[4] = linkCell;
+ if (task_finished)
+ this.tp_datagridview.Rows[this.tp_datagridview.Rows.Count - 2].DefaultCellStyle.ForeColor = Color.DarkGray;
+ }
+
+ //
+ // Clicking a cell opens the task data in a Web browser
+ //
+ this.tp_datagridview.CellContentClick += new DataGridViewCellEventHandler(tp_datagridview_CellContentClick);
+ }
+ catch (Exception err)
+ {
+ showMessage("Error while fetching the list of tasks.");
+ return;
+ }
+ }
+
+ //
+ // Set up the workspace list table view
+ //
+ public void setupWSViewTable(DataGridView gridview)
+ {
+ gridview.DefaultCellStyle = defaultCellStyle;
+ gridview.AlternatingRowsDefaultCellStyle = oddRawCellStyle;
+
+ gridview.ColumnCount = 5;
+ gridview.RowTemplate.MinimumHeight = 80;
+
+ gridview.Columns[0].Name = "Owner";
+ gridview.Columns[0].Width = 80;
+
+ gridview.Columns[1].Name = "Title";
+ gridview.Columns[1].Width = 300;
+
+ gridview.Columns[2].Name = "Summary";
+ gridview.Columns[2].Width = 300;
+
+ gridview.Columns[3].Name = "Updated/Created";
+ gridview.Columns[3].Width = 125;
+
+ gridview.Columns[4].Name = "Web Link";
+ gridview.Columns[4].Width = 200;
+ }
+
+ //
+ // Set up the file list table view
+ //
+ public void setupFileViewTable(DataGridView gridview)
+ {
+ gridview.DefaultCellStyle = defaultCellStyle;
+ gridview.AlternatingRowsDefaultCellStyle = oddRawCellStyle;
+
+ gridview.ColumnCount = 5;
+ gridview.RowTemplate.MinimumHeight = 100;
+ gridview.Columns[0].Name = "Thumbnail";
+ gridview.Columns[0].Width = 110;
+ DataGridViewCellStyle imgStyle = new DataGridViewCellStyle();
+ imgStyle.Padding = new Padding(5);
+ gridview.Columns[0].DefaultCellStyle = imgStyle;
+
+ gridview.Columns[1].Name = "Title";
+ gridview.Columns[1].Width = 400;
+
+ gridview.Columns[2].Name = "Summary";
+ gridview.Columns[2].Width = 400;
+
+ gridview.Columns[3].Name = "Updated/Created";
+ gridview.Columns[3].Width = 125;
+
+ gridview.Columns[4].Name = "Web Link";
+ gridview.Columns[4].Width = 300;
+ }
+
+ //
+ // Setup the task list table view
+ //
+ public void setupTaskViewTable(DataGridView gridview)
+ {
+ gridview.DefaultCellStyle = defaultCellStyle;
+ gridview.AlternatingRowsDefaultCellStyle = oddRawCellStyle;
+
+ gridview.ColumnCount = 5;
+ gridview.RowTemplate.MinimumHeight = 60;
+
+ gridview.Columns[0].Name = "Title";
+ gridview.Columns[0].Width = 300;
+
+ gridview.Columns[1].Name = "Created by/Assigned to";
+ gridview.Columns[1].Width = 120;
+
+ gridview.Columns[2].Name = "Due Date";
+ gridview.Columns[2].Width = 120;
+
+ gridview.Columns[3].Name = "State";
+ gridview.Columns[3].Width = 80;
+
+ gridview.Columns[4].Name = "Web Link";
+ gridview.Columns[4].Width = 300;
+ }
+
+ //
+ // Open a link in the default web browser
+ //
+ void tp_datagridview_CellContentClick(object sender, DataGridViewCellEventArgs e)
+ {
+ if (this.tp_datagridview[e.ColumnIndex, e.RowIndex] is DataGridViewLinkCell)
+ {
+ string link = this.tp_datagridview[e.ColumnIndex, e.RowIndex].Value.ToString();
+ System.Diagnostics.Process.Start(link);
+ }
+ }
+
+ //
+ // Help links
+ //
+ private void help_label1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ {
+ System.Diagnostics.Process.Start("https://github.com/vispower/teamplatform-api");
+ }
+
+ private void help_label2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
+ {
+ System.Diagnostics.Process.Start("https://teamplatform.com/settings#tab-api-s");
+ }
+
+ //
+ // Utility functions
+ //
+ public string convertDateTime(string date)
+ {
+ if (is_blank(date)) return "";
+ DateTime dt = Convert.ToDateTime(date);
+ return dt.Month + "/" + dt.Day + "/" + dt.Year + " " + dt.Hour + ":" + dt.Minute;
+ }
+ public void showMessage(string msg)
+ {
+ this.msg_box.Text = msg;
+ Application.DoEvents();
+ }
+ public bool is_blank(string str)
+ {
+ if (str == null || str == "") return true;
+ return false;
+ }
+ public string truncate(string str, int maxlength)
+ {
+ if (is_blank(str)) return "";
+ return str.Length <= maxlength ? str : str.Substring(0, maxlength) + "...";
+ }
+ }
+
+}
View
126 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/MainForm.resx
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <metadata name="status_strip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+ <value>17, 17</value>
+ </metadata>
+ <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+ <value>51</value>
+ </metadata>
+</root>
View
36 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Program.cs
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2012 VISPOWER TECHNOLOGY, INC.
+ * All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
+ * You may freely redistribute and use this sample code, with or without modification, provided you include the original copyright notice and use restrictions.
+ *
+ * Disclaimer:
+ * THE SAMPLE CODE IS PROVIDED "AS IS," AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
+ * IN NO EVENT SHALL VISPOWER TECHNOLOGY, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT, ARISING IN ANY WAY OUT OF THE USE OF THIS SAMPLE CODE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * For additional information, contact
+ * support@teamplatform.com
+ *
+ * Oct. 22nd, 2012
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace TeamPlatformAPIExample
+{
+ static class Program
+ {
+ [STAThread]
+ static void Main()
+ {
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new MainForm());
+ }
+ }
+}
View
36 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TeamPlatformAPIExample")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("RFI")]
+[assembly: AssemblyProduct("TeamPlatformAPIExample")]
+[assembly: AssemblyCopyright("Copyright © RFI 2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a5e5fa23-96b3-4695-b683-3371c8950bec")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
View
63 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.269
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace TeamPlatformAPIExample.Properties {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TeamPlatformAPIExample.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
View
117 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/Resources.resx
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
View
26 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.269
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace TeamPlatformAPIExample.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
View
7 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/Properties/Settings.settings
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+ <Profiles>
+ <Profile Name="(Default)" />
+ </Profiles>
+ <Settings />
+</SettingsFile>
View
97 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/TeamPlatformAPIExample.csproj
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{9977A1E1-1A7B-4DC8-A133-6339D4790709}</ProjectGuid>
+ <OutputType>WinExe</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>TeamPlatformAPIExample</RootNamespace>
+ <AssemblyName>TeamPlatformAPIExample</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <TargetFrameworkProfile>
+ </TargetFrameworkProfile>
+ <FileAlignment>512</FileAlignment>
+ <SccProjectName>SAK</SccProjectName>
+ <SccLocalPath>SAK</SccLocalPath>
+ <SccAuxPath>SAK</SccAuxPath>
+ <SccProvider>SAK</SccProvider>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
+ <PlatformTarget>x86</PlatformTarget>
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Runtime.Serialization" />
+ <Reference Include="System.ServiceModel.Web" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="MainForm.cs">
+ <SubType>Form</SubType>
+ </Compile>
+ <Compile Include="MainForm.Designer.cs">
+ <DependentUpon>MainForm.cs</DependentUpon>
+ </Compile>
+ <Compile Include="Program.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="tpAPI\tpModels.cs" />
+ <Compile Include="tpAPI\tpOAuth2.cs" />
+ <EmbeddedResource Include="MainForm.resx">
+ <DependentUpon>MainForm.cs</DependentUpon>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resources.resx</DependentUpon>
+ <DesignTime>True</DesignTime>
+ </Compile>
+ <None Include="app.config" />
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Settings.settings</DependentUpon>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
3  examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/app.config
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<configuration>
+<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
View
BIN  examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.exe
Binary file not shown
View
3  ...s/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.exe.config
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<configuration>
+<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
View
BIN  examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.pdb
Binary file not shown
View
BIN  ...s/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.vshost.exe
Binary file not shown
View
3  ...ample/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.vshost.exe.config
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<configuration>
+<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
View
11 ...ple/TeamPlatformAPIExample/TeamPlatformAPIExample/bin/Release/TeamPlatformAPIExample.vshost.exe.manifest
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
+ <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
+ <security>
+ <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
+ <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
+ </requestedPrivileges>
+ </security>
+ </trustInfo>
+</assembly>
View
112 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/tpAPI/tpModels.cs
@@ -0,0 +1,112 @@
+/*
+ * Copyright © 2012 VISPOWER TECHNOLOGY, INC.
+ * All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
+ * You may freely redistribute and use this sample code, with or without modification, provided you include the original copyright notice and use restrictions.
+ *
+ * Disclaimer:
+ * THE SAMPLE CODE IS PROVIDED "AS IS," AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
+ * IN NO EVENT SHALL VISPOWER TECHNOLOGY, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT, ARISING IN ANY WAY OUT OF THE USE OF THIS SAMPLE CODE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * For additional information, contact
+ * support@teamplatform.com
+ *
+ * Oct. 22nd, 2012
+ *
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace TeamPlatformAPIExample
+{
+ //
+ // Sample TeamPlatform Models - User, Workspace, File and Tasks
+ //
+ // Visit https://github.com/vispower/teamplatform-api for the full list of available models.
+ //
+ public class tpModels
+ {
+ public class Auth
+ {
+ public string access_token { get; set; }
+ public string scope { get; set; }
+ public string refresh_token { get; set; }
+ public string expires_at { get; set; }
+ }
+ public class User
+ {
+ public string name {get; set;}
+ public string email { get; set; }
+ public string picture { get; set; }
+ public string team_name { get; set; }
+
+ public string[] user_info_arr()
+ {
+ string [] arr = { "Name: " + name, "Email: " + email, "Team: " + team_name };
+ return arr;
+ }
+ }
+ public class Workspace
+ {
+ public string id { get; set; }
+ public string title { get; set; }
+ public string description { get; set; }
+ public string created_at { get; set; }
+ public string updated_at { get; set; }
+ public string deleted_at { get; set; }
+ public string comments_count { get; set; }
+ public string files_count { get; set; }
+ public string pages_count { get; set; }
+ public string tasks_count { get; set; }
+ public string members_count { get; set; }
+ public string is_template { get; set; }
+ public string status { get; set; }
+ public tpModels.User owner { get; set; }
+ public string root_folder_id { get; set; }
+ }
+ public class File
+ {
+ public string id { get; set; }
+ public string key { get; set; }
+ public string filename { get; set; }
+ public string ftype { get; set; }
+ public string filesize { get; set; }
+ public string created_at { get; set; }
+ public string updated_at { get; set; }
+ public string deleted_at { get; set; }
+ public string comments_count { get; set; }
+ public string workspace_id { get; set; }
+ public string state { get; set; }
+ public string ancestry { get; set; }
+ public string version { get; set; }
+ public string is_root { get; set; }
+ public string download_count { get; set; }
+ public string small { get; set; }
+ public string big { get; set; }
+ public tpModels.User owner { get; set; }
+ public string root_folder_id { get; set; }
+ }
+ public class Task
+ {
+ public string id { get; set; }
+ public string description { get; set; }
+ public string details { get; set; }
+ public string created_at { get; set; }
+ public string updated_at { get; set; }
+ public string due { get; set; }
+ public string finished_at { get; set; }
+ public string started_at { get; set; }
+ public string workspace_id { get; set; }
+ public string state { get; set; }
+ public string ancestry { get; set; }
+ public string position { get; set; }
+ public string trigger_id { get; set; }
+ public string change_status { get; set; }
+ public tpModels.User assigner { get; set; }
+ public tpModels.User assignee { get; set; }
+ }
+ }
+}
View
392 examples/c# example/TeamPlatformAPIExample/TeamPlatformAPIExample/tpAPI/tpOAuth2.cs
@@ -0,0 +1,392 @@
+/*
+ * Copyright © 2012 VISPOWER TECHNOLOGY, INC.
+ * All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
+ * You may freely redistribute and use this sample code, with or without modification, provided you include the original copyright notice and use restrictions.
+ *
+ * Disclaimer:
+ * THE SAMPLE CODE IS PROVIDED "AS IS," AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
+ * IN NO EVENT SHALL VISPOWER TECHNOLOGY, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT, ARISING IN ANY WAY OUT OF THE USE OF THIS SAMPLE CODE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * For additional information, contact
+ * support@teamplatform.com
+ *
+ * Oct. 22nd, 2012
+ *
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using System.Net;
+using System.Runtime.Serialization.Json;
+
+namespace TeamPlatformAPIExample
+{
+ //
+ // API call parameters
+ //
+ public class QueryParameter
+ {
+ private string name = null;
+ private string value = null;
+
+ public QueryParameter(string name, string value)
+ {
+ this.name = name;
+ this.value = value;
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ public string Value
+ {
+ get { return value; }
+ }
+ }
+
+ //
+ // OAuth2 authentication wrapper class
+ //
+ public class tpOAuth2
+ {
+ public enum Method { GET, POST, PUT, DELETE };
+
+ // Statis parameters
+ static string _APIHost = @"https://teamplatform.com";
+ static string _APIVer = @"/api/v1/";
+ static string _APIBase = _APIHost + _APIVer;
+ /////////////////////////////////////////////////
+
+ private string _token = "";
+ private tpModels.User _user;
+
+ //
+ // Client ID and Secret.
+ //
+ // You need to register client at
+ // https://[Your Domain].teamplatform.com/settings#tab-api-s
+ // To get Client ID, Client Secret
+ //
+ static string API_PARAM_AUTH_PWD = "client_id={0}&"
+ + "client_secret={1}&"
+ + "&username={2}&password={3}&"
+ + "grant_type=password&scope=read write";
+
+ //
+ // Sample TeamPlatorm API commands
+ //
+ static string API_ACCESS_TOKEN = _APIBase + "oauth/access_token";
+ static string API_GET_PROFILE = _APIBase + "profile?access_token=";
+ static string API_GET_WORKSPACES = _APIBase + "workspaces?access_token=";
+ static string API_GET_FILES = _APIBase + "files?access_token=";
+ static string API_GET_TASKS = _APIBase + "tasks?access_token=";
+
+
+ public string Token { get { return _token; } set { _token = value; } }
+ public string APIHost { get { return _APIHost; } set { _APIHost = value; } }
+ public tpModels.User User { get { return _user; } set { _user = value; } }
+
+
+ //
+ // TeamPlatform user sign-in with a password method
+ //
+ public bool tpGetAuthorization(string client_id, string client_secret, string email, string pwd, out string error_msg)
+ {
+ error_msg = "";
+
+ try
+ {
+ StringBuilder sb = new StringBuilder();
+ string postData = sb.AppendFormat(API_PARAM_AUTH_PWD, client_id, client_secret, email, pwd).ToString();
+
+ string response = WebRequest(Method.POST, API_ACCESS_TOKEN, postData);
+ if (response.Length > 0)
+ {
+ DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(tpModels.Auth));
+ MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response));
+ tpModels.Auth jsonR = (tpModels.Auth)ser.ReadObject(ms);
+ ms.Close();
+
+ if (jsonR.access_token != null)
+ {
+ //
+ // Use the token for user API query
+ //
+ this.Token = jsonR.access_token;
+ return true;
+ }
+ }
+ }
+ catch(Exception err)
+ {
+ error_msg = "Fail to sign in.";
+ return false;
+ }
+ error_msg = "Failed to get a server response.";
+ return false;
+ }
+
+ //
+ // Get the user profile after signed in
+ //
+ public bool tpGetProfile(out string error_msg)
+ {
+ error_msg = "";
+
+ try
+ {
+ string url = API_GET_PROFILE + this.Token;
+
+ string response = WebRequest(Method.GET, url, string.Empty);
+ if (response.Length > 0)
+ {
+ DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(tpModels.User));
+ MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response));
+ this.User = (tpModels.User)ser.ReadObject(ms);
+ ms.Close();
+ if (this.User.email != null)
+ {
+ return true;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ error_msg = "Failed to get the user profile.";
+ return false;
+ }
+ error_msg = "Failed to get a server response.";
+ return false;
+ }
+
+ //
+ // Get workspace data
+ //
+ public bool tpGetWorkspaces(IList<QueryParameter> options, out string error_msg, out List<tpModels.Workspace> workspaces)
+ {
+ error_msg = "";
+ workspaces = null;
+
+ try
+ {
+ //
+ // Convert options to a query string
+ //
+ string url = API_GET_WORKSPACES + this.Token + '&' + NormalizeRequestParameters(options);
+
+ string response = WebRequest(Method.GET, url, string.Empty);
+ if (response.Length > 0)
+ {
+ DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<tpModels.Workspace>));
+ MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response));
+ workspaces = (List<tpModels.Workspace>)ser.ReadObject(ms);
+ ms.Close();
+ if (workspaces.Count > 0)
+ {
+ return true;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ error_msg = "Failed to get workspace data";
+ return false;
+ }
+ error_msg = "No workspaces found";
+ return false;
+ }
+
+ //
+ // Get file data
+ //
+ public bool tpGetFiles(IList<QueryParameter> options, out string error_msg, out List<tpModels.File> files)
+ {
+ error_msg = "";
+ files = null;
+ try
+ {
+ //
+ // Convert options to a query string
+ //
+ string url = API_GET_FILES + this.Token + '&' + NormalizeRequestParameters(options);
+
+ string response = WebRequest(Method.GET, url, string.Empty);
+ if (response.Length > 0)
+ {
+ DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<tpModels.File>));
+ MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response));
+ files = (List<tpModels.File>)ser.ReadObject(ms);
+ ms.Close();
+ if (files.Count > 0)
+ {
+ return true;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ error_msg = "Failed to get file data.";
+ return false;
+ }
+ error_msg = "No files found.";
+ return false;
+ }
+
+ //
+ // Get task data
+ //
+ public bool tpGetTasks(IList<QueryParameter> options, out string error_msg, out List<tpModels.Task> tasks)
+ {
+ error_msg = "";
+ tasks = null;
+
+ try
+ {
+ //
+ // Convert options to a query string
+ //
+ string url = API_GET_TASKS + this.Token + '&' + NormalizeRequestParameters(options);
+
+ string response = WebRequest(Method.GET, url, string.Empty);
+ if (response.Length > 0)
+ {
+ DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(List<tpModels.Task>));
+ MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(response));
+ tasks = (List<tpModels.Task>)ser.ReadObject(ms);
+ ms.Close();
+ if (tasks.Count > 0)
+ {
+ return true;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ error_msg = "Failed to get task data.";
+ return false;
+ }
+ error_msg = "No tasks found";
+ return false;
+ }
+
+ //
+ // WebRequest wrapper method
+ //
+ public string WebRequest(Method method, string url, string postData)
+ {
+ HttpWebRequest webRequest = null;
+ StreamWriter requestWriter = null;
+ string responseData = "";
+
+ webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
+ webRequest.Method = method.ToString();
+ webRequest.ServicePoint.Expect100Continue = false;
+
+ if (method == Method.POST)
+ {
+ webRequest.ContentType = "application/x-www-form-urlencoded";
+
+ //
+ // POST the data.
+ //
+ requestWriter = new StreamWriter(webRequest.GetRequestStream());
+ try
+ {
+ requestWriter.Write(postData);
+ }
+ catch
+ {
+ throw;
+ }
+ finally
+ {
+ requestWriter.Close();
+ requestWriter = null;
+ }
+ }
+
+ responseData = WebResponseGet(webRequest);
+
+ webRequest = null;
+
+ return responseData;
+
+ }
+
+ //
+ // Process the web response
+ //
+ public string WebResponseGet(HttpWebRequest webRequest)
+ {
+ StreamReader responseReader = null;
+ string responseData = "";
+
+ try
+ {
+ responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
+ responseData = responseReader.ReadToEnd();
+ }
+ catch
+ {
+ throw;
+ }
+ finally
+ {
+ webRequest.GetResponse().GetResponseStream().Close();
+ responseReader.Close();
+ responseReader = null;
+ }
+
+ return responseData;
+ }
+
+ //
+ // Normalize the request parameters
+ //
+ protected string NormalizeRequestParameters(IList<QueryParameter> parameters)
+ {
+ StringBuilder sb = new StringBuilder();
+ QueryParameter p = null;
+ for (int i = 0; i < parameters.Count; i++)
+ {
+ p = parameters[i];
+ sb.AppendFormat("{0}={1}", p.Name, p.Value);
+
+ if (i < parameters.Count - 1)
+ {
+ sb.Append("&");
+ }
+ }
+
+ return sb.ToString();
+ }
+
+ //
+ // Encode URL string
+ //
+ public string UrlEncode(string value)
+ {
+ string unreservedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~";
+ StringBuilder result = new StringBuilder();
+
+ foreach (char symbol in value)
+ {
+ if (unreservedChars.IndexOf(symbol) != -1)
+ {
+ result.Append(symbol);
+ }
+ else
+ {
+ result.Append('%' + String.Format("{0:X2}", (int)symbol));
+ }
+ }
+ return result.ToString();
+ }
+ }
+}
View
11 examples/c# example/c-sharp.md
@@ -0,0 +1,11 @@
+TeamPlatform API Examples - C# Windows Application
+============================
+
+> Download the source code and give it a try.
+
+Requirements
+--------
+
+* Windows OS(XP,Server,7)
+* .Net Framework 3.5
+* Development : Visual Studio 2010
View
10 examples/examples.md
@@ -0,0 +1,10 @@
+TeamPlatform API Examples
+============================
+
+> Example applications using Teamplatform API
+
+Examples
+--------
+
+* [C# Windows Application](https://github.com/vispower/teamplatform-api/blob/master/c# example)
+* More to come...
Please sign in to comment.
Something went wrong with that request. Please try again.