public bool RemoveDenyIp(List <string> ipList)
        {
            if (ipList.Count == 0)
            {
                return(false);
            }

            var iptoblock = new StringBuilder();
            var komma     = "";

            foreach (var ip in ipList)
            {
                iptoblock.Append($"{komma}\"{ip}\"");
                komma = ",";
            }
            var proc = new FuncProcessor <GetResponse <AutoblockIpDate> >("/entry.cgi", _session.sid, new
            {
                api        = "SYNO.Core.Security.AutoBlock.Rules",
                version    = 1,
                block_days = 0,
                overwrite  = "true",
                ip         = $"[ {iptoblock} ]",
                method     = "delete",
                type       = "deny"
            });
            var retval = proc.Run();

            return(retval.success);
        }
        public GetResponse <Office365ListTasks> GetOffice365_ListTasks()
        {
            var proc = new FuncProcessor <GetResponse <Office365ListTasks> >("/entry.cgi", _session.sid, new
            {
                api     = "SYNO.ActiveBackupOffice365",
                version = 1,
                method  = "list_tasks"
            });

            return(proc.Run());
        }
        public GetResponse <CloudSyncSessList> GetSessList(Int64 connId)
        {
            var proc = new FuncProcessor <GetResponse <CloudSyncSessList> >("/entry.cgi", _session.sid, new
            {
                api           = "SYNO.CloudSync",
                version       = 1,
                method        = "list_sess",
                connection_id = connId
            });

            return(proc.Run());
        }
        /// <summary>
        /// Get list with blocked IP addresses
        /// </summary>
        /// <param name="_limit"></param>
        /// <returns></returns>
        public GetResponse <AutoblockIpDate> GetBlockedList(Int64 _limit = 250)
        {
            var proc = new FuncProcessor <GetResponse <AutoblockIpDate> >("/entry.cgi", _session.sid, new
            {
                api     = "SYNO.Core.Security.AutoBlock.Rules",
                version = 1,
                method  = "list",
                limit   = _limit,
                type    = "deny"
            });

            return(proc.Run());
        }
        public GetResponse <Office365ListGeneralLog> GetOffice365_GeneralLog(Int64 _offset = 0, Int64 _limit = 200)
        {
            var proc = new FuncProcessor <GetResponse <Office365ListGeneralLog> >("/entry.cgi", _session.sid, new
            {
                api     = "SYNO.ActiveBackupOffice365",
                version = 1,
                method  = "get_general_log",
                offset  = _offset,
                limit   = _limit
            });

            return(proc.Run());
        }
        public GetResponse <BusinessListActivityLog> GetBusiness_ActivityLog(Int64 _offset = 0, Int64 _limit = 200)
        {
            var proc = new FuncProcessor <GetResponse <BusinessListActivityLog> >("/entry.cgi", _session.sid, new
            {
                api     = "SYNO.ActiveBackup.Log",
                version = 1,
                method  = "list_log",
                offset  = _offset,
                limit   = _limit
            });

            return(proc.Run());
        }
        public CloudSyncData GetConnList()
        {
            var proc = new FuncProcessor <GetResponse <CloudSyncData> >("/entry.cgi", _session.sid, new
            {
                api      = "SYNO.CloudSync",
                version  = 1,
                method   = "list_conn",
                node     = "module_root",
                group_by = "group_by_user",
                is_tray  = false
            });
            var obj = proc.Run();

            return(obj.data as CloudSyncData);
        }
        public GetResponse <DataTaskList> GetTaskList()
        {
            var proc = new FuncProcessor <GetResponse <DataTaskList> >("/entry.cgi", _session.sid, new
            {
                api        = "SYNO.Backup.Task",
                version    = 1,
                method     = "list",
                node       = "module_root",
                sort_by    = "name",
                additional = ""
                             // DSM uses this to request extra data in 1 query.
                             //"[\"last_bkp_time\",\"last_bkp_result\",\"get_source\",\"is_modified\",\"progress_title_type\"]"
            });

            return(proc.Run());
        }
        public GetResponse <Office365ListTaskLog> GetOffice365_TaskLog(DateTime startTime, DateTime endTime, Int64 _offset = 0, Int64 _limit = 10000)
        {
            var proc = new FuncProcessor <GetResponse <Office365ListTaskLog> >("/entry.cgi", _session.sid, new
            {
                api                  = "SYNO.ActiveBackupOffice365",
                version              = 1,
                method               = "list_task_logs",
                job_type             = 0,
                start_run_time       = GetUnixDateTimeSeconds(startTime),
                end_run_time         = GetUnixDateTimeSeconds(endTime),
                transfered_size_from = 0,
                offset               = _offset,
                limit                = _limit
            });

            return(proc.Run());
        }
        public GetResponse <ListVersionInfoList> GetVersions(Int64 taskId, string targetId, Int64 repoId, int _offset = 0, Int64 _limit = 50)
        {
            var proc = new FuncProcessor <GetResponse <ListVersionInfoList> >("/entry.cgi", _session.sid, new
            {
                api          = "SYNO.Backup.Version",
                version      = 2,
                method       = "list",
                offset       = _offset,
                limit        = _limit,
                filter_name  = "available",
                task_id      = taskId,
                repo_id      = repoId,
                target_id    = targetId,
                additional   = "[\"version_operate_property\"]",
                account_meta = "{\"scheduleRule\":\"unlimited\",\"versionDelete\":\"enable\",\"versionLock\":\"enable\",\"versionRotation\":\"custom\",\"statisticsDisplay\":\"all\",\"spaceUsage\":\"target\",\"quota\":0,\"expireTime\":0,\"planGroup\":\"\",\"planPeriod\":\"\",\"account\":\"\",\"isFresh\":false}"
            });

            return(proc.Run());
        }
        public GetResponse <BusinessListInfoList> GetBusiness_InfoList(DateTime startTime, DateTime endTime)
        {
            // did not wanted to include/use a library for json conversion
            var openTag    = "{";
            var closeTag   = "}";
            var jsonFilter = $"{openTag}\"time_start\":{GetUnixDateTimeSeconds(startTime)},\"time_end\":{GetUnixDateTimeSeconds(endTime)}{closeTag}";

            //var x = new { time_start = GetUnixDateTimeSeconds(startTime), time_end = GetUnixDateTimeSeconds(endTime) };
            //var jsonFilter = JsonConvert.SerializeObject(x);

            var proc = new FuncProcessor <GetResponse <BusinessListInfoList> >("/entry.cgi", _session.sid, new
            {
                api     = "SYNO.ActiveBackup.Overview",
                version = 1,
                method  = "list_result_status_summary",
                filter  = jsonFilter
            });

            return(proc.Run());
        }
        /* Not working - version list is not filled
         *
         * public GetResponse<BusinessTaskData2> GetBusiness_TaskList(int TaskId, int _offset=0, int _limit=50)
         * {
         *  // did not wanted to include/use a library for json conversion
         *  var openTag = "{";
         *  var closeTag = "}";
         *  var jsonFilter = $"{openTag}\"offset\":{_offset},\"limit\":{_limit},\"task_id\":{TaskId},\"data_formats\":[1,4]{closeTag}";
         *
         *  var proc = new FuncProcessor<GetResponse<BusinessTaskData2>>("/entry.cgi", _session.sid, new
         *  {
         *      api = "SYNO.ActiveBackup.Task",
         *      version = 1,
         *      method = "list",
         *      offset = _offset,
         *      limit = _limit,
         *      load_status = "true",
         *      load_result = "true",
         *      load_devices = "true",
         *      load_verify_status = "false",
         *      filter = jsonFilter
         *  });
         *  return proc.Run();
         * }
         *
         */



        public GetResponse <BusinessTaskData2> GetBusiness_TaskList(Enum_ActiveBackup_BackupType backupType)
        {
            // did not wanted to include/use a library for json conversion
            var openTag    = "{";
            var closeTag   = "}";
            var jsonFilter = $"{openTag}\"backup_type\":{(int)backupType}{closeTag}";

            var proc = new FuncProcessor <GetResponse <BusinessTaskData2> >("/entry.cgi", _session.sid, new
            {
                api          = "SYNO.ActiveBackup.Task",
                version      = 1,
                method       = "list",
                load_status  = "true",
                load_result  = "true",
                load_devices = "true",
                filter       = jsonFilter
            });

            return(proc.Run());
        }