139 lines
5.2 KiB
C#
139 lines
5.2 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace CSS_Solution.Request
|
|||
|
{
|
|||
|
class Get_Index_Result
|
|||
|
{
|
|||
|
public int? id;
|
|||
|
public string? JSESSIONID;
|
|||
|
public string? RND;
|
|||
|
public DateTime dateTime;
|
|||
|
private string? error_info;
|
|||
|
public string Error_info
|
|||
|
{
|
|||
|
get { return error_info ??= ""; }
|
|||
|
set
|
|||
|
{
|
|||
|
error_info = value;
|
|||
|
is_error = true;
|
|||
|
}
|
|||
|
}
|
|||
|
bool is_error;
|
|||
|
public Get_Index_Result(int _id, string jSESSIONID, string rND, DateTime dateTime)
|
|||
|
{
|
|||
|
id = _id;
|
|||
|
JSESSIONID = jSESSIONID;
|
|||
|
RND = rND;
|
|||
|
error_info = "";
|
|||
|
this.dateTime = dateTime;
|
|||
|
}
|
|||
|
public Get_Index_Result(Get_Index get_Index)
|
|||
|
{
|
|||
|
id = get_Index.Get_Id();
|
|||
|
JSESSIONID = get_Index.Get_cookie()?.Select(element => new { element.Key, element.Value }).Where(element => element.Key.Equals("JSESSIONID")).First().Value;
|
|||
|
RND = get_Index.Get_rnd();
|
|||
|
dateTime = DateTime.Now;
|
|||
|
error_info = "";
|
|||
|
}
|
|||
|
public Get_Index_Result(string error_info) => Error_info = error_info;
|
|||
|
public bool Wrong_Result() => JSESSIONID == null || RND == null;
|
|||
|
public bool isError() => is_error;
|
|||
|
}
|
|||
|
class Login_Result
|
|||
|
{
|
|||
|
public List<KeyValuePair<string, string>> cookie = new List<KeyValuePair<string, string>>();
|
|||
|
public int? id;
|
|||
|
public string? JSESSIONID;
|
|||
|
public string? CERLOGIN;
|
|||
|
public DateTime dateTime;
|
|||
|
private string? error_info;
|
|||
|
public string Error_info
|
|||
|
{
|
|||
|
get { return error_info ??= ""; }
|
|||
|
set
|
|||
|
{
|
|||
|
error_info = value;
|
|||
|
is_error = true;
|
|||
|
}
|
|||
|
}
|
|||
|
bool is_error;
|
|||
|
|
|||
|
public Login_Result(int _id, string jSESSIONID, string cERLOGIN, DateTime dateTime)
|
|||
|
{
|
|||
|
id = _id;
|
|||
|
JSESSIONID = jSESSIONID;
|
|||
|
CERLOGIN = cERLOGIN;
|
|||
|
dateTime = DateTime.Now;
|
|||
|
error_info = "";
|
|||
|
cookie = new List<KeyValuePair<string, string>>();
|
|||
|
cookie.Add(new KeyValuePair<string, string>("JSESSIONID", JSESSIONID));
|
|||
|
cookie.Add(new KeyValuePair<string, string>("CERLOGIN", CERLOGIN));
|
|||
|
}
|
|||
|
public Login_Result(Login login)
|
|||
|
{
|
|||
|
id = login.Get_Id();
|
|||
|
cookie = login.Get_cookie() ?? throw new InvalidOperationException("Cookie of Login is NULL?!");
|
|||
|
for (int i = 0; i < cookie.Count; i++)
|
|||
|
if (cookie[i].Key == "JSESSIONID" || cookie[i].Key == "Path")
|
|||
|
{
|
|||
|
cookie.RemoveAt(i);
|
|||
|
i--;
|
|||
|
}
|
|||
|
JSESSIONID = login.Get_JSESSIONID();
|
|||
|
CERLOGIN = cookie?.Select(x => x).Where(element => element.Key.Equals("CERLOGIN")).First().Value;
|
|||
|
cookie?.Add(new KeyValuePair<string, string>("JSESSIONID", JSESSIONID));
|
|||
|
dateTime = DateTime.Now;
|
|||
|
error_info = "";
|
|||
|
}
|
|||
|
public Login_Result(string error_info) => Error_info = error_info;
|
|||
|
public bool Wrong_Result() => JSESSIONID == null || CERLOGIN == null || cookie.Select(x => new { havenull = x.Value == null }).Where(x => x.havenull).Count() > 0;
|
|||
|
public bool isError() => is_error;
|
|||
|
public List<KeyValuePair<string, string>> Get_cookie() => cookie;
|
|||
|
}
|
|||
|
class To_Course_Result
|
|||
|
{
|
|||
|
public List<KeyValuePair<string, string>> cookie = new List<KeyValuePair<string, string>>();
|
|||
|
public int? id;
|
|||
|
public string? JSESSIONID;
|
|||
|
public string? BINGOCLOUDLB;
|
|||
|
public DateTime dateTime;
|
|||
|
private string? error_info;
|
|||
|
public string Error_info
|
|||
|
{
|
|||
|
get { return error_info ??= ""; }
|
|||
|
set
|
|||
|
{
|
|||
|
error_info = value;
|
|||
|
is_error = true;
|
|||
|
}
|
|||
|
}
|
|||
|
bool is_error;
|
|||
|
public To_Course_Result(int _id,string jSESSIONID,string bINGOCLOUDLB,DateTime dateTime)
|
|||
|
{
|
|||
|
id = _id;
|
|||
|
JSESSIONID = jSESSIONID;
|
|||
|
BINGOCLOUDLB = bINGOCLOUDLB;
|
|||
|
error_info = "";
|
|||
|
this.dateTime = dateTime;
|
|||
|
}
|
|||
|
public To_Course_Result(To_Course to_Course)
|
|||
|
{
|
|||
|
id = to_Course.get_ID();
|
|||
|
cookie = to_Course.Get_cookie() ?? throw new InvalidOperationException("Cookie of ToCourse is NULL?!");
|
|||
|
JSESSIONID = cookie?.Select(x => x).Where(element => element.Key.Equals("JSESSIONID")).First().Value;
|
|||
|
BINGOCLOUDLB = cookie?.Select(x => x).Where(element => element.Key.Equals("BINGOCLOUDLB")).First().Value;
|
|||
|
dateTime = DateTime.Now;
|
|||
|
error_info = "";
|
|||
|
}
|
|||
|
public To_Course_Result(string error_info) => Error_info = error_info;
|
|||
|
public bool Wrong_Result() => JSESSIONID == null || BINGOCLOUDLB == null || cookie.Select(x => new { havenull = x.Value == null }).Where(x => x.havenull).Count() > 0;
|
|||
|
public bool isError() => is_error;
|
|||
|
public List<KeyValuePair<string, string>> Get_cookie() => cookie;
|
|||
|
|
|||
|
}
|
|||
|
}
|