Wednesday, November 23, 2011

Runas Different Credentials In Command Prompt

Sometimes you need to run an executable as a different user via command prompt:
- in scripts
- in Windows 2008 (not 2008 R2), you cannot use shift right click to "run as different user"

Windows come with a command line tool called "runas", which allow users to execute anything as a different user, in the following syntax
runas /user domain\username "full path to exe"

ie.
runas /user domain\username "c:\temp\temp.exe /a /l /r"

Tuesday, November 15, 2011

Active Directory MMCs and Command Line Tools

Administration Tools on your Windows XP/7:
If you need to manage/export data from AD outside of your windows server, install:
- the "Windows Server 2003 Administration Tools Pack" (for windows 2003 AD servers)
http://www.microsoft.com/download/en/details.aspx?id=16770

OR

- the "Remote Server Administration Tools for Windows 7" (for windows 2008 AD servers)
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=7887

They provide Active Directory related MMCs and Directory Services command line tools.

Quickly Exporting AD Information
Dsquery.exe allows you to find any users/groups/OUs/computers etc based on their name/attributes
http://technet.microsoft.com/en-us/library/cc732952(WS.10).aspx

Examples:
To retrieve all AD Groups with the prefix "foo"
dsquery group -name foo*

To retrieve all the users in the container "Users", domain "microsoft.com"
dsquery user cn=users,dc=microsoft,dc=com

Other AD Command Line Tools
Microsoft has also allowed you to perform most basic AD operations such as adding users/groups, resetting passwords, deleting accounts/groups via the command-line tools
http://support.microsoft.com/kb/322684

Thursday, October 27, 2011

Execute Large SQL files

sqlcmd -d [DatabaseName] -S [ServerName] -i [sql script file] -o [output file]

Saturday, September 3, 2011

Mobile Development Resources

Flex Resources
The following Flex ebooks are not too hard to find on the www:
  • Flex in a week 4.5
  • Adobe Flex 4.5 Fundamentals: Training from the Source
  • Flash Builder 4 and Flex 4 Bible
  • Enterprise Development with Flex (Adobe Dev Lib) 2010

Why MonoTouch And Mono For Android

Visual Studio Themes - Dark Background

If you are using a mild VS theme which has a grey background and light brown text:

you may have problems with some html tags having the same color as its text.  You need to change the "default" color 0x020000000 to your desired color.
http://www.hanselman.com/blog/ChangingYourColorsInVisualStudioNETBlackVersusWhite.aspx

The standard options to look out for are options-fonts->

  • Razor
  • Plain Text
  • Line Numbers
  • Comments
  • Identifier
  • Keyword
  • Operator
  • String
  • UserTypes

Removing Empty Folders In Command Prompt

For a quick way to batch remove all empty folders, "cd" into that folder and perform the following:

for /f "usebackq delims=" %d in (`"dir /ad/b/s | sort /R"`) do rd "%d"

Please backup the source folder before doing so, just in case.  Afterwards, you can use beyond compare and order by folder size to compare the results.

Tuesday, August 30, 2011

Salesforce Long Text Area and Formulas

If you try to create a formula on a "Long Text Area" field, salesforce does not support this.

One workaround is to create a new field and another workflow to perform a "field update" on this:
Step 1) Create a new field with data type of "Text Area (Long)"

Step 2) Create a workflow with the following settings:

Evaluation Criteria -> select "Every time a record is created or edited"
Rule Criteria -> select "Formula evaluates to true" and type "true"


Step 3) Select "Add Workflow Action" -> "New Field Update"

Step 4) Select the newly created field as the "Field To Update" and select "Use a formula to set the new value" under "Specify New Field Value"

Step 5) You can now enter in a formula that reference other "Long Text Area" fields.  The results will be posted to the new field of type "Long Text Area".

Reasons Behind This Solution
Basically this allows complex logics, ie perform formula calculations on a long text field, to be offloaded to a  workflow which runs on the background.  As a normal formula needs to be calculated very often and can slow down the page on each load/save, shifting the calculations to workflow helps salesforce lower the CPU usage.

