Exemple #1
0
        /// <summary>
        /// Sets up a basic Rest request with header, url, api and api_key params.
        /// NB: is set to "public" for the DeleteRestObject function in DataSaver.
        /// </summary>
        /// <param name="restMeth"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public static RestRequest RestRequest(Method restMeth, SiteConf.Model model)
        {
            RestRequest request = new RestRequest(RestAPI.API + "{model}/", restMeth);
            request.AddParameter("model", model, ParameterType.UrlSegment);
            request.RequestFormat = DataFormat.Json;
            request.AddParameter("username", RestAPI.API_USER);
            request.AddParameter("api_key", RestAPI.API_HASH);

            return request;
        }
Exemple #2
0
        public void StartWatching(SiteConf.Upload.Object upload)
        {
            // only need to watch if the datasource is a spreadsheet
            if (upload.DataSourceType == DataSourceType.Spreadsheet)
            {
                // try and find an existing watcher
                FileWatchers result = _watcherList.Find(
                    delegate(FileWatchers fw)
                    {
                        return fw.Upload == upload;
                    }
                );

                if (result == null)
                {
                    // start new
                    FileWatchers fw = new FileWatchers();
                    fw.FileWatcher = StartWatching(upload.DataSourceName);
                    fw.Upload = upload;

                    _watcherList.Add(fw);
                }
                else
                {
                    // restart existing
                    result.Upload = upload;
                    result.FileWatcher.Dispose(); // releases any held resources from previous source
                    result.FileWatcher.Path = upload.DataSourceName; // update if user has made changes
                    result.FileWatcher.EnableRaisingEvents = true;
                }
            }
        }
Exemple #3
0
        public void StopWatching(SiteConf.Upload.Object upload)
        {
            FileWatchers result = _watcherList.Find(
                delegate(FileWatchers fw)
                {
                    return fw.Upload == upload;
                }
            );

            // stop the watcher and release any resources
            if (result != null)
            {
                //result.FileWatcher.EnableRaisingEvents = false;
                result.FileWatcher.Dispose(); // dispose of any resources held by watcher
            }
            else
                throw new Exception("Could not find the watcher for this upload.");
        }
Exemple #4
0
        /// <summary>
        /// Saves an Instance for the audit database, This will also go on to save into details 
        /// and the HVPTransaction table as well.
        /// </summary>
        /// <param name="iSession"></param>
        /// <param name="instanceID"></param>
        /// <param name="uploadID"></param>
        /// <param name="passKey"></param>
        public static void SaveInstanceAudit(ISession iSession, int uploadID, DataRow dr, SiteConf.HVPTran.Object trans)
        {
            // get upload
            //Upload upload = DataLoader.GetUpload(iSession, uploadID);

            Instance instance = null;
            // if this is an update we try and get the previous
            if (dr[VariantInstance.Status].ToString() == "Update" ||
                dr[VariantInstance.Status].ToString() == "Delete")
            {
                // get existing instance from audit db using the variant instance hashcode
                instance = DataLoader.GetInstance(iSession, dr[VariantInstance.HashCode].ToString(), uploadID);
            }
            else
            {
                // create new instance
                instance = new Instance();
                instance.VariantInstanceID = dr[0].ToString(); // it is assume the raw variant instance id is kept in the first column
                instance.EncryptedHashCode = dr[VariantInstance.HashCode].ToString();
                instance.GeneName = dr[ExporterCommon.Core.StandardColumns.Gene.GeneName].ToString();
                instance.RecordedDate = DateTime.Now;
                instance.UploadID = uploadID;
                //instance.Gene = gene;
            }

            // create new details
            Details details = new Details();
            details.CheckSum = HashEncoder.EncodeDataRow(dr);
            details.Status = dr[VariantInstance.Status].ToString();
            details.Instance = instance;
            details.TransactionID = trans.ID;

            ITransaction iTrans = iSession.BeginTransaction();
            try
            {
                iSession.Save(instance);
                iSession.Save(details);
                iTrans.Commit();
            }
            catch (Exception ex)
            {
                iTrans.Rollback();
                throw ex;
            }
        }
