Exemple #1
0
        /// <summary>
        /// Cache both inport and export permissions for the specified module.
        /// </summary>
        /// <param name="module">The modules for which permissions should be cached.</param>
        private void CachePermissionsForModule(AvailableModule module)
        {
            if (!string.IsNullOrWhiteSpace(module.module_key))
            {
                CacheAccessPermission(
                    module.module_key,
                    ImportPermissionToken,
                    module.module_acls1.FirstOrDefault(b => b.action == ImportPermissionToken)?.access ?? false);
                CacheAccessPermission(
                    module.module_key,
                    ExportPermissionToken,
                    module.module_acls1.FirstOrDefault(b => b.action == ExportPermissionToken)?.access ?? false);

                try
                {
                    Log.Debug($"Cached {CRMPermissionsCache.cache[module.module_key]} permission for {module.module_key}");
                }
                catch (KeyNotFoundException)
                {
                    // shouldn't ever happen. Ignore for now.
                }
            }
        }
Exemple #2
0
        private void addMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem tsi = sender as ToolStripItem;

            if (tsi != null)
            {
                AvailableModule module = (AvailableModule)tsi.Tag;

                // create a model for this module
                // i use the view to create the model, if it has a default model we get this one
                PresetableViewBase view = module.CreateNewView();
                view.PreInit();
                ModelBase m = ModelBase.CloneModel(view.GetModelBase());

//                // see https://trac.irgendwie.net/PhotoTagStudio/ticket/72
//                // special for rename and copyMove - only on of them in every macro
//                if (m is RenameModel || m is CopyMoveModel)
//                {
//                    // check if there is already on of these
//                    foreach (ListViewItem l in this.listItems.Items)
//                        if (l.Tag is RenameModel || l.Tag is CopyMoveModel)
//                        {
//                            MessageBox.Show("You cannot add more than one of Renamer and Copy/Move to each macro. It makes simply no sense...",
//                                "Execute PhotoTagStudio Macro", MessageBoxButtons.OK, MessageBoxIcon.Information);
//                            return; //do not add
//                        }
//                }

                ListViewItem lvi = new ListViewItem(module.Name);
                lvi.Tag = m;
                this.listItems.Items.Add(lvi);

                this.listItems.SelectedItems.Clear();
                lvi.Selected = true;
            }
        }
Exemple #3
0
 /// <summary>
 /// Is this module a currently selected custom module?
 /// </summary>
 /// <param name="module">The module.</param>
 /// <returns>True if this module is a currently selected custom module.</returns>
 private bool IsSelectedCustomModule(AvailableModule module)
 {
     return(Properties.Settings.Default.CustomModules != null &&
            Properties.Settings.Default.CustomModules.Where(i => i.StartsWith($"{module.module_key}|")).Count() > 0);
 }