Example #1
0
 public Processor()
 {
     Operation = EOperation.None;
     Function  = EFunction.None;
     Lop_Res   = new T();
     Rop       = new T();
 }
Example #2
0
 /// <summary>
 /// Contructs a column object with name, operation on column, text align in column & width
 /// </summary>
 /// <param name="ColumnName"></param>
 /// <param name="Operation"></param>
 /// <param name="Align"></param>
 /// <param name="ColumnWidth"></param>
 public Column(string ColumnName, EOperation Operation, EAlign Align, double ColumnWidth)
 {
     _ColumnName  = ColumnName;
     _Operation   = Operation;
     _Align       = Align;
     _ColumnWidth = ColumnWidth;
 }
Example #3
0
 public Processor(T lop_res, T rop)
 {
     Operation = EOperation.None;
     Function  = EFunction.None;
     Lop_Res   = lop_res;
     Rop       = rop;
 }
Example #4
0
        private bool BinaryOp(RhoAstNode node, EOperation op)
        {
            Generate(node.GetChild(0));
            Generate(node.GetChild(1));

            return(Append(op));
        }
Example #5
0
 private void btnCos_Click(object sender, EventArgs e)
 {
     lastClickedOperator = EOperation.cos;
     rechnungGesamt = "Cos(" + rechnungGesamt + ")";
     tBErgebnis.Text = rechnungGesamt;
     calculate();
 }
Example #6
0
    void Update()
    {
        if (m_operationDelay > 0.0f)
        {
            m_operationDelay -= Time.fixedDeltaTime;
            return;
        }

        if (m_operations.Count > 0)
        {
            EOperation op = m_operations.Dequeue();
            m_operationDelay = DEFAULT_OPERATION_DELAY;

            m_onGoingOperations.Add(new WorkThread(op, DEFAULT_OPERATION_TIMEOUT));
        }

        for (int i = m_onGoingOperations.Count - 1; i >= 0; --i)
        {
            WorkThread work = m_onGoingOperations[i];
            if (work.state == EWorkingState.DONE)
            {
                m_onGoingOperations.RemoveAt(i);
            }
            else
            {
                CommitOperation(work);
            }
        }
    }
Example #7
0
 public void Operate(EOperation op, bool isOneAtATime = true)
 {
     if (!isOneAtATime || !IsWorking(op))
     {
         m_operations.Enqueue(op);
     }
 }
Example #8
0
        private void deleteLessons_Click(object sender, RoutedEventArgs e)
        {
            selectLessonsControl.FillDeleteLessons(uploadedLessons);
            selectLessonsControl.Visibility = Visibility.Visible;

            currentOperation = EOperation.deleteLessons;
        }
Example #9
0
        private void updateLessons_Click(object sender, RoutedEventArgs e)
        {
            selectLessonsControl.FillPutLessons(localLessons, uploadedLessons);
            selectLessonsControl.Visibility = Visibility.Visible;

            currentOperation = EOperation.putLessons;
        }
