本文整理汇总了C#中Connection.SendRequest方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.SendRequest方法的具体用法?C# Connection.SendRequest怎么用?C# Connection.SendRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection.SendRequest方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnTest_Click
private void btnTest_Click(object sender, EventArgs e)
{
txtInfo.Text = string.Empty;
txtUserInfo.Text = string.Empty;
txtPassport.Text = string.Empty;
Connection con = new Connection();
con.EnableSession = false;
con.EnableSecureTunnel = true;
SecurityToken stt = null;
try
{
stt = this.GetSecurityToken();
con.Connect(MainForm.CurrentProject.DevSite.AccessPoint, _contract.Name, stt);
txtInfo.Text = "連線成功";
}
catch (Exception ex)
{
txtInfo.Text = "連線失敗 : \n" + ex.Message;
return;
}
try
{
Envelope env = con.SendRequest("DS.Base.Connect", new Envelope());
txtUserInfo.Text = env.Headers["UserInfo"];
xmlSyntaxLanguage1.FormatDocument(txtUserInfo.Document);
}
catch
{
}
}
示例2: buttonX1_Click
private void buttonX1_Click(object sender, EventArgs e)
{
//FISCA.Authentication.DSAServices.p
Connection con = new Connection();
//取得局端登入後Greening發的Passport,並登入指定的Contract
con.Connect(FISCA.Authentication.DSAServices.DefaultDataSource.AccessPoint, "ischool.kh.central_office.user", FISCA.Authentication.DSAServices.PassportToken);
//取得該Contract所發的Passport
Envelope Response = con.SendRequest("DS.Base.GetPassportToken", new Envelope());
PassportToken Passport = new PassportToken(Response.Body);
//TODO:拿此Passport登入各校
Connection conSchool = new Connection();
conSchool.Connect("dev.jh_kh", "ischool.kh.central_office", Passport);
}
示例3: GetSecurityToken
internal SecurityToken GetSecurityToken()
{
if (!chkPassport.Checked)
{
return new BasicSecurityToken(txtUser.Text, txtPwd.Text);
}
else
{
Connection greenCon = new Connection();
greenCon.EnableSecureTunnel = true;
greenCon.EnableSession = true;
greenCon.Connect(txtProvider.Text, string.Empty, txtUser.Text.Trim(), txtPwd.Text);
Envelope rsp = greenCon.SendRequest("DS.Base.GetPassportToken", new Envelope());
txtPassport.Text = rsp.Body.XmlString;
xmlSyntaxLanguage1.FormatDocument(txtPassport.Document);
PassportSecurityToken stt = new PassportSecurityToken(rsp.Body.XmlString);
return stt;
}
}
示例4: ConvertDSNS
private string ConvertDSNS(string name)
{
if(name.StartsWith("http://",true,CultureInfo.CurrentCulture))
return name;
if(name.StartsWith("https://",true,CultureInfo.CurrentCulture))
return name;
Connection con = new Connection();
con.EnableSession = false;
con.EnableSecureTunnel = false;
con.Connect("http://dsns1.ischool.com.tw/dsns/", "dsns", new PublicSecurityToken());
XmlHelper h = new XmlHelper("<a>" + name + "</a>");
Envelope env = con.SendRequest("DS.NameService.GetDoorwayURL", new Envelope(h));
h = new XmlHelper(env.Body);
string value = h.GetText(".");
if (string.IsNullOrWhiteSpace(value))
throw new Exception("DSNS 名稱解析失敗");
return value;
}
示例5: Test
private void Test()
{
string url = this.ConvertDSNS(txtAccessPoint.Text);
Connection con = new Connection();
con.EnableSecureTunnel = true;
SecurityToken st;
if (rbBasic.Checked)
{
st = new BasicSecurityToken(txtBasicAccount.Text, txtBasicPassword.Text);
}
else
{
Connection c = new Connection();
c.EnableSecureTunnel = true;
c.Connect(txtIssuer.Text, "", txtIssuerAccount.Text, txtIssuerPassword.Text);
Envelope env = c.SendRequest("DS.Base.GetPassportToken", new Envelope());
st = new PassportSecurityToken(env.Body.XmlString);
}
con.Connect(url, txtContract.Text, st);
}
示例6: GetSecurityToken
internal SecurityToken GetSecurityToken()
{
if (_inited)
{
if (rbBasic.Checked)
{
return new BasicSecurityToken(txtUser.Text, txtPwd.Text);
}
else
{
Connection greenCon = new Connection();
greenCon.EnableSecureTunnel = true;
greenCon.EnableSession = true;
greenCon.Connect(txtProvider.Text, string.Empty, txtUser.Text.Trim(), txtPwd.Text);
Envelope rsp = greenCon.SendRequest("DS.Base.GetPassportToken", new Envelope());
PassportSecurityToken stt = new PassportSecurityToken(rsp.Body.XmlString);
return stt;
}
}
else
{
XmlHelper xml = MainForm.Storage.GetPropertyXml("ServiceTestTemp", _contractUniqName);
if (xml == null)
{
return new BasicSecurityToken(MainForm.CurrentProject.DevSite.User, MainForm.CurrentProject.DevSite.Password);
}
else
{
bool passport = xml.TryGetBoolean("UsePassport", false);
if (passport)
{
Connection greenCon = new Connection();
greenCon.EnableSecureTunnel = true;
greenCon.EnableSession = true;
greenCon.Connect(xml.GetText("Auth"), string.Empty, xml.GetText("User"), xml.GetText("Password"));
Envelope rsp = greenCon.SendRequest("DS.Base.GetPassportToken", new Envelope());
return new PassportSecurityToken(rsp.Body.XmlString);
}
else
{
return new BasicSecurityToken(xml.GetText("User"), xml.GetText("Password"));
}
}
}
}
示例7: Login
private void Login()
{
string greeningURL = "http://10.1.1.163/greening2/shared";
string moduleURL = "http://10.1.1.163/modules/shared";
XmlDocument doc = new XmlDocument();
string filename = Path.Combine(Environment.CurrentDirectory, "Setup.config");
this.ShowMessage("載入設定檔");
if (File.Exists(filename))
{
doc.Load(filename);
XmlHelper config = new XmlHelper(doc.DocumentElement);
greeningURL = config.GetText("GreeningAccessPoint");
moduleURL = config.GetText("ModuleAccessPoint");
}
try
{
this.ShowMessage("登入 ischool ....");
Connection greenCon = new Connection();
greenCon.EnableSecureTunnel = true;
greenCon.EnableSession = false;
try
{
greenCon.Connect(greeningURL, "user", txtUser.Text.Trim(), txtPassword.Text);
}
catch (Exception ex)
{
throw new Exception("ischool Account 認證失敗" + ex.Message);
}
Envelope rsp = greenCon.SendRequest("DS.Base.GetPassportToken", new Envelope());
PassportSecurityToken stt = new PassportSecurityToken(rsp.Body.XmlString);
XmlHelper h1 = new XmlHelper(rsp.Body);
string id = h1.GetText("Content/Attributes/ID");
string ftpUser = string.Empty;
string ftpPassword = string.Empty;
string ftpUrl = string.Empty;
bool succeedLoginModuleService = false;
Connection modCon = null;
try
{
this.ShowMessage("載入線上儲存空間設定...");
modCon = new Connection();
modCon.EnableSession = true;
modCon.EnableSecureTunnel = true;
modCon.Connect(moduleURL, "developer", stt);
Envelope env = modCon.SendRequest("GetFTPInfo", new Envelope());
XmlHelper h = new XmlHelper(env.Body);
ftpUser = TripleDESHelper.Decrypt(h.GetText("User"), USE_KEY);
ftpPassword = TripleDESHelper.Decrypt(h.GetText("Password"), USE_KEY);
ftpUrl = TripleDESHelper.Decrypt(h.GetText("FTP"), USE_KEY);
succeedLoginModuleService = true;
}
catch
{
this.ShowMessage("載入失敗!");
succeedLoginModuleService = false;
}
string pwd = string.Empty;
if (chkRemember.Checked)
pwd = txtPassword.Text;
MainForm.Storage.SetPropertyValues("LoginName", txtUser.Text, pwd);
MainForm.Storage.SetProperty("LastLoginName", txtUser.Text);
MainForm.Storage.SetProperty("LastLoginPassword", pwd);
MainForm.Storage.SetProperty("RememberPassword", chkRemember.Checked.ToString().ToLower());
if (Logined != null)
{
this.ShowMessage("登入開發站台...");
LoginEventArgs arg = new LoginEventArgs();
arg.FtpPassword = ftpPassword;
arg.FtpUser = ftpUser;
arg.FtpURL = ftpUrl;
arg.GreeningConnection = greenCon;
arg.ModuleConnection = modCon;
arg.SetModuleConnectionInfo(moduleURL);
arg.LoginUser = txtUser.Text;
arg.GreeningID = id;
arg.SucceedModuleLogin = succeedLoginModuleService;
this.ShowMessage("載入開發站台資訊");
Logined.Invoke(this, arg);
this.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.ShowMessage("※請輸入 ischool Account 密碼");
}
}
示例8: Execute
private void Execute()
{
Connection con = new Connection();
con.EnableSecureTunnel = cmSSLEnable.Checked;
SecurityToken stt = null;
try
{
stt = _sttForm.GetSecurityToken();
con.Connect(txtSiteURL.Text, txtContract.Text, stt); ;
}
catch
{
DialogResult dr = MessageBox.Show("Service 認證失敗 ! \n 是否開啟認證設定畫面? ", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);
if (dr == System.Windows.Forms.DialogResult.Yes)
_sttForm.ShowDialog();
return;
}
Stopwatch w = new Stopwatch();
w.Start();
XmlHelper req = new XmlHelper();
if (!string.IsNullOrWhiteSpace(txtRequest.Text))
req = XmlHelper.ParseAsHelper(txtRequest.Text);
XmlHelper h = new XmlHelper();
try
{
Envelope re = new Envelope(req);
Envelope env = con.SendRequest(txtService.Text, re);
txtResponse.Text = env.Body.XmlString;
try
{
h = new XmlHelper(env.Body);
txtResponse.Text = h.XmlString;
txtRequest.FormatXml();
}
catch { }
txtHeader.Text = env.Headers.XmlString;
txtHeader.FormatXml();
}
catch (DSAServerException ex)
{
txtResponse.Text = ex.Response;
txtResponse.FormatXml();
}
catch (Exception ex)
{
txtResponse.Text = ex.Message;
}
w.Stop();
tsLabelTime.Text = w.ElapsedMilliseconds.ToString();
try
{
string dir = Path.Combine(Environment.CurrentDirectory, "TestServiceConfig");
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
string filename = Path.Combine(dir, this.ServiceUniqName);
XmlDocument doc = new XmlDocument();
doc.LoadXml(txtRequest.Text);
doc.Save(filename);
}
catch { }
}
示例9: DeployConnect
internal static Connection DeployConnect(XmlElement siteElement)
{
XmlHelper h = new XmlHelper(siteElement);
string accesspoint = h.GetText("AccessPoint");
string contract = h.GetText("Contract");
string authType = h.GetText("Authentication/@Type").ToLower();
string username = h.GetText("Authentication/UserName");
string password = h.GetText("Authentication/Password");
string issuer = h.GetText("Authentication/Issuer");
string url = ConvertDSNS(accesspoint);
Connection con = new Connection();
con.EnableSecureTunnel = true;
SecurityToken st;
if (authType == "basic")
{
st = new BasicSecurityToken(username, password);
}
else
{
Connection c = new Connection();
c.EnableSecureTunnel = true;
c.Connect(issuer, "", username, password);
Envelope env = c.SendRequest("DS.Base.GetPassportToken", new Envelope());
st = new PassportSecurityToken(env.Body.XmlString);
}
con.Connect(url, contract, st);
return con;
}
示例10: buttonX1_Click
private void buttonX1_Click(object sender, EventArgs e)
{
string SelectedDSNS = "" + cmbSchool.SelectedValue;
string School = (cmbSchool.SelectedItem as School).Title;
try
{
Connection con = new Connection();
//取得局端登入後Greening發的Passport,並登入指定的Contract
con.Connect(FISCA.Authentication.DSAServices.DefaultDataSource.AccessPoint, "ischool.kh.central_office.user", FISCA.Authentication.DSAServices.PassportToken);
//取得該Contract所發的Passport
Envelope Response = con.SendRequest("DS.Base.GetPassportToken", new Envelope());
PassportToken Passport = new PassportToken(Response.Body);
//TODO:拿此Passport登入各校
Connection conSchool = new Connection();
conSchool.Connect(SelectedDSNS, "ischool.kh.central_office", Passport);
Response = conSchool.SendRequest("_.GetStudentHighConcern", new Envelope());
//<Class>
// <ClassName>101</ClassName>
// <StudentCount>25</StudentCount>
// <Lock />
// <Comment />
// <NumberReduceSum />
// <ClassStudentCount>25</ClassStudentCount>
//</Class>
//班級名稱、實際人數、編班人數、編班順位、編班鎖定、鎖定備註
XElement elmResponse = XElement.Load(new StringReader(Response.Body.XmlString));
grdClassOrder.Rows.Clear();
foreach (XElement elmStudent in elmResponse.Elements("Student"))
{
string ClassName = elmStudent.ElementText("ClassName");
string StudentName = elmStudent.ElementText("StudentName");
string SeatNo = elmStudent.ElementText("SeatNo");
string HighConcern = elmStudent.ElementText("HighConcern");
string NumberReduce = elmStudent.ElementText("NumberReduce");
string DocNo = elmStudent.ElementText("DocNo");
grdClassOrder.Rows.Add(
School,
StudentName,
ClassName,
SeatNo,
NumberReduce,
DocNo
);
}
}
catch (Exception ve)
{
MessageBox.Show(ve.Message);
}
}
示例11: SaveToSite
private void SaveToSite()
{
err.Clear();
if (string.IsNullOrWhiteSpace(txtAccessPoint.Text))
{
err.SetError(txtAccessPoint, "主機位置不可空白");
return;
}
XElement result = GetAppDeployElement();
Connection con = new Connection();
try
{
con.Connect(txtAccessPoint.Text, txtContract.Text, txtUserName.Text, txtPassword.Text);
XmlHelper h = new XmlHelper(result.ToString(SaveOptions.None));
con.SendRequest("Server.DeployApplication", new Envelope(h));
con.SendRequest("LoadBalance.ReloadServer", new Envelope());
}
catch (Exception ex)
{
MessageBox.Show("部署時發生錯誤\n" + ex.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
MessageBox.Show("儲存完成", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
示例12: ImportFromSite
private void ImportFromSite()
{
err.Clear();
if (string.IsNullOrWhiteSpace(txtAccessPoint.Text))
{
err.SetError(txtAccessPoint, "主機位置不可空白");
return;
}
Connection connection = new Connection();
connection.EnableSecureTunnel= true;
try
{
connection.Connect(txtAccessPoint.Text, txtContract.Text, txtUserName.Text, txtPassword.Text);
}
catch (Exception ex)
{
err.SetError(txtAccessPoint, "主機連線失敗 : \n" + ex.Message);
return;
}
XmlHelper h = new XmlHelper();
h.AddElement(".","ApplicationName","shared");
Envelope env = new Envelope(h);
env = connection.SendRequest("Server.ExportApplication", env);
h = new XmlHelper(env.Body);
Console.WriteLine(h.XmlString);
this.Import(h.GetElement("."));
}
示例13: buttonX1_Click
private void buttonX1_Click(object sender, EventArgs e)
{
string SelectedDSNS = "" + cmbSchool.SelectedValue;
string School = (cmbSchool.SelectedItem as School).Title;
try
{
Connection con = new Connection();
//取得局端登入後Greening發的Passport,並登入指定的Contract
con.Connect(FISCA.Authentication.DSAServices.DefaultDataSource.AccessPoint, "ischool.kh.central_office.user", FISCA.Authentication.DSAServices.PassportToken);
//取得該Contract所發的Passport
Envelope Response = con.SendRequest("DS.Base.GetPassportToken", new Envelope());
PassportToken Passport = new PassportToken(Response.Body);
//TODO:拿此Passport登入各校
Connection conSchool = new Connection();
conSchool.Connect(SelectedDSNS, "ischool.kh.central_office", Passport);
Response = conSchool.SendRequest("_.GetClassStudentCount", new Envelope());
//<Class>
// <ClassName>101</ClassName>
// <StudentCount>25</StudentCount>
// <Lock />
// <Comment />
// <NumberReduceSum />
// <ClassStudentCount>25</ClassStudentCount>
//</Class>
//班級名稱、實際人數、編班人數、編班順位、編班鎖定、鎖定備註
XElement elmResponse = XElement.Load(new StringReader(Response.Body.XmlString));
grdClassOrder.Rows.Clear();
List<ClassOrder> ClassOrders = new List<ClassOrder>();
foreach (XElement elmClass in elmResponse.Elements("Class"))
{
ClassOrder vClassOrder = new ClassOrder();
ClassOrders.Add(vClassOrder);
string ClassName = elmClass.ElementText("ClassName");
string StudentCount = elmClass.ElementText("StudentCount");
string ClassStudentCount = elmClass.ElementText("ClassStudentCount");
string NumberReduceSum = elmClass.ElementText("NumberReduceSum");
if (!string.IsNullOrWhiteSpace(NumberReduceSum))
ClassStudentCount = ClassStudentCount + "(" + StudentCount + "+" + NumberReduceSum + ")";
string NumberReduceCount = elmClass.ElementText("NumberReduceCount");
string Lock = elmClass.ElementText("Lock");
string Comment = elmClass.ElementText("Comment");
string ClassOrder = string.Empty;
vClassOrder.ClassName = ClassName;
vClassOrder.StudentCount = StudentCount;
vClassOrder.ClassStudentCount = ClassStudentCount;
vClassOrder.NumberReduceSum = NumberReduceSum;
vClassOrder.NumberReduceCount = NumberReduceCount;
vClassOrder.Lock = Lock;
vClassOrder.Comment = Comment;
vClassOrder.ClassOrderNumber = ClassOrder;
vClassOrder.ClassStudentCountValue = StudentCount.GetInt() + NumberReduceSum.GetInt();
}
ClassOrders.CalculateClassOrder();
foreach(ClassOrder vClassOrder in ClassOrders)
{
grdClassOrder.Rows.Add(
School,
vClassOrder.ClassName,
vClassOrder.StudentCount,
vClassOrder.ClassStudentCount,
vClassOrder.NumberReduceCount,
vClassOrder.ClassOrderNumber,
vClassOrder.Lock,
vClassOrder.Comment);
}
}
catch (Exception ve)
{
MessageBox.Show(ve.Message);
}
}