コード例 #1
0
        void Update()
        {
            if (InitConnection())
            {
                try
                {
                    if (m_bBrokenConnection)
                    {
                        DestroyConnection();
                    }
                    else
                    {
                        // Check our stuff
                        HPMUInt64 CurrentTime = GetTimeSince1970();
                        if (CurrentTime > m_NextUpdate)
#if (DEBUG)
                        { m_NextUpdate = CurrentTime + 10000000;   // Check every 10 seconds
                        }
#else
                        { m_NextUpdate = CurrentTime + 120000000;   // Check every 120 seconds
                        }
#endif
                        // Get text field
                        HPMCustomSettingValue EditFieldValue = m_Session.GlobalGetCustomSettingsValue(EHPMCustomSettingsType.Admin, m_IntegrationIdentifier, "GlobalSettings1/TestTab1/Edit");
                        Console.WriteLine("Example edit field: " + EditFieldValue.m_Value);

                        // Get selected resources
                        HPMCustomSettingValue SelectedResourcesValue = m_Session.GlobalGetCustomSettingsValue(EHPMCustomSettingsType.Admin, m_IntegrationIdentifier, "GlobalSettings1/TestTab2/Subset0");
                        if (SelectedResourcesValue.m_Value.Length > 0)
                        {
                            char[]   DelimitChars = { ' ' }; // This will not work for values with escaped space in them
                            String[] Values       = SelectedResourcesValue.m_Value.Split(DelimitChars);
                            foreach (String Value in Values)
                            {
                                HPMCustomChoiceValue CustomValue = m_Session.UtilDecodeCustomChoiceValue(Value);
                                Console.WriteLine("Value " + Value + " has unique ID " + CustomValue.m_UniqueID);
                                HPMResourceProperties Properties = m_Session.ResourceGetProperties(CustomValue.m_UniqueID);
                                Console.WriteLine("Name: " + Properties.m_Name + ", Email: " + Properties.m_EmailAddress);
                            }
                        }

                        HPMCustomSettingValue AllChoiceValue = m_Session.GlobalGetCustomSettingsValue(EHPMCustomSettingsType.Admin, m_IntegrationIdentifier, "GlobalSettings1/TestTab3/Subset1/Choices");
                        Console.WriteLine("All choices in TestTab3: " + AllChoiceValue.m_Value);

                        // Add new value from SDK if it's not there
                        if (!AllChoiceValue.m_Value.Contains(m_NewValue))
                        {
                            String NewAllChoices = m_NewValue + " " + AllChoiceValue.m_Value;
                            AllChoiceValue.m_Value = NewAllChoices;
                            m_Session.GlobalSetCustomSettingsValue(EHPMCustomSettingsType.Admin, m_IntegrationIdentifier, "GlobalSettings1/TestTab3/Subset1/Choices", AllChoiceValue);
                        }
                    }
                }
                catch (HPMSdkException _Error)
                {
                    Console.WriteLine("Exception in processing loop: " + _Error.ErrorAsStr());
                }
                catch (HPMSdkManagedException _Error)
                {
                    Console.WriteLine("Exception in processing loop: " + _Error.ErrorAsStr());
                }
            }
        }