Example #10
0
        /// <summary>
        /// The purpose of this handler is to make the authorization check before any controller action, possibly
        /// using authorization filter in the pipeline and put before the controller's action declaration.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="requirement"></param>
        /// <returns></returns>
        protected override async Task HandleRequirementAsync(
            AuthorizationHandlerContext context,
            CustomAuthRequirement requirement)
        {
            try {
                //NOTE: Downcasting is required to be able to use "MethodInfo" method.
                var        authorizationFilterContext = (Microsoft.AspNetCore.Mvc.Filters.AuthorizationFilterContext)context.Resource;
                var        controllerActionDescriptor = ((Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor)authorizationFilterContext.ActionDescriptor);
                MethodInfo methodInfo = controllerActionDescriptor.MethodInfo;

                EResourceType resource  = (EResourceType)this.GetCustomAttributeProperty(methodInfo, ResourceVariableName);
                EOperation    operation = (EOperation)this.GetCustomAttributeProperty(methodInfo, OperationVariableName);

                if (operation == EOperation.Invalid || resource == EResourceType.Invalid)
                {
                    throw new UnauthorizedAccessException("Could not find permission or resource.");
                }

                if (authorizationFilterContext.HttpContext == null)
                {
                    throw new UnauthorizedAccessException("HttpContex is null.");
                }

                // The "entityId" holds the Id of the resource for which we are doing the current operation.
                // It is extracted from the request's endpoint path.
                // Basically all entities are attached in the tree to a parent. But if no entity(or parent entity) Id is sent we are
                // passing the Root folder Id. This is valid for objects like Users which are logically attached to the Root.
                object entityId;
                bool   gotEntityId = authorizationFilterContext.RouteData.Values.TryGetValue(AuthConstants.IdNameInActionAttributeRouting, out entityId);

                Guid entityIdAsGuid = Entity.RootId;
                if (gotEntityId)
                {
                    Guid.TryParse((string)entityId, out entityIdAsGuid);
                }

                var user = authorizationFilterContext.HttpContext.User;
                ContextPrincipal principal = new ContextPrincipal(user);

                Role userRole = new Role(); // await permissionsBusinessRepo.GetCurrentRole(principal.UserId, entityIdAsGuid);
                principal.Role = userRole ?? throw new UnauthorizedAccessException("Could not find role.");

                bool canPerformRequiredOperation = true; // permissionsBusinessRepo.CheckPermissionsByActorId(userRole.Id, entityIdAsGuid, resource, operation);

                if (!canPerformRequiredOperation)
                {
                    throw new UnauthorizedAccessException("User does not have this permission.");
                }

                context.Succeed(requirement);
                return;
            }
            catch (UnauthorizedAccessException) {
                context.Fail();
            }
            catch (Exception) {
                context.Fail();
            }
        }
Example #11
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     tBErgebnis.Clear();
     eingegebenZahl = "0";
     lastClickedOperator = EOperation.none;
     gespZahl1 = 0;
     rechnungGesamt = null;
 }
