Example #1
0
        /// <summary>
        /// Update a Resource
        /// </summary>
        /// <param name="source_id">string object</param>
        /// <param name="name"string object></param>
        /// <param name="internal_id">string object</param>
        /// <param name="description">string object</param>
        /// <param name="internal_url">string object</param>
        /// <param name="resourceType">resourceType object</param>
        /// <param name="collection_name">string object</param>
        /// <param name="date_created">DateTime object</param>
        /// <param name="gene_ids">string[] object</param>
        /// <param name="ontologies">string[] object</param>
        /// <param name="pubmedid">string object</param>
        /// <returns></returns>
        public virtual string UpdateResource(string source_id, string name, string internal_id, string description, string internal_url,
            string resourceType, string collection_name, DateTime date_created, string[] gene_ids, string[] ontologies, string pubmedid)
        {
            dkCOIN.typeResource[] resources = new dkCOIN.typeResource[1];
            dkCOIN.typeResource resource = new dkCOIN.typeResource();

            resource.name = name;
            resource.internal_id = internal_id;
            resource.internal_url = internal_url;
            resource.collection_name = collection_name;
            resource.resourcetype = resourceType;
            if (description.Length > 2000)
                description = description.Substring(0, 1999);
            resource.description = description;
            resource.internal_create_date = date_created;
            if (!string.IsNullOrEmpty(pubmedid))
            {
                dkCOIN.typePublication PubMedType = new dkCOIN.typePublication();
                //PubMedType.citation = false;
                PubMedType.pubmed_id = pubmedid;
                resource.pubmed = new dkCOIN.typePublication[1];
                resource.pubmed[0] = PubMedType;
            }
            if (date_created != null)
                resource.internal_create_dateSpecified = true;
            if (gene_ids != null)
                resource.gene_id = gene_ids;
            if (ontologies != null)
                resource.term_identifier = ontologies;
            resources[0] = resource;
            try
            {
                if (webservice == null) return "";
                StartSession();
                int result_ct = 0;
                result_ct = webservice.updateResource(resources).Length;
                dkCOIN.typeResourceResult[] results = new dkCOIN.typeResourceResult[result_ct];
                results = webservice.updateResource(resources);
                string action = results[0].action;
                bool inserted = action.ToLower().StartsWith("inserted");
                EndSession();
                return action + ": " + name + (!inserted ? " updated " : " inserted ") + "successfully.";
            }
            catch (Exception e)
            {
                EndSession();
                string msg = e.Message;
                msg = msg.Replace("\'", "");
                msg = msg.Replace("\n", "");
                EmailErrorNotification("UpdateResource", msg);
                return null;
            }
        }
Example #2
0
        /// <summary>
        /// Gets dkCOIN resources
        /// </summary>
        /// <param name="Search">DKCoinSearch Object</param>
        /// <returns>DKCoinResourceList object</returns>
        public virtual DKCoinResourceList GetResources(DKCoinSearch Search)
        {
            try
            {
                FilterResourceTypes = Search.FilterResourceTypes;
                dkCOIN.typeSearchResourceParams[] parameters = new dkCOIN.typeSearchResourceParams[1];
                dkCOIN.typeSearchResourceParams param = new dkCOIN.typeSearchResourceParams();
                if (!string.IsNullOrEmpty(Search.ResourceType))
                    param.resourcetype = Search.ResourceType;
                //
                //EXCLUDE CURRENT CONSORTIUM'S DATA
                string[] not_source_ids = new string[1];
                string not_source_id = GetSourceID().ToString();
                not_source_ids[0] = not_source_id;
                param.not_source_id = not_source_ids;
                if (!string.IsNullOrEmpty(Search.ResourceName))
                    param.name = Search.ResourceName;
                if (Search.gene_ids != null)
                    param.gene_id = Search.gene_ids;
                if (Search.term_ids != null)
                    param.term_identifier = Search.term_ids;
                if (Search.PubMed != null && !string.IsNullOrEmpty(Search.PubMed.pubmed_id))
                {
                    dkCOIN.typePublication[] pubmedids = new dkCOIN.typePublication[1];
                    pubmedids[0] = Search.PubMed;
                    param.pubmed = pubmedids;
                }
                if (!string.IsNullOrEmpty(Search.Source))
                    param.source_id = Search.Source;
                parameters[0] = param;
                DKCoinResourceList resources = GetResources(parameters);

                return resources;
            }
            catch (Exception e)
            {
                EmailErrorNotification("GetResources(DKCoinSearch Search)", e.Message);
                return null;
            }
        }