Figer's Technology Consulting | All posts by admin

Microsoft Azure mobile services Node.js - Insert record into another table with-in an insert/update call

From Azure portal go into the Insert or update script and add this


function update(item, user, request) {
    request.execute({ success: insertAuditEntry });

    function insertAuditEntry() {
        var auditTable = tables.getTable('audit');
        var audit = {
            record: 'checkins',
            recordId: item.id,
            timestamp: new Date(),
            values: 'Add value here'
        };
        auditTable.insert(audit, {
            success: function() {
                // Write to the response now that all data operations are complete
                request.respond();
            }
        });
    }
}

Simple Javascript to stop the double tap action of zooming on Mobile



var time_stamp= Date.now();

window.addEventListener("touchstart",function(event_){

if (event_.timeStamp-time_stamp<300){ //300ms delay

    time_stamp= Date.now();

    event_.preventDefault();

    return false;

}

    else{ 

        time_stamp= Date.now();

    }

});

Installing free SSL cert on Azure website


No need to re-invent the wheel so I'm just linking to Troy Hunt's article which walks you through the entire process.

1.) Make sure your site is atleast a basic website instance (free and shared don't work, shared really should)

2.) on StartSSL make sure you are using your main browser and that it's a desktop browser when you first sign-up, you need to be able to save the SSL cert the company installs on your browser for further authentication, failing to do so will probably lock you out of your account.

http://www.troyhunt.com/2013/09/the-complete-guide-to-loading-free-ssl.html

Azure Mobile Services Async in .NET Web Forms applications



It's easy to code in Javascript or Java and catch the successful asyncinsert, but in web forms the proper code wasn't obvious nor easily found online. Here is my solution to add a record to my Azure Mobile Service on web forms button click. The key is the line in bold.


        protected void btnAdd_Click(object sender, EventArgs e)

        {

            RegisterAsyncTask(new PageAsyncTask(() => SaveRecord()));

        }


        public async Task SaveRecord()

        {

            //Get Domain name from username (which is email address)

            String[] strUsername = User.Identity.Name.Split('@');

            String strUserDomain = strUsername[1];


            try

                var sunshineTable = client.GetTable<sunshine>();


                var SunshineRecord = new sunshine

                {

                    firstname = this.txtFirstName.Text,

                    lastname = this.txtLastName.Text,

                    email = this.txtEmail.Text,

                    userdomain = strUserDomain

                };


                await sunshineTable.InsertAsync(SunshineRecord);

                String strID = SunshineRecord.Id;


                //Sunshine Record Saved Successfully, now lets save group NPI records

                    var npirecords = client.GetTable<npirecords>();

                    var npirecord = new npirecords();

                    NPIDatatable dtNPIrecords = (NPIDatatable)Session["NPIGroupRecords"];

                    foreach (DataRow row in dtNPIrecords.lNPIDatatable.Rows) // Loop over the rows.

                    {


                        //coveredrecipienttype = this.ddlCoveredRecipientType.SelectedValue,

                        npirecord.firstname = row["First Name"].ToString();

                        npirecord.lastname = row["Last Name"].ToString();

                        npirecord.npi = row["NPI"].ToString();

                        npirecord.credentials = row["Credentials"].ToString();

                        npirecord.gender = row["Gender"].ToString();

                        npirecord.address = row["Address"].ToString();

                        npirecord.city = row["City"].ToString();

                        npirecord.state = row["State"].ToString();

                        npirecord.zip = row["Zip"].ToString();

                        npirecord.country = row["Country"].ToString();

                        npirecord.licensenumber = row["License Number"].ToString();

                        npirecord.licensestate = row["License State"].ToString();

                        npirecord.taxonomycode = row["Taxonomy Code"].ToString();

                        npirecord.sunshinerecordid = strID;

                        await npirecords.InsertAsync(npirecord);

                    };

             }

            catch (Exception ex)

            {

    

            }

        }

Simple Login Page Background Image using CSS



<script>
$('body').css('background-image', 'url(../images/glassbackground.png)');
$('body').css('background-repeat', 'no-repeat');
$('body').css('background-size', '100% 200%');
$('body').css('background-origin', 'content-box');
</script>

ADB over wifi



These easy commands from Terminal on a Mac

To find the IP address of the device: run ./adb shell and then netcfg.


1.) adb tcpip 5555

2.) adb connect 192.168.1.102:5555


Disconnect USB and proceed with wireless debugging.


To switch back to USB when done

3.) adb -s 192.168.1.102:5555 usb 

Google Glass Hello World GDK app in Eclipse