Exemple #1
0
 private void setVariable(QlikInstance Q, string Name, string Comment, string Content)
 {
     try
     {
         Q.doc.Variables(Name).SetComment(Comment);
         Q.doc.Variables(Name).SetContent(Content, true);
     }
     catch
     {
         System.Threading.Thread.Sleep(400);
         Q.doc.Variables(Name).SetComment(Comment);
         Q.doc.Variables(Name).SetContent(Content, true);
     }
 }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            txValCorrect.Text  = "";
            txCommCorrect.Text = "";
            dgVars.Rows.Clear();


            dOF.FileName         = Path.GetFileName(txFlName.Text);
            dOF.InitialDirectory = Path.GetDirectoryName(txFlName.Text);
            dOF.FilterIndex      = 1;

            if (dOF.ShowDialog() == DialogResult.OK)
            {
                try {
                    QV.doc.CloseDoc();
                }
                catch { }
                txFlName.Text = dOF.FileName;
                QV            = new QlikInstance(dOF.FileName);
                lCnt.Text     = "Non-system variables count - " + QV.v.count.ToString();
                addRows();
                bSaveChg.Enabled = false;
            }
        }
Exemple #3
0
        private void bSaveChg_Click(object sender, EventArgs e)
        {
            int i;

            if (!chkCopy.Checked)
            {
                try
                {
                    if (QV == null)
                    {
                        return;
                    }
                    //bSaveChg.Text = "Save changes";
                    bSaveChg.Enabled = false;
                    pbSave.Maximum   = dgVars.Rows.Count;
                    pbSave.Value     = 0;
                    lCurrent.Text    = "Saving...";
                    for (i = 0; i < dgVars.Rows.Count - 1; i++)
                    {
                        setVariable(QV, (string)dgVars[0, i].Value, (string)dgVars[2, i].Value, (string)dgVars[1, i].Value);
                        pbSave.PerformStep();
                        Application.DoEvents();

                        /*
                         * try
                         * {
                         *  QV.doc.Variables(dgVars[0, i].Value).SetComment(dgVars[2, i].Value);
                         *  QV.doc.Variables(dgVars[0, i].Value).SetContent(dgVars[1, i].Value, true);
                         * }
                         * catch
                         * {
                         *  System.Threading.Thread.Sleep(400);
                         *  QV.doc.Variables(dgVars[0, i].Value).SetComment(dgVars[2, i].Value);
                         *  QV.doc.Variables(dgVars[0, i].Value).SetContent(dgVars[1, i].Value, true);
                         * }
                         */
                    }
                    QV.doc.Save();
                    MessageBox.Show("Complete!", "Transfering process",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    lCurrent.Text = "";
                }
                catch
                {
                    bSaveChg.Enabled = true;
                    //bSaveChg.Text = "Saving error";
                    MessageBox.Show("Fail!", "Saving process",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                try
                {
                    bSaveChg.Enabled = false;
                    pbSave.Value     = 0;
                    try
                    { QV.doc.CloseDoc(); }
                    catch { }

                    QV = new QlikInstance(txFlName.Text);
                    QlikInstance QVdest = new QlikInstance(txFlNameDest.Text);
                    if (chkErase.Checked)
                    {
                        pbSave.Maximum = QVdest.v.count;
                        lCurrent.Text  = "Deleting...";
                        for (int ii = 0; ii < QVdest.v.count; ii++)
                        {
                            QVdest.doc.RemoveVariable(QVdest.v.Item(ii).Name);
                            pbSave.PerformStep();
                            Application.DoEvents();
                        }
                    }

                    pbSave.Value   = 0;
                    pbSave.Maximum = QV.v.count;
                    lCurrent.Text  = "Transfering...";
                    string varname;
                    for (int ii = 0; ii < QV.v.count; ii++)
                    {
                        varname = QV.v.Item(ii).Name;
                        QVdest.doc.RemoveVariable(varname);
                        QVdest.doc.CreateVariable(varname);
                        setVariable(QVdest, varname, QV.doc.Variables(varname).GetComment(), QV.doc.Variables(varname).GetRawContent());
                        pbSave.PerformStep();
                        Application.DoEvents();
                    }
                    QVdest.doc.Save();
                    QV.doc.CloseDoc();
                    QVdest.doc.CloseDoc();
                    bSaveChg.Enabled = true;
                    MessageBox.Show("Complete!", "Transfering process",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    lCurrent.Text = "";
                }
                catch
                {
                    bSaveChg.Enabled = true;
                    MessageBox.Show("Fail!", "Transfering process",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
        }