public ExchangeMobileDevice GetMobileDevice(string id)
 {
     try
     {
         LogStart("GetMobileDevice");
         ExchangeMobileDevice ret = ES.GetMobileDevice(id);
         LogEnd("GetMobileDevice");
         return(ret);
     }
     catch (Exception ex)
     {
         LogError("GetMobileDevice", ex);
         throw;
     }
 }
        protected void gvMobile_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ExchangeMobileDevice current = e.Row.DataItem as ExchangeMobileDevice;
                if (current != null)
                {
                    Label lblDate = e.Row.FindControl("lblLastSyncTime") as Label;
                    if (lblDate != null)
                    {
                        lblDate.Text = current.LastSuccessSync == DateTime.MinValue ? string.Empty : current.LastSuccessSync.ToString("g");
                    }

                    Label lblStatus = e.Row.FindControl("lblStatus") as Label;
                    if (lblStatus != null)
                    {
                        switch (current.Status)
                        {
                        case MobileDeviceStatus.PendingWipe:
                            lblStatus.ForeColor = Color.Red;
                            lblStatus.Text      = GetLocalizedString(PendingWipe);
                            break;

                        case MobileDeviceStatus.WipeSuccessful:
                            lblStatus.ForeColor = Color.Green;
                            lblStatus.Text      = GetLocalizedString(WipeSuccessful);
                            break;

                        default:
                            lblStatus.Text      = GetLocalizedString(OK);
                            lblStatus.ForeColor = Color.Black;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(current.DeviceUserAgent))
                    {
                        HyperLink lnkDeviceUserAgent = e.Row.FindControl("lnkDeviceUserAgent") as HyperLink;
                        if (lnkDeviceUserAgent != null)
                        {
                            lnkDeviceUserAgent.Text = GetLocalizedString(Unknown);
                        }
                    }
                }
            }
        }
        private void BindData()
        {
            ExchangeMobileDevice device = ES.Services.ExchangeServer.GetMobileDevice(PanelRequest.ItemID,
                                                                                     PanelRequest.DeviceId);

            if (device != null)
            {
                lblStatus.Text = GetLocalizedString(device.Status.ToString());
                switch (device.Status)
                {
                case MobileDeviceStatus.PendingWipe:
                    lblStatus.ForeColor = Color.Red;
                    break;

                case MobileDeviceStatus.WipeSuccessful:
                    lblStatus.ForeColor = Color.Green;
                    break;

                default:
                    lblStatus.ForeColor = Color.Black;
                    break;
                }
                lblDeviceModel.Text           = device.DeviceModel;
                lblDeviceType.Text            = device.DeviceType;
                lblFirstSyncTime.Text         = DateTimeToString(device.FirstSyncTime);
                lblDeviceWipeRequestTime.Text = DateTimeToString(device.DeviceWipeRequestTime);
                lblDeviceAcnowledgeTime.Text  = DateTimeToString(device.DeviceWipeAckTime);
                lblLastSync.Text           = DateTimeToString(device.LastSyncAttemptTime);
                lblLastUpdate.Text         = DateTimeToString(device.LastPolicyUpdateTime);
                lblLastPing.Text           = device.LastPingHeartbeat == 0 ? string.Empty : device.LastPingHeartbeat.ToString();
                lblDeviceFriendlyName.Text = device.DeviceFriendlyName;
                lblDeviceId.Text           = device.DeviceID;
                lblDeviceUserAgent.Text    = device.DeviceUserAgent;
                lblDeviceOS.Text           = device.DeviceOS;
                lblDeviceOSLanguage.Text   = device.DeviceOSLanguage;
                lblDeviceIMEA.Text         = device.DeviceIMEI;
                lblDevicePassword.Text     = device.RecoveryPassword;

                UpdateButtons(device.Status);

                // form title
                ExchangeAccount account = ES.Services.ExchangeServer.GetAccount(PanelRequest.ItemID, PanelRequest.AccountID);
                litDisplayName.Text = account.DisplayName;
            }
        }