예제 #1
0
        public virtual string Login(string Username, string Password, string Domain)
        {
            var settings = new TeamPulseAppSettings()
            {
                SiteUrl = System.Configuration.ConfigurationManager.AppSettings["TeamPulseUrl"],
                UseWindowsAuth = true,
                Username = Username,
                Password = Password,
                Domain = Domain
            };

            TeamPulseApp app = new TeamPulseApp(settings);
            app.Login();
            DateTime date = DateTime.Now;
            Iteration iteration = app.Iterations.GetAll("$filter=startDate lt DateTime'" + date.ToString("yyyy-MM-dd") + "' and endDate gt DateTime'" + date.ToString("yyyy-MM-dd") + "'&$orderby=startDate desc").results.FirstOrDefault();
            User user = app.Users.GetCurrent();

            var result = new {
                iteration = new {
                    id = iteration.id,
                    startDate = iteration.startDate.ToString("yyyy-MM-dd"),
                    endDate = iteration.endDate.ToString("yyyy-MM-dd")
                },
                accountInfo = new
                {
                    displayName = user.displayName
                }
            };

            return JsonConvert.SerializeObject(result);
        }
 public TeamPulseApp(TeamPulseAppSettings settings)
 {
     this.settings = settings;
 }
        private void LogonExecute(object arg)
        {
            try
            {
                var settings = new TeamPulseAppSettings()
                {
                    SiteUrl = this.TeamPulseUrl,
                    Username = this.UserName,
                    Password = this.Password,
                    Domain = this.AuthenticateWithUserAndPassword ? this.Domain : null
                };

                var app = new TeamPulseApp(settings);
                app.Login();

                ((App)Application.Current).TeamPulseApp = app;

                OnSuccessfulLogin();
            }
            catch (ApplicationException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }