-
Notifications
You must be signed in to change notification settings - Fork 3
/
HASCheckDlg.cs
141 lines (117 loc) · 3.78 KB
/
HASCheckDlg.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Windows;
using Perforce.P4;
using System.Threading;
namespace P4EXP
{
public partial class HASCheckDlg : Form
{
internal string user = "";
internal string port = "";
internal string path = "";
internal bool launch = false;
public Repository Repository;
public Credential Credential;
public bool ExternalAuth=false;
public HASCheckDlg()
{
InitializeComponent();
}
public HASCheckDlg(Repository repository)
{
Repository = repository;
InitializeComponent();
Text = string.Format(Properties.Resources.P4EXP,
user, port);
pictureBox.Image = Properties.Resources.HMFA_spinner_78x78;
authenticatingGridLbl.Text = Properties.Resources.HAS_Authenticating;
timeoutGridLbl.Text = Properties.Resources.HAS_Timeout;
}
private void LaunchingHMFA_Shown(object sender, EventArgs e)
{
return;
}
//public void HASLogin(Repository repository)
//{
// Repository = repository;
// bool test = false;
// P4Server p4Server = Repository.Connection.getP4Server();
// if (p4Server!=null)
// {
// test = p4Server.UrlHandled();
// }
// Task<Credential> task = Task.Run<Credential>(async () => await AsyncLogin());
// Thread.Sleep(3000);
// test = Repository.Connection.getP4Server().UrlHandled();
// if (test)
// {
// while(!task.IsCompleted)
// {
// ShowDialog();
// }
// Close();
// }
// return;
//}
public new DialogResult ShowDialog()
{
bool test = false;
P4Server p4Server = Repository.Connection.getP4Server();
if (p4Server != null)
{
test = p4Server.UrlHandled();
}
Task<Credential> task = Task.Run<Credential>(async () => await AsyncLogin());
Thread.Sleep(3000);
test = Repository.Connection.getP4Server().UrlHandled();
if (test)
{
while (!task.IsCompleted)
{
base.ShowDialog();
}
DialogResult = DialogResult.OK;
base.Close();
return DialogResult;
}
return DialogResult.Cancel;
}
public async Task<Credential> AsyncLogin()
{
Credential = null;
try
{
Credential = await Task.Run(() => Repository.Connection.Login("",null));
if (Credential == null)
{
if (Repository.Connection.LastResults.TaggedOutput != null)
{
foreach(TaggedObject keyValuePairs in Repository.Connection.LastResults.TaggedOutput)
{
if (keyValuePairs.ContainsKey("TicketExpiration"))
{
ExternalAuth = true;
break;
}
}
}
}
}
catch (Exception)
{
}
DialogResult = DialogResult.OK;
base.Close();
return Credential;
}
}
}