Example #12
0
 public async Task ExecuteOperation(EOperation operation)
 {
     Logger.Log(NLog.LogLevel.Info, string.Format("Executing '{0}' on debugger", Enum.GetName(typeof(EOperation), operation)));
     if (!await this.DebuggerInstance.PerformAsync(operation))
     {
         var reason = this.DebuggerInstance.GetLastError();
         MessageBox.Show(string.Format(Properties.Localization.DebuggerContext_OperationFailed_Body, Enum.GetName(typeof(EOperation), operation), reason), Properties.Localization.DebuggerContext_OperationFailed_Title, MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Example #13
0
        private void SetModulePath(EOperation operation)
        {
            string path = Path.Combine(GetModulePath(Module_CB.Text, operation));

            if (Directory.Exists(path))
            {
                Script_FiB.InitialDirectory = path;
                Path_TB.Text = path;
            }
        }
Example #14
0
 public void OperationSet(int newop)
 {
     try
     {
         Operation = (EOperation)newop;
     }
     catch
     {
         throw new ArgumentException();
     }
 }
Example #15
0
 private void Perform(EOperation op)
 {
     if (_local)
     {
         Perform(() => Exec.Perform(op));
     }
     else
     {
         _peer.Execute(_context.Registry.ToPiScript(op));
     }
 }
Example #16
0
        public void UpdatePage()
        {
            switch (currentOperation)
            {
            case EOperation.postLessons: PostLessons(); break;

            case EOperation.putLessons: PutLessons(); break;

            case EOperation.deleteLessons: DeleteLessons(); break;
            }

            currentOperation = EOperation.undefined;
        }
Example #17
0
        /// <summary>
        /// Constructs a new instance
        /// </summary>
        /// <param name="totalWidth">bit-width of operand</param>
        /// <param name="operation">selected operation</param>
        /// <param name="pipelineDepth">desired pipeline depth (i.e. computation latency)</param>
        public FloatNegAbs(int totalWidth, EOperation operation, int pipelineDepth)
        {
            TotalWidth    = totalWidth;
            Operation     = operation;
            PipelineDepth = pipelineDepth;

            _pipeIn = new SLVSignal(totalWidth);

            if (pipelineDepth > 0)
            {
                _pipeOut = new SLVSignal(totalWidth);
            }

            TASite = new TransactionSite(this);
        }
        private void ConvertOperation(MetaClassBuilder mcls, EOperation eop)
        {
            var mop = _factory.MetaOperation();

            mop.Name = eop.Name.ToPascalCase();
            mcls.Operations.Add(mop);
            _map.Add(eop, mop);
            foreach (var eparam in eop.EParameters)
            {
                var mparam = _factory.MetaParameter();
                mparam.Name = eparam.Name.ToCamelCase();
                mop.Parameters.Add(mparam);
                _map.Add(eparam, mparam);
            }
        }
Example #19
0
    public bool IsWorking(EOperation op)
    {
        if (m_operations.Contains(op))
        {
            return(true);
        }

        foreach (WorkThread work in m_onGoingOperations)
        {
            if (work.op == op)
            {
                return(true);
            }
        }

        return(false);
    }
Example #20
0
        public bool Perform(EOperation op)
        {
            switch (op)
            {
            case EOperation.Continue:
            {
                var node = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
                node.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.ContinueExecution);
                node.GetValue_Object()["data"]    = new asapJson.JsonNode((int)EStepType.Continue);
                this.WriteMessage(node);
                return(true);
            }

            case EOperation.StepInto:
            {
                var node = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
                node.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.ContinueExecution);
                node.GetValue_Object()["data"]    = new asapJson.JsonNode((int)EStepType.StepInto);
                this.WriteMessage(node);
                return(true);
            }

            case EOperation.StepOver:
            {
                var node = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
                node.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.ContinueExecution);
                node.GetValue_Object()["data"]    = new asapJson.JsonNode((int)EStepType.StepOver);
                this.WriteMessage(node);
                return(true);
            }

            case EOperation.StepOut:
            {
                var node = new asapJson.JsonNode(new Dictionary <string, asapJson.JsonNode>());
                node.GetValue_Object()["command"] = new asapJson.JsonNode((int)ESendCommands.ContinueExecution);
                node.GetValue_Object()["data"]    = new asapJson.JsonNode((int)EStepType.StepOut);
                this.WriteMessage(node);
                return(true);
            }

            default:
                this.LastError = "Not Implemented";
                return(false);
            }
        }
Example #21
0
        public static string MakeKeyNames(TableInfo tableInfo, EOperation operation)
        {
            var keys = string.Empty;

            if (tableInfo.Keys != null)
            {
                if (tableInfo.Keys.IsAny())
                {
                    foreach (var item in tableInfo.Keys)
                    {
                        keys += string.Format("model.{0},", item);
                    }

                    keys = keys.Substring(0, keys.Length - 1);
                }
            }
            return(keys);
        }
Example #22
0
        public ActionResult <bool> Post(string name, [FromBody] EOperation operation)
        {
            var parameters = new List <DbParameter> {
                _dataSource.Param("@name", name)
            };
            string location = null;

            using (var reader = _dataSource.ExecuteReader("select location from logs.log_applications where name=@name", parameters))
            {
                if (reader.Read())
                {
                    location = reader["location"] as string;
                }
            }
            if (string.IsNullOrEmpty(location))
            {
                throw new Exception($"Could not find location for application '{name}'.");
            }

            //Change Exception to MyException.
            //Catch all exceptions and log.
            //return is different for MyException vs. generic.
            //Implement snack bar.
            //
            var startInfo = new ProcessStartInfo(location)
            {
                CreateNoWindow = true
            };

            using (var process = System.Diagnostics.Process.Start(startInfo))
            {
                process.StartInfo.UseShellExecute  = false;                //true=No application is registered as handling this file
                process.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(location);
                //process.StartInfo.FileName = System.IO.Path.GetFileName( location ); No such file or directory.
                //process.StartInfo.FileName = "."+location;=No such file or directory.
                process.StartInfo.FileName       = location;          //No such file or directory.
                process.StartInfo.CreateNoWindow = true;
                var result = process.Start();
            }

            // if( process==null )
            //  throw new Exception( $"Could not start '{location}'." );
            return(Ok(true));
        }
