/// <summary> /// Gets the display set items needed for an Alternate Key. /// </summary> /// <param name="className">Name of the class.</param> /// <param name="alternateKeyName">Name of the Alternate Key name.</param> /// <returns>String containing the display set items separated by commas.</returns> private string GetAlternateKeyDisplaySet(string className, string alternateKeyName) { string alternateKeyDisplaySet = string.Empty; try { Oids.Oid oidRoot = Oids.Oid.Create(className); Oids.Oid alternateKey = (Oids.Oid)oidRoot.GetAlternateKey(AlternateKeyName); if (alternateKey != null) { // Get the alternate keys attribute names and add to display set. StringBuilder alternateKeyNames = new StringBuilder(); string lSeparador = string.Empty; foreach (Oids.IOidField fieldItem in alternateKey.Fields) { alternateKeyNames.Append(lSeparador); alternateKeyNames.Append(fieldItem.Name); lSeparador = ", "; } alternateKeyDisplaySet = alternateKeyNames.ToString(); } } catch { return(string.Empty); } return(alternateKeyDisplaySet); }
/// <summary> /// Serializes an AlternateKey object to an XML stream. /// </summary> /// <param name="writer">XML stream to write.</param> /// <param name="alternateKey">AlternateKey object.</param> /// <returns>XML stream with the AlternateKey object.</returns> public static XmlWriter Serialize(XmlWriter writer, Oids.Oid alternateKey) { writer.WriteStartElement(DTD.TagAlternateKey); writer.WriteAttributeString(DTD.AlternateKey.TagName, alternateKey.ClassName); // Process element childs. foreach (KeyValuePair <ModelType, object> i in alternateKey.GetFields()) { writer.WriteStartElement(DTD.AlternateKey.TagAlternateKeyField); writer.WriteAttributeString(DTD.AlternateKey.TagType, Convert.MODELTypeToStringType(i.Key)); // Set value for this node. try { writer.WriteString(Convert.TypeToXml(i.Key, i.Value)); } catch (Exception ex) { StringBuilder lMessage = new StringBuilder("Fail Alternate Key Serialize ["); lMessage.Append(alternateKey.ClassName); lMessage.Append(" - "); lMessage.Append(alternateKey.AlternateKeyName); lMessage.Append(']'); throw new ApplicationException(lMessage.ToString(), ex); } writer.WriteEndElement(); } writer.WriteEndElement(); return(writer); }
//public static Oids.Oid Deserialize(XmlReader reader, Oids.Oid oid) /// <summary> /// Deserializes Oid from an XML stream. /// </summary> /// <param name="reader">XML stream.</param> /// <returns>Oid.</returns> public static Oids.Oid Deserialize(XmlReader reader) { Oids.Oid lResult = null; if (reader.IsStartElement(DTD.TagOID)) { string lClassName = reader.GetAttribute(DTD.OID.TagClass); List <KeyValuePair <ModelType, object> > lFields = new List <KeyValuePair <ModelType, object> >(); if (!reader.IsEmptyElement) { reader.ReadStartElement(); do { #region Process tag <OID.Field>. if (reader.IsStartElement(DTD.OID.TagOIDField)) { if (!reader.IsEmptyElement) { ModelType lType = Convert.StringTypeToMODELType(reader.GetAttribute(DTD.OID.TagType)); lFields.Add(new KeyValuePair <ModelType, object>(lType, Convert.XmlToType(lType, reader.ReadString()))); } else { throw new ArgumentException("Xml Reader have one OID.Field with empty Element.", "XmlReader reader"); } } #endregion Process tag <OID.Field>. else { #region Process tag <?> reader.Skip(); if (reader.NodeType == XmlNodeType.None) { break; } else { continue; } #endregion Process tag <?> } } while (reader.Read()); } else { reader.Skip(); } if (lClassName.Length > 0) { lResult = ServerConnection.CreateOid(lClassName, lFields); } } else { throw new ArgumentException("Xml Reader don't have the OID in Start Element.", "XmlReader reader"); } return(lResult); }
/// <summary> /// Checks if the Login form must be showed or not. /// This is calculated according the number of agents defined in the View, /// its kind (anonymous or not), and the number of languages of the application. /// </summary> /// <returns>A boolean value indicating if the Login form is going to be shown or not.</returns> private bool CheckIsAnonymousAndLogIn() { bool lResult = false; if (Logics.Agents.All.Length == 1) { // Create agent info. string lAgentClassName = Logics.Agents.All[0].ToString(); Oids.Oid lagent = Oids.Oid.Create(lAgentClassName); Oids.AgentInfo lAgentInfo = lagent as Oids.AgentInfo; if (lAgentInfo is Oids.AnonymousAgentInfo) { if (CultureManager.SupportedLanguages.Count > 1) { // Apply Change Language menu entry. this.mValidateAgent.Text = CultureManager.TranslateString(LanguageConstantKeys.L_MAIN_CHANGE_LANGUAGE, LanguageConstantValues.L_MAIN_CHANGE_LANGUAGE); // Login form will be showed, because there are more than one language. lResult = false; } else { // Hide Login and Change Password menu entries. this.mValidateAgent.Visible = false; // Login form will not be showed, because the unique agent is anonymous. // and there is only one language. lResult = true; // Assign the unique language supported. foreach (System.Globalization.CultureInfo cultureInfo in CultureManager.SupportedLanguages.Values) { CultureManager.Culture = cultureInfo; } } // Show anonymous agent alias. StringBuilder lStringBuilder = new StringBuilder(); lStringBuilder.Append(CultureManager.TranslateString(lAgentInfo.IdXML + "_Alias", UtilFunctions.ProtectAmpersandChars(lAgentInfo.Alias))); toolStripStatusLabel.Text = lStringBuilder.ToString(); // Show Current culture. toolStripStatusLabelCulture.Text = CultureManager.Culture.Name; // Hide Change Password menu entry. this.mChangePassword.Visible = false; } else { // Login form will be showed, because the agent is not anonymous. lResult = false; } } // Result return. return(lResult); }
/// <summary> /// Serializes an Agent to an XML stream. /// </summary> /// <param name="writer">XML stream to write.</param> /// <param name="agent">Agent.</param> /// <returns>XML stream with the agent.</returns> internal static XmlWriter Serialize(XmlWriter writer, Oids.Oid agent) { if (agent != null && agent.IsValid()) { writer.WriteStartElement(DTD.Request.TagAgent); XMLAdaptorOIDSerializer.Serialize(writer, agent); writer.WriteEndElement(); } return(writer); }
private void mAgent_SelectedIndexChanged(object sender, EventArgs e) { // Hide all the login OIDs. foreach (Control item in mEditors) { item.Visible = false; } // Create the selected agent. string lAgentClassName = (mAgent.SelectedItem as Logics.LogInAgent).Name; Oids.Oid lagent = Oids.Oid.Create(lAgentClassName); // Check if the selected agent is an anonymous agent // to hide the Login and Password controls. AgentInfo lSelectedAgent = lagent as AgentInfo; bool lIsAgentConnectedAnonymous = (lSelectedAgent is AnonymousAgentInfo); this.mlblLogin.Visible = !lIsAgentConnectedAnonymous; this.mlblPassword.Visible = !lIsAgentConnectedAnonymous; this.mTextBoxPassword.Visible = !lIsAgentConnectedAnonymous; if (!lIsAgentConnectedAnonymous) { // Show the login OIDs depending of the selected agent. Logics.LogInAgent lLogInAgent = Logics.Agents.GetLogInAgentByName(lAgentClassName); if (lLogInAgent.AlternateKeyName != string.Empty) { lagent = (Oid)lagent.GetAlternateKey(lLogInAgent.AlternateKeyName); } for (int i = 0; i < lagent.Fields.Count; i++) { mEditors[i].Visible = true; } // Modify the window size depending on the number of arguments in the OID. if (lagent.Fields.Count == 1) { SetClientSizeCore(450, 185); } else { SetClientSizeCore(300 + (lagent.Fields.Count * 100), 185); } } else { // Resize windows size for anonymous agents. SetClientSizeCore(450, 185); } }
private void SuccessAuthenticate(object pObject, EventArgs pEventArgs) { // Check if the agent exists. if (Logics.Logic.Agent != null) { Oids.Oid lAgent = Logics.Logic.Agent; Logics.LogInAgent logInAgent = Logics.Agents.GetLogInAgentByName(lAgent.ClassName); if (logInAgent.AlternateKeyName != string.Empty) { // Get the alternate key of the Oid. lAgent = (Oids.Oid)lAgent.GetAlternateKey(logInAgent.AlternateKeyName); } // HAT Multilanguage: Apply multilanguage to the HAT elements. Controller.ApplyMultilanguage(); // ... and to the fixed strings. MultilanguageFixedString(); Controller.ApplyConnectedAgentVisibility(); // Put the connected agent and the culture on the main form status label. StringBuilder lStringBuilder = new StringBuilder(); if ((lAgent != null) && (lAgent is Oids.AnonymousAgentInfo)) { lStringBuilder.Append(logInAgent.Alias); } else { lStringBuilder.Append(logInAgent.Alias); lStringBuilder.Append(" : "); lStringBuilder.Append(UtilFunctions.OidFieldsToString(lAgent, ' ')); } toolStripStatusLabel.Text = UtilFunctions.ProtectAmpersandChars(lStringBuilder.ToString()); // Show Current culture. toolStripStatusLabelCulture.Text = CultureManager.Culture.Name; // Load instance reports configuration. Logics.Logic.InstanceReportsList.LoadFromFile(Properties.Settings.Default.ConfigurationOfReports); // Load configuration reports file. LoadConfigurationReportsFile(); } else { Close(); } }
/// <summary> /// Deserializes Agent from an XML stream. /// </summary> /// <param name="reader">XML stream.</param> /// <returns>Oid (agent).</returns> public static Oids.Oid Deserialize(XmlReader reader) { Oids.Oid lResult = null; if (reader.IsStartElement(DTD.Request.TagAgent)) { if (!reader.IsEmptyElement) { reader.ReadStartElement(); lResult = XMLAdaptorOIDSerializer.Deserialize(reader); } else { reader.Skip(); } } else { throw new ArgumentException("Xml Reader don't have the Agent in Start Element.", "XmlReader reader"); } return(lResult); }
private void LoadForm(object sender, EventArgs e) { this.Text = "Desktop"; // If there is only one agent and it is anonymous do not show login. if (!CheckIsAnonymousAndLogIn()) { mValidateAgent_Click(sender, e); } else { // Assign the unique agent anonymous as the connected agent. string lAgentClassName = Logics.Agents.All[0].ToString(); Oids.Oid lagent = Oids.Oid.Create(lAgentClassName); Logics.Logic.Agent = lagent as Oids.AgentInfo; // Load instance reports configuration. Logics.Logic.InstanceReportsList.LoadFromFile(Properties.Settings.Default.ConfigurationOfReports); // Load configuration reports file. LoadConfigurationReportsFile(); } }
/// <summary> /// Serializes an Oid object to an XML stream. /// </summary> /// <param name="writer">XML stream to write.</param> /// <param name="oid">Oid.</param> /// <returns>XML stream with the Oid object.</returns> public static XmlWriter Serialize(XmlWriter writer, Oids.Oid oid) { writer.WriteStartElement(DTD.TagOID); writer.WriteAttributeString(DTD.OID.TagClass, oid.ClassName); foreach (KeyValuePair <ModelType, object> i in oid.GetFields()) { writer.WriteStartElement(DTD.OID.TagOIDField); writer.WriteAttributeString(DTD.OID.TagType, Convert.MODELTypeToStringType(i.Key)); try { writer.WriteString(Convert.TypeToXml(i.Key, i.Value)); } catch (Exception ex) { StringBuilder lMessage = new StringBuilder("Fail OID Serialize ["); lMessage.Append(oid.ClassName); lMessage.Append(']'); throw new ApplicationException(lMessage.ToString(), ex); } writer.WriteEndElement(); } writer.WriteEndElement(); return(writer); }
public QueryFilter(string name, Arguments arguments, Oids.Oid lastOid, int blockSize) : this(name, arguments, (Dictionary <string, Oids.Oid>)null, lastOid, blockSize) { }
public QueryFilter(string name, Oids.Oid lastOid) : this(name, (Arguments)null, (Dictionary <string, Oids.Oid>)null, lastOid, 0) { }
public QueryRelated(Dictionary <string, Oids.Oid> linkedTo, Oids.Oid lastOid, int blockSize) { this.BlockSize = blockSize; this.Oid = lastOid; this.LinkedTo = linkedTo; }
public QueryRelated(Oids.Oid lastOid, int blockSize) : this((Dictionary <string, Oids.Oid>)null, lastOid, blockSize) { }
public QueryRelated(Oids.Oid lastOid) : this((Dictionary <string, Oids.Oid>)null, lastOid, 0) { }
public QueryInstanceFromAlternateKey(Oids.Oid oid) : base(oid) { }
public static QueryInstance Create(Oids.Oid oid) { return(new QueryInstance(oid)); }
public QueryInstance(Oids.Oid oid) { this.Oid = oid; }
private void mbOK_Click(object sender, EventArgs e) { #region Actualize current language // Get the current language from the combobox language selector. CultureManager.Culture = new System.Globalization.CultureInfo(((KeyValuePair <string, string>) this.mLanguage.SelectedItem).Key); #endregion Actualize current language string lAgentClassName = (mAgent.SelectedItem as Logics.LogInAgent).Name; Oids.Oid lagent = Oids.Oid.Create(lAgentClassName); lagent.ClearValues(); AgentInfo lAgentInfo = lagent as AgentInfo; Logics.LogInAgent lLogInAgent = Logics.Agents.GetLogInAgentByName(lAgentClassName); // Check if the connected agent has alternate key. if (lLogInAgent.AlternateKeyName != string.Empty) { // Obtain the Alternate Key used by the connected agent class, // in order to be able of filling in the field values from the editors. lagent = (Oid)lagent.GetAlternateKey(lLogInAgent.AlternateKeyName); lagent.AlternateKeyName = lLogInAgent.AlternateKeyName; } if (!(lAgentInfo is AnonymousAgentInfo)) { // To validate that all the login values are introduced. bool lbIsNull = false; // Error provider properties lErrorProvider.Clear(); lErrorProvider.BlinkRate = 500; lErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; #region Validate that the login and password are introduced // Validate the password field. if (mTextBoxPassword.Text == string.Empty) { // Set the focus and error mTextBoxPassword.Focus(); lErrorProvider.SetError(mTextBoxPassword, CultureManager.TranslateString(LanguageConstantKeys.L_PASSWORD_NOT_NULL, LanguageConstantValues.L_PASSWORD_NOT_NULL)); lErrorProvider.SetIconPadding(mTextBoxPassword, -20); lbIsNull = true; } // Validate the login fields. for (int i = mEditors.Length - 1; i >= 0; i--) { if (mEditors[i].Visible) { // Null validation. if (mEditors[i].Text == string.Empty) { // Set the focus and error mEditors[i].Focus(); lErrorProvider.SetError(mEditors[i], CultureManager.TranslateString(LanguageConstantKeys.L_LOGIN_NOT_NULL, LanguageConstantValues.L_LOGIN_NOT_NULL)); lErrorProvider.SetIconPadding(mEditors[i], -20); lbIsNull = true; } } } // If there are any empty argument. if (lbIsNull == true) { // Do not continue return; } #endregion Validate that the login and password are introduced } #region Create the agent int lOidField = 0; try { if (!(lAgentInfo is AnonymousAgentInfo)) { // Set the OID type to the proper control. foreach (Control item in mEditors) { if (item.Visible == true) { try { if (!DefaultFormats.CheckDataType(item.Text, lagent.Fields[lOidField].Type, false)) { string lText = CultureManager.TranslateString(LanguageConstantKeys.L_ERROR_BAD_IDENTITY, LanguageConstantValues.L_ERROR_BAD_IDENTITY); string lMessage = CultureManager.TranslateString(LanguageConstantKeys.L_ERROR, LanguageConstantValues.L_ERROR); MessageBox.Show(lText, lMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } object value = Logics.Logic.StringToModel(lagent.Fields[lOidField].Type, item.Text); lagent.SetValue(lOidField, value); lOidField++; } catch { string lText = CultureManager.TranslateString(LanguageConstantKeys.L_LOGIN_INCORRECT, LanguageConstantValues.L_LOGIN_INCORRECT); string lMessage = CultureManager.TranslateString(LanguageConstantKeys.L_ERROR, LanguageConstantValues.L_ERROR); MessageBox.Show(lText, lMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } } } #region Agent authentication if (lagent is AlternateKey) { AuthenticateAlternateKey(lagent, mTextBoxPassword.Text); } else { Authenticate(lagent as AgentInfo, mTextBoxPassword.Text); } #endregion Agent authentication } catch { string lMessage = CultureManager.TranslateString(LanguageConstantKeys.L_ERROR, LanguageConstantValues.L_ERROR); string lExcepMsg = CultureManager.TranslateString(LanguageConstantKeys.L_ERROR_BAD_IDENTITY, LanguageConstantValues.L_ERROR_BAD_IDENTITY); MessageBox.Show(lExcepMsg, lMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } #endregion Create the agent. }
/// <summary> /// Initializes a new instance of Request. /// </summary> /// <param name="agent">Agent.</param> public Request(Oids.Oid agent) { this.Agent = agent as Oids.AgentInfo; }
/// <summary> /// Initializes a new instance of Request. /// </summary> /// <param name="service">Service.</param> /// <param name="agent">Agent.</param> public Request(ServiceRequest service, Oids.Oid agent) : this(agent) { this.ServerRequest = service; }
public QueryFilter(string name, Dictionary <string, Oids.Oid> linkedTo, Oids.Oid lastOid, int blockSize) : this(name, (Arguments)null, linkedTo, lastOid, blockSize) { }
/// <summary> /// Initializes a new instance of Request. /// </summary> /// <param name="query">Query.</param> /// <param name="agent">Agent.</param> public Request(QueryRequest query, Oids.Oid agent) : this(agent) { this.ServerRequest = query; }
public QueryFilter(string name, Arguments arguments, Dictionary <string, Oids.Oid> linkedTo, Oids.Oid lastOid, int blockSize) : base(linkedTo, lastOid, blockSize) { this.Name = name; this.Variables = new FilterVariables(arguments); }
/// <summary> /// Initializes a new empty instance of ArgumentNavigationFiltering. /// <param name="navigationalFilterID">ID of the filter to apply</param> /// <param name="selectedObjectOID">Oid of the source object of the navigation</param> /// </summary> public SelectedObjectNavigationFiltering(string navigationalFilterID, Oids.Oid selectedObjectOID) { NavigationalFilterID = navigationalFilterID; SelectedObjectOID = selectedObjectOID; }