コード例 #1
0
        public static KeyValueBunch GetPluginProperties(int userId, int pluginId)
        {
            // get plugin
            SystemPluginBase pluginObj = GetSystemPluginInstance(pluginId);

            // get settings
            return(GetPluginPropertiesInternal(userId, pluginId, true, pluginObj.SecureSettings));
        }
コード例 #2
0
        public static int SetPluginProperties(int userId, int pluginId, KeyValueBunch props)
        {
            string xmlText = String.Empty;

            string[][]     pluginProps = null;
            SecurityResult result      = StorehouseController.CheckAccountNotDemoAndActive();

            //
            if (!result.Success)
            {
                return(result.ResultCode);
            }
            if (props != null)
            {
                // create system plugin
                SystemPluginBase pluginObj = GetSystemPluginInstance(userId, pluginId, false);
                // crypt sensitive data
                foreach (string keyName in props.GetAllKeys())
                {
                    //
                    string keyValue = props[keyName];
                    //
                    if (pluginObj.SecureSettings != null)
                    {
                        int indexOf = Array.IndexOf(pluginObj.SecureSettings, keyName);
                        // crypt sensitive data
                        if (indexOf > -1)
                        {
                            keyValue = CryptoUtils.Encrypt(keyValue);
                        }
                    }
                    //
                    props[keyName] = keyValue;
                }

                // load old properties
                KeyValueBunch oldProps = GetPluginPropertiesInternal(userId, pluginId,
                                                                     false, pluginObj.SecureSettings);
                // merge old props with new props
                foreach (string keyName in props.GetAllKeys())
                {
                    // copy
                    oldProps[keyName] = props[keyName];
                }
                //
                pluginProps = oldProps.KeyValueArray;
            }
            // build update xml
            xmlText = SettingsHelper.ConvertObjectSettings(pluginProps, "properties", "property");
            //
            return(EcommerceProvider.SetPluginProperties(SecurityContext.User.UserId, userId, pluginId, xmlText));
        }
コード例 #3
0
        internal static SystemPluginBase GetSystemPluginInstance(int resellerId, int pluginId, bool setupPlugin)
        {
            // load plugin
            SystemPluginBase pluginObj = GetSystemPluginInstance(pluginId);

            //
            if (setupPlugin)
            {
                SetupSystemPlugin(resellerId, pluginObj);
            }
            //
            return(pluginObj);
        }
コード例 #4
0
        internal static SystemPluginBase GetSystemPluginInstance(Contract contract, SupportedPlugin plugin,
                                                                 bool setupPlugin)
        {
            // load plugin
            SystemPluginBase pluginObj = GetSystemPluginInstance(plugin);

            //
            if (setupPlugin)
            {
                SetupSystemPlugin(contract.ResellerId, pluginObj);
            }
            //
            return(pluginObj);
        }
コード例 #5
0
        internal static SystemPluginBase GetSystemPluginInstance(string contractId, int pluginId, bool setupPlugin)
        {
            Contract contract = ContractSystem.ContractController.GetContract(contractId);
            // load plugin
            SystemPluginBase pluginObj = GetSystemPluginInstance(pluginId);

            //
            if (setupPlugin)
            {
                SetupSystemPlugin(contract.ResellerId, pluginObj);
            }
            //
            return(pluginObj);
        }
コード例 #6
0
 internal static void SetupSystemPlugin(int resellerId, SystemPluginBase pluginObj)
 {
     // load plugin settings
     pluginObj.PluginSettings = GetPluginPropertiesInternal(resellerId, pluginObj.PluginId,
                                                            false, pluginObj.SecureSettings);
     // check whether plugin settings should be decrypted
     if (pluginObj.SecureSettings != null && pluginObj.SecureSettings.Length > 0)
     {
         // decrypt secret settings
         foreach (string keyName in pluginObj.SecureSettings)
         {
             // call WebsitePanel Crypto API
             pluginObj.PluginSettings[keyName] = CryptoUtils.Decrypt(pluginObj.PluginSettings[keyName]);
         }
     }
 }
コード例 #7
0
        internal static SystemPluginBase GetSystemPluginInstance(SupportedPlugin plugin)
        {
            // check plugin not empty
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }
            // create system plugin instance
            SystemPluginBase pluginObj = (SystemPluginBase)Activator.CreateInstance(Type.GetType(plugin.TypeName));

            // copy fields
            pluginObj.PluginId   = plugin.PluginId;
            pluginObj.PluginName = plugin.PluginName;
            // return
            return(pluginObj);
        }