Example #23
0
        public static string GetStringOperation(EOperation operation)
        {
            switch (operation)
            {
            case EOperation.Divide:
                return("/");

            case EOperation.Minus:
                return("-");

            case EOperation.Multiply:
                return("*");

            case EOperation.Plus:
                return("+");

            default:
                throw new Exception("");
            }
        }
Example #24
0
        public double CalculateOperations(double number1, EOperation operation, double number2)
        {
            switch (operation)
            {
            case EOperation.Addition:
                return(number1 + number2);

            case EOperation.Subtraction:
                return(number1 - number2);

            case EOperation.Multiplication:
                return(number1 * number2);

            case EOperation.Division:
                return(number1 / number2);

            default:
                return(0);
            }
        }
Example #25
0
        private string[] GetModulePath(string module, EOperation operation)
        {
            string module_dir = string.Empty;
            string finaldir   = operation == EOperation.Installation ? "Install" : "Update";

            switch (module)
            {
            case "moleQule": return(new string[] { Properties.Settings.Default.ROOT_PATH, "moleQule\\moleQule.Library\\SQL\\Updates" });

            case "Hipatia": module_dir = module; break;

            case "Common": module_dir = "moleQule\\moleQule." + module; break;

            default: module_dir = "moleQule." + module; break;
            }

            return(new string[] { Properties.Settings.Default.ROOT_PATH,
                                  module_dir,
                                  "code",
                                  "Library",
                                  "SQL",
                                  finaldir });
        }
Example #26
0
        public bool Perform(EOperation op)
        {
            switch (op)
            {
            case EOperation.Continue:
            case EOperation.StepInto:
            case EOperation.StepOver:
            case EOperation.StepOut:
            {
                var node = new Newtonsoft.Json.Linq.JObject
                {
                    { "command", (int)ESendCommands.BPContinue },
                    { "data", op == EOperation.Continue ? 0 : op == EOperation.StepInto ? 1 : op == EOperation.StepOver ? 2 : 3 }
                };
                this.WriteMessage(node);
                return(true);
            }

            default:
                this.LastError = "Not Implemented";
                return(false);
            }
        }
Example #27
0
        public VectorEquation CalculateVectorsOperations(VectorEquation vector1, EOperation operation, VectorEquation vector2)
        {
            VectorEquation result = new VectorEquation(new Dictionary <string, double>(), 0);

            if (vectorHelper.isEqualVariableVectors(new List <VectorEquation> {
                vector1, vector2
            }))
            {
                List <string> vars = vector1.VectorBody.Keys.ToList();

                foreach (string var in vars)
                {
                    switch (operation)
                    {
                    case EOperation.Addition:
                        result.VectorBody.Add(var, vector1.VectorBody[var] + vector2.VectorBody[var]);
                        break;

                    case EOperation.Subtraction:
                        result.VectorBody.Add(var, vector1.VectorBody[var] - vector2.VectorBody[var]);
                        break;

                    case EOperation.Multiplication:
                        result.VectorBody.Add(var, vector1.VectorBody[var] * vector2.VectorBody[var]);
                        break;

                    case EOperation.Division:
                        result.VectorBody.Add(var, vector1.VectorBody[var] / vector2.VectorBody[var]);
                        break;
                    }
                }

                result.Constant = CalculateOperations(vector1.Constant, operation, vector2.Constant);
            }

            return(result);
        }
        public bool validateEOperation(EOperation obj, DiagnosticChain diagnostics, Dictionary <object, object> context)
        {
            if (!validate_NoCircularContainment(obj, diagnostics, context))
            {
                return(false);
            }
            bool result = validate_EveryMultiplicityConforms(obj, diagnostics, context);

            if (result || diagnostics != null)
            {
                result &= validate_EveryDataValueConforms(obj, diagnostics, context);
            }
            if (result || diagnostics != null)
            {
                result &= validate_EveryReferenceIsContained(obj, diagnostics, context);
            }
            if (result || diagnostics != null)
            {
                result &= validate_EveryBidirectionalReferenceIsPaired(obj, diagnostics, context);
            }
            //if (result || diagnostics != null) result &= validate_EveryProxyResolves(obj, diagnostics, context);
            if (result || diagnostics != null)
            {
                result &= validate_UniqueID(obj, diagnostics, context);
            }
            if (result || diagnostics != null)
            {
                result &= validate_EveryKeyUnique(obj, diagnostics, context);
            }
            if (result || diagnostics != null)
            {
                result &= validate_EveryMapEntryUnique(obj, diagnostics, context);
            }

            return(result);
        }
