Exemplo n.º 1
0
        public override void Run()
        {
            int          count = 1;
            StreamReader file  = new StreamReader(fileName);
            string       SQL   = "";

            while (!file.EndOfStream)
            {
                string RSQL = file.ReadLine();
                if (RSQL.ToUpper().Trim(' ') == "GO")
                {
                    // run SQL
                    if (!QueryExec.Create(BaseType.PDA).Execute(SQL))
                    {
                        Loging.Loging.WriteLog("SQL Error: " + SQL, true, true);
                    }
                    // clear SQL
                    SQL = "";
                    // event
                    Coordinator.ExecuteDelegateArgs args = new Coordinator.ExecuteDelegateArgs();
                    args.Maximum       = Lines;//передавать в args кол-во таблиц и номер текущей (для прогресс бара)
                    args.Pos           = count;
                    args.runningAction = this;
                    args.Name          = Name();
                    OnExecute(this, args);
                    count++;
                }
                else
                {
                    SQL += RSQL;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Tools menu item click
        /// Create a standalone SasMap analysis based on the current query and then run it
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public string Run(
            string args)
        {
            QueryTable  qt;
            MetaTable   mt;
            QueryColumn qc;

            int qid = SS.I.ServicesIniFile.ReadInt("SasMapToolModelQuery", 888070);

            if (qid < 0)
            {
                throw new Exception("SasMapToolModelQuery not defined");
            }

            Query q = QbUtil.ReadQuery(qid);

            if (q == null)
            {
                throw new Exception("Failed to read SasMapToolModelQuery: " + qid);
            }

            q.UserObject = new UserObject(UserObjectType.Query);             // treat this as a new query

            QueryTable sasQt = q.GetQueryTableByNameWithException(SasMapParms.MetaTableName);

            SasQc = sasQt.GetQueryColumnByNameWithException(SasMapParms.ParametersMetaColumnName);

            BaseQuery = GetBaseQuery();
            if (BaseQuery == null || BaseQuery.Tables.Count == 0)
            {
                MessageBoxMx.ShowError("The current query must contain one or more data tables before a SasMap can be defined on the query");
                return("");
            }

            Parms = LastParms;

            qc = BaseQuery?.GetFirstKeyColumn();
            qc = qc.Clone();
            qc.CopyCriteriaFromQueryKeyCriteria(BaseQuery);
            Parms.KeyCriteriaQc = qc;

            Parms.EndpointMc = BaseQuery?.GetFirstResultColumnByPriority(true)?.MetaColumn; // pick the highest priority result column as the default endpoint

            QbUtil.SetMode(QueryMode.Build);                                                // be sure in build mode

            DialogResult dr = Edit();

            if (dr != DialogResult.OK)
            {
                return("");
            }

            StoreParmsInQueryColumnCriteria(Parms, SasQc);

            // Add as a new query and run it

            AnalysisCount++;

            q.Name = "Structure-Activity Similarity Analysis " + AnalysisCount;
            q.SingleStepExecution = true;

            // Add the query to the QueryBuilder and run it

            DelayedCallback.Schedule(             // add and run the query after exiting this dialog
                delegate(object state)
            {
                QbUtil.AddQuery(q);
                QbUtil.SetCurrentQueryInstance(q);                         // set to new query
                QbUtil.RenderQuery();
                QueryExec.RunQuery(q, SS.I.DefaultQueryDest);
            });

            Progress.Hide();

            return("");
        }