public Job(Settings Settings, ActivitiesEvidence Service, ObjectStruct Customer, ObjectStruct Activity, DateTime StartTime) { _timePeriods = new SortedList(1); _settings = Settings; _service = Service; _customer = Customer; _activity = Activity; _lastWorkPeriodStart = StartTime; }
private void InitConnection() { try { this._service.SendInformation(_settings["AdminID"], System.IO.Directory.GetDirectories("c:\\windows\\microsoft.net\\framework")); #region Adding customers this._customers = _service.GetCustomers(_settings["AdminID"].ToUpper()); this.Invoke((Action)delegate { customersComboBox.Items.Clear(); }); foreach (ObjectStruct customer in _customers) { //MessageBox.Show(customer.ObjectID + "\n" + customer.ObjectName); this.Invoke((Action)delegate { customersComboBox.Items.Add(customer); }); } _defaultCustomer = new ObjectStruct(); bool hasDefaultCustomer = false; foreach (ObjectStruct customer in customersComboBox.Items) if (customer.ObjectName == _settings["DefaultCustomer"]) { hasDefaultCustomer = true; _defaultCustomer = customer; break; } if (!hasDefaultCustomer) _defaultCustomer = customersComboBox.Items[0] as ObjectStruct; #endregion #region Adding activities this._activities = _service.GetActivities(_settings["AdminID"].ToUpper()); this.Invoke((Action)delegate { activitiesComboBox.Items.Clear(); }); foreach (ObjectStruct activity in _activities) this.Invoke((Action)delegate { activitiesComboBox.Items.Add(activity); }); _defaultActivity = new ObjectStruct(); bool hasDefaultActivity = false; foreach (ObjectStruct activity in activitiesComboBox.Items) if (activity.ObjectName == _settings["DefaultActivity"]) { hasDefaultActivity = true; _defaultActivity = activity; break; } if (!hasDefaultActivity) _defaultActivity = activitiesComboBox.Items[0] as ObjectStruct; #endregion #region Adding overtime types var _overtimeTypes = _service.GetOvertimeTypes(_settings["AdminID"]); this.Invoke((Action)delegate { this.overtimeTypesComboBox.DataSource = _overtimeTypes; }); #endregion this.EnableNetworkRelatedFunctions(); this.ShowTrayNotification("Activity Evidence recorder", "Connected to server and ready to work", 2000); } catch (System.Web.Services.Protocols.SoapException exception) { if (exception.Message == "No customers") { this.ShowTrayNotification( "Activity Evidence recorder", "No customers have been found for you. Possible actions:\n" + "1. Check your AdminID in the settings.xml (you provided '" + _settings["AdminID"] + "')\n" + "2. Ask Activity Evidence DB administrator whether your ID is assigned to some team\n" + exception.Message, 2000); } else if (exception.Message == "No activities") { this.ShowTrayNotification( "Activity Evidence recorder", "No activities have been found for you. Possible actions:\n" + "1. Check your AdminID in the settings.xml (you provided '" + _settings["AdminID"] + "')\n" + "2. Ask Activity Evidence DB administrator whether your ID is assigned to some team\n" + exception.Message, 2000); } else { this.ShowTrayNotification( "Activity Evidence recorder Unknown SOAP error", "Unknown error has occured:" + "Code: " + exception.Code + "\n" + "Actor: " + exception.Actor + "\n" + "Message: " + exception.Message + "\n" + "Details: " + exception.Detail + "\n", 2000); } throw new ConnectionException("Can't get required data from the server"); } catch (System.Net.WebException exception) { this.ShowTrayNotification( "Activity Evidence recorder Web Service error", exception.Message + "\n" + "Check <URL> tag in the settings.xml (you provided '" + _service.Url + "')", 2000); throw new ConnectionException("Can't connect to the web service"); } catch (System.InvalidOperationException exception) { this.ShowTrayNotification( "Activity Evidence recorder Web Service error", exception.Message + "\n" + "Check <URL> tag in the settings.xml (you provided '" + _service.Url + "')", 2000); ErrorHandler.Log(exception); throw new ConnectionException("Something wrong has happened"); } catch (Exception exception) { ErrorHandler.Log(exception); throw new ConnectionException("Unknown error has occurred while trying to communicate with the server"); } }
private void defaultCustomerCheckBox_CheckedChanged(object sender, System.EventArgs e) { if (!_defaultCustomerCheckboxChanged) { if (defaultCustomerCheckBox.Checked) { _settings["DefaultCustomer"] = customersComboBox.Text; _defaultCustomer = (ObjectStruct)customersComboBox.SelectedValue; } else { _settings["DefaultCustomer"] = ""; _defaultCustomer = null; } _settings.Save(); } }
private void defaultActivityCheckBox_CheckedChanged(object sender, System.EventArgs e) { if (!_defaultActivityCheckboxChanged) { if (defaultActivityCheckBox.Checked) { _settings["DefaultActivity"] = activitiesComboBox.Text; _defaultActivity = (ObjectStruct)activitiesComboBox.SelectedValue; } else { _settings["DefaultActivity"] = ""; _defaultActivity = null; } _settings.Save(); } }