Example #29
0
 private void btnNr_Click(object sender, EventArgs e)
 {
     Button tempBtn = (Button)sender;
     eingegebenZahl += tempBtn.Text;
     rechnungGesamt += tempBtn.Text;
     tBErgebnis.Text += tempBtn.Text;
     lastClickedOperator = EOperation.none;
     doCalculate = true;
 }
Example #30
0
 public WorkThread(EOperation nop, float ntimeout)
 {
     op      = nop;
     timeout = ntimeout;
     state   = EWorkingState.START;
 }
Example #31
0
	public void Operate(EOperation op, bool isOneAtATime = true)
	{
		if( !isOneAtATime || !IsWorking(op) )
		{
			m_operations.Enqueue(op);
		}
	}
Example #32
0
 public object eInvoke(EOperation operation, List <object> arguments)
 {
     throw new NotImplementedException();
 }
Example #33
0
		public WorkThread(EOperation nop, float ntimeout)
		{
			op = nop;
			timeout = ntimeout;
			state = EWorkingState.START;
		}
Example #34
0
        /// <summary>
        /// Constructs a new instance
        /// </summary>
        /// <param name="totalWidth">bit-width of operand</param>
        /// <param name="operation">selected operation</param>
        /// <param name="pipelineDepth">desired pipeline depth (i.e. computation latency)</param>
        public FloatNegAbs(int totalWidth, EOperation operation, int pipelineDepth)
        {
            TotalWidth = totalWidth;
            Operation = operation;
            PipelineDepth = pipelineDepth;

            _pipeIn = new SLVSignal(totalWidth);

            if (pipelineDepth > 0)
            {
                _pipeOut = new SLVSignal(totalWidth);
            }

            TASite = new TransactionSite(this);
        }
Example #35
0
 private void btnExp_Click(object sender, EventArgs e)
 {
     calculate();
     lastClickedOperator = EOperation.exp;
     rechnungGesamt += "-Exp-";
     tBErgebnis.Text += "-Exp-";
     if (gespZahl1 == 0)
     {
         gespZahl1 = Double.Parse(eingegebenZahl);
     }
     eingegebenZahl = "0";
 }
 public override object eInvoke(EOperation paramEOperation, EList<object> paramEList)
 {
     throw new NotImplementedException();
 }
Example #37
0
        private void setOperator(EOperation operant)
        {
            calculate();
            if (lastClickedOperator != EOperation.none)
            {
                rechnungGesamt = rechnungGesamt.Remove(rechnungGesamt.Length - 1, 1);
                tBErgebnis.Text = tBErgebnis.Text.Remove(tBErgebnis.Text.Length - 1, 1);
                doCalculate = false;
                return;
            }

            lastClickedOperator = operant;

            if (gespZahl1 == 0)
            {
                gespZahl1 = Double.Parse(eingegebenZahl);
            }
            eingegebenZahl = "0";
        }
