private static RetsPostObjectResponse Execute(ProgramOptions options, RetsSession session, byte[] fileContents) { RetsPostObjectResponse response = null; ConsoleHelper.WriteInfo("Executing action {0} {1} {2} for ID {3}...", options.Action, options.Resource, options.Type, options.ResourceId); try { string fileName = null; if (!string.IsNullOrWhiteSpace(options.File)) { var fileInfo = new FileInfo(options.File); fileName = fileInfo.Name; } if (options.Action.Equals("Add", StringComparison.InvariantCultureIgnoreCase)) response = session.PostObject(RetsPostObjectParams.ActionAdd(options.ContentType, options.Type, options.Resource, options.ResourceId, options.ObjectId, fileName, fileContents, description: options.Description, label: options.Label, accessibility: options.Accessibility, documentTypeId: options.DocumentTypeId, delegateId: options.DelegateId, delegateHash: options.DelegateHash, delegatePassword: options.DelegatePassword)); else if (options.Action.Equals("Replace", StringComparison.InvariantCultureIgnoreCase)) response = session.PostObject(RetsPostObjectParams.ActionReplace(options.ContentType, options.Type, options.Resource, options.ResourceId, options.ObjectId ?? -1, fileName, fileContents, description: options.Description, label: options.Label, accessibility: options.Accessibility, documentTypeId: options.DocumentTypeId, delegateId: options.DelegateId, delegateHash: options.DelegateHash, delegatePassword: options.DelegatePassword)); else if (options.Action.Equals("Delete", StringComparison.InvariantCultureIgnoreCase)) response = session.PostObject(RetsPostObjectParams.ActionDelete(options.ContentType, options.Type, options.Resource, options.ResourceId, options.ObjectId, options.DelegateId, options.DelegateHash, options.DelegatePassword)); else response = session.PostObject(new RetsPostObjectParams { ContentType = options.ContentType, Accessibility = options.Accessibility, ContentDescription = options.Description, ContentLabel = options.Label, FileContents = fileContents, ObjectId = options.ObjectId, Resource = options.Resource, ResourceId = options.ResourceId, Type = options.Type, UpdateAction = options.Action, DelegateId = options.DelegateId, DelegateHash = options.DelegateHash, DelegatePassword = options.DelegatePassword, DocumentTypeId = options.DocumentTypeId, }); } catch (Exception ex) { ConsoleHelper.WriteFail(ex.Message); Environment.Exit(ExitCode.Fail); } return response; }
private static void Logout(RetsSession session) { ConsoleHelper.WriteInfo("Logging out..."); session.Logout(); }
private static RetsLoginResponse Login(ProgramOptions options, RetsSession session) { ConsoleHelper.WriteInfo("Logging in to {0}...", options.LoginUrl); return session.Login(); }