Toad data modeler scripting: Entity.Attributes[i].Domain returns undefined - toad

I'm trying to programmatically retrieve the domain of a table's field.
We only use domains in our model, as shown below:
The code is the following:
for (var counterAttr = 0; counterAttr < TableObject.Attributes.Count; counterAttr++)
{
var attr = TableObject.Attributes.GetObject(counterAttr);
Log.Information("Field[" +counterAttr +"]: " + attr.Name + " (" + attr.Domain + ")");
}
But unfortunately it outputs as follows:
Field[0]: LDAP_USED_GROUP_ID (undefined)
Field[1]: LDAP_DOMAIN_ID (undefined)
Field[2]: LDAP_USED_GROUP_NAME (undefined)
...
Any ideas?

The solution, found through Toad forums, is to use:
attr.Domain.Name
even if attr.Domain itself is undefinded... who knows?

Related

SqlDataAdapter not loading datatable - C++

I have been trying to load an SQL database into a datatable in C++, however; it doesn't seem to want to work. The connection is working though, as DataReader works. Here is my code
void importDatabase() {
SqlConnection con;
SqlDataAdapter^ da;
SqlCommand cmd;
DataTable^ dt;
int count = 1;
try {
con.ConnectionString = "Data Source=MYNAME\\SQLEXPRESS;Initial Catalog=VinylRecords;Integrated Security=True";
cmd.CommandText = "SELECT * FROM Records";
cmd.Connection = %con;
con.Open();
da = gcnew SqlDataAdapter(%cmd);
dt = gcnew DataTable("Records");
Console::Write(da->ToString());
da->Fill(dt);
for (int i = 0; i < dt->Rows->Count - 1; i++) {
String^ value_string;
value_string = dt->Rows[i]->ToString();
Console::WriteLine(dt->Rows[i]->ToString());
count++;
}
cout << "There are " << count << " many records";
}
catch (Exception^ ex) {
Console::WriteLine(ex->ToString());
}
}
Please note, that I slightly altered the source name to post here, but only the first part.
What is wrong with my code?
So, the problem is here:
dt->Rows[i]->ToString()
Rows[i] is a Row object. And the Row class's ToString() method always prints out the fully qualified typename, which is what you are seeing. So this is technically working just fine. What you will need to do to get something useful is: you will need to access a specific column in that row and get it's value, then output that.
Something along the lines of:
foreach (DataRow dr in dt.Rows)
{
Console.Write(dr.Field<int>("ColumnOne"));
Console.Write(" | ");
Console.WriteLine(dr.Field<string>("ColumnTwo"));
}
I am not entirely sure on the syntax for accessing a specific cell inside of a DataTable when using C++\CLI. So I have provided the C# equivalent to explain why it is you were getting output of managed type names (e.g. "System.Data.DataRow") instead of the info inside of the Row's columns.
Also, I noticed you tagged this question with "mysql", but you are using the ADO.NET System.Data.SqlClient namespace. The SqlDataReader and SqlDataAdapter classes only work with TSQL (Microsoft's SQL Server databases) If you are actually connecting to a mysql database you will want to use the System.Data.OdbcDataAdapter class. You can read a little more here: https://msdn.microsoft.com/en-us/library/ms254931.aspx

get the first parameter of a string using regular expression

function getParameterByName(name, str) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(str);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
I'm using this algorithm for getting the value from the string, found it in internet
my string is
mihpayid=403993715510554486&mode=CC&status=success&unmappedstatus=captured&key=JBZaLc&txnid=t39SfgBZFEFLwhxEC&amount=1000.0&addedon=2014-12-06+17%3A34%3A26&productinfo=Devthon&firstname=sasi.kanth80%40gmail.c&lastname=&address1=&address2=&city=&state=&country=&zipcode=&email=sasi.kanth80%40gmail.com
I'm able to get all the parameters like status key
But I'm unable to get the mihpayid value which is the first parameter
How can I get that any suggestion?
getParameterByName("success", data);
You can make use of this function which will form a flattened array looking like
[key,value, anotherkey,anothervalue,...] so we could just find the value by adding one to the index of key.
function getParameterByName(name, str) {
var arr = str.split('&').map(function(s){
return s.split('=')
}).join().split(","); // flatten the array
return decodeURIComponent(arr[arr.indexOf(name) + 1]);
}
A regular expression like /([a-zA-Z0-9]*)=([^&]*)/ig will return all matches with the variable and value conveniently sorted.
I think your solution is really close, it's just missing a couple of things. One not sure if it is a typo or not but the line var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); ends in a comma. Outside of this the only thing you needed to do is update the following [\\?&] to [\\?&]?
function getParameterByName(name, str) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]?" + name + "=([^&#]*)");
results = regex.exec(str);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
data="mihpayid=403993715510554486&mode=CC&status=success&unmappedstatus=captured&key=JBZaLc&txnid=t39SfgBZFEFLwhxEC&amount=1000.0&addedon=2014-12-06+17%3A34%3A26&productinfo=Devthon&firstname=sasi.kanth80%40gmail.c&lastname=&address1=&address2=&city=&state=&country=&zipcode=&email=sasi.kanth80%40gmail.com";
console.clear();
console.log(getParameterByName("unmappedstatus", data));
console.log(getParameterByName("status", data));
console.log(getParameterByName("mihpayid", data));
Results in Console:
regex:10 Console was cleared
regex:11 captured
regex:12 success
regex:13 403993715510554486
regex:1 undefined

Faceted search on multilist in sitecore 7

I'm able to generate the facet and bind the result in Linkbutton within repeater control. Now I'm facing problem in generating the facet query with OR operator when the user selects more than 1 value of same facet type in Sitecore 7.
What can be done to solve it?
Thanks
Here's a blog post about solving this using PredicateBuilder with a specific code example:
http://www.nttdatasitecore.com/en/Blog/2013/November/Building-Facet-Queries-with-PredicateBuilder.aspx
To implement the Facet search in Sitecore use PredicateBuilder class to build the filter query and then add the filter query to the base query. Code is mentioned below:
List<PeopleFields> objPeoplefields = new List<PeopleFields>();
IQueryable<PeopleFields> Query = null;
var predicatePractice = Sitecore.ContentSearch.Utilities.PredicateBuilder.False<PeopleFields>();
var predicateOffice = Sitecore.ContentSearch.Utilities.PredicateBuilder.False<PeopleFields>();
using (var context = ContentSearchManager.GetIndex(SITECORE_WEB_INDEX).CreateSearchContext())
{
//Base query
Query = context.GetQueryable<PeopleFields>().Where(i => i.FirstName.StartsWith(txtFirstName.Text)).Where(i => i.LastName.StartsWith(txtLastName.Text));
foreach (string strselecteFacet in lstPracticefacetSelected)
{
//filter query
predicatePractice = predicatePractice.Or(x => x.Practice.Like(strselecteFacet));
}
foreach (string strselecteFacet in lstOfficefacetSelected)
{
//Filter query
predicateOffice = predicateOffice.Or(x => x.Office.Like(strselecteFacet));
}
//Joining the filter query alongwith base query
if (lstPracticefacetSelected.Count > 0 && lstOfficefacetSelected.Count > 0)
Query = Query.Filter(predicatePractice).Filter(predicateOffice);
else if (lstPracticefacetSelected.Count > 0 && lstOfficefacetSelected.Count == 0)
Query = Query.Filter(predicatePractice);
else if (lstPracticefacetSelected.Count == 0 && lstOfficefacetSelected.Count > 0)
Query = Query.Filter(predicateOffice);
objPeoplefields = Query.ToList();
}
As a quick way, if you're ok with having SitecoreUISearchResultItem as the query result type, you may be able to utilize the same method Sitecore 7 uses to parse queries entered in the content editor search:
Sitecore.Buckets.Util.UIFilterHelpers.ParseDatasourceString(string query)
If that's not up to what you're after, reading how it's implemented with a decompiler (ILSpy, DotPeek, Reflector, Resharper, etc) may help you in composing an expression manually based on dynamic criteria.

Linq query not matching hrefs

I'm trying to write out all matches found using a regex with the code below:
var source = "<Content><link><a xlink:href=\"tcm:363-48948\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">Read more</a></link><links xlink:href=\"tcm:362-65596\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"/></Content>";
var tridionHref = new Regex("tcm:([^\"]*)");
var elem = XElement.Parse(source);
XNamespace xlink = "http://www.w3.org/1999/xlink";
if (tridionHref.IsMatch(elem.ToString()))
{
foreach (var Id in elem.Elements().Where(x => x.Attribute(xlink + "href") != null))
{
Console.WriteLine(Id.Attribute(xlink + "href").Value); //For testing
Id.Attribute(xlink + "href").Value = Id.Attribute(xlink + "href").Value.Replace("value1", "value2"); //Just to show you an example
}
}
My console window outputs tcm:362-65596 but not tcm:363-48948. It looks like the code doesn't see the value of xlink:href inside my <a> tag as an attribute? Can anyone point me in the right direction? I need to match ALL instances of tcm:([^\"]*).
The problem is you are not looking in the right place. Your elem.Elements is looking at the link element and the links element. Only one of these has the attribute that you are looking for. You'll need to select the elements you want to check more precisely before looking for the right attribute.
I've got it working. I didn't need a regex I just needed to get the Descendants instead inside my for loop. foreach (var Id in elem.Descendants().Where(x => x.Attribute(xlink + "href") != null))

how to get the contents of a list in a webpage

I want to get the content of a list in a webpage from below
http://www.alzgene.org/default.asp
like select gene, there are some genes list, I want to get all the genes from this list, is there any way to do this?
I am not sure I should contact the administrator since it stopped update since april 2011
Thanks
If you know how to run a script in the browser console here is the JS that will give you what you want:
var options = document.getElementById('genesDDDiv').getElementsByTagName('option'),
result = "Options: ";
for(var i = 1; i < options.length; i++) {
result += options[i].innerHTML.replace(/<(\/)?option>/, options[i]) + ",";
}
console.log(result);
Results:
A2M,A2MP,ABCA1,ABCA12,ABCA2,ABCA7,ABCB1,ABCC2,ABCC8,ABCC9,ABCG1,ABCG4,ABCG5,ACAD8,ACAN,ACAT2,ACE,ACF,ACHE,ACO2,ACSL4,ACTA2,ADAM10,ADAM12,ADAM17,ADAM9,ADCYAP1R1,ADORA2A,ADORA2B,ADRA1A,ADRA2A,ADRB1,ADRB2,ADRB3,AGER,AGPAT1,AGT,AHR,AHSG,AKAP8,AKT2,ALB,ALDH18A1,ALDH2,ALOX5,ALOX5AP,ANK3,ANXA8,AP3M1,APBA1,APBB1,APBB1IP,APBB2,APEX1,APH1A,APH1B,APOA1,APOA1BP,APOA2,APOA4,APOA5,APOB,APOBEC1,APOBEC2,APOC1,APOC1P1,APOC2,APOC3,APOC4,APOD,APOE,APOE_e2/3/4,APOM,APP,AR,ARID4A,ARID5B,ARL5B,ARMS2,ARSB,ART3,ATF7,ATP6V0A4,ATXN1,ATXN8OS,AVPR1A,BACE1,BACE2,BAG3,BAT1,BCAM,BCHE,BCL2,BCL3,BCR,BDNF,BICC1,BIN1,BIRC3,BLMH,C10orf112,C12orf41,C1R,C2,C21orf55,C21orf63,C4A,C4B,CACNB2,CALHM1,CALHM2,CALHM3,CAMK1G,CAMK2G,CAND1,CARD8,CASP3,CASP4,CASP6,CASP8,CAST,CAT,CAV1,CAV3,CBLC,CBS,CCDC134,CCL2,CCL3,CCL5,CCL8,CCNT1,CCR2,CCR5,CD14,CD2AP,CD33,CD36,CD40,CDC2,CDK5,CDK5R1,CDKN2A,CDKN2BAS,CDX2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