Exemple #5
0
        private void getHashTableRefSeq(Hashtable refSeqNameHT, Hashtable refSeqVerHT, SiteConf.Upload.Object upload)
        {
            IList<SiteConf.Gene.Object> geneList = ExporterCommon.DataLoader.GetGeneList(upload.ID);

            foreach (SiteConf.Gene.Object gene in geneList)
            {
                refSeqNameHT[gene.GeneName] = gene.RefSeqName;
                refSeqVerHT[gene.GeneName] = gene.RefSeqVersion;
            }
        }
Exemple #6
0
        /// <summary>
        /// Sets the datasource radiobuttons and loads the path in the textbox
        /// </summary>
        /// <param name="upload"></param>
        private void displayUploadDetails(SiteConf.Upload.Object upload)
        {
            txtUpload.Text = upload.Name;
            // selects the datasourcetype radiobutton
            switch (upload.DataSourceType)
            {
                case DataSourceType.Database:
                    rbnDatabase.Checked = true;
                    rbnSpreadsheet.Checked = false;
                    rbnSqlServer.Checked = false;
                    pnlFileSource.Visible = true;
                    pnlServer.Visible = false;
                    testDBServerConnectivityToolStripMenuItem.Enabled = false;
                    break;
                case DataSourceType.Spreadsheet:
                    rbnDatabase.Checked = false;
                    rbnSpreadsheet.Checked = true;
                    rbnSqlServer.Checked = false;
                    pnlFileSource.Visible = true;
                    pnlServer.Visible = false;
                    testDBServerConnectivityToolStripMenuItem.Enabled = false;
                    break;
                case DataSourceType.Server:
                    rbnDatabase.Checked = false;
                    rbnSpreadsheet.Checked = false;
                    rbnSqlServer.Checked = true;
                    pnlFileSource.Visible = false;
                    pnlServer.Visible = true;
                    testDBServerConnectivityToolStripMenuItem.Enabled = true;
                    break;
            }

            if (upload.DataSourceType == DataSourceType.Server)
            {
                txtDatasourceServer.Text = upload.DataSourceName;
                txtDatabase.Text = upload.DatabaseName;
                txtDsUsername.Text = upload.UserName;
                txtDsPassword.Text = upload.Password;
            }
            else
            {
                txtDataSourcePath.Text = upload.DataSourceName;
            }

            // displays the Upload in the title
            SetTitleLabel(upload.Name);
        }
Exemple #7
0
        /// <summary>
        /// This function is to be invoked from the FileWatcher
        /// </summary>
        public void LoadSpreadsheetData(SiteConf.Upload.Object upload, string path)
        {
            // required if calling this function from another thread
            if (InvokeRequired)
            {
                Invoke(new LoadSpreadSheetDataDelegate(LoadSpreadsheetData), upload, path);
            }
            else
            {
                try
                {
                    // load the tab first if not exist and 
                    if (!tabControl1.TabPages.Contains(tabDataUpload))
                        tabControl1.TabPages.Add(tabDataUpload);
                    // switch to the upload tab
                    tabControl1.SelectedTab = tabDataUpload;

                    this.Show();
                    this.WindowState = FormWindowState.Normal;

                    // Bring the form to the front
                    this.TopMost = true;
                    this.TopMost = false;

                    // load the upload details
                    LoadUpload(upload.ID);

                    // prepare the variant source for uploading
                    LoadDataGrid(path);
                    if (invalidResults.Rows.Count > 0)
                    {
                        ShowErrorPage();
                    }
                    
                    // set the path to the spreadsheet if user decides to do a reload
                    _spreadsheetPath = path;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemple #8
0
 public void ReloadDgGene(SiteConf.Upload.Object upload)
 {
     dgGenes.DataSource = ExporterCommon.DataLoader.GetGeneList(upload.ID);
     // hide the first and last columns of the datagrid
     GetColumnID("ID", dgGenes).Visible = false;
     GetColumnID("DiseaseTags", dgGenes).Visible = false;
     GetColumnID("upload", dgGenes).Visible = false;
     GetColumnID("resource_uri", dgGenes).Visible = false;
     
     //dgGenes.Columns[0].Visible = false;
     //dgGenes.Columns[4].Visible = false;
     //dgGenes.Columns[5].Visible = false;
 }