コード例 #1
0
ファイル: Utility.cs プロジェクト: Oman/Maleos
        public static void UpdateStatus(int id, string tableName, string fileName,string title,  int archiveId, IQueryTable toTable, QueryColumn toStatus, QueryColumn toPrimary)
        {
            NBearLite.DbProviders.DbProvider provider =
                        NBearLite.DbProviders.DbProviderFactory.CreateDbProvider(
                                null,
                                "System.Data.SqlServerCe",
                                @"Data Source=enforce.sdf;
                                  Encrypt Database=True;
                                  Password=enforce_123456;
                                  File Mode=shared read;
                                  Persist Security Info=False;");
            Database database = new Database(provider);

            UpdateSqlSection section = new UpdateSqlSection(database, toTable);
            section.AddColumn(toStatus, 2); // 2 代表已归档
            section.Where(toPrimary == id);
            section.Execute();

            InsertSqlSection insert = new InsertSqlSection(database, DataBases.ArchiveExt);
            insert.AddColumn(DataBases.ArchiveExt.ArchiveID, archiveId);
            insert.AddColumn(DataBases.ArchiveExt.TableName, tableName);
            insert.AddColumn(DataBases.ArchiveExt.PrimaryValue, id);
            insert.AddColumn(DataBases.ArchiveExt.FileName, fileName);
            insert.AddColumn(DataBases.ArchiveExt.Title, title);
            insert.AddColumn(DataBases.ArchiveExt.CreateTime, DateTime.Now);
            insert.AddColumn(DataBases.ArchiveExt.ExchangeGUID, CommonInvoke.NewGuid);
            insert.Execute();
        }
コード例 #2
0
        /// <summary>
        /// Prep non-Oracle query
        /// </summary>
        /// <param name="eqp"></param>
        /// <returns></returns>

        public override string PrepareQuery(
            ExecuteQueryParms eqp)
        {
            int cti;

            Eqp = eqp;
            QueryEngine qe = eqp.Qe;
            Query       q  = qe.Query;
            QueryTable  qt = eqp.QueryTable;
            QueryColumn qc;
            MetaTable   mt = qt.MetaTable;
            MetaColumn  mc = null;

            StructCriteriaQc = KeyCriteriaQc = null;

            QueryColumn strQc = qt.FirstStructureQueryColumn;

            if (strQc != null && Lex.IsDefined(strQc.Criteria))
            {
                StructCriteriaQc = strQc;
            }
            else
            {
                throw new Exception("Structure criteria not defined");
            }

            Pssc = ParsedStructureCriteria.Parse(StructCriteriaQc);

            QueryColumn keyQc = qt.KeyQueryColumn;

            if (keyQc != null && Lex.IsDefined(q.KeyCriteria))             //keyQc.Criteria))
            {
                KeyCriteriaQc = keyQc;
            }

            if (StructCriteriaQc == null &&
                KeyCriteriaQc == null &&
                eqp.SearchKeySubset == null)
            {
                throw new Exception("NonSqlBroker - No criteria specified");
            }

            SelectList = new List <MetaColumn>();            // list of selected metacolumns
            foreach (QueryColumn qc2 in qt.QueryColumns)
            {
                if (qc2.MetaColumn == null)
                {
                    continue;                                         // in case metacolumn not defined
                }
                if (qc2.IsKey)
                {
                    qc2.Selected = true;
                }
                if (qc2.Selected || qc2.SortOrder != 0)
                {
                    SelectList.Add(qc2.MetaColumn);
                }
            }

            // Setup for ECFP4 similarity search

            if (Pssc.SearchType == StructureSearchType.MolSim && Pssc.SimilarityType == SimilaritySearchType.ECFP4)
            {
                Ecfp4Dao = null;                 // reset Dao to initiate new search
                return("");
            }

            else if (Pssc.SearchType == StructureSearchType.SmallWorld) // SmallWorld search
            {
                SwDao = null;                                           // reset Dao to initiate new search
                return("");
            }

            else if (Pssc.SearchType == StructureSearchType.Related) // Related structure search
            {
                RSS = null;                                          // reset to initiate new search
                return("");
            }

            else if (!MqlUtil.IsCartridgeMetaTable(mt)) // must be non chemical cartridge table (e.g. User structure DB or structure in Annotation table
            {
                return("");                             // everything looks ok, query criteria stored here, no sql returned
            }
            else
            {
                throw new Exception("Unsupported NonSqlBroker search for table: " + eqp.QueryTable.MetaTable.Label);
            }
        }
コード例 #3
0
ファイル: SqlQueryTranslation.cs プロジェクト: vetraskr/Pagan
 private static string TranslateSelectedColumn(QueryColumn participant)
 {
     return TranslateColumn(participant.Column);
 }
コード例 #4
0
ファイル: WDSHelper.cs プロジェクト: saveenr/saveenr
 public static MusicInfo GetMusicInfoFromRow(object[] values, QueryColumn col_title, QueryColumn col_filename, QueryColumn col_path, QueryColumn col_dur, QueryColumn col_artists, QueryColumn col_albumartist, QueryColumn col_album, QueryColumn col_composer, QueryColumn col_size, QueryColumn col_bitrate, QueryColumn col_year)
 {
     var item = new MusicInfo();
     item.Title = GetString( values[col_title.Ordinal] );
     item.Filename= GetString(values[col_filename.Ordinal]);
     item.Path = GetString(values[col_path.Ordinal]);
     item.Duration = GetDecimal(values[col_dur.Ordinal]);
     item.Artist = GetStringArray(values[col_artists.Ordinal]);
     item.AlbumArtist= GetString(values[col_albumartist.Ordinal]);
     item.AlbumTitle= GetString(values[col_album.Ordinal]);
     item.Composer = GetStringArray(values[col_composer.Ordinal]);
     item.Size = GetDecimal(values[col_size.Ordinal]);
     item.Bitrate= GetInt32(values[col_bitrate.Ordinal]);
     item.Year= GetInt32(values[col_year.Ordinal]);
     return item;
 }
コード例 #5
0
/// <summary>
/// Add criteria to query to do a related structure search
/// </summary>
/// <param name="q"></param>

        void ModifyQueryForRelatedStructureSearch(
            Query q,
            MoleculeControl queryMolCtl)
        {
            q.KeyCriteria = q.KeyCriteriaDisplay = "";             // always remove any existing key criteria

            QueryTable  sqt = AddStructureTableToQuery(q);         // be sure we have a structure table in the query
            QueryColumn sqc = sqt.FirstStructureQueryColumn;

            sqc.Selected = true;

            sqc.DisplayFormatString = "Highlight=true";
            if (AlignMatches.Checked)
            {
                sqc.DisplayFormatString += ";Align=true";
            }

            QueryColumn qc = sqt.GetQueryColumnByName("molSrchType");             // include search type

            if (qc != null)
            {
                qc.Selected = true;
            }

            qc = sqt.GetSimilarityScoreQueryColumn();             // and match score
            if (qc != null)
            {
                qc.Selected = true;
            }

            ParsedStructureCriteria pssc = new ParsedStructureCriteria();

            pssc.SearchType = StructureSearchType.Related;

            //string mfText = sqt.KeyQueryColumn.ActiveLabel + ": " + queryCid; // (queryCid no longer be accurate)
            //pssc.Structure = // just store a comment with the CID in the structure
            //	new ChemicalStructureMx(StructureFormat.MolFile, ChemicalStructureMx.GetTextMessageMolFile(mfText));

            MoleculeMx m = QueryMolCtl.Molecule;

            pssc.Molecule = new MoleculeMx(m.PrimaryFormat, m.PrimaryValue);

            if (AltForms.Checked)
            {
                pssc.SearchTypeUnion |= StructureSearchType.FullStructure;
            }
            if (MatchedPairs.Checked)
            {
                pssc.SearchTypeUnion |= StructureSearchType.MatchedPairs;
            }
            if (SmallWorld.Checked)
            {
                pssc.SearchTypeUnion |= StructureSearchType.SmallWorld;
            }
            if (SimilarSearch.Checked)
            {
                pssc.SearchTypeUnion |= StructureSearchType.MolSim;
            }
            if (Substructure.Checked)
            {
                pssc.SearchTypeUnion |= StructureSearchType.Substructure;
            }

            pssc.MinimumSimilarity = .75;
            pssc.MaxSimHits        = 100;
            pssc.Highlight         = true;
            pssc.Align             = AlignMatches.Checked;
            pssc.ConvertToQueryColumnCriteria(sqc);

            if (ExcludeCurrentResultsCids.Checked && CurrentBaseQueryCidHitList != null)      // add not in list criteria
            {
                string queryStrName = queryMolCtl.GetTemporaryStructureTag();                 // see if we can get the cid

                q.KeysToExclude = new HashSet <string>(CurrentBaseQueryCidHitList);
                if (q.KeysToExclude.Contains(queryStrName))                 // keep query id
                {
                    q.KeysToExclude.Remove(queryStrName);
                }
            }

            else
            {
                q.KeyCriteria = q.KeyCriteriaDisplay = "";                 // no key criteria
            }
            return;
        }
コード例 #6
0
        public DialogResult ShowSelectColumnMenu(Point screenLoc)
        {
            if (Click != null)             // fire Clicked event if handlers present
            {
                Click(this, EventArgs.Empty);
            }

            ToolStripMenuItem fmi = null;

            SelectFieldMenu.Items.Clear();

            ColumnMapCollection cml = DataMap.BuildFilteredColumnMapList(Flags, SelectedColumn);

            foreach (ColumnMapMsx cm in cml.ColumnMapList)
            {
                QueryColumn qc = cm.QueryColumn;
                QueryTable  qt = qc?.QueryTable;
                fmi = new ToolStripMenuItem();
                if (cm.Selected)
                {
                    fmi.Checked = true;
                }
                else
                {
                    fmi.Image = Bitmaps.Bitmaps16x16.Images[(int)qc.MetaColumn.DataTypeImageIndex];
                    fmi.ImageTransparentColor = System.Drawing.Color.Cyan;
                }

                fmi.Text = cm.SpotfireColumnName;
                if (qc != null)
                {
                    fmi.ToolTipText =
                        "===== Mobius Table and Column =====\r\n" +
                        "Table: " + qt.ActiveLabel + "\r\n" +
                        "Column: " + qc.ActiveLabel + "\r\n" +
                        "(" + qc.MetaTableDotMetaColumnName + ")";
                }

                fmi.Tag    = cm;
                fmi.Click += new System.EventHandler(this.FieldMenuItem_Click);

                SelectFieldMenu.Items.Add(fmi);
            }

            if (Flags.IncludeNoneItem)
            {             // added none item
                fmi        = new ToolStripMenuItem();
                fmi.Text   = "(None)";
                fmi.Click += new System.EventHandler(this.FieldMenuItemExtra_Click);
                SelectFieldMenu.Items.Add(fmi);
            }

            if (!String.IsNullOrEmpty(Flags.ExtraItem))
            {             // added extra item
                fmi        = new ToolStripMenuItem();
                fmi.Text   = Flags.ExtraItem;
                fmi.Click += new System.EventHandler(this.FieldMenuItemExtra_Click);
                SelectFieldMenu.Items.Add(fmi);
            }

            SelectFieldMenu.Show(screenLoc.X, screenLoc.Y);

            MenuItemSelected = false;
            while (SelectFieldMenu.Visible)             // wait til menu closes
            {
                Application.DoEvents();
                Thread.Sleep(100);
            }

            if (!MenuItemSelected)
            {
                return(DialogResult.Cancel);                               // treat as cancel if nothing selected
            }
            CheckForSummarizedVersionOfMetaColumn();

            if (EditValueChanged != null)             // fire EditValueChanged event if handlers present
            {
                EditValueChanged(this, EventArgs.Empty);
            }

            return(DialogResult.OK);
        }
コード例 #7
0
        /// <summary>
        /// Add a filter item
        /// </summary>
        /// <param name="qc"></param>
        /// <param name="criteriaText"></param>

        void AddFilter(QueryColumn qc)
        {
            Control    control = null, focusControl = null;
            ColumnInfo colInfo;


            try { colInfo = ResultsFormat.GetColumnInfo(Qm, qc); }
            catch { return; }             // ignore if col no longer in query

            int buttonDy = 4;

            if (qc.SecondaryFilterType == FilterType.BasicCriteria)
            {
                FilterBasicCriteriaControl fbc = new FilterBasicCriteriaControl();
                fbc.Setup(colInfo, this);
                if (qc == ActiveQueryColumn)
                {
                    focusControl = fbc.Value;                                          // put focus on value if this is the active column
                }
                control = fbc;
            }

            else if (qc.SecondaryFilterType == FilterType.CheckBoxList)
            {
                FilterCheckBoxListControl flc = new FilterCheckBoxListControl();
                flc.Setup(colInfo);
                control = flc;
            }

            else if (qc.SecondaryFilterType == FilterType.ItemSlider)
            {
                FilterItemSliderControl fis = new FilterItemSliderControl();
                fis.Setup(colInfo);
                control  = fis;
                buttonDy = 16;
            }

            else if (qc.SecondaryFilterType == FilterType.RangeSlider)
            {
                FilterRangeSliderControl frs = new FilterRangeSliderControl();
                frs.Setup(colInfo);
                control  = frs;
                buttonDy = 16;
            }

            else if (qc.SecondaryFilterType == FilterType.StructureSearch)
            {
                FilterStructureControl fss = new FilterStructureControl();
                fss.Setup(colInfo);
                control = fss;
            }

            control.Top   = PanelYPos;
            control.Left  = 0;
            control.Width = ScrollablePanel.Width - 34;
            ScrollablePanel.Controls.Add(control);
            if (focusControl != null)
            {
                focusControl.Focus();
            }

//			if (qc.SecondaryFilterType != FilterType.StructureSearch)
            AddFilterDropDownButton(qc, ScrollablePanel.Width - 32, PanelYPos + buttonDy);

            PanelYPos += control.Height + 2;

            return;
        }
コード例 #8
0
        public static DialogResult Show(
            QueryColumn qc)
        {
            string tok;

            if (Instance == null)
            {
                Instance = new DateFormatDialog();
            }
            DateFormatDialog dfd = Instance;

            MetaColumn mc = qc.MetaColumn;

            if (mc.DataType != MetaColumnType.Date)
            {
                XtraMessageBox.Show(mc.Label + " is not a date field");
                return(DialogResult.Cancel);
            }

            // Setup

            new JupyterGuiConverter().ConvertFormOrUserControl(Instance);

            string fmt = qc.DisplayFormatString;

            if (Lex.IsNullOrEmpty(fmt))
            {
                fmt = "d-MMM-yyyy";                                     // default format
            }
            if (Lex.Contains(fmt, "d-MMM-yyyy"))
            {
                dfd.d_MMM_yyyy.Checked = true;
            }
            else if (Lex.Contains(fmt, "d-MMM-yy"))
            {
                dfd.d_MMM_yy.Checked = true;
            }
            else if (Lex.Contains(fmt, "M/d/yyyy"))
            {
                dfd.M_d_yyyy.Checked = true;
            }
            else if (Lex.Contains(fmt, "M/d/yy"))
            {
                dfd.M_d_yy.Checked = true;
            }
            else if (Lex.Contains(fmt, "none"))
            {
                dfd.DateNone.Checked = true;
            }
            else
            {
                dfd.d_MMM_yyyy.Checked = true;              // in case of no match
            }
            if (Lex.Contains(fmt, "h:mm:ss tt"))
            {
                dfd.h_mm_ss_tt.Checked = true;                                              // check in reverse order to get correct hit
            }
            else if (Lex.Contains(fmt, "h:mm tt"))
            {
                dfd.h_mm_tt.Checked = true;
            }
            else if (Lex.Contains(fmt, "H:mm:ss"))
            {
                dfd.H_mm_ss.Checked = true;
            }
            else if (Lex.Contains(fmt, "H:mm"))
            {
                dfd.H_mm.Checked = true;
            }
            else
            {
                dfd.TimeNone.Checked = true;
            }

// Show form & get new values

            DialogResult dr = dfd.ShowDialog(SessionManager.ActiveForm);

            if (dr == DialogResult.OK)
            {
                if (dfd.d_MMM_yyyy.Checked)
                {
                    fmt = "d-MMM-yyyy";
                }
                else if (dfd.d_MMM_yy.Checked)
                {
                    fmt = "d-MMM-yy";
                }
                else if (dfd.M_d_yyyy.Checked)
                {
                    fmt = "M/d/yyyy";
                }
                else if (dfd.M_d_yy.Checked)
                {
                    fmt = "M/d/yy";
                }
                else if (dfd.DateNone.Checked)
                {
                    fmt = "none";
                }

                if (dfd.H_mm.Checked)
                {
                    fmt += " H:mm";
                }
                else if (dfd.H_mm_ss.Checked)
                {
                    fmt += " H:mm:ss";
                }
                else if (dfd.h_mm_tt.Checked)
                {
                    fmt += " h:mm tt";
                }
                else if (dfd.h_mm_ss_tt.Checked)
                {
                    fmt += " h:mm:ss tt";
                }
                else if (dfd.TimeNone.Checked)
                {
                }
                ;                                                   // nothing if no time

                qc.DisplayFormatString = fmt;
            }

            return(dr);
        }
コード例 #9
0
ファイル: Query.cs プロジェクト: FizzcodeSoftware/DbTools
 /// <summary>
 /// Inner join the <paramref name="table"/>.
 /// The <see cref="QueryBuilder"/> will automatically build the equality join condition, from the <paramref name="columnSource"/> to the Primary Key of the main table of the Query..
 /// If the table is referenced in other parts of the query, use table aliasing.
 /// </summary>
 /// <param name="table">The table to join.</param>
 /// <param name="columnSource">The column of the joined table to join on.</param>
 /// <param name="columns">The columns to include in the query. Provide any number of <see cref="QueryColumn"/>s, or <see cref="SqlColumn"/>s (which will be impicitly cast as a QueryColumn.</param>
 /// <returns>The Query.</returns>
 public Query InnerJoinTo(SqlTable table, QueryColumn columnSource, params QueryColumn[] columns)
 {
     return(InnerJoin(table, columnSource, null, columns));
 }
コード例 #10
0
ファイル: Query.cs プロジェクト: FizzcodeSoftware/DbTools
 /// <summary>
 /// Inner join the <paramref name="table"/>.
 /// The <see cref="QueryBuilder"/> will automatically build the equality join condition, from the <paramref name="columnSource"/> and the <paramref name="columnTarget"/>.
 /// If the table is referenced in other parts of the query, use table aliasing.
 /// </summary>
 /// <param name="table">The table to join.</param>
 /// <param name="columnSource">The column of the joined table to join on.</param>
 /// <param name="columnTarget">The column of the other table to join. This might be a column of the main table of the Query, or a column of the table of another QueryElement.</param>
 /// <param name="columns">The columns to include in the query. Provide any number of <see cref="QueryColumn"/>s, or <see cref="SqlColumn"/>s (which will be impicitly cast as a QueryColumn.</param>
 /// <returns>The Query.</returns>
 public Query InnerJoin(SqlTable table, QueryColumn columnSource, QueryColumn columnTarget, params QueryColumn[] columns)
 {
     return(InnerJoinAlias(table, null, columnSource, columnTarget, columns));
 }
コード例 #11
0
ファイル: Query.cs プロジェクト: FizzcodeSoftware/DbTools
 /// <summary>
 /// Inner join the <paramref name="table"/> with an <paramref name="alias"/>.
 /// The <see cref="QueryBuilder"/> will automatically build the equality join condition, from the <paramref name="columnSource"/> to the Primary Key of the main table of the Query..
 /// If the table is referenced in other parts of the query, use table aliasing.
 /// </summary>
 /// <param name="table">The table to join.</param>
 /// <param name="alias">The alias for the table.</param>
 /// <param name="columnSource">The column of the joined table to join on.</param>
 /// <param name="columns">The columns to include in the query. Provide any number of <see cref="QueryColumn"/>s, or <see cref="SqlColumn"/>s (which will be impicitly cast as a QueryColumn.</param>
 /// <returns>The Query.</returns>
 public Query InnerJoinAlias(SqlTable table, string alias, QueryColumn columnSource, params QueryColumn[] columns)
 {
     return(InnerJoinAlias(table, alias, columnSource, null, columns));
 }
コード例 #12
0
        /// <summary>
        /// Write Csv file of data
        /// </summary>
        /// <param name="csvFile"></param>
        /// <param name="includeProtein"></param>
        /// <param name="includeElectronDensity"></param>

        void WriteCsvFile(
            string csvFile,
            bool exportSingle,
            QueryColumn qcProtein,
            QueryColumn qcDensity,
            QueryColumn qcTarget,
            QueryManager qm,
            string url,
            string densityMapUrl,
            string target)
        {
            string     rec;
            DataRowMx  dr;
            StringMx   sx;
            List <int> markedRows;
            //string finalUrl;

            StreamWriter sw = new StreamWriter(csvFile);

            rec = "BSL_XRAY_CMPLX_URL,BSL_XRAY_EDENSITY_URL,TRGT_LABEL";
            sw.WriteLine(rec);             // header

            string filePath    = DownloadFile(url);
            string mapFilePath = DownloadFile(densityMapUrl);

            if (qm == null)             // export from HTML
            {
                rec = "";
                //if (!Lex.Contains(url, "edensity")) // assume protein/ligand
                rec += filePath;

                rec += ",";

                if (mapFilePath != null)
                {
                    rec += mapFilePath;
                }

                rec += ",";                 // nothing for target for now

                if (target != null)
                {
                    rec += target;
                }

                sw.WriteLine(rec);
            }

            else             // export from XtraGrid
            {
                ResultsFormatter fmtr = qm.ResultsFormatter;

                if (exportSingle)                 // put single row to export in table
                {
                    markedRows = new List <int>();
                    CellInfo cinf = qm.MoleculeGrid.LastMouseDownCellInfo;
                    markedRows.Add(cinf.DataRowIndex);                     // indicate current row
                }

                else
                {
                    markedRows = fmtr.MarkedRowIndexes;
                }

                foreach (int ri in markedRows)
                {
                    dr  = qm.DataTable.Rows[ri];
                    rec = "";
                    if (qcProtein != null)
                    {
                        url      = Lex.ToString(dr[qcProtein.VoPosition]);
                        filePath = DownloadFile(url);
                        if (String.IsNullOrEmpty(filePath))
                        {
                            continue;
                        }
                        rec += filePath;
                    }

                    rec += ",";

                    if (qcDensity != null)
                    {
                        string mapUrl = Lex.ToString(dr[qcDensity.VoPosition]);
                        mapFilePath = DownloadFile(mapUrl);
                        rec        += mapFilePath;
                    }
                    else if (!IncludeElectronDensityPyMol.Checked)
                    {
                        // do nothing, user does not want map
                    }
                    else if (densityMapUrl == null && !exportSingle)
                    {
                        densityMapUrl = _xRay2Request ? GetXray2DensityMapUrl(url, _currentMetaTable, _currentPdbColumnName) : GetXray1DensityMapUrl(url, _currentMetaTable);
                        mapFilePath   = DownloadFile(densityMapUrl);
                        rec          += mapFilePath;
                    }
                    else if (densityMapUrl != null)
                    {
                        mapFilePath = DownloadFile(densityMapUrl);
                        rec        += mapFilePath;
                    }

                    rec += ",";

                    if (qcTarget != null)
                    {
                        target = Lex.ToString(dr[qcTarget.VoPosition]);
                        rec   += target;
                    }

                    densityMapUrl = null;                     //we only get the map from the first record

                    sw.WriteLine(rec);
                }
            }

            sw.Close();
            return;
        }
コード例 #13
0
        /// <summary>
        /// Handle a click on a link to a 3D structure & open in Vida
        /// If clicked from an XtraGrid give the user a range of options for the data
        /// to be exported. If clicked from a HTML page give limited options.
        /// </summary>
        /// <param name="mtName"></param>
        /// <param name="mcName"></param>
        /// <param name="url"></param>

        public void ClickFunction(
            string mtName,
            string mcName,
            string url)
        {
            ResultsFormatter fmtr = null;
            ResultsField     rfld = null;
            //DataRowMx dr;
            StringMx     sx;
            StreamWriter sw;
            int          markedCount   = 0;
            string       densityMapUrl = null;
            string       target        = null;

            _currentMetaTable     = mtName;
            _currentPdbColumnName = mcName;

            IncludeElectronDensityPyMol.Checked = false;

            MetaTable mt = MetaTableCollection.Get(mtName);

            if (mt == null)
            {
                return;
            }

            MetaColumn mc = mt.GetMetaColumnByName(mcName);

            if (mc == null)
            {
                return;
            }

            _xRay2Request = Lex.Contains(mtName, "XRay2");    // newer XRay2 database table?
            _urlFileName  = Path.GetFileName(url);            // extract file name from url

            QueryManager qm = ClickFunctions.CurrentClickQueryManager;

            if (qm != null)
            {
                Query         q  = qm.Query;
                ResultsFormat rf = qm.ResultsFormat;
                fmtr = qm.ResultsFormatter;

                rfld = rf.GetResultsField(mc);
                if (rfld == null)
                {
                    return;
                }

                QueryTable qt = q.GetQueryTableByNameWithException(mtName);
                _qcProtein = qt.GetQueryColumnByNameWithException(mcName);

                if (_xRay2Request)                 // newer XRay2 database
                {
                    string mapUrl = "";
                    if (mcName == "ALIGNED_SPLIT_COMPLEX_URL")
                    {
                        mapUrl = "ALIGNED_SPLIT_MAP_URL";
                    }
                    else if (mcName == "ALIGNED_FULL_COMPLEX_URL")
                    {
                        mapUrl = "ALIGNED_FULL_MAP_URL";
                    }
                    else if (mcName == "ORIGINAL_PDB_URL")
                    {
                        mapUrl = "ORIGINAL_MAP_URL";
                    }                                                                 //{ mapUrl = "ORIGINAL_MAP_URL"; }

                    _qcDensity = qt.GetQueryColumnByName(mapUrl);                     //("ALIGNED_SPLIT_MAP_URL");
                    if (_qcDensity != null && !_qcDensity.Selected)
                    {
                        _qcDensity = null;
                    }

                    _qcTarget = qt.GetQueryColumnByName("primary_gene_name_alias");
                    if (_qcTarget != null && !_qcTarget.Selected)
                    {
                        _qcTarget = null;
                    }
                }

                if (_qcDensity != null)
                {
                    // if there is a density map url located in the density column, enable the PyMol CheckEdit
                    DataRowMx dr = qm.DataTable.Rows[qm.MoleculeGrid.LastMouseDownCellInfo.DataRowIndex];
                    densityMapUrl = Lex.ToString(dr[_qcDensity.VoPosition]);
                }
                else
                {
                    // user did not select the map column, try to retrieve the XRay1 or Xray2 density map url fromt he metatable
                    densityMapUrl = _xRay2Request ? GetXray2DensityMapUrl(url, qt.MetaTable.Name, mcName) : GetXray1DensityMapUrl(url, qt.MetaTable.Name);
                }

                // default checkbox to false so user does not load electron density maps everytime, since these take
                // extra time to load.
                IncludeElectronDensityPyMol.Checked = false;

                IncludeElectronDensityPyMol.Enabled = !string.IsNullOrEmpty(densityMapUrl);

                if (_qcProtein == null && _qcDensity == null)
                {
                    throw new Exception("Neither the PDB nor the MAP column is selected in the query");
                }

                markedCount = fmtr.MarkedRowCount;
                int unmarkedCount = fmtr.UnmarkedRowCount;

                if (markedCount == 0 || unmarkedCount == 0)                 // if no specific selection assume user wants single structure
                {
                    ExportSingle.Checked = true;
                    FileName.Text        = _urlFileName;
                }
                else
                {
                    ExportMarked.Checked = true;                  // assume wants marked structures
                }
                ExportMarked.Enabled = true;
            }

            else              // simple setup for click from HTML display
            {
                ExportSingle.Checked = true;
                ExportMarked.Enabled = false;
                FileName.Text        = _urlFileName;

                densityMapUrl = GetXray2DensityMapUrl(url, _currentMetaTable, mcName);
                target        = GetTarget(url, _currentMetaTable, mcName);


                ////IncludeProtein.Enabled = IncludeElectronDensityEnabled = false;

                ////if (Lex.Eq(mcName, "bsl_xray_cmplx_url"))
                ////  IncludeProtein.Checked = true;

                ////else if (Lex.Eq(mcName, "bsl_xray_edensity_url"))
                ////  IncludeElectronDensityChecked = true;
            }

            if (mcName == "ALIGNED_SPLIT_MAP_URL" || mcName == "ALIGNED_FULL_MAP_URL" || mcName == "ORIGINAL_MAP_URL")              // not viewable fileds
            {
                DisablePymol();
                DisableMoe();
                ExportToFile.Enabled = ExportToFile.Checked = true;
            }

            else if (mcName == "ALIGNED_FULL_COMPLEX_URL" || mcName == "ORIGINAL_PDB_URL" || mcName == "ALIGNED_SPLIT_COMPLEX_URL")             // viewable by PyMol
            {
                EnableMoe();
                EnablePymol();
                ExportToFile.Enabled = true;
                ExportToFile.Checked = false;
            }
            else             //everything else should be viewable by MOE
            {
                EnableMoe();
                DisablePymol();
                ExportToFile.Enabled = true;
                ExportToFile.Checked = false;
            }

            DialogResult dlgRslt = ShowDialog(SessionManager.ActiveForm);

            if (dlgRslt == DialogResult.Cancel)
            {
                return;
            }

            bool exportSingle = ExportSingle.Checked;
            bool exportMarked = !exportSingle;

            if (!IncludeElectronDensityPyMol.Checked)
            {
                densityMapUrl = null;
            }

            if (exportMarked)             // see if reasonable count if exporting marked rows
            {
                string msg;
                if (markedCount == 0)
                {
                    msg = "No rows have been marked for export";
                    MessageBoxMx.Show(msg, "Mobius", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (markedCount > 10)
                {
                    msg =
                        markedCount + " structures have been selected out export.\n" +
                        "Are you sure these are the structures you want to export?";
                    dlgRslt = MessageBoxMx.Show(msg, "Mobius", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (dlgRslt != DialogResult.Yes)
                    {
                        return;
                    }
                }
            }

            // Export to PyMol (Schrodinger) - Collab with Paul Sprengeler and Ken Schwinn
            // Relavant Files:
            // 1. Plugin: CorpView.py (in Mobius config dir)
            // 2. Script: CorpView.pml - Runs the plugin and then passes in the .csv file (in Mobius config dir)
            //		 Expected content (note: <csv-file-name> gets replaced):
            //			import pymol
            //			pluginLocation = 'C:\Progra~1\PyMOL\PyMOL\modules\pmg_tk\startup\CorpView.py'
            //			cmd.do('run ' + pluginLocation)
            //			cmd.do('lv_create_environment')
            //			cmd.do('lv_import_mobius <csv-file-name>')
            //			cmd.do('lv_destroy_environment')
            // 3. Csv file: PyMolBatchLoad.csv - Csv file in format expected by plugin (in Mobius temp dir)

            if (ExportToPyMol.Checked)
            {
                ExportToPyMolMethod(url, densityMapUrl, target, qm);
            }

            else if (ExportToMOE.Checked)             // Export to MOE
            {
                ExportToMOEMethod(url, qm, fmtr, rfld);
            }

            else
            {
                ExportToFilesMethod(url, qm, fmtr, rfld);
            }
        }
コード例 #14
0
/// <summary>
/// Execute structure search for structures stored in an Oracle text column
/// </summary>
/// <param name="sql">Basic sql to select key & structure</param>

        public void ExecuteInternalOracleStructureColumnSearch(
            string sql,
            MoleculeFormat structureFormat)
        {
            string cid, molString;

            object[]   vo;
            MoleculeMx cs;
            bool       match = false;

            QueryColumn molsimQc = Eqp.QueryTable.GetSelectedMolsimQueryColumn();             // get any column to return similarity score in

            DbCommandMx drd = new DbCommandMx();

            if (Eqp.SearchKeySubset == null)
            {
                drd.Prepare(sql);
                drd.ExecuteReader();
            }

            else             // limit to list
            {
                sql += " where " + Eqp.QueryTable.MetaTable.KeyMetaColumn.Name + " in (<list>)";
                drd.PrepareListReader(sql, DbType.String);

                List <string> dbKeySubset = new List <string>();
                foreach (string key in Eqp.SearchKeySubset)
                {
                    string dbKey = CompoundId.NormalizeForDatabase(key, Eqp.QueryTable.MetaTable);
                    dbKeySubset.Add(dbKey);
                }
                drd.ExecuteListReader(dbKeySubset);
            }

            drd.CheckForCancel = Eqp.CheckForCancel;             // set cancel check flag

            StructureMatcher matcher = new StructureMatcher();   // allocate structure matcher
            List <object[]>  results = new List <object[]>();

            int matchCount = 0;

            while (drd.Read())
            {
                cid = drd.GetObject(0).ToString();
                cid = CompoundId.Normalize(cid, Eqp.QueryTable.MetaTable);                 // normalize adding prefix as needed

                molString = drd.GetString(1);
                if (String.IsNullOrEmpty(molString))
                {
                    continue;
                }

                cs = new MoleculeMx(structureFormat, molString);
                if (Pssc.SearchType == StructureSearchType.Substructure)
                {
                    if (matcher.IsSSSMatch(Pssc.Molecule, cs))
                    {
                        vo    = new object[SelectList.Count];
                        vo[0] = CompoundId.Normalize(cid, Eqp.QueryTable.MetaTable);                         // normalize adding prefix
                        results.Add(vo);
                    }
                }

                else if (Pssc.SearchType == StructureSearchType.MolSim)
                {
                    double score = matcher.Molsim(Pssc.Molecule, cs, Pssc.SimilarityType);
                    if (score >= Pssc.MinimumSimilarity)
                    {
                        vo    = new object[SelectList.Count];
                        vo[0] = CompoundId.Normalize(cid, Eqp.QueryTable.MetaTable);                         // normalize adding prefix
                        if (vo.Length >= 2)
                        {
                            vo[1] = (float)score;
                        }

                        results.Add(vo);
                    }
                }

                else if (Pssc.SearchType == StructureSearchType.FullStructure)
                {
                    if (matcher.FullStructureMatch(Pssc.Molecule, cs, Pssc.Options))
                    {
                        vo    = new object[SelectList.Count];
                        vo[0] = CompoundId.Normalize(cid, Eqp.QueryTable.MetaTable);                         // normalize adding prefix
                        results.Add(vo);
                    }
                }
                matchCount++;

//				if (matchCount >100) break; // debug

                if (drd.Cancelled)
                {
                    Eqp.Qe.Cancelled = true;
                    drd.Dispose();
                    Results = null;
                    return;
                }
            }

            drd.Dispose();

            Results = results;
            return;
        }
コード例 #15
0
ファイル: TableMapModel.cs プロジェクト: 80880655/Esign
        /// <summary>
        /// 更新表

        /// </summary>
        /// <param name="database">Comfy.Data.Database</param>
        /// <param name="table">table類</param>
        /// <param name="model">model類</param>
        /// <param name="updateFields">要更新的字段,名字要和model中的屬性相同。如果要更新所有的字段,此參數為null</param>
        /// <param name="whereStrs">條件字段</param>
        public static void UpdateTable(Database database, QueryTable table, Object model, Comfy.Data.QueryColumn[] updateFields, Comfy.Data.QueryColumn[] whereQc)
        {
            Type   modelType = model.GetType();
            Type   tableType = table.GetType();
            String s         = "";

            Comfy.Data.QueryColumn wQc       = null;
            UpdateSqlSection       updateSql = database.Update(table);

            if (updateFields == null)   //更新所有字段

            {
                foreach (System.Reflection.PropertyInfo info in modelType.GetProperties())  //更新所有字段

                {
                    s = info.Name;
                    int i = 0;
                    foreach (QueryColumn wqc in whereQc)
                    {
                        if (wqc.Name == s)
                        {
                            i++;
                            break;
                        }
                    }
                    if (i == 0)
                    {
                        QueryColumn qc = (Comfy.Data.QueryColumn)table.GetType().GetProperty(s).GetValue(table, null);
                        updateSql.AddColumn(qc, info.GetValue(model, null));
                    }
                }
            }
            else //更新部分字段
            {
                foreach (QueryColumn qc in updateFields)
                {
                    foreach (System.Reflection.PropertyInfo info in modelType.GetProperties())  //更新所有字段

                    {
                        if (qc.Name == info.Name)
                        {
                            updateSql.AddColumn(qc, info.GetValue(model, null));
                            break;
                        }
                    }
                }
            }

            foreach (QueryColumn wqc in whereQc)
            {
                foreach (System.Reflection.PropertyInfo wInfo in modelType.GetProperties()) //條件語句
                {
                    if (wqc.Name == wInfo.Name)
                    {
                        updateSql.Where(wqc == wInfo.GetValue(model, null));
                        break;
                    }
                }
            }
            updateSql.Execute();
        }
コード例 #16
0
ファイル: TableColumnData.cs プロジェクト: brhinescot/Loom
 private TableColumnData(ITable table, string columnName, DbType dbType, int maxLength, ColumnProperties columnProperties, string defaultValue, string alias, QueryColumn foreignKeyColumn, IQueryableColumn localizedColumn)
 {
     this.table            = table;
     this.localizedColumn  = localizedColumn;
     this.foreignKeyColumn = foreignKeyColumn;
     Alias                 = alias;
     this.defaultValue     = defaultValue;
     this.columnProperties = columnProperties;
     this.dbType           = dbType;
     this.maxLength        = maxLength;
     this.columnName       = columnName;
 }
コード例 #17
0
ファイル: Query.cs プロジェクト: FizzcodeSoftware/DbTools
 /// <summary>
 /// Left join the <paramref name="table"/> with an <paramref name="alias"/>.
 /// The <see cref="QueryBuilder"/> will automatically build the equality join condition, from the <paramref name="columnSource"/> and the <paramref name="columnTarget"/>.
 /// If the table is referenced in other parts of the query, use table aliasing.
 /// </summary>
 /// <param name="table">The table to join.</param>
 /// <param name="alias">The alias for the table.</param>
 /// <param name="columnSource">The column of the joined table to join on.</param>
 /// <param name="columnTarget">The column of the other table to join. This might be a column of the main table of the Query, or a column of the table of another QueryElement.</param>
 /// <param name="columns">The columns to include in the query. Provide any number of <see cref="QueryColumn"/>s, or <see cref="SqlColumn"/>s (which will be impicitly cast as a QueryColumn.</param>
 /// <returns>The Query.</returns>
 public Query LeftJoinAlias(SqlTable table, string alias, QueryColumn columnSource, QueryColumn columnTarget, params QueryColumn[] columns)
 {
     return(Join(new Join(table, alias, columnSource, columnTarget, JoinType.Left, columns)));
 }
コード例 #18
0
        private void Init()
        {
            Risk_CAFlowProgressID = new QueryColumn(this.GetTableAliasName() + ".Risk_CAFlowProgressID", DbType.Guid, "Risk_CAFlowProgressID", true);

            Risk_ItemID = new QueryColumn(this.GetTableAliasName() + ".Risk_ItemID", DbType.Guid, "Risk_ItemID", false);

            WorkID = new QueryColumn(this.GetTableAliasName() + ".WorkID", DbType.String, "WorkID", false);

            CurrentNodeID = new QueryColumn(this.GetTableAliasName() + ".CurrentNodeID", DbType.String, "CurrentNodeID", false);

            CurrentNodeName = new QueryColumn(this.GetTableAliasName() + ".CurrentNodeName", DbType.String, "CurrentNodeName", false);

            IsNew = new QueryColumn(this.GetTableAliasName() + ".IsNew", DbType.Boolean, "IsNew", false);

            BtnList = new QueryColumn(this.GetTableAliasName() + ".BtnList", DbType.String, "BtnList", false);

            AltContent = new QueryColumn(this.GetTableAliasName() + ".AltContent", DbType.String, "AltContent", false);

            Solutions = new QueryColumn(this.GetTableAliasName() + ".Solutions", DbType.String, "Solutions", false);

            AccepteApplicanceFormFileID = new QueryColumn(this.GetTableAliasName() + ".AccepteApplicanceFormFileID", DbType.Guid, "AccepteApplicanceFormFileID", false);

            SelfInspectionFormFileID = new QueryColumn(this.GetTableAliasName() + ".SelfInspectionFormFileID", DbType.Guid, "SelfInspectionFormFileID", false);

            AcceptRecordFileID = new QueryColumn(this.GetTableAliasName() + ".AcceptRecordFileID", DbType.Guid, "AcceptRecordFileID", false);

            ReformFileID = new QueryColumn(this.GetTableAliasName() + ".ReformFileID", DbType.Guid, "ReformFileID", false);

            OtherID = new QueryColumn(this.GetTableAliasName() + ".OtherID", DbType.Guid, "OtherID", false);

            UnitID = new QueryColumn(this.GetTableAliasName() + ".UnitID", DbType.Guid, "UnitID", false);

            UnitName = new QueryColumn(this.GetTableAliasName() + ".UnitName", DbType.String, "UnitName", false);

            UserID = new QueryColumn(this.GetTableAliasName() + ".UserID", DbType.Guid, "UserID", false);

            UserName = new QueryColumn(this.GetTableAliasName() + ".UserName", DbType.String, "UserName", false);

            Sort = new QueryColumn(this.GetTableAliasName() + ".Sort", DbType.Int32, "Sort", false);

            AddTime = new QueryColumn(this.GetTableAliasName() + ".AddTime", DbType.DateTime, "AddTime", false);

            UpdateTime = new QueryColumn(this.GetTableAliasName() + ".UpdateTime", DbType.DateTime, "UpdateTime", false);

            this.AddColumn(Risk_CAFlowProgressID);

            this.AddColumn(Risk_ItemID);

            this.AddColumn(WorkID);

            this.AddColumn(CurrentNodeID);

            this.AddColumn(CurrentNodeName);

            this.AddColumn(IsNew);

            this.AddColumn(BtnList);

            this.AddColumn(AltContent);

            this.AddColumn(Solutions);

            this.AddColumn(AccepteApplicanceFormFileID);

            this.AddColumn(SelfInspectionFormFileID);

            this.AddColumn(AcceptRecordFileID);

            this.AddColumn(ReformFileID);

            this.AddColumn(OtherID);

            this.AddColumn(UnitID);

            this.AddColumn(UnitName);

            this.AddColumn(UserID);

            this.AddColumn(UserName);

            this.AddColumn(Sort);

            this.AddColumn(AddTime);

            this.AddColumn(UpdateTime);

            //        Risk_Item = new Risk_ItemTableSchema();
            //Risk_Item.SetRelation(this, this.Risk_ItemID == Risk_Item.Risk_ItemID, "Risk_Item");
            //this.AddForeignTable(Risk_Item, "Risk_Item");
        }
コード例 #19
0
        /// <summary>
        /// Do setup in preparation for decompose
        /// </summary>
        /// <param name="qt"></param>
        /// <param name="q"></param>

        public void PrepareForDecompose(
            QueryTable qt,
            Query q)
        {
            throw new NotImplementedException();
#if false
            Stopwatch sw = Stopwatch.StartNew();

            MetaTable mt = qt.MetaTable;

            QueryColumn qc = qt.GetQueryColumnByName("core");
            if (qc == null)
            {
                throw new UserQueryException("Core column not defined in rgroup_decomposition table");
            }
            string molfile = qc.MolString;
            if (molfile == null || molfile == "")
            {             // core not defined in Rgroup decomposition table, try to get from structure search in rest of query
                foreach (QueryTable qt3 in q.Tables)
                {
                    if (!qt3.MetaTable.IsRootTable)
                    {
                        continue;
                    }
                    MetaColumn mc3 = qt3.MetaTable.FirstStructureMetaColumn;
                    if (mc3 != null)
                    {
                        QueryColumn qc3 = qt3.GetQueryColumnByName(mc3.Name);
                        molfile = qc3.MolString;
                        break;
                    }
                }
            }

            if (molfile == null || molfile == "")
            {
                throw new UserQueryException("R-group decomposition core structure is not defined");
            }

            bool allowHydrogenSubstituents = true;
            qc = qt.GetQueryColumnByName("AllowHydrogenSubstituents");
            if (Lex.Contains(qc?.Criteria, "'N'"))
            {
                allowHydrogenSubstituents = false;                                                // set to false if "no" criteria specified
            }
            TerminateOptionString = "First mapping";
            bool allowMultipleCoreMappings = false;

            qc = qt.GetQueryColumnByName("Terminate_Option");
            if (qc != null && qc.Criteria != "")
            {
                ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(qc.Criteria);
                TerminateOptionString     = psc.Value;
                allowMultipleCoreMappings = Lex.Contains(TerminateOptionString, "All");
            }

            MoleculeMx cs = new MoleculeMx(MoleculeFormat.Molfile, molfile);
            cs.GetCoreRGroupInfo(out RgCounts, out RgTotalCount);             // need to redefine these

            RGroupDecomp.Initialize();

            RGroupDecomp.SetAlignStructuresToCore(true);
            RGroupDecomp.SetAllowMultipleCoreMappings(allowMultipleCoreMappings);
            RGroupDecomp.SetIncludeHydrogenFragments(allowHydrogenSubstituents);

            if (DebugMx.True)             // debug
            {
                String  coreSmiles = "[R1]c1cn2c3c(c1= O)cc(c(c3SC(C2)[R4])[R3])[R2]";
                string  coreChime  = "CYAAFQwAUewQeV58YHemfM^EQqPRfIYlJGEkx6M7e4db95jjK5HrNFVP2e1qHphWPL98KvcvrsF7bP9bRcW4QH$si9PXkkuwre6Q5UkHZjciQqeAKVLSHNAeQTAMlkiXEBD$BePpbNQCPD3BkklFEaQqwokeI$FwUoS5cAixQXkMbLTWDaAK7t7cOkSmt3RhwQedbrba6OHKBq3OF4Dhlz$0BfLeKCUUo8ixle176M2aIzXUccTOU8Xy8ARwE3bTyMfjuI3UunZceJf4iZELvsj3PX2MHZG73baUvQGS4DaxUaBGps81PPiDljfvxwFv8OfdOyIRlOBeuEAvk2rT9SRT6oMZIV6UtLFvmCHdwKnu9WtrfV1rEctydNUVxW4qKVlV0rZtpK1oZXuKcv6WVdl6r2hrjVLxBhblTVKO7w1qGRoziquOnPQkKd9H4EQfV0rP6mzI8Au8ulti2fu3YKB94lPXftPGbwr5yA";
                IMolLib coreMol    = MolLibFactory.NewMolLib(MoleculeFormat.Molfile, molfile);
                coreChime = MoleculeMx.MolfileStringToChimeString(molfile);
                molfile   = coreMol.MolfileString;
            }

            CoreMolecule = CdkMol.Util.MolfileStringToMolecule(molfile);
            RGroupDecomp.SetCoreStructure(CoreMolecule, false);

            CoreChemicalStructure = new MoleculeMx(MoleculeFormat.Molfile, molfile);
            StrMatcher            = null;

            int msTime = (int)sw.ElapsedMilliseconds;
            if (RGroupDecomp.Debug)
            {
                DebugLog.Message("Time(ms): " + msTime);
            }

            return;
#endif
        }
コード例 #20
0
/// <summary>
/// Add a new filter
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void AddFilterButton_Click(object sender, EventArgs e)
        {
            QueryColumn qc = null;

            FieldSelectorControl fieldSelector = new FieldSelectorControl();
            Point p = new Point(AddFilterButton.Left, AddFilterButton.Bottom);

            p = this.PointToScreen(p);

            SelectColumnOptions flags = new SelectColumnOptions();

            flags.SearchableOnly      = true;
            flags.FirstTableKeyOnly   = true;
            flags.SelectFromQueryOnly = true;
            DialogResult dr = fieldSelector.SelectColumnFromQuery(Qm.Query, null, flags, p.X, p.Y, out qc);

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

            if (qc.SecondaryFilterType != FilterType.Unknown)
            {
            }                                                                 // already have a filter
            if (qc.MetaColumn.DataType == MetaColumnType.Structure)
            {
                qc.SecondaryFilterType = FilterType.StructureSearch;
            }

            else
            {
                ColumnStatistics stats = null;
                if (Qm != null && Qm.DataTableManager != null)
                {
                    stats = Qm.DataTableManager.GetStats(qc);
                }
                if (stats != null && stats.DistinctValueList.Count <= 10)
                {
                    qc.SecondaryFilterType = FilterType.CheckBoxList;
                }
                else if (qc.MetaColumn.IsNumeric)
                {
                    qc.SecondaryFilterType = FilterType.RangeSlider;
                }
                else
                {
                    qc.SecondaryFilterType = FilterType.BasicCriteria;
                }
            }

            ActiveQueryColumn = qc;

            if (!Qm.DataTableManager.FiltersEnabled)             // be sure filters are enabled & view also
            {
                Qm.DataTableManager.FiltersEnabled = true;
                Qm.DataTableManager.ApplyFilters();
                Qm.DataTableManager.UpdateFilterState();
                QueryResultsControl.GetQrcThatContainsControl(this).UpdateFilteredViews();
            }

            Render();
        }
コード例 #21
0
        /// <summary>
        /// SetupQueryTableForRGroupDecomposition
        /// </summary>
        /// <param name="qt"></param>
        /// <param name="q"></param>

        public void SetupQueryTableForRGroupDecomposition(
            QueryTable qt,
            Query q)
        {
            Stopwatch sw = Stopwatch.StartNew();

            MetaTable mt = qt.MetaTable;

            QueryColumn qc = qt.GetQueryColumnByName("core");

            if (qc == null)
            {
                throw new UserQueryException("Core column not defined in rgroup_decomposition table");
            }
            string molfile = qc.MolString;

            if (molfile == null || molfile == "")
            {             // core not defined in Rgroup decomposition table, try to get from structure search in rest of query
                foreach (QueryTable qt3 in q.Tables)
                {
                    if (!qt3.MetaTable.IsRootTable)
                    {
                        continue;
                    }
                    MetaColumn mc3 = qt3.MetaTable.FirstStructureMetaColumn;
                    if (mc3 != null)
                    {
                        QueryColumn qc3 = qt3.GetQueryColumnByName(mc3.Name);
                        molfile = qc3.MolString;
                        break;
                    }
                }
            }

            if (molfile == null || molfile == "")
            {
                throw new UserQueryException("R-group decomposition core structure is not defined");
            }

            MoleculeMx cs = new MoleculeMx(MoleculeFormat.Molfile, molfile);

            cs.GetCoreRGroupInfo(out RgCounts, out RgTotalCount);

            if (RgCounts.Count == 0 || (RgCounts.ContainsKey(0) && RgCounts.Count == 1))
            {
                throw new UserQueryException("R-group decomposition core structure must contain at least one numbered R-group");
            }

            qc = qt.GetQueryColumnByName("R1_Structure");             // update any core structure label
            if (qc == null)
            {
                throw new UserQueryException("Can't find R1_Structure in " + mt.Label);
            }
            if (qc.Label.IndexOf("\tChime=") > 0)
            {
                qc.Label            = "R-group, Core\tChime=" + cs.GetChimeString();      // reference core in query col header label
                qc.MetaColumn.Width = 25;
            }

            SetRnToMatchR1(qt, "Structure");             // reset querycolumn selection & width to match R1
            SetRnToMatchR1(qt, "Smiles");
            SetRnToMatchR1(qt, "Formula");
            SetRnToMatchR1(qt, "Weight");
            SetRnToMatchR1(qt, "SubstNo");

            int msTime = (int)sw.ElapsedMilliseconds;

            //if (RGroupDecomp.Debug) DebugLog.Message("Time(ms): " + msTime);

            return;
        }
コード例 #22
0
    /// <summary>
    /// Saves the values.
    /// </summary>
    public void Save()
    {
        if (Node == null)
        {
            return;
        }

        if (!RaiseOnCheckPermissions(PERMISSION_MODIFY, this))
        {
            var cui = MembershipContext.AuthenticatedUser;
            if ((cui == null) || ((UserID != cui.UserID) && !cui.IsAuthorizedPerResource("CMS.Users", PERMISSION_MODIFY)))
            {
                RedirectToAccessDenied("CMS.Users", PERMISSION_MODIFY);
            }
        }

        // Prepare selected values
        InitCurrentValues();

        bool logUpdateTask = false;

        // Remove old items
        string newValues = ValidationHelper.GetString(selectCategory.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, mCurrentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            // Add all new items to user
            foreach (string item in newItems)
            {
                int categoryId = ValidationHelper.GetInteger(item, 0);
                DocumentCategoryInfo.Provider.Remove(Node.DocumentID, categoryId);
            }

            logUpdateTask = true;
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(mCurrentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            // Add all new items to user
            foreach (string item in newItems)
            {
                int categoryId = ValidationHelper.GetInteger(item, 0);

                // Make sure, that category still exists
                if (CategoryInfo.Provider.Get(categoryId) != null)
                {
                    DocumentCategoryInfo.Provider.Add(Node.DocumentID, categoryId);
                }
            }

            var catsToRemove = DocumentCategoryInfoProvider.GetDocumentCategories(Node.DocumentID)
                               .Column(QueryColumn.FromExpression("CategoryID AS ID"))
                               .Where("EXISTS (SELECT CategoryID FROM CMS_Category AS CC WHERE CC.CategoryIDPath LIKE CategoryIDPath + '/%' AND CC.CategoryID IN (SELECT CategoryID FROM CMS_DocumentCategory WHERE DocumentID = " + Node.DocumentID + "))")
                               .TypedResult;

            if (!DataHelper.DataSourceIsEmpty(catsToRemove))
            {
                foreach (DataRow dr in catsToRemove.Tables[0].Rows)
                {
                    // Remove categories covered by their children from document
                    DocumentCategoryInfo.Provider.Remove(Node.DocumentID, ValidationHelper.GetInteger(dr["ID"], 0));
                }
            }

            logUpdateTask = true;
        }

        // Raise on after save
        if (OnAfterSave != null)
        {
            OnAfterSave();
        }

        if (logUpdateTask)
        {
            // Log the synchronization if category bindings were changed
            DocumentSynchronizationHelper.LogDocumentChange(Node.NodeSiteName, Node.NodeAliasPath, TaskTypeEnum.UpdateDocument, DocumentManager.Tree);
        }

        isSaved = true;

        // Clear content changed flag, changes are saved directly
        DocumentManager.ClearContentChanged();
    }
コード例 #23
0
        public void Setup(ColumnInfo colInfo)
        {
            InSetup = true;

            ColInfo = colInfo;             // save ref to colInfo
            QueryColumn qc = colInfo.Qc;

            Stats = colInfo.Rfld.GetStats();
            RangeFilter.Properties.Minimum = 0;
            RangeFilter.Properties.Maximum = Stats.DistinctValueList.Count - 1;

            ParsedSingleCriteria psc = MqlUtil.ParseSingleCriteria(ColInfo.Qc.SecondaryCriteria);             // parse criteria

            TrackBarRange tbr = new TrackBarRange(0, Stats.DistinctValueList.Count - 1);

            RangeFilter.Value = tbr;

            if (psc != null && psc.OpEnum == CompareOp.Between && Stats.DistinctValueList.Count > 0)             // setup prev value
            {
                MetaColumnType type    = ColInfo.Mc.DataType;
                MobiusDataType lowVal  = MobiusDataType.New(type, psc.Value);
                MobiusDataType highVal = MobiusDataType.New(type, psc.Value2);
                if (MetaColumn.IsDecimalMetaColumnType(type))
                {                 // adjust decimal comparison values by an epsilon
                    double e = MobiusDataType.GetEpsilon(Stats.MaxValue.FormattedText);
                    lowVal.NumericValue  += e;
                    highVal.NumericValue -= e;
                }

                int lowPos = -1;
                for (int i1 = 0; i1 < Stats.DistinctValueList.Count; i1++)
                {
                    MobiusDataType mdt  = Stats.DistinctValueList[i1];
                    string         fTxt = mdt.FormattedText;

                    if (mdt.CompareTo(lowVal) <= 0 || Lex.Eq(fTxt, psc.Value))
                    {
                        lowPos = i1;
                    }
                    else
                    {
                        break;
                    }
                }

                int highPos = -1;
                for (int i1 = Stats.DistinctValueList.Count - 1; i1 >= 0; i1--)
                {
                    MobiusDataType mdt  = Stats.DistinctValueList[i1];
                    string         fTxt = mdt.FormattedText;

                    if (mdt.CompareTo(highVal) >= 0 || Lex.Eq(fTxt, psc.Value2))
                    {
                        highPos = i1;
                    }
                    else
                    {
                        break;
                    }
                }

                if (lowPos >= 0 && highPos >= 0)
                {
                    tbr = new TrackBarRange(lowPos, highPos);
                    RangeFilter.Value = tbr;
                }
            }

            UpdateLabels();

            RangeFilter.Focus();
            InSetup = false;
            return;
        }
コード例 #24
0
ファイル: QueryColumnTests.cs プロジェクト: vetraskr/Pagan
 public void QueryColumnsAreEqualIfTheColumnsAreEqual()
 {
     var qc1 = new QueryColumn(_table.Controller.Id);
     var qc2 = new QueryColumn(_table.Controller.Id);
     Assert.AreEqual(qc1, qc2);
 }
コード例 #25
0
 /// <summary>
 /// 获取总的数据条数
 /// </summary>
 /// <param name="DB"></param>
 /// <param name="column"></param>
 /// <returns></returns>
 public static int GetTotalRecord(EDatabase db, IQueryTable table, QueryColumn column, WhereClip where)
 {
     return(Convert.ToInt32(db.Select(table, column.Count()).Where(where).ToScalar()));
 }
コード例 #26
0
ファイル: Query.cs プロジェクト: saveenr/saveenr
 public QueryColumn Add( WDSField f)
 {
     var col = new QueryColumn(f, this.Columns.Count);
     this.Columns.Add( col );
     return col;
 }
コード例 #27
0
        /// <summary>
        /// Invoke the editor
        /// </summary>
        /// <param name="qc">QueryColumn to edit</param>
        /// <returns></returns>

        public static bool Edit(
            QueryColumn qc)
        {
            ParsedSingleCriteria psc;

            if (qc.MetaColumn.DictionaryMultipleSelect)
            {
                return(CriteriaDictMultSelect.Edit(qc));
            }

            if (Instance == null)
            {
                Instance = new CriteriaMolFormula();
            }

            if (qc.Criteria != "")
            {
                psc = MqlUtil.ParseQueryColumnCriteria(qc);
            }

            else
            {
                psc        = new ParsedSingleCriteria();
                psc.OpEnum = CompareOp.FormulaEqual;
            }

            Instance.Formula.Text = psc.Value;
            if (psc.OpEnum == CompareOp.FormulaEqual)
            {
                Instance.ExactMF.Checked = true;
            }
            else
            {
                Instance.PartialMF.Checked = true;
            }

            DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);

            if (dr == DialogResult.Cancel)
            {
                return(false);
            }

            string val = Instance.Formula.Text.Trim();

            if (val == "")             // no criteria
            {
                qc.Criteria = qc.CriteriaDisplay = "";
                return(true);
            }

            if (Instance.ExactMF.Checked)
            {
                qc.Criteria        = qc.MetaColumn.Name + " fmla_eq " + Lex.AddSingleQuotes(val);;
                qc.CriteriaDisplay = "= " + val;
            }

            else
            {
                qc.Criteria        = qc.MetaColumn.Name + " fmla_like " + Lex.AddSingleQuotes(val);
                qc.CriteriaDisplay = "like " + val;
            }

            return(true);
        }
コード例 #28
0
        /// <summary>
        /// Analyze key criteria in token list.
        /// A saved list reference is returned as a set of key values &
        /// blanked out in the token list.
        /// Other key references are returned as a set of indexes in a list.
        /// </summary>
        /// <param name="q"></param>
        /// <param name="Qtd"></param>
        /// <param name="tokens"></param>
        /// <param name="keyCriteriaPositions">Token indexes for key criteria column names</param>
        /// <param name="keyCriteriaSavedListKeys">Keys in any referenced saved list</param>
        /// <param name="keyCriteriaInListKeys">Keys in any literal list </param>
        /// <param name="keyCriteriaConstantPositions">Positions of key values for literal lists</param>

        public static void AnalyzeKeyCriteria(
            Query q,
            QueryTableData[] Qtd,
            List <MqlToken> tokens,
            out CompareOp keyCriteriaOp,
            out List <int> keyCriteriaPositions,
            out List <string> keyCriteriaSavedListKeys,
            out List <string> keyCriteriaInListKeys,
            out List <int> keyCriteriaConstantPositions)
        {
            string tok1, tok2, tok3, tok4, tok5;

            keyCriteriaOp                = CompareOp.Unknown;
            keyCriteriaPositions         = new List <int>();
            keyCriteriaSavedListKeys     = null;
            keyCriteriaInListKeys        = null;
            keyCriteriaConstantPositions = new List <int>();

            for (int tki = 0; tki < tokens.Count; tki++)
            {
                QueryColumn qc = tokens[tki].Qc;
                if (qc == null)
                {
                    continue;
                }
                if (!qc.IsKey)
                {
                    continue;
                }

                keyCriteriaPositions.Add(tki);                 // remember position of key col reference

                if (tokens.Count < tki + 2)
                {
                    throw new QueryException("Incomplete compound id criteria at end of statement");
                }

                bool notLogic = false;

                tok1 = GetTokenListString(tokens, tki + 1);

                if (Lex.Eq(tok1, "Not"))
                {
                    notLogic = true;
                    tki++;
                    if (tokens.Count < tki + 2)
                    {
                        throw new QueryException("Incomplete compound id criteria at end of statement");
                    }
                    tok1 = GetTokenListString(tokens, tki + 1);
                }

                tok2 = GetTokenListString(tokens, tki + 2);
                tok3 = GetTokenListString(tokens, tki + 3);
                tok4 = GetTokenListString(tokens, tki + 4);
                tok5 = GetTokenListString(tokens, tki + 5);

                // Saved List

                if (tokens.Count > tki + 3 && Lex.Eq(tok1, "In") &&
                    Lex.Eq(tok2, "List"))
                {                 // have a saved list
                    keyCriteriaOp = CompareOp.InList;

                    if (keyCriteriaSavedListKeys != null)                     // already have it?
                    {
                        throw new UserQueryException("Only one condition is allowed for the " + qc.ActiveLabel + " field");
                    }

                    if (notLogic)                     // not currently allowed for saved lists
                    {
                        throw new UserQueryException("\"Not\" logic is not allowed for " + qc.ActiveLabel + " saved lists");
                    }

                    string     listName = tokens[tki + 3].Tok.Text;
                    UserObject uo       = ResolveCidListReference(listName);
                    if (uo == null)
                    {
                        throw new UserQueryException("Key list " + listName + " not found");
                    }
                    listName = uo.InternalName;
                    CidList keyCriteriaSavedList = CidListDao.Read(listName, QueryEngine.GetRootTable(q));
                    if (keyCriteriaSavedList == null)
                    {
                        throw new UserQueryException("Key list " + listName + " not found");
                    }
                    keyCriteriaSavedListKeys = keyCriteriaSavedList.ToStringList();
                    tokens[tki].Qc           = null;
                    tokens[tki].Tok.Text     = "";
                    for (int tki2 = tki + 1; tki2 <= tki + 3; tki2++)
                    {
                        tokens[tki2].Tok.Text = "";
                    }
                    if (!MqlUtil.DisableAdjacentAndLogic(tokens, tki, tki + 3))
                    {
                        throw new UserQueryException("Only \"And\" logic is allowed with " +
                                                     qc.ActiveLabel + " saved lists");
                    }

                    int ti = q.GetQueryTableIndexByAlias(qc.QueryTable.Alias);
                    Qtd[ti].CriteriaCount--;
                    keyCriteriaPositions.RemoveAt(keyCriteriaPositions.Count - 1);
                }

                // Explicit list of allowed keys

                else if (tokens.Count > tki + 2 && Lex.Eq(tok1, "In") &&
                         Lex.Eq(tok2, "("))
                {
                    keyCriteriaOp = CompareOp.In;

                    int listKeyCount = 0;                     // count keys in this list
                    for (int tki2 = tki + 3; tki2 < tokens.Count; tki2++)
                    {
                        tok1 = tokens[tki2].Tok.Text;
                        if (tok1 == ",")
                        {
                            continue;
                        }
                        else if (tok1 == ")")
                        {
                            break;
                        }
                        keyCriteriaConstantPositions.Add(tki2);
                        if (keyCriteriaInListKeys == null)
                        {
                            keyCriteriaInListKeys = new List <string>();
                        }

                        MetaTable rootTable = QueryEngine.GetRootTable(q);
                        string    normKey   = CompoundId.Normalize(tok1, rootTable);
                        if (normKey != null && normKey != "")
                        {
                            keyCriteriaInListKeys.Add(normKey);
                            listKeyCount++;
                        }
                    }

                    if (listKeyCount == 0)
                    {
                        throw new UserQueryException("The query contains an invalid empty list of " + qc.ActiveLabel + "s");
                    }
                }

                // Between a range of key values

                else if (tokens.Count > tki + 4 && Lex.Eq(tok1, "Between") &&
                         Lex.Eq(tok3, "And"))
                {
                    keyCriteriaOp = CompareOp.Between;

                    keyCriteriaConstantPositions.Add(tki + 2);
                    keyCriteriaConstantPositions.Add(tki + 4);
                }

                // Single key value, treat like a list with a single value

                else if (Lex.Eq(tok1, "="))
                {
                    keyCriteriaOp = CompareOp.Eq;

                    keyCriteriaConstantPositions.Add(tki + 2);
                    if (keyCriteriaInListKeys == null)
                    {
                        keyCriteriaInListKeys = new List <string>();
                    }

                    MetaTable rootTable = QueryEngine.GetRootTable(q);
                    string    normKey   = CompoundId.Normalize(tok2, rootTable);
                    if (Lex.IsDefined(normKey))
                    {
                        keyCriteriaInListKeys.Add(normKey);
                    }
                }

                // Other binary operator

                else if (MqlUtil.IsBasicComparisonOperator(tok1))
                {
                    keyCriteriaOp = CompareOpString.ToCompareOp(tok1);
                    keyCriteriaConstantPositions.Add(tki + 2);
                }

                // Unary operator "is null"

                else if (Lex.Eq(tok1, "Is") && Lex.Eq(tok2, "Null"))
                {
                    keyCriteriaOp = CompareOp.IsNull;
                }

                // Unary operator "is not null"

                else if (Lex.Eq(tok1, "Is") && Lex.Eq(tok2, "Not") && Lex.Eq(tok3, "Null"))
                {
                    keyCriteriaOp = CompareOp.IsNotNull;
                }

                else
                {
                    throw new QueryException("Unrecognized compound id condition " + tok1);
                }
            }

            return;
        }
コード例 #29
0
/// <summary>
/// Setup the form
/// </summary>
/// <param name="query"></param>
/// <param name="optionPage"></param>
/// <param name="ti"></param>

        void Setup(
            Query query,
            string optionPage,
            ref int ti)
        {
            QueryTable  qt;
            QueryColumn qc;
            MetaTable   mt;
            string      txt;
            int         i1, i2;

            Query = query;

            string formCaption = "Query Options";

            if (Security.IsAdministrator(Security.UserName) && query.UserObject.Id > 0)
            {
                formCaption += " (Query Id: " + query.UserObject.Id + ")";
            }
            Text = formCaption;

            int tpi = -1;

            if (optionPage == "SumPos")
            {
                tpi = 0;
            }
            else if (optionPage == "Alert")
            {
                tpi = 1;
            }
            else if (optionPage == "Misc")
            {
                tpi = 1;
            }
            else if (optionPage == "Advanced")
            {
                tpi = 2;
            }

            if (tpi >= 0)
            {
                Tabs.SelectedTabPageIndex = tpi;                       // goto any specified page, otherwise stay where we were last time
            }
            // Setup general tab

            txt = SS.I.DefaultNumberFormat.ToString() + " (" + SS.I.DefaultDecimals.ToString() + ")";
            DefaultNumberFormat.Text = txt;

            txt = QbUtil.ConvertStatDisplayFormat(query.StatDisplayFormat);
            QnfStatsTextEdit.Text = txt;

            SetAlertText(query);

            TableColumnZoom.ZoomPct    = SS.I.TableColumnZoom;                  // Setup zoom controls
            GraphicsColumnZoom.ZoomPct = SS.I.GraphicsColumnZoom;

// Advanced options - query specific

            DuplicateKeyValues.Checked   = query.DuplicateKeyValues;
            FilterNullRows.Checked       = query.FilterNullRows;
            ShowCondFormatLabels.Checked = query.ShowCondFormatLabels;
            //BrowseExistingResultsWhenOpened.Checked = query.BrowseExistingResultsWhenOpened;
            RunQueryWhenOpened.Checked = query.RunQueryWhenOpened;
            //UseCachedData.Checked = query.UseCachedData;
            CombineSearchAndRetrieval.Checked = query.SingleStepExecution;
            Multitable.Checked  = query.Multitable;            // (not visible)
            MobileQuery.Checked = query.Mobile;


// Advanced options - applies to all queries

            RepeatReport.Checked               = SS.I.RepeatReport;
            ShowStereoComments.Checked         = SS.I.ShowStereoComments;
            BreakHtmlPopupsAtPageWidth.Checked = SS.I.BreakHtmlPopupsAtPageWidth;
            RestoreWindowsAtStartup.Checked    = SS.I.RestoreWindowsAtStartup;

            HilightCorpIdChanges.Checked       = SS.I.HilightCidChanges;
            RemoveLeadingZerosFromCids.Checked = SS.I.RemoveLeadingZerosFromCids;
            MarkCheckBoxesInitially.Checked    = SS.I.GridMarkCheckBoxesInitially;

            EvenRowBackgroundColor.Color = SS.I.EvenRowBackgroundColor;
            OddRowBackgroundColor.Color  = SS.I.OddRowBackgroundColor;

            DnfMc            = new MetaColumn();  // setup to get new number format info
            DnfMc.DataType   = MetaColumnType.QualifiedNo;
            DnfMc.Format     = SS.I.DefaultNumberFormat;
            DnfMc.Decimals   = SS.I.DefaultDecimals;
            DnfQc            = new QueryColumn();
            DnfQc.MetaColumn = DnfMc;

            DefaultToSingleStepQueryExecution.Checked = MqlUtil.DefaultToSingleStepQueryExecution;

            // Setup summarization / table position tab

            CustomSummarization.Visible = Aggregator.IsAvailableForUser;

            DataTable dt = CreateDataTable();

            OriginalQueryTables = new Dictionary <string, QueryTable>();            // keep set of original tables
            for (i1 = 0; i1 < query.Tables.Count; i1++)
            {
                qt = query.Tables[i1];
                mt = qt.MetaTable;

                object cs;
                if (mt.SummarizedExists)
                {
                    if (qt.MetaTable.UseSummarizedData)
                    {
                        cs = true;
                    }
                    else
                    {
                        cs = false;
                    }
                }
                else
                {
                    cs = DBNull.Value;
                }

                string tableLabel = qt.ActiveLabel;
                while (OriginalQueryTables.ContainsKey(tableLabel))
                {
                    tableLabel += ".";                                   // avoid unlikely but possible dup name
                }
                OriginalQueryTables.Add(tableLabel, qt);                 // accumulate original labels

                int selectCount = 0, criteriaCount = 0;
                for (i2 = 0; i2 < qt.QueryColumns.Count; i2++)
                {
                    qc = qt.QueryColumns[i2];
                    if (qc.Selected)
                    {
                        selectCount++;
                    }
                    if (qc.Criteria != "")
                    {
                        criteriaCount++;
                    }
                }
                txt = selectCount.ToString() + "/" +
                      qt.QueryColumns.Count.ToString() + ", " + criteriaCount.ToString();

                DataRow dr = DataTable.NewRow();
                dr["SummarizedCol"] = cs;
                dr["TableNameCol"]  = tableLabel;
                dr["SelectedFieldsAndCriteriaCountsCol"] = txt;
                DataTable.Rows.Add(dr);
            }

            TableGrid.DataSource = DataTable;

            if (ti >= 0 && ti < query.Tables.Count)
            {
                SelectRow(ti);
            }

            if (ServicesIniFile.Read("QueryOptionsHelpUrl") != "")
            {
                Help.Enabled = true;
            }

            EditAlertOnOpen = Lex.Eq(optionPage, "Alert");

            return;
        }