Exemplo n.º 1
0
		private static IOption CreateShellOption(Category shellSubCategory, OptionDefType uiOption)
		{
			return CreateShellOptionInternal(shellSubCategory, uiOption, GetDataTypeDefaultValue(uiOption.DataType));
		}
Exemplo n.º 2
0
		private static IOption CreateShellOptionInternal(Category shellSubCategory, OptionDefType uiOption,
		                                                 string defaultValue)
		{
			IOption shellOption = null;
			string s = !string.IsNullOrEmpty(string.Concat(uiOption.Text)) ? string.Concat(uiOption.Text) : defaultValue;

			if (string.IsNullOrEmpty(s))
			{
				s = string.Empty;
			}

			bool canOverride = uiOption.IsOverrideAllowed;
			switch (uiOption.DataType)
			{
				case OptionDataTypeEnum.Boolean:
					{
						bool val = GetBool(s);
						shellOption = new BoolOption(uiOption.Name, val, val, canOverride)
						              	{
						              		DisplayName = uiOption.DisplayText,
						              		Description = uiOption.DisplayText,
						              		Category = shellSubCategory == null ? null : shellSubCategory.Parent,
						              		SubCategory = shellSubCategory
						              	};
						break;
					}
				case OptionDataTypeEnum.Integer:
					{
						int val = GetInt(s);
						shellOption = new IntegerOption(uiOption.Name, val, val, canOverride)
						              	{
						              		DisplayName = uiOption.DisplayText,
						              		Description = uiOption.DisplayText,
						              		Category = shellSubCategory == null ? null : shellSubCategory.Parent,
						              		SubCategory = shellSubCategory
						              	};
						break;
					}
				case OptionDataTypeEnum.String:
					{
						if (uiOption.Encrypted)
						{
							shellOption = new EncryptionOption(uiOption.Name, s, s, canOverride)
							              	{
							              		DisplayName = uiOption.DisplayText,
							              		Description = uiOption.DisplayText,
							              		Category = shellSubCategory == null ? null : shellSubCategory.Parent,
							              		SubCategory = shellSubCategory
							              	};
						}
						else
						{
							shellOption = new StringOption(uiOption.Name, s, s, canOverride)
							              	{
							              		DisplayName = uiOption.DisplayText,
							              		Description = uiOption.DisplayText,
							              		Category = shellSubCategory == null ? null : shellSubCategory.Parent,
							              		SubCategory = shellSubCategory,
							              		IsPrimaryKey = uiOption.IsPrimaryKey
							              	};
						}
						break;
					}
				case OptionDataTypeEnum.Color:
					{
						var val = GetColor(s);
						shellOption = new ColorOption(uiOption.Name, val, val, canOverride)
						              	{
						              		DisplayName = uiOption.DisplayText,
						              		Description = uiOption.DisplayText,
						              		Category = shellSubCategory == null ? null : shellSubCategory.Parent,
						              		SubCategory = shellSubCategory
						              	};
						break;
					}
				case OptionDataTypeEnum.KeyValueRange:
					{
						int val = GetInt(s);
						shellOption = new EnumOption(uiOption.Name, val, val, canOverride, GetEnumValues(uiOption))
						              	{
						              		DisplayName = uiOption.DisplayText,
						              		Description = uiOption.DisplayText,
						              		Category = shellSubCategory == null ? null : shellSubCategory.Parent,
						              		SubCategory = shellSubCategory
						              	};

						break;
					}
				case OptionDataTypeEnum.Format:
				case OptionDataTypeEnum.Range:
				default:
					{
						// do nothing. these need to be converted
#if DEBUG
						throw new NotImplementedException();
#else
						break;
#endif
					}
			}

			return shellOption;
		}
Exemplo n.º 3
0
		public static OptionGroupInstance CreateShellOptionGroupInstance(Category shellSubCategory,
		                                                                 UIOptionGroupInstanceType instance)
		{
			OptionGroupInstance shellOptionGroupInstance = new OptionGroupInstance
			                                               	{
			                                               		InstanceName = instance.Name,
			                                               		DisplayName = instance.DisplayText,
			                                               		Description = instance.DisplayText,
			                                               		Category = shellSubCategory == null ? null : shellSubCategory.Parent,
			                                               		SubCategory = shellSubCategory
			                                               	};

			foreach (OptionDefType option in instance.OptionDef)
			{
				if (option.DataType == OptionDataTypeEnum.KeyValueRange)
				{
					SetValueRange(shellSubCategory, shellOptionGroupInstance, option, false);
				}
				IOption newOpt = CreateShellOption(shellSubCategory, option);

				shellOptionGroupInstance.SubOptions.Add(newOpt);
				newOpt.Parent = shellOptionGroupInstance;
			}

			return shellOptionGroupInstance;
		}
Exemplo n.º 4
0
		public static void SetValueRange(Category shellSubCategory, OptionGroupInstance shellOptionGroupInstance,
		                                 OptionDefType option, bool setDefaultValue)
		{
			Dictionary<string, string> attrs = OptionApi.GetAttributeList(GetOptionGroupTypeName(shellSubCategory),
			                                                              shellOptionGroupInstance.Name, option.Name);

			string valueRange = null;
			if (attrs.TryGetValue("ValueRange", out valueRange))
			{
				option.ValueRange = valueRange;

				string defaultValue = null;
				if (setDefaultValue && attrs.TryGetValue("DefaultValue", out defaultValue))
				{
					option.Text = new[] {defaultValue};
				}
			}
		}
Exemplo n.º 5
0
		public static IOption CreateShellOption(Category shellSubCategory, UIOptionType option, string defaultValue)
		{
			return CreateShellOptionInternal(shellSubCategory, option, defaultValue);
		}
Exemplo n.º 6
0
		public static string GetOptionGroupTypeName(Category subCat)
		{
			if (subCat == null)
			{
				return "DocumentProviders"; // for now
			}

			switch (subCat.Name.ToLower())
			{
				case "imanage":
					return "InterwovenServers";
				case "sharepoint":
					return "SharePointSiteCollection";
				case "edocs":
					return "Hummingbird";
				case "netdocuments":
					return "NetDocumentsUsers";
                case "worldox":
                    return "WorldoxSettings";
				default:
					return subCat.Name;
			}
		}
Exemplo n.º 7
0
		private Category BuildShellSubCategory(Category shellCategory, UIOptionSubCategoryType subCategory)
		{
			Category shellSubCategory = new Category
			                            	{
			                            		DisplayName = subCategory.DisplayText,
			                            		Name = subCategory.Name,
			                            		Parent = shellCategory,
			                            		Order = GetOrderId(shellCategory.Name, subCategory.Name)
			                            	};
			return shellSubCategory;
		}
Exemplo n.º 8
0
		private void ProcessOption(MainViewModel model, Dictionary<string, AreaOption> areas, Category shellCategory,
		                           Category shellSubCategory, OptionBaseType option)
		{
			if (option is UIOptionType)
			{
				var uiOption = option as UIOptionType;

				if (!ShouldOptionBeVisible(uiOption, model.AppModel.IsAdmin))
				{
					return;
				}

				var shellOption = CreateShellOption(shellSubCategory, uiOption);
				if (shellOption != null)
				{
					shellOption.IsEnabled = ShouldOptionBeEnabled(uiOption, model.AppModel.IsAdmin);
					shellOption.Category = shellCategory;
					shellOption.SubCategory = shellSubCategory;
					if (!string.IsNullOrEmpty(uiOption.Area))
					{
						if (!areas.ContainsKey(uiOption.Area))
						{
							var area = new AreaOption
							           	{
							           		Name = uiOption.Area,
							           		DisplayName = uiOption.DisplayText,
							           		Description = uiOption.DisplayText,
							           		Category = shellCategory,
							           		SubCategory = shellSubCategory
							           	};
							areas.Add(uiOption.Area, area);
						}
						areas[uiOption.Area].AddSubOption(shellOption, uiOption.PolicyScope);
					}
					else
					{
						model.AddOption(shellOption);
					}
				}
			}
			else if (option is UIOptionGroupType)
			{
				shellSubCategory.ContainsInstances = true;
				var optionGroup = option as UIOptionGroupType;
				foreach (var instance in optionGroup.OptionGroupInstances)
				{
					model.AddOption(CreateShellOptionGroupInstance(shellSubCategory, instance));
				}
			}
		}
Exemplo n.º 9
0
		private void ProcessSubCategory(MainViewModel model, Dictionary<string, AreaOption> areas, Category shellCategory,
		                                UIOptionSubCategoryType subCategory)
		{
			Category shellSubCategory = model.GetSubCategory(shellCategory.Name, subCategory.Name) ??
			                            BuildShellSubCategory(shellCategory, subCategory);
			shellSubCategory.Model = model;
			foreach (var option in subCategory.Options)
			{
				ProcessOption(model, areas, shellCategory, shellSubCategory, option);
			}
		}
Exemplo n.º 10
0
		private Category BuildShellCategory(UIOptionCategoryType category)
		{
			var shellCategory = new Category
			                    	{
			                    		Name = category.Name,
			                    		DisplayName = category.DisplayText,
			                    		Order = GetOrderId(category.Name, string.Empty),
			                    	};
			return shellCategory;
		}
Exemplo n.º 11
0
		internal void NavigateHome()
        {
			// Unselect current selection else navigation to the item selected before we selected 'home' will fail.
			if (SelectedCategory != null && SelectedCategory.Parent != null && SelectedCategory.Parent.SelectedSubCategory != null)
			{
				SelectedCategory.Parent.SelectedSubCategory = null;
			}

			_model.SelectedCategory = null;
			SelectedCategory = null;
			
			NavigateTo("Home");			
		}
Exemplo n.º 12
0
		private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
		{
			if (e.NewValue != null)
			{
				if (e.NewValue.GetType() == typeof (Category))
				{
					_category = e.NewValue as Category;
					if (_category != null
					    && (_category.Options.Count > 0
						|| _category.ContainsInstances ))
					{
						Visibility = Visibility.Visible;
					}
					else
					{
						Visibility = Visibility.Hidden;
					}
					return;
				}
				if (e.NewValue.GetType() == typeof(OptionGroupInstance))
				{
					_option = e.NewValue as OptionGroupInstance;
					Category cat = _option.SubCategory;

					if (_category == null)
					{
						_category = cat;
					}
					else if (cat.Name != _category.Name)
					{
						_category = cat;
					}

					return;
				}
			}
			ContentTemplate = null;
			_category = null;
		}
Exemplo n.º 13
0
		private static void AddOptionGroupInstance(Category subCategory)
		{
			Dictionary<string, OptionInfo> groupDefs = OptionApi.GetGroupDefinitions(OptionMapper.GetOptionGroupTypeName(subCategory));
			
			var ogi = new OptionGroupInstance
			          	{
                            InstanceName = Workshare.Options.Converters.Xml.DefaultXmlReadVisitor.UnsavedInstanceName,
			          		Category = subCategory.Parent,
			          		SubCategory = subCategory,
			          		DataType = typeof (OptionGroupInstance).ToString()
			          	};

            if (subCategory != null)
            {
                ogi.CanChangeOverride = subCategory.Model.AppModel.IsAdmin;
				ogi.CanChangeDeploy = subCategory.Model.AppModel.IsAdmin;
            }

			foreach (OptionInfo option in groupDefs.Values)
			{
				UIOptionType op = new UIOptionType
				{
					Name = option.Name
				};

				OptionDataTypeEnum dt;

				if (Enum.TryParse(option.DataType, true, out dt))
				{
					op.DataType = dt;
				}

				// TODO: Hardcode passwords to true for now.
				if ( op.Name == "Password")
				{
					op.Encrypted = true;
					op.EncryptedSpecified = true;
					op.DataType = OptionDataTypeEnum.String;
					op.DataTypeSpecified = true;
				}

				op.DisplayText = option.DisplayText;
				op.Text = new[] { string.Empty };

                string primaryKey = option.GetAttribute("IsPrimaryKey");
                if (!string.IsNullOrEmpty(primaryKey))
                    op.IsPrimaryKey = Boolean.Parse(primaryKey);

				if (op.DataType == OptionDataTypeEnum.KeyValueRange)
				{
					OptionMapper.SetValueRange(subCategory, ogi, op, true);
				}
				IOption opt = OptionMapper.CreateShellOption(subCategory, op, option.DefaultValue);
				ogi.SubOptions.Add(opt);
                opt.Parent = ogi;

			}
			subCategory.Options.Add(ogi);
		}