Example #38
0
	public bool IsWorking(EOperation op)
	{
		if( m_operations.Contains(op) )
		{
			return true;
		}
		
		foreach( WorkThread work in m_onGoingOperations )
		{
			if( work.op == op )
			{
				return true;
			}
		}
		
		return false;
	}
Example #39
0
 /// <summary>
 /// Конструктор 1
 /// </summary>
 /// <param name="operandA">Операнд A</param>
 /// <param name="condition">Условие</param>
 /// <param name="operandB">Операнд B</param>
 public Operation(AData operandA, EOperation condition, AData operandB)
 {
     _operandA  = operandA;
     _operation = condition;
     _operandB  = operandB;
 }
Example #40
0
 private void btnGleich_Click(object sender, EventArgs e)
 {
     calculate();
     lastClickedOperator = EOperation.gleich;
     calculate();
     eingegebenZahl = "0";
 }
Example #41
0
 /// <summary>
 /// Конструктор 2
 /// </summary>
 /// <param name="field">Коле</param>
 /// <param name="condition">Условие</param>
 /// <param name="value">Значение</param>
 public Operation(Expression <Func <T, object> > field, EOperation condition, object value)
     : this(new Column <T>(field), condition, new Value(value))
 {
 }
Example #42
0
        private void calculate()
        {
            if (!doCalculate)
            {
                return;
            }

            if (double.TryParse(eingegebenZahl.ToString(), out result))
            {
                tempInZahl = Double.Parse(eingegebenZahl);

                switch (lastClickedOperator)
                {
                    case EOperation.none:
                        break;
                    case EOperation.plus:
                        gespZahl1 += tempInZahl;
                        break;
                    case EOperation.minus:
                        gespZahl1 -= tempInZahl;
                        break;
                    case EOperation.mal:
                        gespZahl1 *= tempInZahl;
                        break;
                    case EOperation.dividiert:
                        gespZahl1 /= tempInZahl;
                        break;
                    case EOperation.mod:
                        gespZahl1 = gespZahl1 % tempInZahl;
                        break;
                    case EOperation.prozent:
                        gespZahl1 = (gespZahl1 / 100) * tempInZahl;
                        break;
                    case EOperation.bruch:
                        gespZahl1 = 1 / tempInZahl;
                        break;
                    case EOperation.exp:
                        gespZahl1 = gespZahl1 * Math.Pow(10, tempInZahl);
                        break;
                    case EOperation.gleich:
                        tBErgebnis.Text = rechnungGesamt + Environment.NewLine + gespZahl1.ToString();
                        doCalculate = true;
                        lastClickedOperator = EOperation.none;
                        break;
                    case EOperation.log:
                        gespZahl1 = Math.Log10(tempInZahl);
                        tBErgebnis.Text = rechnungGesamt + Environment.NewLine + gespZahl1.ToString();
                        break;
                    case EOperation.sin:
                        gespZahl1 = Math.Sin(tempInZahl);
                        tBErgebnis.Text = rechnungGesamt + Environment.NewLine + gespZahl1.ToString();
                        break;
                    case EOperation.cos:
                        gespZahl1 = Math.Cos(tempInZahl);
                        tBErgebnis.Text = rechnungGesamt + Environment.NewLine + gespZahl1.ToString();
                        break;
                    case EOperation.tan:
                        gespZahl1 = Math.Tan(tempInZahl);
                        tBErgebnis.Text = rechnungGesamt + Environment.NewLine + gespZahl1.ToString();
                        break;
                    default:
                        break;
                }
            }
            else
            {
                MessageBox.Show("Sie haben keine Zahlen eingegeben. Bevor sie einen Rechenoperator wählen, muss sie Zahlen eingeben", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                tBErgebnis.Clear();
                return;
            }
        }