예제 #1
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + System.IO.Path.DirectorySeparatorChar + "config"))
     {
         Sqo.SiaqodbConfigurator.EncryptedDatabase = false;
         Sqo.Siaqodb siaqodb = new Sqo.Siaqodb(AppDomain.CurrentDomain.BaseDirectory + System.IO.Path.DirectorySeparatorChar + "config");
         try
         {
             Sqo.IObjectList <ReferenceItem> references = siaqodb.LoadAll <ReferenceItem>();
             foreach (ReferenceItem refItem in references)
             {
                 listBox1.Items.Add(refItem);
             }
             Sqo.IObjectList <NamespaceItem> namespacesItems = siaqodb.LoadAll <NamespaceItem>();
             foreach (NamespaceItem nItem in namespacesItems)
             {
                 textBox1.Text += nItem + Environment.NewLine;
             }
         }
         finally
         {
             siaqodb.Close();
             EncryptionSettings.SetEncryptionSettings();//set back settings
         }
     }
 }
예제 #2
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + System.IO.Path.DirectorySeparatorChar + "config"))
            {
                assemblies.Clear();
                namespaces.Clear();
                Sqo.SiaqodbConfigurator.EncryptedDatabase = false;
                Sqo.Siaqodb siaqodb = new Sqo.Siaqodb(AppDomain.CurrentDomain.BaseDirectory + System.IO.Path.DirectorySeparatorChar + "config");
                try
                {
                    siaqodb.DropType <ReferenceItem>();
                    siaqodb.DropType <NamespaceItem>();
                    foreach (object o in listBox1.Items)
                    {
                        ReferenceItem refItem = o as ReferenceItem;
                        if (refItem == null)
                        {
                            refItem = new ReferenceItem(o.ToString());
                        }
                        assemblies.Add(refItem);
                        siaqodb.StoreObject(refItem);

                        if (File.Exists(refItem.Item))
                        {
                            try
                            {
                                File.Copy(refItem.Item, AppDomain.CurrentDomain.BaseDirectory + "\\" + System.IO.Path.GetFileName(refItem.Item), true);
                            }
                            catch
                            {
                            }
                        }
                    }
                    foreach (string s in textBox1.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        NamespaceItem nobj = new NamespaceItem(s);
                        namespaces.Add(nobj);
                        siaqodb.StoreObject(nobj);
                    }
                }
                finally
                {
                    siaqodb.Close();
                    EncryptionSettings.SetEncryptionSettings();//set back settings
                }
            }

            this.DialogResult = true;
        }
예제 #3
0
        public void Execute(string path)
        {
            if (this.path != path)
            {
                if (!System.IO.Directory.Exists(path))
                {
                    textBox1.Text             = "Invalid folder! choose a valid database folder";
                    tabControl1.SelectedIndex = 1;
                    return;
                }

                this.path = path;
            }

            textBox1.Text = "";

            Sqo.SiaqodbConfigurator.EncryptedDatabase = false;

            Sqo.Siaqodb siaqodbConfig = new Sqo.Siaqodb(AppDomain.CurrentDomain.BaseDirectory + "\\config");
            Sqo.IObjectList <NamespaceItem> namespaces = siaqodbConfig.LoadAll <NamespaceItem>();
            Sqo.IObjectList <ReferenceItem> references = siaqodbConfig.LoadAll <ReferenceItem>();
            siaqodbConfig.Close();

            EncryptionSettings.SetEncryptionSettings();//set back settings

            string ifEncrypted = @" Sqo.SiaqodbConfigurator.SetLicense(@"" qU3TtvA4T4L30VSlCCGUTbooYKG1XXCnjJ+jaPPrPLaD7PdPw9HujjxmkZ467OqZ"");";

            if (EncryptionSettings.IsEncryptedChecked)
            {
                ifEncrypted += @" Sqo.SiaqodbConfigurator.EncryptedDatabase=true;
                                 Sqo.SiaqodbConfigurator.SetEncryptor(Sqo.BuildInAlgorithm." + EncryptionSettings.Algorithm + @"); 

                                ";
                if (!string.IsNullOrEmpty(EncryptionSettings.Pwd))
                {
                    ifEncrypted += @" SiaqodbConfigurator.SetEncryptionPassword(""" + EncryptionSettings.Pwd + @""");";
                }
            }
#if TRIAL
            ifEncrypted += @" SiaqodbConfigurator.SetTrialLicense(""" + TrialLicense.LicenseKey + @""");";
#endif
            string metBody = ifEncrypted + @" Siaqodb siaqodb = Sqo.Internal._bs._ofm(@""" + this.path + @""",""SiaqodbManager,SiaqodbManager2"");
			
							object list= ("                             + this.textEditor1.Text + @").ToList();
                            siaqodb.Close();
                            return list;
							 "                            ;
            var    c       = new CodeDom();
            //c.AddReference(@"System.Core.dll");
            //c.AddReference(@"siaqodb.dll");
            //c.AddReference(@"System.Windows.Forms.dll");


            foreach (ReferenceItem refi in references)
            {
                c.AddReference(refi.Item);
            }
            System.CodeDom.CodeNamespace n = c.AddNamespace("LINQQuery");
            foreach (NamespaceItem nitem in namespaces)
            {
                n.Imports(nitem.Item);
            }
            n.Imports("System.Collections.Generic")
            .Imports("System.Linq")
            .Imports("Sqo")



            .AddClass(
                c.Class("RunQuery")
                .AddMethod(c.Method("object", "FilterByLINQ", "", metBody)));

            Assembly assembly = c.Compile(WriteErrors);

            if (assembly != null)
            {
                Type       t      = assembly.GetType("LINQQuery.RunQuery");
                MethodInfo method = t.GetMethod("FilterByLINQ");

                try
                {
                    var retVal = method.Invoke(null, null);

                    IList w = ((IList)retVal);

                    this.dataGridView1.DataSource          = w;
                    this.dataGridView1.AutoGenerateColumns = true;
                    this.tabControl1.SelectedIndex         = 0;
                    //this.lblNrRows.Text = ar.Count + " rows";
                }
                catch (Exception ex)
                {
                    WriteErrors(ex.ToString());
                    this.tabControl1.SelectedIndex = 1;
                }
            }
            else
            {
                this.tabControl1.SelectedIndex = 1;
            }
        }