Пример #1
0
        private async void RefreshComboBoxDataFromDfApi()
        {
            if (dfApi == null || dfApi.apiUrl != apiUrlTextBox.Text)
            {
                if (string.IsNullOrWhiteSpace(apiUrlTextBox.Text) ||
                    string.IsNullOrWhiteSpace(apiUserTextBox.Text) ||
                    string.IsNullOrWhiteSpace(apiPasswordTextBox.Text))
                {
                    MessageBox.Show("Los campos ApiUrl, Usuario y Contraseña no pueden estar en blanco.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                dfApi = new DfApi(apiUrlTextBox.Text);

                if (!(await dfApi.loginAsync(apiUserTextBox.Text, apiPasswordTextBox.Text)))
                {
                    MessageBox.Show("Ocurrió un error al chequear las credenciales de la Api Dokuflex. Por favor revice los datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    dfApi = null;
                    return;
                }

                var userGroups = await dfApi.getUserGroups();

                communityComboBox.DataSource = new BindingList <UserGroup>(userGroups);

                var process = await dfApi.getProcess();

                processComboBox.DataSource = new BindingList <Process>(process);
            }
        }
Пример #2
0
        /// <summary>
        /// This method will set up the DeepFreeze object and wrap all the methods/functions
        /// </summary>
        /// <returns>
        /// Bool indicating success of call
        /// </returns>
        public static bool InitDfWrapper()
        {
            try
            {
                //reset the internal objects
                _dfWrapped    = false;
                ActualDf      = null;
                DeepFreezeApi = null;
                LogFormatted("Attempting to Grab DeepFreeze Types...");

                //find the base type
                DfType = AssemblyLoader.loadedAssemblies
                         .Select(a => a.assembly.GetExportedTypes())
                         .SelectMany(t => t)
                         .FirstOrDefault(t => t.FullName == "DF.DeepFreeze");

                if (DfType == null)
                {
                    return(false);
                }

                LogFormatted("DeepFreeze Version:{0}", DfType.Assembly.GetName().Version.ToString());

                //now the KerbalInfo Type
                KerbalInfoType = AssemblyLoader.loadedAssemblies
                                 .Select(a => a.assembly.GetExportedTypes())
                                 .SelectMany(t => t)
                                 .FirstOrDefault(t => t.FullName == "DF.KerbalInfo");

                if (KerbalInfoType == null)
                {
                    return(false);
                }

                //now the DeepFreezer (partmodule) Type
                DeepFreezerType = AssemblyLoader.loadedAssemblies
                                  .Select(a => a.assembly.GetExportedTypes())
                                  .SelectMany(t => t)
                                  .FirstOrDefault(t => t.FullName == "DF.DeepFreezer");

                if (DeepFreezerType == null)
                {
                    return(false);
                }

                //now the FrznCrewMbr Type
                FrznCrewMbrType = AssemblyLoader.loadedAssemblies
                                  .Select(a => a.assembly.GetExportedTypes())
                                  .SelectMany(t => t)
                                  .FirstOrDefault(t => t.FullName == "DF.FrznCrewMbr");

                if (FrznCrewMbrType == null)
                {
                    return(false);
                }

                //now grab the running instance
                LogFormatted("Got Assembly Types, grabbing Instance");
                try
                {
                    ActualDf = DfType.GetField("Instance", BindingFlags.Public | BindingFlags.Static).GetValue(null);
                }
                catch (Exception)
                {
                    LogFormatted("No Instance found - most likely you have an old DeepFreeze installed");
                    return(false);
                }
                if (ActualDf == null)
                {
                    LogFormatted("Failed grabbing Instance");
                    return(false);
                }

                //If we get this far we can set up the local object and its methods/functions
                LogFormatted("Got Instance, Creating Wrapper Objects");
                DeepFreezeApi = new DfApi(ActualDf);
                _dfWrapped    = true;
                return(true);
            }
            catch (Exception ex)
            {
                LogFormatted("Unable to setup InitDFWrapper Reflection");
                LogFormatted("Exception: {0}", ex);
                _dfWrapped = false;
                return(false);
            }
        }