예제 #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 TimeTrackingModel(TeamPulseApp app)
        {
            this.App = app;
            this.currentUser = App.Users.GetCurrent();

            StartTrackTimeCommand = new RelayCommand(StartTrackTimeExecute, StartTrackTimeCanExecute);
            StopTrackTimeCommand = new RelayCommand(StopTrackTimeExecute, StopTrackTimeCanExecute);

            LoadData();

            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
        }
        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);
            }
        }