private static string GetExceptionMessage(MiResult errorCode, string errorMessage, InstanceHandle errorDetailsHandle) { string exceptionMessage = GetExceptionMessage(errorDetailsHandle); if (!string.IsNullOrEmpty(exceptionMessage)) { return(exceptionMessage); } ApplicationMethods.GetCimErrorFromMiResult(errorCode, errorMessage, out errorDetailsHandle); try { exceptionMessage = GetExceptionMessage(errorDetailsHandle); if (!string.IsNullOrEmpty(exceptionMessage)) { return(exceptionMessage); } } finally { if (errorDetailsHandle != null) { var disosable = errorDetailsHandle as IDisposable; if (disosable != null) { disosable.Dispose(); } } } return(errorCode.ToString()); }
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(ApplicationMethods applicationmethods, System.Data.DataSet data) { // Do nothing if we have nothing if (data == null || data.Tables.Count == 0 || data.Tables[0].Rows.Count == 0) { return; } // Create a local variable for the new instance. ApplicationMethod newobj = null; // Create a local variable for the data row instance. System.Data.DataRow dr = null; // Iterate through the table rows for (int i = 0; i < data.Tables[0].Rows.Count; i++) { // Get a reference to the data row dr = data.Tables[0].Rows[i]; // Create a new object instance newobj = System.Activator.CreateInstance(applicationmethods.ContainsType[0]) as ApplicationMethod; // Let the instance set its own members newobj.SetMembers(ref dr); // Add the new object to the collection instance applicationmethods.Add(newobj); } }
/// <summary> /// Fill method for populating an entire collection of ApplicationMethods /// </summary> public virtual void Fill(ApplicationMethods applicationMethods) { // create the connection to use SqlConnection cnn = new SqlConnection(ApplicationMethod.GetConnectionString()); try { using (cnn) { // open the connection cnn.Open(); // create an instance of the reader to fill. SqlDataReader datareader = SqlHelper.ExecuteReader(cnn, "gsp_SelectApplicationMethods"); // Send the collection and data to the object factory CreateObjectsFromData(applicationMethods, datareader); // close the connection cnn.Close(); } // nullify the connection cnn = null; } catch (SqlException sqlex) { throw sqlex; } }
public CimInstance(CimClass cimClass) { InstanceHandle instanceHandle = null; this._CimSessionInstanceID = Guid.Empty; if (cimClass != null) { MiResult miResult = ApplicationMethods.NewInstance(CimApplication.Handle, cimClass.CimSystemProperties.ClassName, cimClass.ClassHandle, out instanceHandle); if (miResult != MiResult.INVALID_PARAMETER) { CimException.ThrowIfMiResultFailure(miResult); this._myHandle = new SharedInstanceHandle(instanceHandle); miResult = InstanceMethods.SetNamespace(this._myHandle.Handle, cimClass.CimSystemProperties.Namespace); CimException.ThrowIfMiResultFailure(miResult); miResult = InstanceMethods.SetServerName(this._myHandle.Handle, cimClass.CimSystemProperties.ServerName); CimException.ThrowIfMiResultFailure(miResult); return; } else { throw new ArgumentOutOfRangeException("cimClass"); } } else { throw new ArgumentNullException("cimClass"); } }
public CimInstance(string className, string namespaceName) { InstanceHandle instanceHandle = null; this._CimSessionInstanceID = Guid.Empty; if (className != null) { MiResult miResult = ApplicationMethods.NewInstance(CimApplication.Handle, className, null, out instanceHandle); MiResult miResult1 = miResult; if (miResult1 != MiResult.INVALID_PARAMETER) { CimException.ThrowIfMiResultFailure(miResult); this._myHandle = new SharedInstanceHandle(instanceHandle); if (namespaceName != null) { miResult = InstanceMethods.SetNamespace(this._myHandle.Handle, namespaceName); CimException.ThrowIfMiResultFailure(miResult); } return; } else { throw new ArgumentOutOfRangeException("className"); } } else { throw new ArgumentNullException("className"); } }
private void Initialize(CimSubscriptionDeliveryType types) { SubscriptionDeliveryOptionsHandle subscriptionDeliveryOptionsHandle = null; MiResult miResult = ApplicationMethods.NewSubscriptionDeliveryOptions(CimApplication.Handle, (MiSubscriptionDeliveryType)types, out subscriptionDeliveryOptionsHandle); CimException.ThrowIfMiResultFailure(miResult); this._subscriptionDeliveryOptionsHandle = subscriptionDeliveryOptionsHandle; }
}//END GetParameter method // ================================================================================== /// <summary> /// This method sets the custom command parameter value. /// </summary> /// <param name="Value"> ApplicationMethods enumeration /// of application methods /// </param> // --------------------------------------------------------------------------------- public void setCustomMethod ( ApplicationMethods Value ) { // // get the string value of the parameter list. // String value = Value.ToString ( ); this.AddParameter ( CommandParameters.Custom_Method, value ); }
/// <summary> /// this method to initialise the class. /// </summary> /// <param name="Title">String: command title</param> /// <param name="ApplicationId">String: application identifier</param> /// <param name="ApplicationObject">String: Application object identifier</param> /// <param name="ApplicationMethod">String method emerated value</param> public Command ( String Title, String ApplicationId, String ApplicationObject, ApplicationMethods ApplicationMethod ) { this._Id = Guid.NewGuid ( ); this._Title = Title; this._Type = CommandTypes.Normal_Command; this._ApplicationId = ApplicationId; this._Object = ApplicationObject; this._Method = ApplicationMethod; }
}//END property. //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #endregion #region Class compare methods // ================================================================================== /// <summary> /// This method compares the existing command object with a passed command object. /// To determine if they are the same command. /// </summary> /// <remarks> /// This method consists of following steps. /// /// 1. Command Id's match return true /// /// 2. command AppId, Object, Method and Titles match return true. /// /// 3. return false /// /// </remarks> /// <param name="PageCommand">Evado.UniForm.Model.Command object</param> /// <returns>Bool: true = matching command</returns> // --------------------------------------------------------------------------------- public bool isCommand ( Command PageCommand ) { // // Initialise the methods variables and objects. // String PageId = PageCommand.GetPageId(); String currentPageId = this.GetPageId(); Guid DataGuid = PageCommand.GetGuid ( ); Guid currentDataGuid = this.GetGuid ( ); // // if the command identifiers match same command return true; // if ( this._Id == PageCommand.Id ) { return true; } // // Set the short title that is included in the command history. // PageCommand.setShortTitle ( ); if ( PageCommand.Method == ApplicationMethods.Custom_Method ) { ApplicationMethods method = PageCommand.getCustomMethod ( ); // // If the AppId, Object, method and title match then same command return true. // if ( this._ApplicationId == PageCommand.ApplicationId && this._Object == PageCommand.Object && this._Method == method ) { return true; } return false; } // // If the AppId, Object, method and title match then same command return true. // if ( this._ApplicationId == PageCommand.ApplicationId && this._Object == PageCommand.Object && this._Method == PageCommand.Method && PageId == currentPageId && DataGuid == currentDataGuid ) { return true; } return false; }//END isCommand method.
/// <summary> /// Gets all the available objects. /// </summary> public virtual ApplicationMethods GetAll() { // create a new instance of the return object ApplicationMethods objects = new ApplicationMethods(); // fill the objects this.Fill(objects); // return the filled object from the service return(objects); }
public static CimSession Create(string computerName, CimSessionOptions sessionOptions) { IPAddress pAddress = null; InstanceHandle instanceHandle = null; SessionHandle sessionHandle = null; CimSession cimSession; string protocol; DestinationOptionsHandle destinationOptionsHandle; string str = computerName; if (!string.IsNullOrEmpty(str) && IPAddress.TryParse(str, out pAddress) && pAddress.AddressFamily == AddressFamily.InterNetworkV6 && str[0] != '[') { str = string.Concat("[", str, "]"); } IDisposable disposable = CimApplication.AssertNoPendingShutdown(); using (disposable) { ApplicationHandle handle = CimApplication.Handle; if (sessionOptions == null) { protocol = null; } else { protocol = sessionOptions.Protocol; } string str1 = str; if (sessionOptions == null) { destinationOptionsHandle = null; } else { destinationOptionsHandle = sessionOptions.DestinationOptionsHandle ?? sessionOptions.DestinationOptionsHandleOnDemand; } MiResult miResult = ApplicationMethods.NewSession(handle, protocol, str1, destinationOptionsHandle, out instanceHandle, out sessionHandle); if (miResult != MiResult.NOT_FOUND) { CimException.ThrowIfMiResultFailure(miResult, instanceHandle); CimSession cimSession1 = new CimSession(sessionHandle, computerName); cimSession = cimSession1; } else { throw new CimException(miResult, null, instanceHandle, System.Management.Automation.Strings.UnrecognizedProtocolName); } } return cimSession; }
private static ApplicationHandle GetApplicationHandle() { ApplicationHandle applicationHandle = null; InstanceHandle instanceHandle = null; MiResult miResult = ApplicationMethods.Initialize(0, AppDomain.CurrentDomain.FriendlyName, out instanceHandle, out applicationHandle); CimException.ThrowIfMiResultFailure(miResult, instanceHandle); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.DomainUnload += (object sender, EventArgs eventArgs) => CimApplication.Shutdown(); AppDomain appDomain = AppDomain.CurrentDomain; appDomain.ProcessExit += (object param0, EventArgs param1) => { ApplicationMethods.SupressFurtherCallbacks(); CimApplication.Shutdown(); }; return(applicationHandle); }
}//END deleteAfterCommand method. // ================================================================================== /// <summary> /// Gets the last previous groupCommand /// </summary> /// <param name="CustomCommand">Guid Command identifer</param> /// <returns>ClientPageCommand</returns> // ---------------------------------------------------------------------------------- private bool updateCommandParameters ( Command CustomCommand ) { this.LogMethod ( "updateCommandParameters method. " ); // // Intialise the methods variables and objects. // int lastCount = this._CommandHistoryList.Count - 1; Command lastCommand = this._CommandHistoryList [ lastCount ]; // // Get the custom groupCommand parameter. // ApplicationMethods method = CustomCommand.getCustomMethod ( ); // // custom groupCommand parameter method is not a selection groupCommand exit. if ( method != ApplicationMethods.Get_Object && method != ApplicationMethods.List_of_Objects ) { return false; } // // To cater for when the custom command is on the default or home page. // if ( lastCommand.ApplicationId == "Default" || lastCommand.Object == "Default" ) { lastCommand.ApplicationId = CustomCommand.ApplicationId; lastCommand.Object = CustomCommand.Object; } // // Iterate through the groupCommand parameters to update them. // foreach ( Parameter customParameter in CustomCommand.Parameters ) { lastCommand.AddParameter ( customParameter.Name, customParameter.Value ); }//END iteration loop return true; }//END getCommonPageCommand method.
/// <summary> /// The object factory for a particular data collection instance. /// </summary> public virtual void CreateObjectsFromData(ApplicationMethods applicationmethods, System.Data.SqlClient.SqlDataReader data) { // Do nothing if we have nothing if (data == null) { return; } // Create a local variable for the new instance. ApplicationMethod newobj = null; // Iterate through the data reader while (data.Read()) { // Create a new object instance newobj = System.Activator.CreateInstance(applicationmethods.ContainsType[0]) as ApplicationMethod; // Let the instance set its own members newobj.SetMembers(ref data); // Add the new object to the collection instance applicationmethods.Add(newobj); } }
internal static void Restart(bool elevate) { ApplicationMethods.RestartApplication(elevate); }