Exemple #1
0
        public void deployExtension(myQv.QMSClientEnhanced qvClient, Guid qvsId, string fileName)
        {
            ExtensionUploadHandle handle = qvClient.InitiateUploadExtensionObject(qvsId);

            if (handle != null)
            {
                FileStream fs = new FileStream(fileName, FileMode.Open);

                int maxBufferSize = 1024 * 16;

                byte[] buffer = new byte[maxBufferSize];
                int    bytesRead;

                while ((bytesRead = fs.Read(buffer, 0, maxBufferSize)) > 0)
                {
                    //Copy the read bytes into a new buffer with the same size as the number of received bytes
                    byte[] byteWireBuffer = new byte[bytesRead];
                    Buffer.BlockCopy(buffer, 0, byteWireBuffer, 0, bytesRead);

                    //Write the buffer to the QVS
                    handle = qvClient.WriteExtensionObject(handle, byteWireBuffer);
                }

                //Finalize the upload. This will install the extension object if it is valid.
                List <QVSMessage> msg = qvClient.CloseAndInstallExtensionObject(handle);

                msg.ForEach(
                    m => myCore.Logging.log(m.Text, 2, myCore.LogType.Information)
                    );
            }
        }
Exemple #2
0
        public void init()
        {
            myCore.Logging.log("Extension Server Lib loading ...", 0, myCore.LogType.Information);

            myCore.Logging.log("Starting log server ...", 1, myCore.LogType.Information);

            myCore.PipeLoggingServer pl = new myCore.PipeLoggingServer();

            myCore.Logging.log("Deploying QARs ...", 1, myCore.LogType.Information);

            myCore.Logging.log("Connecting to QVS ...", 2, myCore.LogType.Information);

            try
            {
                myQv.QMSClientEnhanced qvClient = myQv.QMSClientFactory.getClient(new Uri("http://localhost"));
                Guid qvsId = qvClient.GetServices(frqtlib.QMSAPI.ServiceTypes.QlikViewServer)[0].ID;

                string path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                foreach (string fileName in Directory.EnumerateFiles(Path.Combine(path, "Extensions"), "*.QAR"))
                {
                    myCore.Logging.log("Initiating upload for {0} ...", 2, myCore.LogType.Information, fileName);

                    try
                    {
                        this.deployExtension(qvClient, qvsId, fileName);
                    }
                    catch (System.Exception)
                    {
                        myCore.Logging.log("Unable to deploy {0} ... Retrying ...", 2, myCore.LogType.Error, fileName);

                        try
                        {
                            this.deployExtension(qvClient, qvsId, fileName);
                        }
                        catch (System.Exception e)
                        {
                            myCore.Logging.log("Unable to deploy {0} ... ", 2, myCore.LogType.Error, fileName);
                            throw e;
                        }
                    }
                }
            }
            catch (System.Exception e)
            {
                myCore.Logging.log("Unable to connect to local QMS API ... Manually deploy extensions or add current user to QlikView Management Service API group ...", 2, myCore.LogType.Error);
            }
        }
Exemple #3
0
        public static QMSClientEnhanced getClient(Uri qms = null)
        {
            if (qms == null)
            {
                qms = QMSClientFactory.defaultUri;
            }

            if (QMSClientFactory.clientList.ContainsKey(qms) && QMSClientFactory.clientList[qms].State == System.ServiceModel.CommunicationState.Opened)
            {
                return(QMSClientFactory.clientList[qms]);
            }
            else
            {
                QMSClientEnhanced client = ((qms == QMSClientFactory.defaultUri) ? new QMSClientEnhanced() : new QMSClientEnhanced(qms));

                if (QMSClientFactory.clientList.ContainsKey(qms))
                {
                    QMSClientFactory.clientList.Remove(qms);
                }
                QMSClientFactory.clientList.Add(qms, client);

                return(client);
            }
        }