public FortViewData(String gvType) { this.gvType = gvType; this.mapper = new FortMapper(); this.setting = Setting.Load(this.GvType); }
public static Setting Load(String gvType) { var set = new Setting(); if (gvType == "FE") { set.TargetPath = Properties.Settings.Default.TargetPath; set.FileHeader = Properties.Settings.Default.FileHeader; set.ServerUrl = Properties.Settings.Default.ServerUrl; set.ServerKey = Properties.Settings.Default.ServerKey; set.AuthId = Properties.Settings.Default.AuthId; set.AuthPass = Properties.Settings.Default.AuthPass; set.GvType = gvType; } else if (gvType == "TE") { set.TargetPath = Properties.Settings.Default.TargetPathTe; set.FileHeader = Properties.Settings.Default.FileHeaderTe; set.ServerUrl = Properties.Settings.Default.ServerUrlTe; set.ServerKey = Properties.Settings.Default.ServerKeyTe; set.AuthId = Properties.Settings.Default.AuthIdTe; set.AuthPass = Properties.Settings.Default.AuthPassTe; set.GvType = gvType; } else { throw new Exception("Unknown Type"); } return set; }
private String PostServer(String path, String data, String method, Setting set) { if (set == null) { throw new System.Net.WebException(); } Uri uri = new Uri(set.ServerUrl + path); client.Credentials = new NetworkCredential(set.AuthId, set.AuthPass); NameValueCollection vc = new NameValueCollection(); vc.Add("k", set.ServerKey); vc.Add("d", data); if (method == "put" || method == "delete") { vc.Add("_method", method); } return Encoding.UTF8.GetString(client.UploadValues(uri, vc)); }