/// <summary> /// Generates the correct bindingFlag necessary for a late binding call /// given an <see cref="EOperationType"/> type. /// </summary> /// <param name="type"> /// <see cref="EOperationType"/> type /// </param> /// <returns> /// Correct binding flags for that type call, added to /// BindingFlags.Public | BindingFlags.Static flags /// </returns> internal static BindingFlags ComputeBindingFlags(EOperationType type) { switch (type) { case EOperationType.Method: return(BindingFlags.InvokeMethod); case EOperationType.PropertyGet: return(BindingFlags.GetProperty); case EOperationType.PropertySet: return(BindingFlags.SetProperty); case EOperationType.FieldSet: return(BindingFlags.SetField); case EOperationType.FieldGet: return(BindingFlags.GetField); case EOperationType.IndexGet: return(BindingFlags.InvokeMethod); case EOperationType.IndexSet: return(BindingFlags.InvokeMethod); } return(BindingFlags.Default); }
public SentryOperator(string username, string password, string sentryLoc, EOperationType operation, MainForm mainForm) { _username = username; _password = password; _sentryLoc = sentryLoc; _operation = operation; _mainForm = mainForm; }
private void OpenSelectorDialog(EOperationType operationType) { var control = new SellMateCoupleSelector { OperationType = operationType, Symbol = SelectedUnLSymbol }; var form = control.ShowControl(ParentForm, true); form.TopMost = true; }
public RequestData(SerializationInfo info, StreamingContext context) { RequestId = (int)info.GetValue("RequestId", typeof(int)); ViewId = (int)info.GetValue("ViewId", typeof(int)); ClientId = (string)info.GetValue("ClientId", typeof(string)); ClientURL = (string)info.GetValue("ClientURL", typeof(string)); TupleData = (DIDATuple)info.GetValue("TupleData", typeof(DIDATuple)); Operation = (EOperationType)info.GetValue("Operation", typeof(EOperationType)); }
public RequestData(int requestId, int viewId, string clientId, string clientUrl, DIDATuple tuple, EOperationType operationType) { RequestId = requestId; ViewId = viewId; ClientId = clientId; ClientURL = clientUrl; TupleData = tuple; Operation = operationType; }
public void ConsumeRequest(DIDATuple tuple, EXuLiskovOperation operation) { Utils.Print(" [*] Recieved new request...", verbose: Verbose); EOperationType requestOperation = GetPrimitiveOperationType(operation); RequestData requestData = new RequestData(++requestCounter, backgroundClientView.ViewId, ClientId, $"tcp://localhost:{ClientPort}", tuple, requestOperation); XuLiskovRequest request = new XuLiskovRequest(requestData, operation); ExecuteConsumption(request, operation); }
/// <summary> /// Calls an operation of specifyed name, with arguments. /// Operation in this context is any method or property in /// an object /// </summary> /// <param name="instanceObject"> /// Instance object which recieves the operation call. /// </param> /// <param name="operationName">Name of operation to be called</param> /// <param name="args">Args for this operation call. Must be passed as an array of /// objects, or null if the method doesn't need arguments</param> /// <param name="retVal">Object containing the operation return value, or null if /// method returns nothing. /// The object must be casted by the user to the correct type</param> /// <param name="operationType">Type of the operation.</param> /// <returns> /// Bool if call was succesfull, false if some error ocurred. /// </returns> /// <exception cref="ArgumentException"> /// Throwed if any argument is incorrect /// </exception> /// <exception cref="Exception"> /// Throwed if the call fails /// </exception> internal static bool CallOperation( object instanceObject, string operationName, object[] args, out object retVal, EOperationType operationType) { if (instanceObject == null) { throw new Exception(ErrorStrings.LATEBINDING_OBJECT_NOT_SET); } //Must assign this retVal = null; //Bad method name if (operationName == string.Empty) { throw new ArgumentException(ErrorStrings.LATEBINDING_EMPTY_CALL_STRING); } BindingFlags bFlags = ComputeBindingFlags(operationType); //Do call try { //Do late binding call retVal = instanceObject.GetType().InvokeMember(operationName, bFlags, null, instanceObject, args); } catch (Exception e) { if (e.InnerException != null && e.InnerException is COMException) { throw new OperationCallFailedException( ErrorStrings.LATEBINDING_CALL_FAILED + " " + e.Message, Marshal.GetExceptionForHR((e.InnerException as COMException).ErrorCode)); } throw new OperationCallFailedException(ErrorStrings.LATEBINDING_CALL_FAILED + " " + e.Message, e); } //All OK return(true); }
/// <summary> /// Calls an operation of specifyed name, with arguments. /// Operation in this context is any method or property in /// an object /// </summary> /// <param name="instanceObject"> /// Instance object which recieves the operation call. /// </param> /// <param name="operationName"> /// Name of operation to be called</param> /// <param name="args"> /// Args for this operation call. Must be passed as an array of /// objects, or null if the method doesn't need arguments /// </param> /// <param name="retVal"> /// Object containing the operation return value, or null if /// method returns nothing. /// The object must be casted by the user to the correct type /// </param> /// <param name="refParams"> /// Indicates if any of the arguments must be passed by reference /// </param> /// <param name="type"> /// Value from <see cref="EOperationType"/> representing /// the type of call we are making /// </param> /// <returns> /// Bool if call was succesfull, false if some error ocurred. /// </returns> /// <exception cref="ArgumentException"> /// Throwed if any argument is incorrect /// </exception> /// <exception cref="Exception"> /// Throwed if the call fails /// </exception> internal static bool CallOperation( object instanceObject, string operationName, object[] args, out object retVal, ParameterModifier refParams, EOperationType type) { //Error check if (instanceObject == null) { throw new NullReferenceException("Instance object has not been properly initialized."); } //Must make an assignation 'cause retVal is marked with 'out' retVal = null; StackFrame sf = new StackFrame(true); //Do late call try { retVal = instanceObject.GetType().InvokeMember(operationName, ComputeBindingFlags(type), null, instanceObject, args, new ParameterModifier[] { refParams }, null, null); } catch (Exception e) { if (e.InnerException != null && e.InnerException is COMException) { throw new Exception( ErrorStrings.LATEBINDING_CALL_FAILED + " " + e.Message, Marshal.GetExceptionForHR((e.InnerException as COMException).ErrorCode)); } throw new Exception(ErrorStrings.LATEBINDING_CALL_FAILED + " " + e.Message, e); } //All OK return(true); }
private void RepeatOperation(EOperationType operationType, XuLiskovRequest request, string reason = "reason not specified") { if (operationType == EOperationType.Write) { Utils.Print($" >> Retrying <WRITE> operation, {reason}..."); Write(request); } else if (operationType == EOperationType.Read) { Utils.Print($" >> Retrying <READ> operation, {reason}..."); Read(request); } else { Utils.Print($" >> Retrying <TAKE> operation, {reason}..."); EXuLiskovOperation concreteOperation = request.Operation; Take(request, concreteOperation); } }
private void CallServers(DIDATuple tuple, EOperationType requestOperation) { Utils.Print("[*] Requesting servers...", verbose: Verbose); RequestData requestData = new RequestData(++requestCounter, backgroundClientView.ViewId, ClientId, $"tcp://localhost:{ClientPort}", tuple, requestOperation); List <ServerData> replicasList = backgroundClientView.ReplicasList; allResponsesEvent.Reset(); int replicasCount = replicasList.Count; var tasks = new Task <ReplyData> [replicasCount]; for (int i = 0; i < replicasCount; i++) { ServerData serverData = replicasList[i]; tasks[i] = Task.Run(() => ExecuteRemoteOperation(serverData, requestData)); } Task.WaitAny(tasks); HandleResponses(requestData); }
public RecordNotFoundException(EOperationType operationType, string source, string searchField, string searchParameter) { SearchParameter = String.Format("Field: {0}: {1}", searchField, searchParameter); Operation = operationType; ObjectName = source; }
/// <summary> /// Creates an instance of RecordNotFoundException. /// </summary> /// <param name="operationType">What type of operation was in progress when this exception was raised.</param> /// <param name="source">The object or table that was being accessed when the exception occurred.</param> /// <param name="id">The Id of the record that was being worked with.</param> public RecordNotFoundException(EOperationType operationType, string source, string id) { SearchParameter = "ID: " + id; Operation = operationType; ObjectName = source; }
/// <summary> /// 列表 /// </summary> /// <param name="dp"></param> /// <returns></returns> public DataTable GetList(int logUserId, string logUserName, DateTime startDate, DateTime endDate, EOperationType operationType, string moduleName, string account, int pageIndex, int pageSize, out int count) { count = 0; DateTime tmpStartDate = ConvertHelper.ObjectToDateTime(startDate.ToShortDateString() + " 00:00:00"); DateTime tmpEndDate = ConvertHelper.ObjectToDateTime(endDate.AddDays(1).ToShortDateString() + " 00:00:00"); Expression <Func <SysLog, bool> > condition = t => t.CreateDate >= tmpStartDate && t.CreateDate <= endDate; if (!string.IsNullOrEmpty(moduleName)) { condition.And(t => t.BusinessName.Contains(moduleName)); } if (operationType != EOperationType.全部) { condition.And(t => t.OperationType == operationType.GetHashCode()); } if (!string.IsNullOrEmpty(account)) { condition.And(t => t.CreateUserName.Contains(account)); } try { #region 系统日志 SysLog sysLogModel = new SysLog(); sysLogModel.TableName = "SysLog"; sysLogModel.BusinessName = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName); sysLogModel.CreateUserId = logUserId; sysLogModel.CreateUserName = logUserName; sysLogModel.OperationType = EOperationType.访问.GetHashCode(); this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null); #endregion var list = dal.GetList(pageIndex, pageSize, out count, condition, t => t.CreateDate, false).Cast <SysLog>().ToList(); return(ConvertHelper.ToDataTable <SysLog>(list)); } catch (Exception ex) { this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message); } return(null); }