QMSClient.SaveCALConfiguration似乎不起作用

时间:2016-11-16 16:25:53

标签: qlikview

任何人都可以帮助我理解为什么以下这个不会删除命名的cals。它似乎工作正常,直到它执行保存的最后一行。我没有收到任何例外或错误消息。

当我查看系统>许可证下的QV管理控制台时,我仍然可以看到应该删除的那些(命名用户CAL)

客户端内部版本号:11.20.13314.0

        QMSClient Client;
        string QMS = "http://localhost:4799/QMS/Service";
        Client = new QMSClient("BasicHttpBinding_IQMS", QMS);
        string key = Client.GetTimeLimitedServiceKey();
        ServiceKeyClientMessageInspector.ServiceKey = key;

        List<ServiceInfo> MyQVS = Client.GetServices(ServiceTypes.QlikViewServer);
        Client.ClearQVSCache(QVSCacheObjects.All);

        CALConfiguration myCALs = Client.GetCALConfiguration(MyQVS[0].ID, CALConfigurationScope.NamedCALs);
        List<AssignedNamedCAL> currentNamedCALs = myCALs.NamedCALs.AssignedCALs.ToList();
        List<int> indexToRemove = new List<int>();

        int cnt = 1;
        for (int i = 0; i < currentNamedCALs.Count; i++)
        {
            if ((currentNamedCALs[i].QuarantinedUntil < System.DateTime.Now)
                && (currentNamedCALs[i].LastUsed < DateTime.Now.AddDays(daysFromToday)))
            {
                Console.WriteLine("[" + cnt + "] " + currentNamedCALs[i].UserName +
                    "; Last used: " + currentNamedCALs[i].LastUsed);
                indexToRemove.Add(i);
                cnt++;
            }
        }
        Console.WriteLine();
        for (int i = indexToRemove.Count; i > 0; i--)
        {
            if (currentNamedCALs[indexToRemove[i - 1]] != null)
            {
                currentNamedCALs.RemoveAt(indexToRemove[i - 1]);
            }
        }

        Console.WriteLine("\nDone");
        myCALs.NamedCALs.AssignedCALs = currentNamedCALs;
        Client.SaveCALConfiguration(myCALs);

0 个答案:

没有答案