521 lines
28 KiB
C#
521 lines
28 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Web.Mvc;
|
|
using System.Security.Principal;
|
|
using System.Security.Cryptography;
|
|
namespace NP.Base
|
|
{
|
|
public partial class BaseController : Controller
|
|
{
|
|
protected override void OnException(ExceptionContext filterContext)
|
|
{
|
|
if (filterContext == null) {return;}
|
|
var ex = filterContext.Exception ?? new Exception("No further information exists.");
|
|
|
|
try{SetError(filterContext.RequestContext.HttpContext.Request.Url + ":" + ex.Message + ex.StackTrace + Server.UrlDecode(filterContext.HttpContext.Request.Params.ToString()));}
|
|
catch (Exception ex2) {Logger.Error(ex.Message + ex2.Message, ex);}
|
|
TempData["err"] = filterContext.RequestContext.HttpContext.Request.Url + ":" + ex.Message + ex.StackTrace;
|
|
filterContext.Result = new RedirectResult("/Account/Error?_code=" + ENUM.JSONCode.NoLogin + "&_msg=인증없음");
|
|
}
|
|
protected void SetError(String err){Dao.Save("sys.error", new System.Collections.Hashtable() { { "err", err },{"userno",SUserInfo.UserNo } });}
|
|
protected override void OnActionExecuting(ActionExecutingContext filterContext)
|
|
{
|
|
Response.Headers.Remove("Server");
|
|
Response.AddHeader("P3P", "CP=\"ALL DSP COR MON LAW IVDi HIS IVAi DELi SAMi OUR LEG PHY UNI ONL DEM STA INT NAV PUR FIN OTC GOV\"");
|
|
Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
|
|
Response.Cache.SetNoStore();
|
|
Response.Cache.SetRevalidation(System.Web.HttpCacheRevalidation.AllCaches);
|
|
|
|
//Response.Cache.SetExpires(DateTime.Now);
|
|
//Response.Cache.SetMaxAge(new TimeSpan(0, 0, 30));
|
|
ViewBag.IsHome = false;
|
|
ViewBag.SSUserNo = 0;
|
|
ViewBag.SSUserName = "";
|
|
ViewBag.SSUserType = 0;
|
|
ViewBag.SSASNo = 0;
|
|
ViewBag.SSUserInfo = "";
|
|
ViewBag.SSLoginKey = 0;
|
|
ViewBag.SSLoginTime = DateTime.Now.ToString("yyMMddHHmmss");
|
|
ViewBag.SSUIP = GetUserIP();
|
|
ViewBag.SiteTitle = "영남건설기술교육원";
|
|
ViewBag.AssignLogo = string.Empty;
|
|
ViewBag.isPayTest = GetConfig("ispaytest");
|
|
var suiv = TopMenuNo == 1 ? SUI : SUIF;
|
|
var suitv = TopMenuNo == 1 ? SUIT : SUIFT;
|
|
//디버그로그
|
|
if ("Y".Equals(GetConfig("isdebug")))
|
|
{
|
|
var rtn = System.Threading.Tasks.Task.Run(async () => Console.WriteLine(await Dao.Log(
|
|
new NP.Model.PageLog() { uno = SUserInfo.UserNo, uip = GetUserIP(), logsite = 1, loginfo = Request.Url.ToString() + Request.Params.ToString() })));
|
|
}
|
|
var newck = filterContext.HttpContext.Request.Cookies[suiv];
|
|
if (TopMenuNo == 2 && newck == null)
|
|
{
|
|
newck = filterContext.HttpContext.Request.Cookies[SUIFCROOM];
|
|
}
|
|
if (newck != null)
|
|
{
|
|
var sui = DecString(newck.Value).Split('$');
|
|
//var sui = DecString("kMA1yvFp2GPs5aP8fUuRwYCWEamo5aHhb1Mlg6m+T9ef07yi4y+7K11xRQqyQHgI/gjzLYLNrqEIGd1GYUIKjZp5iLFJY+jdFoO95T9LrVdk6reEo8Yz4aToiMV67F3citUUG+Kuw1aUngmft+OKZg==x").Split('$');
|
|
if (sui.Length > 8 && sui[0] == SUIDATE)
|
|
{
|
|
//디버그로그
|
|
if ("Y".Equals(GetConfig("isdebug")))
|
|
{
|
|
var rtn = System.Threading.Tasks.Task.Run(async () => Console.WriteLine(await Dao.Log(
|
|
new NP.Model.PageLog() { uno = SUserInfo.UserNo, uip = GetUserIP(), logsite = 1, loginfo = Request.Url.PathAndQuery })));
|
|
}
|
|
ViewBag.SSUserNo = SUserInfo.UserNo = Convert.ToInt32(sui[1]);
|
|
ViewBag.SSUserName = SUserInfo.UserName = sui[2];
|
|
ViewBag.SSUserType = SUserInfo.UserType = Convert.ToInt32(sui[3]);
|
|
ViewBag.SSASNo = SUserInfo.ASNo = Convert.ToInt32(sui[4]);
|
|
ViewBag.SSUserInfo = SUserInfo.UserInfo = sui[5];//관리자가 사용자backdoor진입시 "usertype.userno" 값으로 사용자 세션 제거 안하도록 사용하는 구분자 필드
|
|
ViewBag.SSLoginKey = SUserInfo.LoginKey = Convert.ToInt32(sui[6]); //로그인키
|
|
ViewBag.SSLoginTime = sui[7];
|
|
//filterContext.Result = new RedirectResult("/Account/Error?_code=9991");
|
|
//최근서버접속시간이 30분 초과되었고 현재시간이 18시 이후라면 자동로그아웃 처리
|
|
//또는 최근서버접속시간이 8시간(480분) 초과되었다면 자동로그아웃 처리
|
|
//로그인키가 다르다면 로그아웃처리
|
|
if (SUserInfo.UserNo > 0 && !Request.Url.AbsolutePath.ToUpper().Equals("/ACCOUNT/INDEX") && !Request.Url.AbsolutePath.ToUpper().Equals("/ACCOUNT/LOGOUT"))
|
|
{
|
|
try
|
|
{
|
|
var tc = Request.Cookies.Get(suitv);
|
|
if (tc == null || string.IsNullOrEmpty(tc.Value) || Convert.ToDateTime(DecString(tc.Value)).AddHours(8) < DateTime.Now)
|
|
{
|
|
CookieClear(null, true);
|
|
if (Request.IsAjaxRequest())
|
|
{
|
|
filterContext.Result = new RedirectResult("/Account/Error?_code=9991");
|
|
}
|
|
else
|
|
{
|
|
filterContext.Result = new RedirectResult("/Account/Index?istimeout=true");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//tc.Value = EncString(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
//Response.Cookies.Add(tc);
|
|
Response.Cookies[suitv].Value = EncString(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
//상시 db접속요청(쪽지수, 알림 수 등) 작업은 여기서 일괄처리해야 성능향상됨
|
|
ViewBag.Main3MAlarmCount = ViewBag.MainMemoNotCount = 0;
|
|
var data = new List<NP.Model.Data>() { };
|
|
if (Request.IsAjaxRequest())
|
|
{
|
|
data = Dao.Get<NP.Model.Data>("common.check.loginkey", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo }, { "loginkey", SUserInfo.LoginKey }, { "IsDupCheck", IsDupCheck } }).ToList();
|
|
if (data.Count() < 1)
|
|
{
|
|
CookieClear(null, true);
|
|
filterContext.Result = new RedirectResult("/Account/Error?_code=9991");
|
|
}
|
|
}
|
|
else if (TopMenuNo == 1)
|
|
{
|
|
//관리자사이트
|
|
data = Dao.Get<NP.Model.Data>("common.check.admin", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo }, { "loginkey", SUserInfo.LoginKey }, { "IsDupCheck", IsDupCheck } }).ToList();
|
|
if (data.Count() < 1)
|
|
{
|
|
CookieClear(null, true);
|
|
filterContext.Result = new RedirectResult("/Account/Index?istimeout=true");
|
|
}
|
|
else
|
|
{
|
|
ViewBag.MainMemoNotCount = data.First().intval;
|
|
}
|
|
|
|
}
|
|
else if (TopMenuNo == 2)
|
|
{
|
|
var subdomain = Request.Url.Host.Split('.')[0].ToUpper();
|
|
if (Request.Url.AbsolutePath.ToUpper().StartsWith("/CROOM/"))
|
|
{
|
|
ViewBag.croomlectno = GetLong(Request["croomlectno"]);
|
|
ViewBag.croomcmno = GetInt(Request["croomcmno"]);
|
|
//추후 강사등의 권한 추가
|
|
ViewBag.croomusertype = ViewBag.croomlectno > 0 ? 1 : ViewBag.croomcmno > 0 ? 0 : 0;
|
|
ViewBag.croomparam = ViewBag.croomlectno > 0 ? string.Format("croomlectno={0}", ViewBag.croomlectno) : ViewBag.croomcmno > 0 ? string.Format("croomcmno={0}", ViewBag.croomcmno) : "";
|
|
|
|
//ViewBag.maintyear,ViewBag.maintseq,ViewBag.maincgname,ViewBag.maincname,ViewBag.mainclassno
|
|
if (Request.Url.AbsolutePath.ToUpper().StartsWith("/CROOM/") && ViewBag.croomlectno > 0)
|
|
{
|
|
//강의실(학생모드)
|
|
if (MainSubDomain.ToUpper() != subdomain && subdomain != "222")
|
|
{
|
|
data = Dao.Get<NP.Model.Data>("common.check.frontcroom.subdomain", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo }, { "loginkey", SUserInfo.LoginKey }, { "lectno", ViewBag.croomlectno }, { "IsDupCheck", IsDupCheck }, { "subdomain", subdomain } }).ToList();
|
|
if (data.Count() > 0)
|
|
{
|
|
ViewBag.SiteTitle = data.First().strval4;
|
|
ViewBag.AssignLogo = data.First().fileurl;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
data = Dao.Get<NP.Model.Data>("common.check.frontcroom", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo }, { "loginkey", SUserInfo.LoginKey }, { "lectno", ViewBag.croomlectno }, { "IsDupCheck", IsDupCheck } }).ToList();
|
|
}
|
|
if (data.Count() < 1)
|
|
{
|
|
CookieClear(null, true);
|
|
filterContext.Result = new RedirectResult("/Account/Index?istimeout=true");
|
|
}
|
|
else if (data.First().intval3 < 1)
|
|
{
|
|
filterContext.Result = new RedirectResult("/My/Lecture");
|
|
}
|
|
else
|
|
{
|
|
ViewBag.croomcmno = data.First().intval11;
|
|
ViewBag.MainMemoNotCount = data.First().intval;
|
|
ViewBag.Main3MAlarmCount = data.First().intval2;
|
|
ViewBag.maintyear = data.First().intval3;
|
|
ViewBag.maintseq = data.First().intval4;
|
|
ViewBag.mainclassno = data.First().intval5;
|
|
ViewBag.mainmenuplan = data.First().intval6;
|
|
ViewBag.mainmenustudy = data.First().intval7;
|
|
ViewBag.mainmenuexam = data.First().intval8;
|
|
ViewBag.mainmenuresearch = data.First().intval9;
|
|
ViewBag.mainmenugrade = data.First().intval10;
|
|
ViewBag.maincgname = data.First().strval;
|
|
ViewBag.maincname = data.First().strval2;
|
|
ViewBag.mainboardmaster = data.First().strval3;
|
|
}
|
|
}
|
|
//else if (Request.Url.AbsolutePath.ToUpper().StartsWith("/CROOM/") && ViewBag.croomcmno > 0)
|
|
//{
|
|
// //강의실(교수모드?)
|
|
// data = Dao.Get<NP.Model.Data>("common.check.frontcroomprofessor?", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo }, { "loginkey", SUserInfo.LoginKey }, { "cmno", ViewBag.croomcmno },{ "IsDupCheck", IsDupCheck } }).ToList();
|
|
// if (data.Count() < 1)
|
|
// {
|
|
// CookieClear(null, true);
|
|
// filterContext.Result = new RedirectResult("/Account/Index?istimeout=true");
|
|
// }
|
|
// else if (data.First().intval3 < 1)
|
|
// {
|
|
// filterContext.Result = new RedirectResult("/My/Lecture");
|
|
// }
|
|
// else
|
|
// {
|
|
// //ViewBag.MainMemoNotCount = data.First().intval;
|
|
// //ViewBag.Main3MAlarmCount = data.First().intval2;
|
|
// //ViewBag.maintmyear = data.First().intval3;
|
|
// //ViewBag.maintseq = data.First().intval4;
|
|
// //ViewBag.mainclassno = data.First().intval5;
|
|
// //ViewBag.maincgname = data.First().strval;
|
|
// //ViewBag.maincname = data.First().strval2;
|
|
// }
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
//사용자사이트
|
|
data = Dao.Get<NP.Model.Data>("common.check.front", new System.Collections.Hashtable() { { "userno", SUserInfo.UserNo }, { "loginkey", SUserInfo.LoginKey }, { "IsDupCheck", IsDupCheck } }).ToList();
|
|
if (data.Count() < 1)
|
|
{
|
|
CookieClear(null, true);
|
|
filterContext.Result = new RedirectResult("/Account/Index?istimeout=true");
|
|
}
|
|
else
|
|
{
|
|
ViewBag.MainMemoNotCount = data.First().intval;
|
|
ViewBag.Main3MAlarmCount = data.First().intval2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Dao.Save("sys.error", new System.Collections.Hashtable() { { "err", filterContext.RequestContext.HttpContext.Request.Url + ":" + ex.Message + ex.StackTrace }, { "userno", SUserInfo.UserNo } });
|
|
CookieClear(null, true);
|
|
if (Request.IsAjaxRequest())
|
|
{
|
|
filterContext.Result = new RedirectResult("/Account/Error?_code=9991");
|
|
}
|
|
else
|
|
{
|
|
filterContext.Result = new RedirectResult("/Account/Index?istimeout=true");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
CookieClear(null, true);
|
|
if (Request.IsAjaxRequest())
|
|
{
|
|
filterContext.Result = new RedirectResult("/Account/Error?_code=9991");
|
|
}
|
|
else
|
|
{
|
|
filterContext.Result = new RedirectResult("/Account/Index");
|
|
}
|
|
}
|
|
}
|
|
base.OnActionExecuting(filterContext);
|
|
}
|
|
protected DateTime ToDate(String d){return Convert.ToDateTime(d);}
|
|
protected DateTime LastTime(DateTime dt){return Convert.ToDateTime(dt.ToString("yyyy-MM-dd 23:59:59"));}
|
|
protected Int64? SetNullFile(Int64? fgno){if ((fgno ?? 1) < 1){return null;}return fgno;}
|
|
/// <summary>
|
|
/// 시험정보수정여부 (응시자가 존재하는지) "_hide": 존재, "": 없음(수정가능)
|
|
/// </summary>
|
|
/// <param name="ExamNo"></param>
|
|
/// <returns></returns>
|
|
protected String ExamSaveValid(int exno){return Dao.Get<int>("cm.exsave.valid", exno).First() > 0 ? "_hide" : "";}
|
|
protected String SDSaveValid(int sdno) { return Dao.Get<int>("cm.sdsave.valid", sdno).First() > 0 ? "_hide" : ""; }
|
|
protected String RSSaveValid(int rsno) { return Dao.Get<int>("cm.rssave.valid", rsno).First() > 0 ? "_hide" : ""; }
|
|
protected String RSCSaveValid(int rscno) { return Dao.Get<int>("cm.rscsave.valid", rscno).First() > 0 ? "_hide" : ""; }
|
|
/// <summary>
|
|
/// 문제은행 수정 시 이미 시험에 매핑된 문항은 문제/해설/사용여부/음성파일경로/객관식보기/객관식정답여부만 저장되도록 처리할려고 사용함
|
|
/// </summary>
|
|
/// <param name="QNo"></param>
|
|
/// <returns></returns>
|
|
protected int ExamQuestionCount(Int64 qno) {return Dao.Get<int>("cm.questionusings", qno).First();}
|
|
protected String CookieGet(String cid, String dv)
|
|
{
|
|
var cv = Request.Cookies[cid];
|
|
if (cv != null)
|
|
{
|
|
return cv.Value;
|
|
}
|
|
return dv;
|
|
}
|
|
protected void CookieSet(String cid, String v, int days = 1)
|
|
{
|
|
var cv = Request.Cookies[cid];
|
|
if (cv == null)
|
|
{
|
|
cv = new System.Web.HttpCookie(cid);
|
|
cv.Value = v;
|
|
cv.Expires = DateTime.Now.AddYears(days);
|
|
Response.Cookies.Add(cv);
|
|
}
|
|
else
|
|
{
|
|
cv.Value = v;
|
|
cv.Expires = DateTime.Now.AddYears(days);
|
|
Response.Cookies.Add(cv);
|
|
}
|
|
}
|
|
protected void CookieClear(String cid, bool isauthclear = false)
|
|
{
|
|
var suiv = TopMenuNo == 1 ? SUI : SUIF;
|
|
var suitv = TopMenuNo == 1 ? SUIT : SUIFT;
|
|
if (isauthclear)
|
|
{
|
|
ViewBag.SSUserNo = SUserInfo.UserNo = 0;
|
|
if (Request.Cookies[suiv] != null)
|
|
{
|
|
Response.Cookies[suiv].Value = null;
|
|
}
|
|
if (Request.Cookies[suitv] != null)
|
|
{
|
|
Response.Cookies[suitv].Value = null;
|
|
}
|
|
if (Request.Cookies[SUIFCROOM] != null)
|
|
{
|
|
Response.Cookies[SUIFCROOM].Value = null;
|
|
}
|
|
Response.Cookies[suiv].Expires = DateTime.Now.AddDays(-1);
|
|
Response.Cookies[suitv].Expires = DateTime.Now.AddDays(-1);
|
|
Response.Cookies[SUIFCROOM].Expires = DateTime.Now.AddDays(-1);
|
|
}
|
|
else
|
|
{
|
|
var cv = Request.Cookies[cid];
|
|
if (cv != null)
|
|
{
|
|
cv.Value = null;
|
|
cv.Expires = DateTime.Now.AddDays(-1);
|
|
Response.Cookies.Add(cv);
|
|
}
|
|
}
|
|
}
|
|
protected System.Collections.Hashtable InitHash(Int64 cno = 0, Int64 uno = 0)
|
|
{
|
|
return new System.Collections.Hashtable() { {"cno", cno }, {"uno", uno }, { "uip", GetUserIP() } };
|
|
}
|
|
protected bool HasFile(System.Web.HttpFileCollectionBase hfb)
|
|
{
|
|
for(int i = 0; i < hfb.Count; i++)
|
|
{
|
|
if (!string.IsNullOrEmpty(hfb[i].FileName))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
protected IList<NP.Model.File> GetFiles(Int64 fgno)
|
|
{
|
|
return Dao.GetFiles(fgno);
|
|
}
|
|
protected IList<NP.Model.File> GetFiles(String fgnos)
|
|
{
|
|
return Dao.GetFiles(fgnos);
|
|
}
|
|
protected System.Collections.Hashtable HT(String htv)
|
|
{
|
|
var rtn = new System.Collections.Hashtable() { };
|
|
foreach (var ht in htv.Split(';'))
|
|
{
|
|
rtn.Add(ht.Split(':')[0], ht.Split(':')[1]);
|
|
}
|
|
return rtn;
|
|
}
|
|
/// <summary>
|
|
/// logtype(10:사용자목록조회,20:사용자정보조회,30:사용자정보수정,40:사용자권한입장, 50: 고객사정보조회, 60: 결제상세정보조회, 70: 배송상세정보조회, 80: 시험정보조회)
|
|
/// logtarget(11: 수강생목록, 12: 교강사목록, 13: 운영자목록, 21: 사용자,31: 고객사, 41: 결제정보, 51: 입장)
|
|
/// </summary>
|
|
/// <param name="BaseNo"></param>
|
|
/// <param name="LogType"></param>
|
|
/// <param name="LogAct"></param>
|
|
/// <param name="LogInfo"></param>
|
|
/// <returns></returns>
|
|
protected int LogSet(NP.Model.ActLog log)
|
|
{
|
|
try
|
|
{
|
|
return Dao.Save("cm.actlog.set", log);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
try
|
|
{
|
|
SetError("logset:" + ex.Message);
|
|
}
|
|
catch (Exception ex2) { Logger.Error(ex.Message + ex2.Message, ex); }
|
|
}
|
|
return 0;
|
|
}
|
|
public int AuthSet(NP.Model.AuthLog log)
|
|
{
|
|
try
|
|
{
|
|
if (log.logtype == 1)
|
|
{
|
|
return Dao.Save("cm.authlog.set2", log);
|
|
}
|
|
return Dao.Save("cm.authlog.set", log);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
try
|
|
{
|
|
SetError("authlogset:" + ex.Message);
|
|
}
|
|
catch (Exception ex2) { Logger.Error(ex.Message + ex2.Message, ex); }
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
protected bool FrontMenu(string fmtype)
|
|
{
|
|
System.IO.StreamReader reader = null;
|
|
System.Net.WebRequest request;
|
|
System.IO.Stream dataStream = null;
|
|
System.Net.WebResponse response = null;
|
|
if(GetConfig("isstaging") == "1")
|
|
{
|
|
try
|
|
{
|
|
|
|
request = System.Net.WebRequest.Create(GetConfig("fronturl").Replace("https://", "http://") + "/Open/" + fmtype);
|
|
//request = System.Net.WebRequest.Create(GetConfig("fronturl") + "/Open/" + fmtype);
|
|
request.Method = "POST";
|
|
//request.PreAuthenticate = true;
|
|
//request.UseDefaultCredentials = false;
|
|
string postData = "This is a test that posts this string to a Web server.";
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
request.ContentType = "application/x-www-form-urlencoded";
|
|
request.ContentLength = byteArray.Length;
|
|
dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
response = request.GetResponse();
|
|
//Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
dataStream = response.GetResponseStream();
|
|
reader = new System.IO.StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();
|
|
//Console.WriteLine(responseFromServer);
|
|
reader.Close();
|
|
dataStream.Close();
|
|
response.Close();
|
|
return true;
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
SetError("FrontMemnu()" + ":" + Request.Url + ":" + ex.Message + ex.StackTrace);
|
|
if (reader != null)
|
|
{
|
|
reader.Close();
|
|
}
|
|
if (dataStream != null)
|
|
{
|
|
dataStream.Close();
|
|
}
|
|
if (response != null)
|
|
{
|
|
response.Close();
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bool result = true;
|
|
foreach(var d in GetConfig("adminips").Split(';'))
|
|
{
|
|
try
|
|
{
|
|
request = System.Net.WebRequest.Create("http://"+d + "/Open/" + fmtype);
|
|
//request = System.Net.WebRequest.Create(GetConfig("fronturl") + "/Open/" + fmtype);
|
|
request.Method = "POST";
|
|
//request.PreAuthenticate = true;
|
|
//request.UseDefaultCredentials = false;
|
|
string postData = "This is a test that posts this string to a Web server.";
|
|
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
|
|
request.ContentType = "application/x-www-form-urlencoded";
|
|
request.ContentLength = byteArray.Length;
|
|
dataStream = request.GetRequestStream();
|
|
dataStream.Write(byteArray, 0, byteArray.Length);
|
|
dataStream.Close();
|
|
response = request.GetResponse();
|
|
//Console.WriteLine(((HttpWebResponse)response).StatusDescription);
|
|
dataStream = response.GetResponseStream();
|
|
reader = new System.IO.StreamReader(dataStream);
|
|
string responseFromServer = reader.ReadToEnd();
|
|
//Console.WriteLine(responseFromServer);
|
|
reader.Close();
|
|
dataStream.Close();
|
|
response.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
SetError("FrontMemnu()" + ":" + Request.Url + ":" + ex.Message + ex.StackTrace);
|
|
if (reader != null)
|
|
{
|
|
reader.Close();
|
|
}
|
|
if (dataStream != null)
|
|
{
|
|
dataStream.Close();
|
|
}
|
|
if (response != null)
|
|
{
|
|
response.Close();
|
|
}
|
|
result = false;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
}
|