Quickly Selecting Data from Salesforce Using System Log

If you just want to quickly see some data in your salesforce instance, you can execute soql queries by opening the Setup-> "System Log" and type in the following

System.debug ( [select Dealer_group_display__c from Account where Id = '001M0000005OFab']);
System.debug( UserInfo.getSessionId() );

This saves you from opening the Apex dataloader.

Developing Native Mobile Applications For Multiple Devices

If you are like me who needs to develop mobile applications, but doesn't want to stick with just one platform, you can try the following products:
PhoneGap http://www.phonegap.com/
Developers create a mobile version of their application using HTML 5 / Javascripts / CSS.  PhoneGap compile this as a native device application which can be hosted in the respective app stores.  The advantage is you are programming in HTML 5 which can than also be hosted as a mobile version of your website.  PhoneGap is free but does take a bit of configuration.

Adobe Flash Builder 4.5 http://www.adobe.com/devnet/flex/articles/mobile-development-flex-flashbuilder.html
For small applications, Adobe's latest Flash Builder 4.5.1 update allow developers to create a mobile Flex project.  It is fairly easy to learn for basic functionalities and is powerful enough to call external webservices and meet other real-life requirements.

Both products allow you to deploy to iPhones/iPads/Androids/Blackberry Tablets as native applications.

The advantage of developing uses these instead of just having a mobile version of your website is that you can minimise network traffic and provide a better user experience after the application is downloaded/installed.

Wednesday, May 18, 2011

DreamFactory migration steps

The following is just one way to migration an installation (ie OpenWealth).

1) Install package onto the new site
2) Use Monarch to migrate data across
3) Migrate page layout

Salesforce Migration Order/Best Practices

A snippet from Dream Factory's Snapshot documentation:

In order to achieve maximum results with your deployment, it is recommended that you follow the documented order of operations that is detailed below for Asset SnapShot Push. This order will minimize the errors generated by contingent dependencies and relationships in your Org. Carefully read any error messages and make adjustments as necessary. If you need to be able to push individual object fields then use the Object SnapShot Push.

1.    Objects: All *
2.    Apex Classes
3.    Apex Components
4.    Apex Pages
5.    Apex Triggers
6.    S-Controls
7.    Page Layouts
8.    Static Resources
9.    Letterheads
10.    Workflows **
11.    Report Types
12.    Home Page Web Links
13.    Home Page Components
14.    Home Page Layouts
15.    Custom Tabs
16.    Custom Labels
17.    Custom Applications
18.    Custom Object Translation
19.    Custom Sites
20.    Profiles: All ***
   
   
* This will push all Object fields plus their related Record Types, Web Links, Validation Rules, Search Layouts and List Views. These settings can also be pushed individually if needed.

** Users tied to workflows must be created in the Destination Org prior to pushing

*** This will push all Profile metadata plus the related settings including: Application Visibility, Field Level Security, Layout Assignments, Object Permissions, Record Type Visibility and Tab Visibility. These settings can also be pushed individually if needed.

Thursday, May 5, 2011

VMware vConverter Cannot Find Your Hard Drive

After you have installed vConverter, it may not be able to find any partition on your machine that needs to be converter.  This is caused by Windows UAC!

If you run the vConverter "As Administrator", vConverter will then see your hard drive.

http://communities.vmware.com/thread/285316

Monday, May 2, 2011

Quick Tools

If you had problems with how MsPaint scews up an image's transparent background, you can try Paint.Net
getpaint.net

If you need to do presentations and need to record it to a video, use Cyberlink YouCam.
http://www.cyberlink.com/products/youcam/overview_en_US.html
supported format AVI/WMV

Free Video Recording
http://camstudio.org/

Monday, April 11, 2011

SalesForce Tools


SF tools:

Force.com explorer (see all sf objects like how SQL management studio works for MS-SQL)

Adobe flash builder - To develop flex/flash and access SF data via queryResult

Force.com dataloader - upload from csv

Force.com IDE - should just download eclipse and use the sf plug-in instead

For sample data, use random name generator to excel to generate dummy excel files for uploading to SF

