/// <summary> /// Loads the time entry. /// </summary> private void LoadTimeEntry(int timeId, string matterReference) { TimeServiceClient timeService = null; try { timeService = new TimeServiceClient(); TimeReturnValue returnValue = timeService.GetTime(_logonSettings.LogonId, timeId); if (returnValue.Success) { if (returnValue.Time != null) { Session[SessionName.ProjectId] = returnValue.Time.ProjectId; GetClientDetails(matterReference); GetTimeTypes(returnValue.Time.ProjectId); _ddlTimeType.SelectedIndex = -1; for (int i = 0; i < _ddlTimeType.Items.Count; i++) { if (GetValueOnIndexFromArray(_ddlTimeType.Items[i].Value, 0) == returnValue.Time.TimeTypeId.ToString()) { _ddlTimeType.Items[i].Selected = true; break; } } _txtUnits.Text = returnValue.Time.Units.ToString(); _txtNotes.Text = returnValue.Time.Notes; } } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (timeService != null) { if (timeService.State != System.ServiceModel.CommunicationState.Faulted) { timeService.Close(); } } } }
static void Main(String[] arguments) { if (2 != arguments.Length) { ShowUsage(); return; } String userName = arguments[0]; String password = arguments[1]; using (TimeServiceClient service = new TimeServiceClient()) { service.ClientCredentials.UserName.UserName = userName; service.ClientCredentials.UserName.Password = password; Console.WriteLine("Time is: " + service.GetTime()); } }
/// <summary> /// Loads the time entry. /// </summary> private void LoadTimeEntry(int timeId, string matterReference) { TimeServiceClient timeService = null; try { timeService = new TimeServiceClient(); TimeReturnValue returnValue = timeService.GetTime(_logonSettings.LogonId, timeId); if (returnValue.Success) { if (returnValue.Time != null) { Session[SessionName.ProjectId] = returnValue.Time.ProjectId; GetClientDetails(matterReference); GetTimeTypes(returnValue.Time.ProjectId); _ddlTimeType.SelectedIndex = -1; for (int i = 0; i < _ddlTimeType.Items.Count; i++) { if (GetValueOnIndexFromArray(_ddlTimeType.Items[i].Value, 0) == returnValue.Time.TimeTypeId.ToString()) { _ddlTimeType.Items[i].Selected = true; break; } } _txtUnits.Text = returnValue.Time.Units.ToString(); _txtNotes.Text = returnValue.Time.Notes; } } else { throw new Exception(returnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (timeService != null) { if (timeService.State != System.ServiceModel.CommunicationState.Faulted) timeService.Close(); } } }