Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Irgendeine abstrakte Basis, die nebenbei auch die Webheader Collection als statische Variable hält
- public abstract class CoBRAService
- {
- public CoBRAService(string username, string password, string webserviceRootUrl)
- {
- Username = username;
- Password = password;
- BaseService = new CoBRABaseService();
- DmsService = new CoBRADmsService();
- WebserviceRootUrl = webserviceRootUrl;
- SetWebserviceRootUrl(WebserviceRootUrl);
- }
- // STATISCHE VARIABLE IN EINER ABSTRAKTEN KLASSE MÖGLICH?
- public static WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
- public CoBRABaseService BaseService { get; private set; }
- public dmsService DmsService { get; private set; }
- public string WebserviceRootUrl { get; private set; }
- public string Username { get; set; }
- public string Password { get; set; }
- public bool Login()
- {
- try
- {
- CoBRA_BASE.ResultVoid loginResult = BaseService.loginUser(Username, Password);
- double? loginErrorCode = loginResult.errorCode;
- return loginErrorCode == 0;
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- return false;
- }
- }
- protected bool CheckSession(int errorCode)
- {
- bool activeSession = errorCode == 0;
- if (!activeSession)
- {
- BaseService.SetSessionExpired();
- activeSession = Login();
- if (activeSession)
- {
- BaseService.SetSessionActive();
- }
- }
- return activeSession;
- }
- public bool SetWebserviceRootUrl(string rootUrl)
- {
- bool validRootUrl = false;
- try
- {
- WebserviceRootUrl = rootUrl;
- BaseService.Url = $"{WebserviceRootUrl}/svc/cobra.cfc?wsdl";
- DmsService.Url = $"{WebserviceRootUrl}/svc/dms.cfc?wsdl";
- validRootUrl = true;
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- }
- return validRootUrl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement