Ejemplo n.º 1
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;
		}
Ejemplo n.º 2
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};
				}
			}
		}
Ejemplo n.º 3
0
        private static bool TestSharePointConnect(OptionGroupInstance ogi)
        {
            try
            {
                IWSDocumentProvider10 dp10 = GetDocProvider(SharePointProgId);
                if (dp10 != null)
                {
                    IServiceInfo serviceinfo = dp10 as IServiceInfo;
                    if (serviceinfo != null && !string.IsNullOrEmpty(SharePointServiceId))
                    {
                        serviceinfo.ServiceID = SharePointServiceId;
                    }
                    else
                    {
                        Logger.LogInfo("IServiceInfo is not implemented by this DocProvider or ServiceId is null");
                    }
                    string server = (from o in ogi.SubOptions
                                     where o.Name == "ServerName"
                                     select o.StringValue).FirstOrDefault();
                    if (!string.IsNullOrEmpty(server))
                    {
                        // The TestConnection method cannot handle
                        // having a slash at the end of the url.
                        server = server.TrimEnd('/');

                        return dp10.TestConnection(server, "", "", false);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
            }
            return false;
        }
Ejemplo n.º 4
0
        private static bool TestInterwovenConnect(OptionGroupInstance ogi)
        {
            try
            {
                IWSDocumentProvider10 dp10 = GetDocProvider(InterwovenDPProgId);
                if (dp10 != null)
                {
                    string server = (from o in ogi.SubOptions
                                     where o.Name == "ServerName"
                                     select o.StringValue).FirstOrDefault();
                    string user = (from o in ogi.SubOptions
                                   where o.Name == "UserID"
                                   select o.StringValue).FirstOrDefault();
                    string pass = (from o in ogi.SubOptions
                                   where o.Name == "Password"
                                   select o.StringValue).FirstOrDefault();
                    var boolOpt = (from o in ogi.SubOptions
                                   where o.Name == "TrustedLogin"
                                   select o).FirstOrDefault() as BoolOption;
                    bool bTrustedLogin = boolOpt.Value;
                    return dp10.TestConnection(server, user, pass, bTrustedLogin);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
            }

            return false;
        }
Ejemplo n.º 5
0
 public static bool TestConnection(OptionGroupInstance ogi)
 {
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         switch (ogi.SubCategory.Name)
         {
             case "iManage":
                 return TestInterwovenConnect(ogi);
             case "SharePoint":
                 return TestSharePointConnect(ogi);
             default:
                 // do nothing
                 return false;
         }
     }
     finally
     {
         Mouse.OverrideCursor = Cursors.Arrow;
     }
 }
Ejemplo n.º 6
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);
		}
Ejemplo n.º 7
0
 internal void SortBy(OptionGroupInstance InstanceTemplate)
 {
     SubOptions.Sort(item => InstanceTemplate.SubOptions.FindIndex(opt => opt.Name == item.Name));
 }