Beispiel #1
0
        public RetsLoginResponse Login()
        {
            var request = new RetsRequest();
            LoginInfo = new RetsLoginResponse();

            var loginRequest = new RetsLoginRequest
                                   {
                                       MethodUrl = SessionInfo.BaseUrl + SessionInfo.LoginUrl,
                                       Session = SessionInfo
                                   };

            LoginInfo.Parse(request.Post(loginRequest));
            IsValid = LoginInfo.IsSuccessful;

            return LoginInfo;
        }
Beispiel #2
0
        public RetsLogoutResponse Logout()
        {
            if (IsValid)
            {
                string transactionUrl = LoginInfo.GetCapabilityUrl(StandardCapability.Logout);
                if (!string.IsNullOrWhiteSpace(transactionUrl))
                {
                    string fullLogoutUrl = transactionUrl.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) || transactionUrl.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase)
                                               ? transactionUrl
                                               : SessionInfo.BaseUrl + transactionUrl;

                    var request = new RetsRequest();
                    var response = new RetsLogoutResponse();

                    var logoutRequest = new RetsLogoutRequest
                                            {
                                                MethodUrl = fullLogoutUrl,
                                                Session = SessionInfo
                                            };

                    try
                    {
                        response.Parse(request.Post(logoutRequest));

                        return response;
                    }
                    finally
                    {
                        LoginInfo = null;
                        IsValid = false;
                        SessionInfo.Cookies = null;
                    }
                }
            }

            return null;
        }
Beispiel #3
0
        public RetsPostObjectResponse PostObject(RetsPostObjectParams postObjectParams)
        {
            if (IsValid)
            {
                string transactionUrl = LoginInfo.GetCapabilityUrl(StandardCapability.PostObject);
                if (!string.IsNullOrWhiteSpace(transactionUrl))
                {
                    string fullPostObjectUrl = transactionUrl.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase) || transactionUrl.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase)
                                                   ? transactionUrl
                                                   : SessionInfo.BaseUrl + transactionUrl;

                    var request = new RetsRequest();
                    var response = new RetsPostObjectResponse();
                    var postObjectRequest = new RetsPostObjectRequest
                                                {
                                                    MethodUrl = fullPostObjectUrl,
                                                    Session = SessionInfo,
                                                    UpdateAction = postObjectParams.UpdateAction,
                                                    ContentType = postObjectParams.ContentType,
                                                    Type = postObjectParams.Type,
                                                    Resource = postObjectParams.Resource,
                                                    ResourceId = postObjectParams.ResourceId,
                                                    ObjectId = postObjectParams.ObjectId,
                                                    PostBody = postObjectParams.FileContents,
                                                    FileName = postObjectParams.FileName,
                                                    ContentDescription = postObjectParams.ContentDescription,
                                                    ContentLabel = postObjectParams.ContentLabel,
                                                    Accessibility = postObjectParams.Accessibility,
                                                    DelegateId = postObjectParams.DelegateId,
                                                    DelegateHash = postObjectParams.DelegateHash,
                                                    DelegatePassword = postObjectParams.DelegatePassword,
                                                    DocumentTypeId = postObjectParams.DocumentTypeId,
                                                };

                    response.Parse(request.Post(postObjectRequest));

                    return response;
                }
            }

            return null;
        }