public void uploadFieldDataWorker(UserProfile profile) { getSerializers(); _userNo = (profile.AgentURI == null) ? "" : profile.AgentURI.Replace(@"http://id.snsb.info/Agents/", ""); _projectID = profile.ProjectID ?? 0; if (_mobileDB != null && _repository != null && _sync != null) { configureUploadANSL(); syncData(); } else _Log.Error("At least one Serializer is missing!"); }
public UserProfileDialog(bool loadContext) : this() { Cursor.Current = Cursors.WaitCursor; InitializeComponent(); base.adjustControlSizes(); #if DEBUG this.MinimizeBox = false; this.ControlBox = true; #else this.MinimizeBox = true; this.ControlBox = true; #endif if (loadContext) { this.labelProjectName.Text = ""; // Fill comboBoxes this.fillComboBoxToolbarIcons(); this.fillComboBoxContext(); this.fillComboBoxDisplayLevel(); this.fillComboBoxLanguageContext(); this.fillComboBoxTaxonomyGroup(); try { if (UserProfiles.Instance.Current != null) { user = UserProfiles.Instance.Current; this.fillControls(); } } catch (ConnectionCorruptedException ex) { throw ex; } // Further initialization try { //Layout erzeugen (Keine Überschneidungen) layout = LayoutFactory.Instance.CreateLayout(this, false); //Beim Kontextmanager registrieren ContextManager.Instance.Register(this); } catch (ContextCorruptedException ex) { throw new ContextCorruptedException("Form can't be shown and will be closed. (" + ex.Message + ")"); } //Kontext ausführen //Sprachkontext String language = null; try { language = UserProfiles.Instance.Current.LanguageContext; } catch (ConnectionCorruptedException) { } try { if (language != null && !language.Equals(String.Empty)) { if (ContextManager.Instance.GetContext(language) != null) ContextManager.Instance.GetContext(language).Configure(this); else { throw new ContextCorruptedException("Form can't be shown and will be closed. (" + language + " context doesn't exist)"); } } } catch (Exception) { throw new ContextCorruptedException("Form can't be shown and will be closed. (Error while configuring language context)"); } //Weiterer Kontext String context = null; try { context = UserProfiles.Instance.Current.Context; } catch (ConnectionCorruptedException) { } try { if (context != null && !context.Equals(String.Empty)) { if (ContextManager.Instance.GetContext(context) != null) ContextManager.Instance.GetContext(context).Configure(this); else { throw new ContextCorruptedException("Form can't be shown and will be closed. (" + context + " context doesn't exist)"); } } } catch (Exception) { throw new ContextCorruptedException("Form can't be shown and will be closed. (Error while configuring " + context + " context)"); } } Cursor.Current = Cursors.Default; }
private void updateProfile() { _profile = null; if (Connections != null) { if (Settings != null && (_settings = Settings.getOptions()) != null) { if ((_mobileSerializer = Connections.MobileDB) != null) { MessengerInstance.Send<StatusNotification>("Services_UserProfile_SearchingProfile"); //Prüfen ob ein UserProfile zum LoginNamen existiert. IList<UserProfile> profiles = new List<UserProfile>(); IRestriction r = RestrictionFactory.Eq(typeof(UserProfile), "_LoginName", _settings.Username); //IRestriction r = RestrictionFactory.Eq(typeof(UserProfile), "_LoginName", "TestEditor"); profiles = _mobileSerializer.Connector.LoadList<UserProfile>(r); if (profiles.Count > 0) { _profile = profiles[0]; } else { MessengerInstance.Send<StatusNotification>("Services_UserProfile_CreatingNew"); _profile = createProfile(); } MessengerInstance.Send<StatusNotification>("Services_UserProfile_Loaded"); _operation.success(); } else _Log.Error("Mobile DB not connected"); } else _Log.Error("Settings N/A"); } else _Log.Error("Connections N/A"); _operation.failure("Services_UserProfile_Error_MissingConnectivitiy",""); }
static void Main() { //Kontextkonfiguration laden String _progPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); String contextPath = String.Concat(_progPath, @"\CustomizedContext\"); String defaultContextFile = String.Concat(_progPath, @"\DefaultContext.xml"); String contextFile = String.Concat(_progPath, @"\context.xml"); if (Directory.Exists(contextPath)) { try { StreamWriter write = new StreamWriter(contextFile, false); write.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); write.WriteLine("<ContextRoot xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"); StreamReader read = new StreamReader(defaultContextFile); write.Write(read.ReadToEnd()); read.Close(); write.WriteLine("<Context ContextId=\"Customized\">"); DirectoryInfo dirInfo = new DirectoryInfo(contextPath); FileInfo[] fileInfo = dirInfo.GetFiles("*.xml"); foreach (FileInfo item in fileInfo) { if (item != null) { write.WriteLine(); read = new StreamReader(item.FullName); write.Write(read.ReadToEnd()); read.Close(); write.WriteLine(); } } write.WriteLine("</Context>"); write.WriteLine("</ContextRoot>"); write.Flush(); write.Close(); } catch (Exception) { if (MessageBox.Show("Context Files couldn't be read. Do you want to continue Application nonetheless without contexts?.", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) contextFile = null; else return; } } try { if (contextFile != null) XMLConfigurator.Configure(contextFile); //Actions freischalten ActionRegistry.Instance.RegisterAction(new SetVisibleAction()); ActionRegistry.Instance.RegisterAction(new SetTextAction()); ActionRegistry.Instance.RegisterAction(new SetDefaultValueAction()); } catch (ContextCorruptedException ex) { MessageBox.Show(ex.Message + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } UserProfile active = new UserProfile("Piesche"); active.Context = "Customized"; active.LanguageContext = "English"; active.LoginName = "Piesche"; active.ToolbarIcons = "small"; UserProfiles.Instance.Current = active; if (active != null) { try { Cursor.Current = Cursors.WaitCursor; Cursor.Show(); Application.Run(new EditContextForm()); Cursor.Current = Cursors.Default; } catch (InvalidOperationException except) { MessageBox.Show(except.Message + ". Application will shut down.", "Application Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } } }
private void UserProfileDialog_Closing(object sender, CancelEventArgs e) { if(this.textBoxUserLoginName.Text.Equals(String.Empty)&& cancel == false) { MessageBox.Show("Required LoginName for UserProfile is missing!"); e.Cancel = true; } else if (cancel == true) this.DialogResult = DialogResult.Cancel; else { Cursor.Current = Cursors.WaitCursor; if (user == null) { try { user = UserProfiles.Instance.CreateUserProfile(this.textBoxUserLoginName.Text); if (!this.textBoxNameCache.Text.Equals(String.Empty)) user.CombinedNameCache = this.textBoxNameCache.Text; } catch (UserProfileCorruptedException ex) { Cursor.Current = Cursors.Default; if (MessageBox.Show(ex.Message + " New User couldn't be created. Do you want to close dialog nonetheless?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { this.DialogResult = DialogResult.Cancel; } else { e.Cancel = true; } } } else { user.LoginName = this.textBoxUserLoginName.Text; user.CombinedNameCache = this.textBoxNameCache.Text; } user.LanguageContext = this.comboBoxLanguageContext.Text; user.Context = this.comboBoxContext.Text; user.StopGPS = this.checkBoxStopGPS.Checked; user.DefaultIUGeographyAnalysis = this.checkBoxDefaultIUGeoAnalysis.Checked; user.Displaylevel = new DisplayLevel(this.comboBoxDisplayLevel.Text); user.ToolbarIcons = this.comboBoxToolbarIcons.Text; try { UserProfiles.Instance.Update(user); UserProfiles.Instance.Current = user; this.DialogResult = DialogResult.OK; } catch (UserProfileCorruptedException ex) { Cursor.Current = Cursors.Default; if (MessageBox.Show(ex.Message + " Changes won't be saved. Do you want to close dialog nonetheless?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { this.DialogResult = DialogResult.Cancel; } else { e.Cancel = true; } } } ContextManager.Instance.UnRegisterAll(this); Cursor.Current = Cursors.Default; }
public MainForm(UserProfile up) : this() { try { UserProfiles.Instance.Current = up; } catch (ConnectionCorruptedException ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Severe Program Exception (" + ex.Message + "). Program couldn't be started."); this.Close(); } }
private UserProfiles() { IRestriction restrict = RestrictionFactory.TypeRestriction(typeof(UserProfile)); _userList = con.LoadList<UserProfile>(restrict); this._currentProfile = SERIALIZER.CreateISerializableObject<UserProfile>(); }
public void Update(UserProfile up) { if (up != null) { try { con.Save(up); } catch (Exception ex) { throw new UserProfileCorruptedException("User Profile couldn't be updated. ("+ex.Message+")"); } } }
public void Remove(UserProfile up) { if (up != null) { try { con.Delete(up); } catch (Exception ex) { throw new UserProfileCorruptedException("User Profile couldn't be deleted."); } } }
private void chooseProject() { String temp = this.listBoxChooseProject.SelectedItem.ToString(); // extract selected ProjectID temp = temp.Remove(temp.IndexOf(':')); int proID; String proName; try { proID = int.Parse(temp); proName = this.getProjectName(proID); } catch (Exception) { proID = -1; proName = null; } if (this.startMobileConnection(true) && mobileDBSerializer != null) { UserProfile profile = new UserProfile(); IRestriction r = RestrictionFactory.Eq(typeof(UserProfile), "_LoginName", loginName); //IRestriction r = RestrictionFactory.Eq(typeof(UserProfile), "_LoginName", "Simmel"); profile = mobileDBSerializer.Connector.Load<UserProfile>(r); if (profile != null) { if (proID > 0) { profile.ProjectID = proID; profile.ProjectName = proName; mobileDBSerializer.Connector.Save(profile); } } this.endMobileConnection(true); // change ProjectID and ProjectName on Labels if (proID > 0 && proName != null) { this.labelCurrentProject.Text = "Project: " + proID; this.labelProjectName.Text = proName; } } this.projectID = proID; this.listBoxChooseProject.Visible = false; this.buttonChoose.Visible = false; this.buttonChooseProject.Enabled = true; }