コード例 #1
0
        private static LdapOperationStatus ToLdapOperationStatus()
        {
            var operations = LDAPTasks.GetTasks().ToList();

            foreach (var o in operations)
            {
                if (!string.IsNullOrEmpty(o.InstanseId) &&
                    Process.GetProcesses().Any(p => p.Id == int.Parse(o.InstanseId)))
                {
                    continue;
                }

                o.SetProperty(LdapOperation.PROGRESS, 100);
                LDAPTasks.RemoveTask(o.Id);
            }

            var operation =
                operations
                .FirstOrDefault(t => t.GetProperty <int>(LdapOperation.OWNER) == TenantProvider.CurrentTenantID);

            if (operation == null)
            {
                return(null);
            }

            if (DistributedTaskStatus.Running < operation.Status)
            {
                operation.SetProperty(LdapOperation.PROGRESS, 100);
                LDAPTasks.RemoveTask(operation.Id);
            }

            var certificateConfirmRequest = operation.GetProperty <LdapCertificateConfirmRequest>(LdapOperation.CERT_REQUEST);

            var result = new LdapOperationStatus
            {
                Id        = operation.Id,
                Completed = operation.GetProperty <bool>(LdapOperation.FINISHED),
                Percents  = operation.GetProperty <int>(LdapOperation.PROGRESS),
                Status    = operation.GetProperty <string>(LdapOperation.RESULT),
                Error     = operation.GetProperty <string>(LdapOperation.ERROR),
                CertificateConfirmRequest = certificateConfirmRequest,
                Source        = operation.GetProperty <string>(LdapOperation.SOURCE),
                OperationType = Enum.GetName(typeof(LdapOperationType),
                                             (LdapOperationType)Convert.ToInt32(operation.GetProperty <string>(LdapOperation.OPERATION_TYPE))),
                Warning = operation.GetProperty <string>(LdapOperation.WARNING)
            };

            if (!(string.IsNullOrEmpty(result.Warning)))
            {
                operation.SetProperty(LdapOperation.WARNING, ""); // "mark" as read
            }

            return(result);
        }
コード例 #2
0
        private static LDAPSupportSettingsResult ToLdapSettingsResult()
        {
            var operations = LDAPTasks.GetTasks().ToList();

            foreach (var o in operations)
            {
                if (!string.IsNullOrEmpty(o.InstanseId) &&
                    Process.GetProcesses().Any(p => p.Id == int.Parse(o.InstanseId)))
                {
                    continue;
                }

                o.SetProperty(LDAPOperation.PROGRESS, 100);
                LDAPTasks.RemoveTask(o.Id);
            }

            var operation =
                operations
                .FirstOrDefault(t => t.GetProperty <int>(LDAPOperation.OWNER) == TenantProvider.CurrentTenantID);

            if (operation == null)
            {
                return(new LDAPSupportSettingsResult
                {
                    Id = null,
                    Completed = true,
                    Percents = 100,
                    Status = "",
                    Error = Resource.LdapSettingsInternalServerError,
                    Source = ""
                });
            }

            if (DistributedTaskStatus.Running < operation.Status)
            {
                operation.SetProperty(LDAPOperation.PROGRESS, 100);
                LDAPTasks.RemoveTask(operation.Id);
            }

            var certificateConfirmRequest = operation.GetProperty <NovellLdapCertificateConfirmRequest>(LDAPOperation.CERT_REQUEST);

            var result = new LDAPSupportSettingsResult
            {
                Id        = operation.Id,
                Completed = operation.GetProperty <bool>(LDAPOperation.FINISHED),
                Percents  = operation.GetProperty <int>(LDAPOperation.PROGRESS),
                Status    = operation.GetProperty <string>(LDAPOperation.RESULT),
                Error     = operation.GetProperty <string>(LDAPOperation.ERROR),
                CertificateConfirmRequest = certificateConfirmRequest,
                Source = operation.GetProperty <string>(LDAPOperation.SOURCE)
            };

            return(result);
        }