To create word templates, Docx is actually a zip file.  You can extract it and update the document.xml

To toggle between the field codes and word documents, use alt f9 in MS-Word

Sunday, April 10, 2011

Google calender

If you like the google calender, you must check out the following jquery calender control. 

http://arshaw.com/fullcalendar/

SalesForce Admin ADM 201

Test Concepts in Admin ADM 201

-Different types of relationships for custom objects
-If you want to disable viewing all objects in an application, where do you set this?
-If the system wide default is read/write, how can you restrict what records the user can view?
-what will happen to the existing exchange rates will you turn on advance currency management
-mass transfer of user's records (one of the following will not be mass transferred: open case, close case, open activity, closed activity)


Wednesday, March 2, 2011

Retring WCF calls, using Func

Sometimes because the internet connection is not great, you might want to implement code to retry WCF calls.  However, instead of writing for loops on each clientproxy.MethodCall, you can write an extension method that retries it for you.  Since WCF calls has a single parameter - TWcfRequest and a single response - TWcfResponse, we can use the delegate Func<TWcfRequest, TWcfResponse> and pass the desired WCF method down this extension method.


public static class WcfClientBaseExtension
    {
        /// <summary>
        /// Retry WCF call multiple times
        /// </summary>
        /// <typeparam name="TChannel"></typeparam>
        /// <typeparam name="TWcfRequest"></typeparam>
        /// <typeparam name="TWcfResponse"></typeparam>
        /// <param name="client"></param>
        /// <param name="tryExecute"></param>
        /// <param name="wcfRequest"></param>
        /// <returns></returns>
        public static TWcfResponse ExecuteRepeatedly<TChannel, TWcfRequest, TWcfResponse>(this ClientBase<TChannel> client,
                    Func<TWcfRequest, TWcfResponse> tryExecute, TWcfRequest wcfRequest)
            where TChannel : class
            where TWcfRequest : class
            where TWcfResponse : class
        {
            int maxRetryCount = FrameworkConfigHelper.MaxWcfRetryCount;

            for (int currentRetryCount = 0; currentRetryCount < maxRetryCount; currentRetryCount++)
            {
                try
                {
                    return tryExecute(wcfRequest);
                }
                //SOAP Faults - business requirement
                catch (FaultException)
                {
                    //need to allow business exceptions to go to top level
                    throw;
                }
                //Connection timeout
                catch (EndpointNotFoundException)
                {
                    //endpoint don't respond in timely manner
                    //swallow technical exceptions unless it's the last retry
                    if (currentRetryCount == maxRetryCount - 1)
                        throw;
                }
                catch (Exception)
                {
                    //rethrow all other errors for now
                    throw;
                }
            }
            return null;
        }

       
    }


For usage:
var searchResponse = client.ExecuteRepeatedly<ICollateralRegistrationSearch, SearchByRegistrationNumberRequestType, SearchByRegistrationNumberResponseType>
                                            (client.SearchByRegistrationNumber, searchByRegistrationNumberRequestType);

Monday, January 24, 2011

SSRS tools

In addition to the Report Builder 3.0 tool from microsoft, there are also different ways to create RDL and RDLC reports:
http://msdn.microsoft.com/en-us/library/ms155792.aspx

Report builder provides a very quick report designer to play with your existing data.  It generates RDL and can be uploaded to the reporting server immediately.

Saturday, January 1, 2011

Passing Data from ViewModel to Javascript on the View

Option 1: construct the javascript into a string put it directly into the ViewData
ViewData["clientScript"] = "<script type='text/javascript'>initialize();addOverLay(-34.397, 150.644)</script>";

<%=ViewData["clientScript"]%>

This is of course prone to javascipt attacks

Option 2: Convert to Json(InfoList is of type string)

var js = new JavaScriptSerializer();
var listOfInfos = new List<string> {"abc", "cde"};

var viewModel = new InfoModel
               
{
                   
InfoList = js.Serialize(listOfInfos);
               
};
return View(viewModel);

In the View
   <script type="text/javascript">
      var result = <%= Model.InfoList%>
   </script>