// Use this for initialization void Start() { if (Button == null) { Debug.LogError("Button label not found!"); } if (ListValues == null || ListValues.Length < 2) { Debug.LogError("List Values needs a least 2 items"); } bgSprite = Button.GetComponentInChildren <UISprite>(); if (bgSprite == null) { Debug.LogError("Sprite not found in button"); } string currentItem = (string)Commands.Instance.Command(command.ToString(), ""); for (int i = 0; i < ListValues.Length; i++) { if (ListValues[i].ItemValue.ToUpper() == currentItem.ToUpper()) { currentIndex = i; bgSprite.spriteName = ListValues[i].SpriteValue; } } if (currentIndex == -1) { Debug.Log(currentItem + " not found on list!"); } }
public static object GetValue(Guid WatchedGuid, CommandType type) { //await Task.Factory.StartNew(() => WaitForValue(WatchedGuid)); Console.WriteLine("GetValue:Awaiting -> " + type.ToString()); maxtries = 0; while (!SyncReturns.ContainsKey(WatchedGuid) && maxtries < RTC_NetCore.DefaultMaxRetries) { maxtries++; //WaitMiliseconds(2); if (maxtries % 100 == 0) { RTC_Core.SendCommandToBizhawk(new RTC_Command(CommandType.BOOP)); System.Windows.Forms.Application.DoEvents(); } Thread.Sleep(2); } if (maxtries >= RTC_NetCore.DefaultMaxRetries) { //MessageBox.Show("An inter-thread synchronous method has timed before a response arrived. Aborting current procedure."); return(null); } object ret = SyncReturns[WatchedGuid]; SyncReturns.Remove(WatchedGuid); Console.WriteLine("GetValue:Returned -> " + type.ToString()); return(ret); }
// Use this for initialization private void Start() { if (ButtonLabel == null) { Debug.LogError("Button label not found!"); } if (ListValues == null || ListValues.Length < 2) { Debug.LogError("List Values needs a least 2 items"); } string currentItem = (string)Commands.Instance.Command(command.ToString(), ""); ButtonLabel.text = currentItem; for (int i = 0; i < ListValues.Length; i++) { if (ListValues[i].ToUpper() == currentItem.ToUpper()) { currentIndex = i; } } if (currentIndex == -1) { Debug.Log(currentItem + " not found on list!"); } }
/// <summary> /// Method used by validation of params /// </summary> /// <param name="storedProcedureOrQuery"></param> /// <param name="type"></param> /// <param name="parameters"></param> /// <param name="connStr"></param> /// <param name="transaction"></param> private static void ParamsAreValid(string storedProcedureOrQuery, CommandType type, List <SqlParameter> parameters, string connStr, SqlTransaction transaction) { if (string.IsNullOrEmpty(storedProcedureOrQuery) && type.ToString() == "StoredProcedure") { throw new DataAccessException(ErrorsAndExceptionsCatalog._602_Code, ErrorsAndExceptionsCatalog._602_StoredProdecureNotFound); } //else if (!storedProcedureOrQuery.StartsWith("G") && type.ToString() == "StoredProcedure")// que no contenga una sentencia // throw new DataAccessException(ErrorsAndExceptionsCatalog._601_Code, ErrorsAndExceptionsCatalog._601_InvalidStoredProcedure); if (string.IsNullOrEmpty(storedProcedureOrQuery) && type.ToString() == "Text") { throw new DataAccessException(ErrorsAndExceptionsCatalog._604_Code, ErrorsAndExceptionsCatalog._604_QueryNotFound); } else if (!storedProcedureOrQuery.Contains("S") && type.ToString() == "Text") { throw new DataAccessException(ErrorsAndExceptionsCatalog._603_Code, ErrorsAndExceptionsCatalog._603_InvalidQuery); } if (type.ToString().ToLower() != "text" && type.ToString().ToLower() != "storedprocedure") { throw new DataAccessException(ErrorsAndExceptionsCatalog._605_Code, ErrorsAndExceptionsCatalog._605_InvalidCommandType); } //if (parameters.Count == 0) // throw new DataAccessException(ErrorsAndExceptionsCatalog._614_Code, ErrorsAndExceptionsCatalog._614_ParametersNotFound); if (string.IsNullOrEmpty(connStr)) { throw new DataAccessException(ErrorsAndExceptionsCatalog._607_Code, ErrorsAndExceptionsCatalog._607_ConnectionStringNotFound); } else if (!connStr.StartsWith("d")) // deberia ser que empiece con otra que no sea 'd' { throw new DataAccessException(ErrorsAndExceptionsCatalog._606_Code, ErrorsAndExceptionsCatalog._606__InvalidConnectionString); } }
private static string[] ProcessParametersInput() { CheckLastCommandAndExitApp(); List <string> parameters = new List <string>(); Console.WriteLine($"For Resource {resType.ToString()} and Command {cmdType.ToString()} "); switch (cmdType) { case CommandType.DELETE: // Delete using "DELETE /trustFrameworkPolicies/{id}" case CommandType.GET: case CommandType.BACKUPKEYSETS: case CommandType.GETACTIVEKEY: case CommandType.GENERATEKEY: // Get a specific policy using "GET /trustFrameworkPolicies/{id}" Console.WriteLine($"For Command: {cmdType.ToString()} Enter Id of {resType.ToString()} "); if (cmdType == CommandType.GENERATEKEY) { Console.WriteLine("optionally, type test, if you want to simply try this out"); } break; case CommandType.CREATE: // Create a policy using "POST /trustFrameworkPolicies" with XML in the body Console.WriteLine($"For Command: {cmdType.ToString()} specify path of {resType.ToString()} "); break; case CommandType.UPDATE: case CommandType.UPLOADCERTIFICATE: case CommandType.UPLOADPKCS: case CommandType.UPLOADSECRET: // Update using "PUT /trustFrameworkPolicies/{id}" with XML in the body Console.WriteLine($"For Command: {cmdType.ToString()} (space separated) specify Id and path of {resType.ToString()} "); if (resType != ResourceType.POLICIES) { Console.WriteLine("optionally, type test for both, if you want to simply try this out"); } break; } Console.Write(":> "); var pars = Console.ReadLine(); if (string.IsNullOrWhiteSpace(pars)) { ProcessParametersInput(); } var parsArray = Regex.Split(pars, "\\s(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"); parameters = new List <string>(parsArray); if ((cmdType == CommandType.UPDATE && parameters.Count != 2) || parameters.Any(string.Empty.Contains)) { ProcessParametersInput(); } return(parameters.ToArray()); }
public override string ToString() { if (Quantity == 1) { return(Type.ToString()); } return($"{Type.ToString()}{Quantity.ToString()}"); }
/// <summary> /// This method will create a location in your locations database /// (which will save to your isxeq2locations.xml file) creating a label for you. /// Please understand that this only works well for stationary actors. /// </summary> /// <param name="action">add or delete</param> /// <param name="notes">notes</param> /// <returns>call success</returns> public bool Location(CommandType action, string notes = null) { switch (action) { case CommandType.Add: return(notes == null?this.ExecuteMethod("Location", action.ToString()) : this.ExecuteMethod("Location", action.ToString(), notes)); case CommandType.Delete: return(ExecuteMethod("Location", action.ToString())); default: return(false); } }
/// <summary> /// This method will compare the command type and append unidnetified words to the respective text file /// </summary> /// <param name="commandType">identified command type</param> public static void AddUnidentifiedWordsToCommandText(CommandType commandType) { try { var testFiles = FileManager.GetTestFiles(); var textFile = ""; // get the text file by first removing the file extension, and it's checking whether it's ending // with the provided command type foreach ( var testFile in testFiles.Where( testFile => testFile.Remove(testFile.IndexOf(VbwFileManager.FileExtension(), StringComparison.Ordinal)) .EndsWith(commandType.ToString()))) { // if so, set that particular testFile as the file name textFile = testFile; } // assign the unidentified words to the test file DataManager.AppendToFile(textFile, UnIdentifiedWords); } catch (Exception ex) { Log.ErrorLog(ex); throw; } }
static internal ArgumentOutOfRangeException NotSupportedCommandType(CommandType value) { #if DEBUG switch(value) { case CommandType.Text: case CommandType.StoredProcedure: Debug.Assert(false, "valid CommandType " + value.ToString()); break; case CommandType.TableDirect: break; default: Debug.Assert(false, "invalid CommandType " + value.ToString()); break; } #endif return ODBC.NotSupportedEnumerationValue(typeof(CommandType), (int)value); }
/// <summary> /// This method will compare the command type and append unidnetified words to the respective text file /// </summary> /// <param name="commandType">identified command type</param> public static void AddUnidentifiedWordsToCommandText(CommandType commandType) { try { var testFiles = FileManager.GetTestFiles(); var textFile = ""; // get the text file by first removing the file extension, and it's checking whether it's ending // with the provided command type foreach ( var testFile in testFiles.Where( testFile => testFile.Remove(testFile.IndexOf(VbwFileManager.FileExtension(), StringComparison.Ordinal)) .EndsWith(commandType.ToString()))) { // if so, set that particular testFile as the file name textFile = testFile; } // assign the unidentified words to the test file DataManager.AppendToFile(textFile, UnIdentifiedWords); } catch (Exception ex) { Log.ErrorLog(ex); throw; } }
public static string TypeToString(CommandType type) { switch (type) { case CommandType.None: return("None"); case CommandType.Group: return("Group"); case CommandType.UIMove: return("Move"); case CommandType.UIDelete: return("Delete"); case CommandType.UIRename: return("Rename"); case CommandType.IOMove: return("Move"); case CommandType.IODelete: return("Delete"); case CommandType.IORename: return("Rename"); default: return(type.ToString()); } }
public override string ToString() { return(string.Format("{0} {1} {2}", CommandType.ToString(), Position != null ? Position.ToString() : string.Empty, !IsExecutable ? "[ignored]" : string.Empty)); }
private object ExecuteByScalarMain( CommandType type, string sqlOrSpName, params DbParameter[] parameters) { LastException = null; LastDataResult = new DataResult() { TransactionID = TransactionID, ExecuteMethod = "DataApi.ExecuteByScalarMain", CommandType = type, Command = sqlOrSpName, Parameters = new List <DbParameter>(parameters), }; var log = LogRecord .Create() .SetTransactionID(this.TransactionID); try { using (var command = Connection.CreateCommand()) { command.CommandType = type; command.CommandText = sqlOrSpName; if (null != parameters) { foreach (var parameter in parameters) { if (null == parameter) { continue; } command.Parameters.Add(parameter); } } OpenConnection(); var value = command.ExecuteScalar(); LastDataResult.ScalarValue = value; return(value); } } catch (Exception ex) { LastDataResult.Success = false; LastDataResult.Exception = ex; LastException = ex; log.Add(ex); throw; } finally { log .Add("CommandType", type.ToString()) .Add("sqlOrSpName", sqlOrSpName) .AddRange(ToAnys(parameters)); if (null == LastException) { log.Debug(); } else { log.Error(); } } }
internal static InvalidOperationException DeriveParametersNotSupported(Type type, CommandType commandType) { var args = new[] {type.ToString(), commandType.ToString()}; return new InvalidOperationException( GetExceptionMessage( "{0} DeriveParameters only supports CommandType.StoredProcedure, not CommandType.{1}.", args)); }
public XmlNode exportXMLnode() { XmlDocument xmlDoc = new XmlDocument(); StringWriter stringWriter = new StringWriter(); XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter); XmlNode rootNode = null; if (isNodeComment) { rootNode = xmlDoc.CreateComment(comment); xmlDoc.AppendChild(rootNode); return(rootNode); } rootNode = xmlDoc.CreateElement(dimnType.ToString()); xmlDoc.AppendChild(rootNode); if (slaveType == SlaveTypes.IEC61850Server) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } XmlAttribute attr2 = xmlDoc.CreateAttribute("ReportingIndex"); attr2.Value = iec61850reportingindex.ToString(); rootNode.Attributes.Append(attr2); XmlAttribute attrDataType = xmlDoc.CreateAttribute("DataType"); attrDataType.Value = DataType.ToString(); rootNode.Attributes.Append(attrDataType); XmlAttribute attrCommandType = xmlDoc.CreateAttribute("CommandType"); attrCommandType.Value = CommandType.ToString(); rootNode.Attributes.Append(attrCommandType); XmlAttribute attrDeadband = xmlDoc.CreateAttribute("BitPos"); attrDeadband.Value = BitPos.ToString(); rootNode.Attributes.Append(attrDeadband); XmlAttribute attrMultiplier = xmlDoc.CreateAttribute("Complement"); attrMultiplier.Value = Complement.ToString(); rootNode.Attributes.Append(attrMultiplier); XmlAttribute attrConstant = xmlDoc.CreateAttribute("Description"); attrConstant.Value = Description.ToString(); rootNode.Attributes.Append(attrConstant); } if ((slaveType == SlaveTypes.IEC101SLAVE) || (slaveType == SlaveTypes.IEC104) || (slaveType == SlaveTypes.MODBUSSLAVE) || (slaveType == SlaveTypes.UNKNOWN)) { foreach (string attr in arrAttributes) { XmlAttribute attrName = xmlDoc.CreateAttribute(attr); attrName.Value = (string)this.GetType().GetProperty(attr).GetValue(this); rootNode.Attributes.Append(attrName); } } return(rootNode); }
public string ToStringRegister() { if (CommandType == CommandTypes.PLACE) { return(ToString()); } return($"{CommandType.ToString()}"); }
public ICommand <PersonViewModel> Build(PersonViewModel viewModel, CommandType commandType) { if (commandType == CommandType.Update) { return(new UpdatePersonCommand(_personService, _mapper.Map(viewModel))); } throw new ArgumentException("No command for " + commandType.ToString(), "commandType"); }
private void SendCommandWithConfirmation(CommandType command) { if (MessageBox.Show(Application.Current.MainWindow, "Are you sure?", command.ToString(), MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { SendCommand(command); MessageBox.Show("Executed " + command, "Server command", MessageBoxButton.OK); } }
/*internal void SendCommand(int agentId, CommandType commandType) * { * SendCommand(agentId, commandType.ToString(), string.Empty); * }*/ internal void SendCommand(int agentId, CommandType commandType, string parameter) { if (string.IsNullOrWhiteSpace(parameter)) { throw new EngineApiException("Paremeter paremeter cannot be null, empty, or whitespace."); } SendCommand(agentId, commandType.ToString(), parameter); }
internal static InvalidOperationException DeriveParametersNotSupported(Type type, CommandType commandType) { var args = new[] { type.ToString(), commandType.ToString() }; return (new InvalidOperationException( GetExceptionMessage( "{0} DeriveParameters only supports CommandType.StoredProcedure, not CommandType.{1}.", args))); }
public static void SendCommand(CommandType command, string[] args) { if (!PipeClient.IsConnected()) return; List<string> argsToSend = new List<string> { command.ToString() }; argsToSend.AddRange(args); PipeClient.SendMessage(string.Join(MessageSeparator.ToString(), argsToSend)); }
private string GetArgs(StateArgs x, CommandType commandType) { string server = String.IsNullOrWhiteSpace(x.Server) ? _server : x.Server; string ret = String.IsNullOrWhiteSpace(server) ? "" : "//" + server + " "; ret += $"{(commandType == CommandType.State ? "query" : commandType.ToString().ToLower())} {x.Service}"; return(ret); }
public IEnumerable <ICommand> Create(CommandType commandType) { // Services will returned in the order they were registered in the Startup. var commands = _serviceProvider.GetServices <ICommand>(); commands = commandType == CommandType.All ? commands : commands.Where(x => x.GetType().Name.Equals(commandType.ToString())); return(commands); }
internal void print() { Console.WriteLine("Command: " + CommandType.ToString()); Console.WriteLine("Length: " + Length); Console.WriteLine("Errorcode: " + ErrorCode); for (int i = 0; i < Length; i++) { Console.WriteLine("Reply[" + i + "]: " + dataArray[i].ToString("X")); } }
public string Test2(CommandType cmdType) { string msg = "CommandType:" + cmdType.ToString(); IContextProperty prop = System.Runtime.Remoting.Contexts.Context.DefaultContext.GetProperty("UserData") as IContextProperty; if (null != prop) msg += prop.ToString(); msg += "线程ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId + " "; Log.Dac(msg); return "收到" + msg; }
public EventPayloadIndentifier(byte[] payload, int commitSequence, DataProviderCommandSource dataProvider, CommandType commandType, Type type) { Payload = payload; CommitSequence = commitSequence; DataProvider = dataProvider.ToString(); DataProviderId = (int) dataProvider; CommandType = commandType.ToString(); CommandTypeId = (int) commandType; Type = type; }
public void WrapAndPublish(ICommand command, CommandType commandType) { var message = new BusMessage { CommandType = commandType.ToString(), MessageId = command.CommandId, BodyJson = JsonConvert.SerializeObject(command, new IsoDateTimeConverter()), SendDateTime = "" //use default }; Publish(message); }
public IReferenceSetCommand GetReferenceSetCommand(CommandType commandType, UserContext userContext, ResourceProperty property, EntityMetadata entityMetadata, string membershipId, ResourceType resourceType) { Envelope<PSRunspace, UserContext> envelope = this.runspaceStore.Borrow(userContext, membershipId); PSReferenceSetCmdletInfo item = null; try { item = ((PSEntityMetadata)entityMetadata).CmdletsForReferenceSets[property.Name].Cmdlets[commandType]; } catch (KeyNotFoundException keyNotFoundException) { Tracer tracer = new Tracer(); tracer.DebugMessage(string.Concat("GetCommand cannot find commandType: ", commandType.ToString())); object[] fullName = new object[3]; fullName[0] = property.ResourceType.FullName; fullName[1] = property.Name; fullName[2] = commandType.ToString(); string str = string.Format(CultureInfo.CurrentCulture, Resources.PropertyDoesNotHaveCommand, fullName); throw new InvalidOperationException(str); } return new PSReferenceCommand(envelope, resourceType, item); }
public void AddCmdlet(CommandType commandType, string cmdletName) { try { this.Cmdlets.Add(commandType, new PSCmdletInfo(cmdletName)); } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; object[] str = new object[1]; str[0] = commandType.ToString(); string str1 = string.Format(CultureInfo.CurrentCulture, Resources.DuplicateCommandInEntityMetadata, str); throw new InvalidSchemaException(str1, argumentException); } }
public ICommand GetCommand(CommandType commandType, UserContext userContext, ResourceType entityType, EntityMetadata entityMetadata, string membershipId) { Envelope<PSRunspace, UserContext> envelope = this.runspaceStore.Borrow(userContext, membershipId); PSEntityMetadata pSEntityMetadatum = entityMetadata as PSEntityMetadata; object[] assemblyQualifiedName = new object[3]; assemblyQualifiedName[0] = "entityMetadata"; assemblyQualifiedName[1] = entityMetadata.GetType().AssemblyQualifiedName; assemblyQualifiedName[2] = typeof(PSEntityMetadata).AssemblyQualifiedName; ExceptionHelpers.ThrowArgumentExceptionIf("entityMetadata", pSEntityMetadatum == null, Resources.InvalidArgClrType, assemblyQualifiedName); object[] name = new object[2]; name[0] = entityType.Name; name[1] = commandType.ToString(); ExceptionHelpers.ThrowArgumentExceptionIf("entityMetadata", !pSEntityMetadatum.Cmdlets.ContainsKey(commandType), Resources.EntityDoesNotHaveCommand, name); return new PSCommand(envelope, entityType, pSEntityMetadatum.Cmdlets[commandType], commandType); }
// // Constructs a string representation of a command without the \r\n // public static string GetStringCommand(CommandType commandType, string key, long size, long ttl) { string result = commandType.ToString() + " " + key; if (commandType == CommandType.SET || commandType == CommandType.VALUE) { result += " " + size.ToString() ; } if (commandType == CommandType.SET) { result += " " + ttl.ToString(); } return result; }
public static string ControlAppPool(string appPoolName, CommandType command, string username, string pwd) { string appPoolPath = Constants.AddressHeader + Constants.AppPools + "/" + appPoolName; try { using (DirectoryEntry appPoolEntry = username == null ? new DirectoryEntry(appPoolPath) : new DirectoryEntry(appPoolPath, username, pwd, AuthenticationTypes.Secure)) { appPoolEntry.Invoke(command.ToString(), null); appPoolEntry.Close(); return Constants.Success; } } catch(Exception e) { return e.Message; } }
public static string TypeToString(CommandType type) { switch (type) { case CommandType.None: return "None"; case CommandType.Group: return "Group"; case CommandType.UIMove: return "Move"; case CommandType.UIDelete: return "Delete"; case CommandType.UIRename: return "Rename"; case CommandType.IOMove: return "Move"; case CommandType.IODelete: return "Delete"; case CommandType.IORename: return "Rename"; default: return type.ToString(); } }
/// <summary> /// 通过事务执行非查询命令 /// </summary> /// <param name="Trans">事务对象</param> /// <param name="CommandType">命令类型</param> /// <param name="CommandTimeout">命令超时时间</param> /// <param name="SqlText">sql命令</param> /// <param name="SqlParms">sql命令参数</param> /// <returns>返回影响的行数</returns> private static int ExecuteNonQuery(SqlTransaction Trans, CommandType CommandType, int CommandTimeout, string SqlText, params SqlParameter[] SqlParms) { SqlCommand dc = new SqlCommand(); try { PrepareCommand(dc, Trans.Connection, CommandType, CommandTimeout, Trans, SqlText, SqlParms); //执行命令 int result = dc.ExecuteNonQuery(); return result; } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.Append(ex.ToString()); //sb.Append("\r\n"); //sb.Append("ConnectionString: "); //sb.Append(Trans.Connection.ConnectionString); sb.Append("\r\n"); sb.Append("CommandType: "); sb.Append(CommandType.ToString()); sb.Append("\r\n"); sb.Append("CommandTimeout: "); sb.Append(dc.CommandTimeout.ToString()); sb.Append("\r\n"); sb.Append("CommandText: "); sb.Append(dc.CommandText); sb.Append("\r\n"); if (SqlParms != null && SqlParms.Length > 0) { sb.Append("SqlParameters: "); sb.Append("\r\n"); foreach (SqlParameter parm in SqlParms) { sb.Append(parm.ParameterName); sb.Append("="); sb.Append(Convert.ToString(parm.Value)); sb.Append("\r\n"); } sb.Append("\r\n"); } //throw new DBException(sb.ToString()); throw new Exception("系统提示错误:" + ex.Message); } }
public Zoom setCommandType(CommandType cmdType) { comboBox_cmd.Text = cmdType.ToString(); return this; }
/// <summary> /// Executes the scalar. /// </summary> /// <param name="commandType">Type of the command.</param> /// <param name="commandText">The command text.</param> /// <returns></returns> public override object ExecuteScalar(CommandType commandType, string commandText) { WsProxy.AdventureWorksServices proxy = new WsProxy.AdventureWorksServices(); proxy.Url = this.url; return proxy.ExecuteScalar((WsProxy.CommandType)Enum.Parse(typeof(WsProxy.CommandType), commandType.ToString(), false), commandText); }
/// <summary> /// Alias of SecurityGroupSetPermission(String, String, int) /// </summary> /// <param name="groupName">The name of the group to modify the permission of</param> /// <param name="permissionName">The name of the permission to set the authority of</param> /// <param name="authority">The level of authority to set for this permission</param> /// <returns>The built command to dispatch</returns> public static ICommand SecurityGroupSetPermission(String groupName, CommandType permissionName, int authority) { return CommandBuilder.SecurityGroupSetPermission(groupName, permissionName.ToString(), authority); }
/// <summary> /// Alias of SecurityGroupSetPermission(String, String) /// </summary> /// <returns>The built command to dispatch</returns> public static ICommand SecurityQueryPermission(CommandType permissionName, String accountName) { return CommandBuilder.SecurityQueryPermission(permissionName.ToString(), accountName); }
internal static Exception CheckPowershellForException(string cmdletName, CommandType commandType, System.Management.Automation.PowerShell powerShell) { Exception streamException = PSCommand.CheckInvocationStateInfoForException(powerShell.InvocationStateInfo); if (streamException == null) { streamException = PSCommand.GetStreamException(cmdletName, powerShell.Streams); } string commandText = powerShell.Commands.Commands[0].CommandText; if (streamException != null) { if (!(streamException.GetType() == typeof(ItemNotFoundException)) || commandType != CommandType.Read && commandType != CommandType.Delete && commandType != CommandType.Update) { streamException = new CommandInvocationFailedException(commandText, streamException); } else { if (commandType == CommandType.Read || commandType == CommandType.Delete) { string[] str = new string[7]; str[0] = "Cmdlet "; str[1] = cmdletName; str[2] = " generated ItemNotFoundException exception. Command string was "; str[3] = commandText; str[4] = ". But this is a "; str[5] = commandType.ToString(); str[6] = "operation, so suppressing that message"; TraceHelper.Current.DebugMessage(string.Concat(str)); streamException = null; } else { string[] strArrays = new string[5]; strArrays[0] = "Cmdlet "; strArrays[1] = cmdletName; strArrays[2] = " generated ItemNotFoundException exception. Command string was "; strArrays[3] = commandText; strArrays[4] = ". But the operation is Update, so throwing DataServiceException with 404"; TraceHelper.Current.DebugMessage(string.Concat(strArrays)); streamException = new DataServiceException(0x194, null, Resources.ResourceNotFoundException, null, streamException); } } } return streamException; }
internal static CodeStatement SetCommandTypeStatement(CodeExpression commandExpression, CommandType commandType) { return CodeGenHelper.Assign(CodeGenHelper.Property(commandExpression, "CommandType"), CodeGenHelper.Field(CodeGenHelper.GlobalTypeExpr(typeof(CommandType)), commandType.ToString())); }
/// <summary> /// Alias of SecurityGroupSetPermission(String, String, String) /// </summary> /// <returns>The built command to dispatch</returns> public static ICommand SecurityQueryPermission(CommandType permissionName, String protocolName, String playerUid) { return CommandBuilder.SecurityQueryPermission(permissionName.ToString(), protocolName, playerUid); }
/// <summary> /// This method will create a location in your locations database /// (which will save to your isxeq2locations.xml file) creating a label for you. /// Please understand that this only works well for stationary actors. /// </summary> /// <param name="action">add or delete</param> /// <param name="notes">notes</param> /// <returns>call success</returns> public bool Location(CommandType action, string notes = null) { switch (action) { case CommandType.Add: return notes == null ? this.ExecuteMethod("Location", action.ToString()) : this.ExecuteMethod("Location", action.ToString(), notes); case CommandType.Delete: return ExecuteMethod("Location", action.ToString()); default: return false; } }
/// <summary> /// 执行查询命令,返回DataTable /// </summary> /// <param name="ConnectionString">连接字符串</param> /// <param name="Database">默认数据库名</param> /// <param name="CommandType">命令类型</param> /// <param name="CommandTimeout">命令超时时间</param> /// <param name="SqlText">sql命令</param> /// <param name="SqlParms">sql命令参数</param> /// <returns></returns> private static DataTable ExecuteQueryDT(string ConnectionString, CommandType CommandType, int CommandTimeout, string SqlText, params SqlParameter[] SqlParms) { SqlCommand dc = new SqlCommand(); using (SqlConnection conn = new SqlConnection(ConnectionString)) { try { PrepareCommand(dc, conn, CommandType, CommandTimeout, null, SqlText, SqlParms); //执行命令 SqlDataAdapter da = new SqlDataAdapter(dc); DataTable dt = new DataTable(); da.Fill(dt); return dt; } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.Append(ex.ToString()); //sb.Append("\r\n"); //sb.Append("ConnectionString: "); //sb.Append(ConnectionString); sb.Append("\r\n"); sb.Append("Database: "); sb.Append(conn.Database); sb.Append("\r\n"); sb.Append("CommandType: "); sb.Append(CommandType.ToString()); sb.Append("\r\n"); sb.Append("CommandTimeout: "); sb.Append(dc.CommandTimeout.ToString()); sb.Append("\r\n"); sb.Append("CommandText: "); sb.Append(dc.CommandText); sb.Append("\r\n"); if (SqlParms != null && SqlParms.Length > 0) { sb.Append("SqlParameters: "); sb.Append("\r\n"); foreach (SqlParameter parm in SqlParms) { sb.Append(parm.ParameterName); sb.Append("="); sb.Append(Convert.ToString(parm.Value)); sb.Append("\r\n"); } sb.Append("\r\n"); } throw new Exception(sb.ToString()); } } }
/// <summary> /// 执行查询命令 /// </summary> /// <param name="ConnectionString">连接字符串</param> /// <param name="Database">默认数据库名</param> /// <param name="CommandType">命令类型</param> /// <param name="CommandTimeout">命令超时时间</param> /// <param name="SqlText">sql命令</param> /// <param name="SqlParms">sql命令参数</param> /// <returns>返回结果集第一行第一列的数据对象</returns> private static object ExecuteScalar(string ConnectionString, CommandType CommandType, int CommandTimeout, string SqlText, params SqlParameter[] SqlParms) { SqlCommand dc = new SqlCommand(); using (SqlConnection conn = new SqlConnection(ConnectionString)) { try { PrepareCommand(dc, conn, CommandType, CommandTimeout, null, SqlText, SqlParms); //执行命令 object result = dc.ExecuteScalar(); return result; } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.Append(ex.ToString()); //sb.Append("\r\n"); //sb.Append("ConnectionString: "); //sb.Append(ConnectionString); sb.Append("\r\n"); sb.Append("Database: "); sb.Append(conn.Database); sb.Append("\r\n"); sb.Append("CommandType: "); sb.Append(CommandType.ToString()); sb.Append("\r\n"); sb.Append("CommandTimeout: "); sb.Append(dc.CommandTimeout.ToString()); sb.Append("\r\n"); sb.Append("CommandText: "); sb.Append(dc.CommandText); sb.Append("\r\n"); if (SqlParms != null && SqlParms.Length > 0) { sb.Append("SqlParameters: "); sb.Append("\r\n"); foreach (SqlParameter parm in SqlParms) { sb.Append(parm.ParameterName); sb.Append("="); sb.Append(Convert.ToString(parm.Value)); sb.Append("\r\n"); } sb.Append("\r\n"); } throw new Exception(sb.ToString()); } } }
public void Send(CommandType command, Dictionary<string, object> operands) { if (operands == null) operands = new Dictionary<string, object>(); Send(new Dictionary<string, object>(operands) {{"cmd", command.ToString()}}); }
/// <summary> /// 执行查询命令,返回DataReader对象 /// </summary> /// <param name="ConnectionString">连接字符串</param> /// <param name="Database">默认数据库名</param> /// <param name="CommandType">命令类型</param> /// <param name="CommandTimeout">命令超时时间</param> /// <param name="SqlText">sql命令</param> /// <param name="SqlParms">sql命令参数</param> /// <returns></returns> private static SqlDataReader ExecuteReader(string ConnectionString, CommandType CommandType, int CommandTimeout, string SqlText, params SqlParameter[] SqlParms) { SqlCommand dc = new SqlCommand(); SqlConnection conn = new SqlConnection(ConnectionString); try { PrepareCommand(dc, conn, CommandType, CommandTimeout, null, SqlText, SqlParms); //执行命令 SqlDataReader dr = dc.ExecuteReader(CommandBehavior.CloseConnection); return dr; } catch (Exception ex) { conn.Close(); StringBuilder sb = new StringBuilder(); sb.Append(ex.ToString()); //sb.Append("\r\n"); //sb.Append("ConnectionString: "); //sb.Append(ConnectionString); sb.Append("\r\n"); sb.Append("Database: "); sb.Append(conn.Database); sb.Append("\r\n"); sb.Append("CommandType: "); sb.Append(CommandType.ToString()); sb.Append("\r\n"); sb.Append("CommandTimeout: "); sb.Append(dc.CommandTimeout.ToString()); sb.Append("\r\n"); sb.Append("CommandText: "); sb.Append(dc.CommandText); sb.Append("\r\n"); if (SqlParms != null && SqlParms.Length > 0) { sb.Append("SqlParameters: "); sb.Append("\r\n"); foreach (SqlParameter parm in SqlParms) { sb.Append(parm.ParameterName); sb.Append("="); sb.Append(Convert.ToString(parm.Value)); sb.Append("\r\n"); } sb.Append("\r\n"); } //throw new DBException("系统提示错误:"+ex.Message+sb.ToString()); throw new Exception("系统提示错误:" + ex.Message); } }
private object ExecuteByScalarMain( CommandType type, string sqlOrSpName, params DbParameter[] parameters) { LastException = null; LastDataResult = new DataResult() { TransactionID = TransactionID, ExecuteMethod = "DataApi.ExecuteByScalarMain", CommandType = type, Command = sqlOrSpName, Parameters = new List<DbParameter>(parameters), }; var log = LogRecord .Create() .SetTransactionID(this.TransactionID); try { using(var command = Connection.CreateCommand()) { command.CommandType = type; command.CommandText = sqlOrSpName; if(null != parameters) { foreach(var parameter in parameters) { if(null == parameter) { continue; } command.Parameters.Add(parameter); } } OpenConnection(); var value = command.ExecuteScalar(); LastDataResult.ScalarValue = value; return value; } } catch(Exception ex) { LastDataResult.Success = false; LastDataResult.Exception = ex; LastException = ex; log.Add(ex); throw; } finally { log .Add("CommandType", type.ToString()) .Add("sqlOrSpName", sqlOrSpName) .AddRange(ToAnys(parameters)); if(null == LastException) { log.Debug(); } else { log.Error(); } } }
public SqlCommand GetDBCommand(SqlConnection sqlcn, String CmdText, CommandType CmdType, CommandBehavior CmdBehavior, SqlParameter[] sqlParam) { SqlCommand sqlcmd = null; try { sqlcmd = new SqlCommand(CmdText, sqlcn); sqlcmd.CommandType = CmdType; sqlcmd.CommandTimeout = GetCommandTimeout(); Utilities.DebugLogging.Log("CONNECTION STRING " + sqlcn.ConnectionString); Utilities.DebugLogging.Log("COMMAND TEXT " + CmdText); Utilities.DebugLogging.Log("COMMAND TYPE " + CmdType.ToString()); if (sqlParam != null) Utilities.DebugLogging.Log("NUMBER OF PARAMS " + sqlParam.Length); AddSQLParameters(sqlcmd, sqlParam); } catch (Exception ex) { Utilities.DebugLogging.Log(ex.Message); Utilities.DebugLogging.Log(ex.StackTrace); } return sqlcmd; }
private DataResult ExecuteMain( CommandType type, string sqlOrSpName, params DbParameter[] parameters) { LastException = null; LastDataResult = null; var result = new DataResult() { TransactionID = TransactionID, ExecuteMethod = "DataApi.ExecuteMain", CommandType = type, Command = sqlOrSpName, Parameters = new List<DbParameter>(parameters), }; var log = LogRecord .Create() .SetTransactionID(this.TransactionID); try { using(var command = Connection.CreateCommand()) { command.CommandType = type; command.CommandText = sqlOrSpName; AddParameters(command, parameters); OpenConnection(); result.AffectedCount = command.ExecuteNonQuery(); return result; } } catch(Exception ex) { LastException = ex; log.Add(ex); result.Success = false; result.Exception = ex; throw; } finally { log .Add("CommandType", type.ToString()) .Add("sqlOrSpName", sqlOrSpName) .AddRange(ToAnys(parameters)) .Add("AffectedCount", result.AffectedCount); if(null == LastException) { log.Debug(); } else { log.Error(); } LastDataResult = result; } }