I have never wrote a script before and I was asked today to make a Visual SourceSafe script that returns all of the labels that are stored.
I have 0 idea on how to start this as I have never wrote a script before. Can anybody point me in the right direction with this please?
Thanks!
You can use the History command of SourceSafe to get the history info of an item and extract the label info you need.
Here is a simple sample for you:
private void GetItem(VSSItem vssItem)
{
if (vssItem.Type == 0) //Type == 0 means it's a project
{
bool bIncludeDeleted = false;
IVSSItems vssItems = vssItem.get_Items(bIncludeDeleted);
foreach (VSSItem vssitem in vssItems)
{
GetItem(vssitem);
foreach (IVSSVersion vssVersion in vssitem.get_Versions(0))
{
string vssItemName = "";
if (vssVersion.VSSItem.Name == "")
vssItemName = vssitem.Spec;
else
vssItemName = vssVersion.VSSItem.Spec;
if (vssVersion.Action.IndexOf("Label") > -1 )
{
if (vssitem.Spec == vssVersion.VSSItem.Spec)
{
MessageBox.Show("Item " + vssItemName + " in " + "Version " + vssVersion.VersionNumber.ToString() + " With the lable: " + vssVersion.Label);
}
}
}
}
}
Related
I am trying to use translation string in my adapter but it returns numbers instead
if(currentItem.budget != null){
holder.budget.text = "$ " + currentItem.budget.format()
} else {
holder.budget.text = R.string.open_to_suggestions.toString()
}
R.string.open_to_suggestions.toString() supposed to return string text Open to suggestions but it returns numbers such as 2131755113 not sure why! any idea?
To show the string resource you must use context.getString()
if(currentItem.budget != null) {
holder.budget.text = "$ " + currentItem.budget.format()
} else {
val context = holder.itemView.context
holder.budget.text = context.getString(R.string.open_to_suggestions)
}
Please take a look at the definition of getString here
I am banging my head against the wall with this. I am trying to create a search function for a table in my database. I want to be able to search by ID and by first name + last name.
The search by ID function is working perfect:
if (is_id_search)
{
for (int i = 0; i < rowcount; i++)
{
if (table.Rows[i][0].ToString() == searched_id)
{
MessageBox.Show("Student With ID: " + searched_id + " Found", "", MessageBoxButtons.OK);
display_searched_info(table.Rows[i]);
break;
}
else
{
if (i == (rowcount - 1))
{
MessageBox.Show("SEARCH FAILED: Student ID Not Found!", "Search Failed!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
But when I try the same with searching by name it can't match the input string and the value in the table, I have even set a MessageBox to pop up on each iteration of the for loop displaying row[i][column].ToString() and it outputs the name I am searching but still says not found (code below):
else
{
for (int i = 0; i < rowcount; i++)
{
MessageBox.Show(table.Rows[i][1].ToString());
if (table.Rows[i][1].ToString() == searched_Fname)
{
MessageBox.Show("Student By Name Of: " + searched_Fname + " Found!", "Success!", MessageBoxButtons.OK);
break;
}
else
{
if (i == (rowcount - 1))
{
MessageBox.Show("Student By The Name Of: " + searched_Fname + " " + searched_Lname + " Not Found",
"Search Failed!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
Any help/advice is greatly appreciated (a couple of screenshots below)
output string from searched column
error message
Have you tried changing (table.Rows[i][0].ToString() == searched_Fname) for the String
Generic Fetch XML To Get All attributes from any entity in Microsoft Dynamics CRM 2011?
if you want it to be generic, youll have to use reflection to loop through the members and build the query xml dynamically.
something like:
Type type = TypeOf(Contact);
PropertyInfo[] properties = type.GetProperties();
foreach (PropertyInfo property in properties)
{
/////here you chain the members for the xml
Console.WriteLine("Name: " + property.Name + ", Value: " + property.GetValue(obj, null));
}
To fetch details from any entity use below method.
Please read Note and Parameter Description before using this generic Fetchxml generator.
Note : fieldToQuery, operatorForCondition, fieldQueryValue Should have Array Same count to work this function and well Mappep with respective to each other to get desired result
parameter name = "entityName" = Name of Entity of which details to fetch.
parameter name = "fieldsToSearch" = What all fields you want to fetch, if Sent Null, by default all fields are fetched from entity
parameter name = "filterType" = "AND" or "OR"
parameter name = "fieldToQuery" = Array of Field name on which to query
parameter name = "operatorForCondition" = Array of operator between fieldToQuery(Field Name) and fieldQueryValue(Field Value) like "eq, like"
parameter name = "fieldQueryValue" = Array of Field Value respective to fieldToQuery (Field Name) by which to query
Function stats from here
`
public static Microsoft.Xrm.Sdk.EntityCollection RetrieveEntityDetailsByFetchXml(string entityName, string[] fieldsToSearch, string filterType, string[] fieldToQuery, string[] operatorForCondition, string[] fieldQueryValue)
{
string _fetchDetailsXml = #"<fetch version='1.0' mapping='logical' output-format='xml-platform'> <entity name='" + entityName + "'> ";
_fetchDetailsXml = GenerateFetchXMLForAttributes(fieldsToSearch, _fetchDetailsXml);
_fetchDetailsXml += "<filter type='" + filterType + "'>";
if (fieldQueryValue.Count() != fieldToQuery.Count() && fieldToQuery.Count() != operatorForCondition.Count())
{
throw new ApplicationException("FieldtoQuery and FieldQueryValue are not mapped correctly fieldToQuery : " + fieldToQuery.Count() + " fieldQueryValue : " + fieldQueryValue.Count() + ".");
}
_fetchDetailsXml = GenerateFetchXMLForConditions(fieldToQuery, operatorForCondition, fieldQueryValue, _fetchDetailsXml);
_fetchDetailsXml += "</filter> </entity> </fetch>";
Microsoft.Xrm.Sdk.EntityCollection _entityDetailsColl = CrmConnectionsManager.OrganizationServiceProxy.RetrieveMultiple(new FetchExpression(_fetchDetailsXml));
// Note : "_entityDetailsColl" cast this object to respective Entity object
if (_entityDetailsColl != null && _entityDetailsColl.Entities.Count() > 0)
{
return _entityDetailsColl;
}
return null;
} `
`
public static string GenerateFetchXMLForAttributes(string[] fieldsToSearch, string fetchXml)
{
if (fieldsToSearch != null && fieldsToSearch.Count() > 0)
{
foreach (string field in fieldsToSearch)
{
fetchXml += "<attribute name='" + field + "' />";
}
}
else
{
fetchXml += "<all-attributes/>";
}
return fetchXml;
}
public static string GenerateFetchXMLForConditions(string[]fieldToQuery,string[] operatorForCondition, string[] fieldQueryValue, string _fetchDetailsXml)
{
if (fieldToQuery != null && fieldToQuery.Count() > 0)
{
for (int count = 0; count < fieldToQuery.Count(); count++)
{
_fetchDetailsXml += "<condition attribute='" + fieldToQuery[count] + "' operator='" + operatorForCondition[count] + "' value='" + fieldQueryValue[count] + "' uiname='' uitype='' /> ";
}
}
else
{
_fetchDetailsXml += "<all-attributes/>";
}
return _fetchDetailsXml;
}
`
Retrieving “all attributes” is computationally more expensive than retrieving just those you need (also consider the IO cost). If you are looking for a way to view the attributes then write code for just those you need try this:
In the CRM web GUI:
1.Navigate to the view that displays the records in question
2.Click the Advanced Find button in the Ribbon Bar
3.Configure your “find” until it shows the records you are looking for
4.Click the Download Fetch XML button in the Ribbon Bar
5.Open the file with a text viewer (or your favorite development tool)
If you want to use this XML directly you might consider:
Use FetchXML to Construct a Query
http://msdn.microsoft.com/en-us/library/gg328117.aspx
I am trying to write a method which takes a file path and a revision number as its arguments and returns the date the revision is associated with. The code I have works (although pretty slowely) however, when I put a revision number greater than 51 in, the output gets messed up.. Here is the API.
Input
String [] filePaths= {"//file/x/y/strings/somefile.csv"};
p4Client.getDateAssociatedWithFileRevision(filePaths, 52);
Output - This should just be one line...
Rev number: 2 :: Revision Date: Wed Aug 24 23:48:42 BST 2005
Rev number: 52 :: Revision Date: Wed Aug 24 23:52:53 BST 2005
Rev number: 51 :: Revision Date: Sat Aug 20 02:01:59 BST 2005
getDateAssociatedWithFileRevision
public Date getDateAssociatedWithFileRevision(String [] filePath, int revisionNumber) {
List<IFileSpec> fileList = null;
Map<IFileSpec,List<IFileRevisionData>> fileRevisionData = null;
String currentFile = null;
Date revisionDate = null;
try
{
String file = filePath[0] + "#" + revisionNumber;
currentFile = file;
fileList = getIFileSpecList(file); //Get list of file(s) in path
for(IFileSpec fileSpec: fileList)
{
if(file.toString() == null)
{
System.out.println("\"" + currentFile +"\"" + " does not exist...");
break;
}
fileRevisionData = fileSpec.getRevisionHistory(0, true,false,true,false);
int i = 0;
for(List<IFileRevisionData> revisionData : fileRevisionData.values()) {
revisionDate = revisionData.get(0).getDate();
int revision = revisionData.get(0).getRevision();
System.out.println("Rev number: " +revision +" :: " + "Revision Date: " + revisionDate);
System.out.println(i);
i++;
}
}
}
catch(Exception e){e.printStackTrace();}
return revisionDate;
}
GetIFileSpecList
public List<IFileSpec> getIFileSpecList(String file) {
List<IFileSpec> fileList = null;
try {
fileList = iServer.getDepotFiles(
FileSpecBuilder.makeFileSpecList(new String[] {file}), false); //Get list of file(s) in path
}
catch(Exception e){e.printStackTrace();}
return fileList;
}
Edit
Just figured out that the output is getting messed up after an integration, just need to find a way to handle them now..
Too much work. Take this command-line idea ("p4 files will get you that info, parsed") and make Perforce do the joins of the data for you. Then Java-ize it.
% p4 -Ztag files //guest/jeff_bowles/scripts/0228devbranch.html
... depotFile //guest/jeff_bowles/scripts/0228devbranch.html
... rev 2
... change 4421
... action edit
... type ktext
... time 1093044566
% p4 -Ztag files //guest/jeff_bowles/scripts/0228devbranch.html#1
... depotFile //guest/jeff_bowles/scripts/0228devbranch.html
... rev 1
... change 4420
... action add
... type ktext
... time 1093042787
I managed to return only the date I want by adding an if statement (marked below). I don't know how elegant this solution is... any comments are welcome.
getDateAssociatedWithFileRevision
public Date getDateAssociatedWithFileRevision(String [] filePath, int revisionNumber) {
List<IFileSpec> fileList = null;
Map<IFileSpec,List<IFileRevisionData>> fileRevisionData = null;
String currentFile = null;
Date revisionDate = null;
try
{
String file = filePath[0] + "#" + revisionNumber;
currentFile = file;
fileList = getIFileSpecList(file); //Get list of file(s) in path
for(IFileSpec fileSpec: fileList)
{
if(file.toString() == null)
{
System.out.println("\"" + currentFile +"\"" + " does not exist...");
break;
}
fileRevisionData = fileSpec.getRevisionHistory(0, true,false,true,false);
for(List<IFileRevisionData> revisionData : fileRevisionData.values()) {
int revision = revisionData.get(0).getRevision();
-------------> if(revision.equals(revisionNumber))
{
revisionDate = revisionData.get(0).getDate();
System.out.println("Rev number: " +revision +" :: " + "Revision Date: " + revisionDate);
break;
}
}
}
}
catch(Exception e){e.printStackTrace();}
return revisionDate;
}
I am working on an iPad app using appcelarator titanium and need to iterate over the content of a directory and determine the type of the contained items, whether it is a file or directory.
This is what I have so far:
dirFullPath = '/full/path/to/directory';
var dir = Titanium.Filesystem.getFile(dirFullPath);
var dirItems = dir.getDirectoryListing();
for ( var i=0; i<dir.length; i++ ) {
itemFullPath = dirFullPath
+ Titanium.Filesystem.getSeparator()
+ dir[i].toString();
testItem = Titanium.Filesystem.getFile(itemFullPath);
if ( testItem.exists() ) {
alert(itemFullPath + ' exists.'); // item exists, alert box appears
if ( testItem.isDirectory ) {
alert(itemFullPath + ' is a directory.'); // this code is never executed
}
else if ( testItem.isFile ) {
alert(itemFullPath + ' is a file.'); // this code is never executed
}
else {
alert(itemFullPath + ' is an unknown object.'); // this alert is always shown
}
}
}
I always get the alert box saying " is an unknown object.". It seems, that isFile and isDirectory are not working properly, or did I miss something? Does anybody else had the same problem?
Thanks for any advice!
The following should work:
var isDirectory = function(f){
return f.exists() && f.getDirectoryListing() != null;
}
var isFile = function(f){
return f.exists() && f.getDirectoryListing() == null;
}