public void SetSource(Type type, string name) { QueryType = type; if (!string.IsNullOrEmpty(name)) { sourceName = name; SourceType = typeRegistry.GetTypeOrNull(sourceName); } else { sourceName = ConfigurationName.Get(type).Fullname; SourceType = type; } }
// Module defining this command // Optional custom code for this activity /// <summary> /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run. /// </summary> /// <param name="context">The NativeActivityContext for the currently running activity.</param> /// <returns>A populated instance of System.Management.Automation.PowerShell</returns> /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks> protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context) { System.Management.Automation.PowerShell invoker = global::System.Management.Automation.PowerShell.Create(); System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName); // Initialize the arguments if (ComputerName.Expression != null) { targetCommand.AddParameter("ComputerName", ComputerName.Get(context)); } if (ApplicationName.Expression != null) { targetCommand.AddParameter("ApplicationName", ApplicationName.Get(context)); } if (ConnectionUri.Expression != null) { targetCommand.AddParameter("ConnectionUri", ConnectionUri.Get(context)); } if (ConfigurationName.Expression != null) { targetCommand.AddParameter("ConfigurationName", ConfigurationName.Get(context)); } if (AllowRedirection.Expression != null) { targetCommand.AddParameter("AllowRedirection", AllowRedirection.Get(context)); } if (Name.Expression != null) { targetCommand.AddParameter("Name", Name.Get(context)); } if (InstanceId.Expression != null) { targetCommand.AddParameter("InstanceId", InstanceId.Get(context)); } if (Credential.Expression != null) { targetCommand.AddParameter("Credential", Credential.Get(context)); } if (Authentication.Expression != null) { targetCommand.AddParameter("Authentication", Authentication.Get(context)); } if (CertificateThumbprint.Expression != null) { targetCommand.AddParameter("CertificateThumbprint", CertificateThumbprint.Get(context)); } if (Port.Expression != null) { targetCommand.AddParameter("Port", Port.Get(context)); } if (UseSSL.Expression != null) { targetCommand.AddParameter("UseSSL", UseSSL.Get(context)); } if (ThrottleLimit.Expression != null) { targetCommand.AddParameter("ThrottleLimit", ThrottleLimit.Get(context)); } if (State.Expression != null) { targetCommand.AddParameter("State", State.Get(context)); } if (SessionOption.Expression != null) { targetCommand.AddParameter("SessionOption", SessionOption.Get(context)); } if (PSSessionId.Expression != null) { targetCommand.AddParameter("Id", PSSessionId.Get(context)); } if (ContainerId.Expression != null) { targetCommand.AddParameter("ContainerId", ContainerId.Get(context)); } if (VMId.Expression != null) { targetCommand.AddParameter("VMId", VMId.Get(context)); } if (VMName.Expression != null) { targetCommand.AddParameter("VMName", VMName.Get(context)); } return(new ActivityImplementationContext() { PowerShellInstance = invoker }); }
public static string Представление(object obj) { //TODO NullabeTypes if (obj == null) { return(""); } var objType = obj.GetType(); var underlyingType = Nullable.GetUnderlyingType(objType); if (underlyingType != null) { return(Представление(GetPropertyValue <object>(objType, "Value", obj))); } var stringObj = obj as string; if (stringObj != null) { return(stringObj); } var typeObj = obj as Type; if (typeObj != null) { return(GetTypePresentation(typeObj)); } if (objType.IsClass) { var configurationName = ConfigurationName.Get(objType); if (configurationName.Scope == ConfigurationScope.Справочники) { return(GetPropertyValue <string>(objType, "Наименование", obj) ?? ""); } if (configurationName.Scope == ConfigurationScope.Документы) { var builder = new StringBuilder(); builder.Append(Synonym.OfClass(obj)); var number = GetPropertyValue <string>(objType, "Номер", obj); if (!string.IsNullOrEmpty(number)) { builder.Append(" "); builder.Append(number); } var date = GetPropertyValue <DateTime?>(objType, "Дата", obj); if (date.HasValue) { builder.Append(" от "); builder.Append(date.Value.ToString("dd.MM.yyyy H:mm:ss")); } return(builder.ToString()); } if (configurationName.Scope == ConfigurationScope.ПланыСчетов) { return(GetPropertyValue <string>(objType, "Код", obj) ?? ""); } } if (objType.IsEnum) { return(Synonym.OfEnumUnsafe(obj)); } if (obj is int) { return(((int)obj).ToString(russianCultureInfo)); } if (obj is long) { return(((long)obj).ToString(russianCultureInfo)); } if (obj is decimal) { return(((decimal)obj).ToString(russianCultureInfo)); } if (obj is bool) { return((bool)obj ? "Да" : "Нет"); } if (obj is DateTime) { return(((DateTime)obj).ToString("dd.MM.yyyy H:mm:ss")); } if (obj is Guid) { return(((Guid)obj).ToString()); } if (obj is byte) { return(((byte)obj).ToString(russianCultureInfo)); } if (obj is sbyte) { return(((sbyte)obj).ToString(russianCultureInfo)); } if (obj is short) { return(((short)obj).ToString(russianCultureInfo)); } if (obj is ushort) { return(((ushort)obj).ToString(russianCultureInfo)); } if (obj is uint) { return(((uint)obj).ToString(russianCultureInfo)); } if (obj is ulong) { return(((ulong)obj).ToString(russianCultureInfo)); } if (obj is float) { return(((float)obj).ToString(russianCultureInfo)); } if (obj is double) { return(((double)obj).ToString(russianCultureInfo)); } const string messageFormat = "can't get ПРЕДСТАВЛЕНИЕ for object [{0}] of type [{1}]"; throw new NotSupportedException(string.Format(messageFormat, obj, objType.FormatName())); }
public BuiltQuery Build() { var resultBuilder = new StringBuilder(); resultBuilder.Append("ВЫБРАТЬ "); var isCount = Count.HasValue && Count.Value; if (isCount) { resultBuilder.Append("КОЛИЧЕСТВО("); } if (Take.HasValue) { resultBuilder.Append("ПЕРВЫЕ "); resultBuilder.Append(Take.Value); resultBuilder.Append(" "); } string selection; if (isCount) { selection = "*"; } else if (projection == null) { selection = ConfigurationName.Get(SourceType).HasReference ? "src.Ссылка" : "*"; } else { selection = projection.GetSelection(); } resultBuilder.Append(selection); if (isCount) { resultBuilder.Append(") КАК src_Count"); } resultBuilder.Append(" ИЗ "); resultBuilder.Append(sourceName); if (TableSectionName != null) { resultBuilder.Append('.'); resultBuilder.Append(TableSectionName); } resultBuilder.Append(" КАК src"); if (whereParts.Count > 0) { resultBuilder.Append(" ГДЕ "); if (whereParts.Count == 1) { resultBuilder.Append(whereParts[0]); } else { resultBuilder.Append("("); resultBuilder.Append(whereParts.JoinStrings(" И ")); resultBuilder.Append(")"); } } if (Orderings != null) { resultBuilder.Append(" УПОРЯДОЧИТЬ ПО "); for (var i = 0; i < Orderings.Length; i++) { if (i != 0) { resultBuilder.Append(','); } var ordering = Orderings[i]; resultBuilder.Append(ordering.Field.Expression); if (!ordering.IsAsc) { resultBuilder.Append(" УБЫВ"); } } } return(new BuiltQuery(SourceType, resultBuilder.ToString(), parameters, projection, isCount)); }