Пример #1
0
        private void MainLoad(object sender, EventArgs e)
        {
            LBVersion.Text = string.Format("LazyBot Evolution V{0}", LazyVersion);
            expandableSplitter1.Expanded = false;
            DoLoad.Load();
            LoadCustomClasses();
            LoadEngines();
            SelectEngine.SelectedIndex = SelectEngine.FindStringExact(LazySettings.SelectedEngine, -1);
            SelectCombat.SelectedIndex = SelectEngine.FindStringExact(LazySettings.SelectedCombat, -1);
            if (SelectEngine.SelectedIndex == -1)
            {
                SelectEngine.SelectedIndex = 0;
            }
            if (SelectCombat.SelectedIndex == -1)
            {
                SelectCombat.SelectedIndex = 0;
            }
            PluginCompiler.RecompileAll();
            PluginCompiler.StartSavedPlugins();
            LoadPluginButtons();
            RegisterHotKeys();
            Engine.StateChange     += UpdateStateChange;
            ObjectManager.NoAttach += LogOut;
#if RELEASE
            CBDebug.Checked = LazySettings.DebugLog;
#endif
//#if DEBUG
            // buttonX1.Visible = true;
            // buttonX2.Visible = true;        I Dont Like To Look At this In debug
//#endif
        }
Пример #2
0
        public DataSet Execute(string sql)
        {
            var parserManager = new ParserManager(Configuration);

            var parseStatementsResult = parserManager.ParseStatements(sql);

            if (parseStatementsResult.Errors.Any())
            {
                var sb = new StringBuilder();

                foreach (var error in parseStatementsResult.Errors)
                {
                    sb.AppendLine($"{error.Message}");
                }

                throw new Exception(sb.ToString());
            }

            var statements = parseStatementsResult.Value;

            var dataSet = new DataSet();

            using (var service = OrganizationService.Create(Credential))
            {
                foreach (var statement in statements)
                {
                    if (statement is SelectStatement)
                    {
                        var crmInstance  = new CRMInstance(service);
                        var selectEngine = new SelectEngine(crmInstance, Configuration);

                        var selectStatement = (SelectStatement)statement;

                        var dt = selectEngine.Execute(selectStatement);

                        dataSet.Tables.Add(dt);
                    }
                    else if (statement is UpdateStatement)
                    {
                        throw new NotSupportedException($"'Update' statement is currently not supported.");
                    }
                    else if (statement is DeleteStatement)
                    {
                        throw new NotSupportedException($"'Delete' statement is currently not supported.");
                    }
                }
            }

            return(dataSet);
        }