Beispiel #1
0
        private string Match(string atocc)
        {
            var    token       = this.TokenStream.Peek();
            string token_AToCC = token.AToCCFormat();

            if (!this._hitEndOfFile)
            {
                if (token_AToCC != atocc)
                {
                    if (token.Type == TokenType.EndOfStream)
                    {
                        ErrorManager.Add($"Unexpected end of file. Expected {atocc}", token.SourceLocation);
                        this._hitEndOfFile = true;
                    }
                    else
                    {
                        ErrorManager.Add($"Expected {atocc}. Got '{token.TokenContent}'.", token.SourceLocation);
                    }
                }
                else
                {
                    this.TokenStream.NextToken();
                }
            }

            return(token.TokenContent);
        }
        public bool Delete(int contractId)
        {
            ResultManager.IsCorrect = false;

            // validate bayer contract associated
            ContractDistributor item = Repository.ContractsDistributor.Get(contractId);

            if (item.ContractDistributorStatusId == 1 || item.ContractDistributorStatusId == 2)
            {
                ResultManager.Add(ErrorDefault, Trace + "DeleteContractDistributor.### El Convenio con Distribuidor seleccionado no se puede eliminar, su estatus es activo / vencido.");
                return(false);
            }

            // now proceed with the delete operation
            try
            {
                Repository.ContractsDistributor.Remove(contractId);

                Repository.Complete();
                ResultManager.IsCorrect = true;
            }
            catch (Exception ex)
            {
                ErrorManager.Add(Trace + "", ErrorDefault, "Exception while deleting distributor contract ", ex);
                ResultManager.IsCorrect = false;
            }

            return(ResultManager.IsCorrect);
        }
Beispiel #3
0
        private void SkipErrors(string first, string follow, bool hasEpsilonProduction = true)
        {
            Token  token;
            string lookahead;
            bool   errorReported = false;

            do
            {
                token     = this.TokenStream.Peek();
                lookahead = token.AToCCFormat();

                if (token.Type == TokenType.EndOfStream)
                {
                    break;
                }

                if (first.HasToken(lookahead) || (hasEpsilonProduction && follow.HasToken(lookahead)))
                {
                    return;
                }

                if (!errorReported)
                {
                    ErrorManager.Add($"Expected {(first + " " + follow).Trim().Replace(" ", ", ")}. Got '{token.TokenContent}'.", token.SourceLocation);
                    errorReported = true;
                }

                this.TokenStream.NextToken(); // Disregard this current token.
            } while (token.Type != TokenType.EndOfStream);
        }
Beispiel #4
0
        private Token NextTokenFromScanner(Scanner scanner)
        {
            this.RemoveWhitespacePrefixFromScanner(scanner);

            if (scanner.HasNextChar())
            {
                char   symbol    = scanner.NextCharNoEx();
                string content   = String.Empty;
                int    startPos  = scanner.CursorPosition.characterNumber;
                int    startLine = scanner.CursorPosition.lineNumber + 1;

                // ID?
                if (symbol.IsLetter())
                {
                    do
                    {
                        content += symbol;
                        symbol   = scanner.NextCharNoEx();
                    } while (symbol.IsLetterOrDigitOrUnderscore());

                    if (this.OutputToErrorList)
                    {
                        ErrorManager.Add($"Invalid symbol in identifier sequence: '{symbol}'", (startLine, scanner.CursorPosition.characterNumber));
                    }

                    scanner.GoBack();

                    if (Language.Keywords.Contains(content))
                    {
                        return(new Token()
                        {
                            Type = TokenType.Keyword, TokenContent = content, SourceLocation = (startLine, startPos)
                        });
 public override void Visit(ClassDecl classDecl)
 {
     if (classes.ContainsKey(classDecl.ClassName))
     {
         ErrorManager.Add($"Multiple class declaration of class {classDecl.ClassName}.", classDecl.Location);
         return;
     }
     classes.Add(classDecl.ClassName, classDecl);
 }
        public override void Visit(VarDecl varDecl)
        {
            if (varDecl.Type == "float" || varDecl.Type == "int")
            {
                return;
            }

            if (this._globalScope.Get($"{varDecl.Type}-{Classification.Class}") == null)
            {
                ErrorManager.Add($"The type {varDecl.Type} could not be found or does not exist.", varDecl.Location);
            }
        }
 public override void Visit(AssignStat assignStat)
 {
     if (assignStat.ExpressionValue is Node expression)
     {
         if (assignStat.Variable.SemanticalType != expression.SemanticalType)
         {
             ErrorManager.Add($"Could not convert {expression.SemanticalType} to a {assignStat.Variable.SemanticalType}.", assignStat.Location);
         }
         assignStat.SemanticalType = expression.SemanticalType;
     }
     else
     {
         ErrorManager.Add($"Could not establish an expression value.", assignStat.Location);
     }
 }
        public override void Visit(ReturnStat returnStat)
        {
            returnStat.SemanticalType = ((Node)returnStat.ReturnValueExpression).SemanticalType;

            if (this._lastFunctionRequiredReturnType == "__MAIN__")
            {
                ErrorManager.Add("Cannot return in main.", returnStat.Location);
                return;
            }

            if (this._lastFunctionRequiredReturnType != returnStat.SemanticalType)
            {
                ErrorManager.Add($"Must return a value of type {this._lastFunctionRequiredReturnType}. Cannot convert {returnStat.SemanticalType} to it.", returnStat.Location);
            }
        }
 public override void Visit(RelExpr relExpr)
 {
     if (relExpr.RHS is Node rhs)
     {
         if (relExpr.LHS is Node lhs)
         {
             if (lhs.SemanticalType != rhs.SemanticalType)
             {
                 ErrorManager.Add($"Inconsistent types: Cannot perform {lhs.SemanticalType} {relExpr.RelationOperator} {rhs.SemanticalType}", relExpr.Location);
             }
         }
         relExpr.SemanticalType = rhs.SemanticalType;
     }
     else
     {
         ErrorManager.Add("There is no RHS for this relational expression.", relExpr.Location);
     }
 }
 public override void Visit(MultOp multOp)
 {
     if (multOp.RHS is Node rhs)
     {
         if (multOp.LHS is Node lhs)
         {
             if (lhs.SemanticalType != rhs.SemanticalType)
             {
                 ErrorManager.Add($"Inconsistent types: Cannot perform {lhs.SemanticalType} {multOp.Operator} {rhs.SemanticalType}", multOp.Location);
             }
         }
         multOp.SemanticalType = rhs.SemanticalType;
     }
     else
     {
         ErrorManager.Add("There is no RHS for this multiplication operation.", multOp.Location);
     }
 }
Beispiel #11
0
        public bool Delete(int contractId)
        {
            ResultManager.Clear();

            // validate bayer contract associated
            ContractSubdistributor item = Repository.ContractsSubdistributor.Get(contractId);

            if (item.ContractSubdistributorStatusId == 1 || item.ContractSubdistributorStatusId == 2)
            {
                if (!CurrentUser.IsInRole(UserRole.AppAdmin))
                {
                    ResultManager.Add("Este convenio no puede ser eliminado en el estatus actual, solo puede eliminarse por el administrado", Trace + "Delete.111 Error por Regla de negocio: no se puede eliminar un convenio con estatus activo/vencido, a menos que sea por el administrador.");
                    return(false);
                }
            }

            // now proceed with the delete operation
            try
            {
                IEnumerable <int> purchaseIds = Repository.DistributorPurchasesXContractSubdistributors.GetAll().Where(x => x.ContractSubdistributorId == contractId).Select(y => y.Id);
                foreach (int purchaseId in purchaseIds)
                {
                    Repository.DistributorPurchasesXContractSubdistributors.Remove(purchaseId);
                }

                Repository.SubdistributorDiscountCoupons.Remove(item.SubdistributorDiscountCoupon.Id);
                Repository.SubdistributorPromotionCoupons.Remove(item.SubdistributorPromotionCoupon.Id);

                Repository.ContractsSubdistributor.Remove(contractId);

                Repository.Complete();
                ResultManager.IsCorrect = true;
            }
            catch (Exception ex)
            {
                ErrorManager.Add(Trace + "", ErrorDefault, "Exception while deleting subdistributor contract ", ex);
                ResultManager.IsCorrect = false;
            }

            return(ResultManager.IsCorrect);
        }
Beispiel #12
0
        /*deprecated: param userId only instead of all user object, so we can reuse method
         * public bool PerformPasswordReset(User model, string userPassword)
         * {
         *  Model.User newUser;
         *  try
         *  {
         *      //retrieve user from DB
         *      newUser = Repository.Users.Get(model.Id);
         *
         *      if (newUser.Cat_UserStatus.IdB != "created" && newUser.Cat_UserStatus.IdB != "active")
         *      {
         *          ErrorManager.Add(Trace + "CreateUser.311", ErrorDefault, "The user '" + model.NickName + "' was attempted to perform password reset while being in an unexpected status. Status expected 'created' or 'active', but current user status in DB is '" + newUser.Cat_UserStatus.IdB + "'");
         *          return false;
         *      }
         *
         *      //update password info
         *      string auxSalt;
         *      newUser.Hash = PSD.Security.Identity.HashPassword(userPassword, out auxSalt);
         *      newUser.Salt = auxSalt;
         *      newUser.FailedLoginAttempts = 0;
         *      newUser.LastLoginDate = PSD.Common.Dates.Today;
         *      newUser.LastPasswordChangeDate = PSD.Common.Dates.Today;
         *      newUser.LoginToken = null;
         *      newUser.LoginTokenGeneratedDate = null;
         *
         *      //update DB
         *      Repository.Complete();
         *  }
         *  catch (Exception ex)
         *  {
         *      ErrorManager.Add(Trace + "CreateUser.531", ErrorDefault, "Exception thrown when trying to create user '" + model.NickName + "'", detailException: ex);
         *      return false;
         *  }
         *
         *  User = newUser;
         *  return true;
         * }
         */
        public bool UpdateUserDetails(BayerEmployee model, string userRoleIdB)
        {
            if (model == null)
            {
                return(false);
            }

            if (IsMailAddressCurrentlyUsed(model.EMail, CurrentUser.Id))
            {
                ResultManager.Add(ErrorDefault, Trace + "La direccion de email '" + model.EMail + "' actualmente esta asignada a otro usuario, por favor ingresa una diferente.");
                return(false);
            }

            BayerEmployee auxEmployee = null;

            try
            {
                auxEmployee = Repository.BayerEmployees.Get(model.Id);
                //User.Cat_UserStatusId = model.Cat_UserStatusId;
                auxEmployee.User.NickName = model.EMail;
                auxEmployee.EMail         = model.EMail;
                auxEmployee.Name          = model.Name;
                auxEmployee.LastNameF     = model.LastNameF;
                auxEmployee.LastNameM     = model.LastNameM;
                auxEmployee.PhoneNumber   = model.PhoneNumber;


                Repository.Complete();
                ResultManager.Add("Perfil actualizado", "");
                ResultManager.IsCorrect = true;
                return(true);
            }
            catch (Exception ex)
            {
                ErrorManager.Add("", ErrorDefault, "", ex);
                ResultManager.Add(ErrorDefault, "");
                ResultManager.IsCorrect = false;
            }

            return(false);
        }
        private bool SendUserInvitationEmail(User user)
        {
            string tokenUrl = Configurations.HostUrl + "Account/LoginByToken?token=" + user.LoginToken;
            Dictionary <string, string> emailParams = new Dictionary <string, string>()
            {
                { "userNickName", user.NickName }, { "message", "Hemos creado una cuenta para usted, de click en la liga de abajo para activar su cuenta:" }, { "tokenUrl", tokenUrl }
            };
            string messageBody = "<h2>Información de su nueva cuenta</h2><h3>Bayer - Portal de Servicios al Distribuidor</h3><p>@userNickName</p><p>@message</p><p><a href='@tokenUrl'>Activar su cuenta</a></p>";
            string subject     = "Informacion de su nueva cuenta - Bayer Portal de Servicios al Distribuidor";

            PSD.Util.Mailer mailer = new Util.Mailer("*****@*****.**", "Roomie@01", "www.roomie-it.org", 25, false);
            if (mailer.SendSingle(user.NickName, subject, messageBody, emailParams))
            {
                return(true);
            }
            else
            {
                ErrorManager.Add(Trace + "SendInvitationEmail.911", "Error while sending email to employee '" + user.NickName + "'", mailer.ResultDetails[0]);
                return(false);
            }
        }
Beispiel #14
0
        private bool SendContactEmail(string contactName, string contactMail, string contactMessage)
        {
            Dictionary <string, string> emailParams = new Dictionary <string, string>()
            {
                { "contactName", contactName },
                { "contactMail", contactMail },
                { "contactMessage", contactMessage }
            };
            string subject     = Configurations.LayoutEmailContactPage_Subject;
            string messageBody = Configurations.LayoutEmailContactPage_Body;
            string mailAddress = Configurations.MailServerContactPageMailTo;

            if (SendEmail(mailAddress, subject, messageBody, emailParams))
            {
                return(true);
            }
            else
            {
                ErrorManager.Add(Trace + "SendContactEmail.911", "Error while sending contact email to '" + mailAddress + "' from '" + contactMail + "' ");
                return(false);
            }
        }
Beispiel #15
0
        public bool ValidateLoginToken(string token)
        {
            if (string.IsNullOrWhiteSpace(token))
            {
                ErrorManager.Add(Trace + "LoginByToken.111", "No se recibió ningún token", "Token was null or empty");
                return(false);
            }

            token = token.Trim();
            try
            {
                user = Repository.Users.GetByToken(token);
            }
            catch (Exception ex)
            {
                ErrorManager.Add(Trace + "LoginByToken.311", "Error al validar token", "Error while trying to retrieve user for token '" + token + "' from database.", ex);
                return(false);
            }

            if (user == null)
            {
                ErrorManager.Add(Trace + "LoginByToken.351", "Token inválido", "No user found for token '" + token + "' in database.");
                return(false);
            }

            //validations
            if (user.LoginTokenGeneratedDate == null)
            {
                ErrorManager.Add(Trace + "LoginByToken.511", "Token inválido", "Token '" + token + "' is incorrectly setup in database, it does not have a value set for 'LoginTokenGeneratedDate'.");
                return(false);
            }
            if (user.LoginTokenGeneratedDate.Value.AddDays(15) <= PSD.Common.Dates.Today)
            {
                ErrorManager.Add(Trace + "LoginByToken.531", "Token inválido", "Token '" + token + "' it's 'LoginTokenGeneratedDate' was '" + Common.Dates.ToString(user.LoginTokenGeneratedDate.Value, Common.Enums.DateFormat.IngDate) + "'.");
                return(false);
            }

            return(true);
        }
Beispiel #16
0
        public async Task <CommandResult> Publish(IDateProvider dateProvider, IHtmlProcessor processor)
        {
            var errors = new ErrorManager()
                         .Required(Title, "Title")
                         .Required(Tags, "Tags")
                         .Required(Summary, "Summary")
                         .Required(Content, "Content")
                         .IfTrue(Language == Language.Farsi && string.IsNullOrEmpty(EnglishUrl), "EnglishUrl is required for Farsi posts")
                         .Add(ValidateCodeBlocks());

            if (errors.Dirty)
            {
                return(errors.ToResult());
            }

            if (!_publishDate.HasValue)
            {
                _publishDate = dateProvider.Now;
            }

            try
            {
                Post = new Post(Id,
                                Title,
                                _publishDate.Value,
                                Language,
                                Summary,
                                Tags,
                                GetImageDirectoryName(),
                                await processor.ProcessAsync(Content));
            }
            catch (ServiceDependencyException exc)
            {
                errors.Add(exc.Message);
            }

            return(errors.ToResult());
        }
        private bool SendEmailContractApprovedDistributor(string toName, string toEMail, int contractId, string contractIdB)
        {
            string urlContractDetails = Configurations.HostUrl + "Contracts/MyDistributorContracts/Detail/" + contractId;
            Dictionary <string, string> emailParams = new Dictionary <string, string>()
            {
                { "userName", toName },
                { "message", "Hemos actualizado los detalles de su convenio, de click en la liga de abajo para ver el convenio:" },
                { "urlContractDetails ", urlContractDetails },
                { "contractIdB", contractIdB }
            };
            string messageBody = "<h2>Actualización de convenio: @contractIdB</h2><h3>Mi Portal Bayer</h3><p>@userName</p><p>@message</p><p><a href='@urlContractDetails '>Ver convenio</a></p>";
            string subject     = "Actualización de convenio: @contractIdB - Mi Portal Bayer";

            if (SendEmail(toEMail, subject, messageBody, emailParams))
            {
                return(true);
            }
            else
            {
                ErrorManager.Add(Trace + "SendEmailContractApprovedDistributor.911", "Error while sending email to '" + toEMail + "'");
                return(false);
            }
        }
        private bool SendEmailToDistributorRequestApproval(string toName, string toEMail, int contractId, string contractIdB)
        {
            string urlContractDetails = Configurations.HostUrl + "Contracts/MyDistributorContracts/Detail/" + contractId;
            Dictionary <string, string> emailParams = new Dictionary <string, string>()
            {
                { "userName", toName },
                { "message", "Por favor verifique la información y apruebe el convenio @contractIdB dando click en la liga de abajo:" },
                { "urlContractDetails ", urlContractDetails },
                { "contractIdB", contractIdB }
            };
            string subject     = Configurations.LayoutEmailContractDistributor_SendTodistributor_Subject;
            string messageBody = Configurations.LayoutEmailContractDistributor_SendTodistributor_Body;

            if (SendEmail(toEMail, subject, messageBody, emailParams))
            {
                return(true);
            }
            else
            {
                ErrorManager.Add(Trace + "SendEmailToDistributorRequestApproval.911", "Error while sending email to '" + toEMail + "'");
                return(false);
            }
        }
Beispiel #19
0
        public void Generate(Program ast)
        {
            if (ast == null)
            {
                ErrorManager.Add("Code Generation: Could not find the main program.", (0, 0));
                return;
            }

            this.Table = ast.Table.Copy();

            // Generate the code.
            var memVisitor = new MemorySizeVisitor(this.Table);

            ast.Accept(memVisitor);

            var stackVisitor = new StackIncreaserVisitor(this.Table);

            ast.Accept(stackVisitor);

            var moonVisitor = new MoonVisitor(this.Table);

            ast.Accept(moonVisitor);
        }
        public bool SendUserInvitationEmail(int userId)
        {
            User   user  = null;
            string token = PSD.Common.Random.Token(20);

            user = Repository.Users.Get(userId);
            if (user == null)
            {
                ErrorManager.Add(Trace + "SendInvitationEmail.211", "Error while retrieving user from database", "No user was found with Id '" + userId + "'");
                return(false);
            }
            try
            {
                user.LoginToken = token;
                user.LoginTokenGeneratedDate = PSD.Common.Dates.Today;
                Repository.Complete();
            }
            catch (Exception ex)
            {
                ErrorManager.Add(Trace + "SendInvitationEmail.311", "Exception was thrown while retrieving user's token from database", "User Id '" + user.Id + "'", ex);
            }

            return(SendUserInvitationEmail(user));
        }
        public override void Visit(FuncDef funcDef)
        {
            // We don't need to handle free-functions.
            if (funcDef.ScopeResolution == null)
            {
                return;
            }

            // Make sure the class exists.
            var classScope = this.GlobalScope.Get($"{funcDef.ScopeResolution.ID}-{Classification.Class}");

            if (classScope != null)
            {
                // Make sure the function exists.
                var function = classScope.Link.Get($"{funcDef.FunctionName}-{Classification.Function}");
                if (function != null)
                {
                    // Get the return type and the parameters.
                    var types      = function.Type.Split('-');
                    var returnType = types[0];
                    var parameters = types[1].Length == 0 ? new string[0] : types[1].Split(',');

                    // Make sure the return type matches with the number of parameters
                    if (funcDef.ReturnType == returnType)
                    {
                        if (funcDef.Parameters.Count == parameters.Count())
                        {
                            bool valid = true;

                            // Make sure each parameter matches.
                            for (int i = 0; i < funcDef.Parameters.Count; i++)
                            {
                                string expectedType = parameters[i];
                                string receivedType = funcDef.Parameters[i].Type + "[]".Repeat(funcDef.Parameters[i].Dimensions.Count);

                                if (expectedType == string.Empty)
                                {
                                    expectedType = "no parameters";
                                }
                                if (receivedType == string.Empty)
                                {
                                    receivedType = "no parameters";
                                }

                                // Apply pseudo type checking.
                                if (expectedType != receivedType)
                                {
                                    ErrorManager.Add($"Invalid parameter type: Expected {expectedType}, got {receivedType}", funcDef.Parameters[i].Location);
                                    valid = false;
                                    break;
                                }
                            }

                            if (valid)
                            {
                                function.Link = funcDef.Entry.Link;
                            }
                        }
                        else
                        {
                            ErrorManager.Add($"Invalid amount of parameters. Expected {parameters.Length}. Got {funcDef.Parameters.Count}.", funcDef.Location);
                        }
                    }
                    else
                    {
                        ErrorManager.Add($"Invalid return type: Expected {returnType}, got {funcDef.ReturnType}", funcDef.Location);
                    }
                }
                else
                {
                    ErrorManager.Add($"The class {funcDef.ScopeResolution.ID} does not define a function {funcDef.FunctionName}.", funcDef.Location);
                }
            }
            else
            {
                ErrorManager.Add($"The class {funcDef.ScopeResolution.ID} could not be resolved to a type.", funcDef.ScopeResolution.Location);
            }
        }
        public bool UpdateBayerEmployee(BayerEmployee model, List <int?> selectedZones)
        {
            if (model == null)
            {
                return(false);
            }

            //business validations
            //*is email already used
            if (IsMailAddressCurrentlyUsed(model.EMail, model.Id))
            {
                ResultManager.Add(ErrorDefault, Trace + "La direccion de email '" + model.EMail + "' actualmente esta asignada a otro usuario, por favor ingresa una diferente.");
                return(false);
            }
            //*is zone(s) already assigned
            foreach (int item in selectedZones)
            {
                MunicipalitiesXEmployee auxMunicipality = null;
                switch (model.User.RolesXUser.First().Cat_UserRoleId)
                {
                case 3:
                    auxMunicipality = Repository.BayerEmployees.GRVAssignedToZone(item);
                    if (auxMunicipality != null && auxMunicipality.BayerEmployeeId != model.Id)
                    {
                        ResultManager.Add("La zona '" + auxMunicipality.Municipality.Zone.Name + "' ya esta asignada al GRV '" + auxMunicipality.BayerEmployee.NameDisplay + "'", Trace + "CreateBayerEmployee.311 Zona en conflicto 'id:" + item + "'");
                        return(false);
                    }
                    break;

                case 5:
                    auxMunicipality = Repository.BayerEmployees.RTVAssignedToZone(item);
                    if (auxMunicipality != null && auxMunicipality.BayerEmployeeId != model.Id)
                    {
                        ResultManager.Add("La zona '" + auxMunicipality.Municipality.Zone.Name + "' ya esta asignada al RTV '" + auxMunicipality.BayerEmployee.NameDisplay + "'", Trace + "CreateBayerEmployee.321 Zona en conflicto 'id:" + item + "'");
                        return(false);
                    }
                    break;

                default:
                    ResultManager.Add(ErrorDefault, Trace + "CreateBayerEmployee.391 rol de usuario no esperado'" + model.User.RolesXUser.First().Cat_UserRoleId + "'");
                    return(false);
                }
            }

            BayerEmployee auxEmployee = null;

            try
            {
                auxEmployee = Repository.BayerEmployees.Get(model.Id);
                //User.Cat_UserStatusId = model.Cat_UserStatusId;
                auxEmployee.IdB           = model.IdB;
                auxEmployee.User.NickName = model.EMail;
                auxEmployee.EMail         = model.EMail;
                auxEmployee.Name          = model.Name;
                auxEmployee.LastNameF     = model.LastNameF;
                auxEmployee.LastNameM     = model.LastNameM;
                auxEmployee.PhoneNumber   = model.PhoneNumber;

                List <MunicipalitiesXEmployee> auxMXE = new List <MunicipalitiesXEmployee>();
                bool auxExist;

                //update selected zones
                if (selectedZones == null) //is there a zone selected on this last change?
                {                          //none selected, remove all
                    foreach (MunicipalitiesXEmployee item in auxEmployee.MunicipalitiesXEmployee)
                    {
                        //auxEmployee.MunicipalitiesXEmployee.Remove(item);
                        Repository.MunicipalitiesXEmployee.Remove(item.Id);
                    }
                }
                else
                {//some selected, update
                    //identify records to delete (not selected anymore)
                    foreach (MunicipalitiesXEmployee item in auxEmployee.MunicipalitiesXEmployee)
                    {
                        auxExist = false;
                        foreach (int itemSelectedZoneId in selectedZones)
                        {
                            if (item.Municipality.Cat_ZoneId == itemSelectedZoneId)
                            {
                                auxExist = true;
                                break;
                            }
                        }
                        if (!auxExist)
                        {
                            auxMXE.Add(item);
                        }
                    }
                    //delete records (not selected anymore)
                    foreach (MunicipalitiesXEmployee item in auxMXE)
                    {
                        Repository.MunicipalitiesXEmployee.Remove(item.Id);
                    }
                    auxMXE.Clear();

                    //identify records to add (not yet in db)
                    List <AddressMunicipality> municipalitiesXZone = (List <AddressMunicipality>)Repository.AddressMunicipalities.GetByZoneIds(selectedZones);
                    foreach (AddressMunicipality item in municipalitiesXZone)
                    {
                        auxExist = false;
                        foreach (MunicipalitiesXEmployee itemMXE in auxEmployee.MunicipalitiesXEmployee)
                        {
                            if (item.Id == itemMXE.AddressMunicipalityId)
                            {
                                auxExist = true;
                                break;
                            }
                        }
                        if (!auxExist)
                        {
                            auxMXE.Add(new MunicipalitiesXEmployee()
                            {
                                AddressMunicipalityAddressStateId = item.AddressStateId,
                                AddressMunicipalityId             = item.Id,
                                BayerEmployeeId = auxEmployee.Id
                            });
                        }
                    }
                    //insert records (not yet in db)
                    foreach (MunicipalitiesXEmployee item in auxMXE)
                    {
                        auxEmployee.MunicipalitiesXEmployee.Add(item);
                    }
                    auxMXE.Clear();
                }

                Repository.Complete();
                ResultManager.Add("Perfil actualizado", "");
                ResultManager.IsCorrect = true;
                return(true);
            }
            catch (Exception ex)
            {
                ErrorManager.Add("", ErrorDefault, "", ex);
                ResultManager.Add(ErrorDefault, "");
            }

            return(false);
        }
        public bool CreateEmployee(Model.BayerEmployee model /*, string selectedRoleIdB*/)//Model.Employee employee)
        {
            ResultManager.Clear();
            string token = PSD.Common.Random.Token(20);

            Model.User user = null;

            try
            {
                user = new User();
                user.Cat_UserStatusId        = 4;
                user.Cat_UserStatus          = Repository.UserStatuses.Get(4);///TODO: why do I need this if i already set statusId (doesn't update automatically unless i restart app)
                user.NickName                = model.EMail;
                user.FailedLoginAttempts     = 0;
                user.LoginToken              = token;
                user.LoginTokenGeneratedDate = PSD.Common.Dates.Today;

                Model.RolesXUser rolesXUser = new RolesXUser();
                rolesXUser.UserId         = user.Id;
                rolesXUser.Cat_UserRoleId = model.User.RolesXUser.First().Cat_UserRoleId;//Repository.UserRoles.GetByRoleIdB(selectedRoleIdB).Id;
                //Repository.RolesXUser.Add(rolesXUser);
                user.RolesXUser = new List <RolesXUser>()
                {
                    rolesXUser
                };

                Model.BayerEmployee employee = new BayerEmployee();
                employee.IdB       = model.IdB;
                employee.Name      = string.IsNullOrWhiteSpace(model.Name) ? "" : model.Name;
                employee.LastNameF = string.IsNullOrWhiteSpace(model.LastNameF) ? "" : model.LastNameF;
                employee.LastNameM = string.IsNullOrWhiteSpace(model.LastNameM) ? "" : model.LastNameM;
                employee.EMail     = model.EMail;
                employee.User      = user;

                Model.MunicipalitiesXEmployee        municipalityXEmployee;
                List <Model.MunicipalitiesXEmployee> municipalitiesXEmployee = new List <MunicipalitiesXEmployee>();
                foreach (MunicipalitiesXEmployee item in model.MunicipalitiesXEmployee)
                {
                    municipalityXEmployee = new MunicipalitiesXEmployee();
                    municipalityXEmployee.AddressMunicipalityAddressStateId = item.AddressMunicipalityAddressStateId;
                    municipalityXEmployee.AddressMunicipalityId             = item.AddressMunicipalityId;
                    municipalityXEmployee.BayerEmployeeId = employee.Id;
                    municipalitiesXEmployee.Add(municipalityXEmployee);
                }
                employee.MunicipalitiesXEmployee = municipalitiesXEmployee;

                Repository.BayerEmployees.Add(employee);

                Repository.Complete();
                ResultManager.IsCorrect = true;
            }
            catch (Exception ex)
            {
                ErrorManager.Add(Trace + "", ErrorDefault, "exception while creating employee", ex);
                ResultManager.Add(ErrorDefault, "No se ha creado el nuevo usuario");
                return(false);
            }

            if (SendUserInvitationEmail(user))
            {
                ResultManager.Add("El usuario se ha creado correctamente", "");
            }
            else
            {
                //ResultManager.IsCorrect = false;
                ResultManager.Add("El usuario se ha creado correctamente, sin embargo hubo un problema al enviar la invitación de correo", "Puede reenviar la invitación desde la página de detalle de usuario");
            }
            return(ResultManager.IsCorrect);
        }
        public override void Visit(Program node)
        {
            // Determines whether or not a class contains full implementation.
            Dictionary <string, object> Done = new Dictionary <string, object>();

            // This is done after we visited all the classes.
            foreach (var classEntry in classes.Values)
            {
                var visiting       = new Stack <ClassDecl>();
                var visited        = new Dictionary <string, object>();
                var implementation = new SymbolTable();
                var focus          = classEntry;

                implementation.AddRange(classEntry.Table.GetAll(), classEntry.Location);

                do
                {
                    visited.Add(focus.ClassName, null);
                    foreach (var parent in focus.InheritingClasses.IDs)
                    {
                        if (Done.ContainsKey(parent))
                        {
                            implementation.AddRange(classes[parent].Table.GetAll(), classEntry.Location, true);
                        }
                        else
                        {
                            if (visited.ContainsKey(parent))
                            {
                                ErrorManager.Add($"Circular dependancy deteced between {focus.ClassName} and {parent}.", focus.Location);
                                visiting.Clear();
                                break;
                            }
                            else
                            {
                                if (classes.ContainsKey(parent))
                                {
                                    implementation.AddRange(classes[parent].Table.GetAll(), classEntry.Location);
                                    visiting.Push(classes[parent]);
                                }
                                else
                                {
                                    ErrorManager.Add($"The class {parent} cannot be found or is not defined.", focus.Location);
                                }
                            }
                        }
                    }

                    if (visiting.Count > 0)
                    {
                        focus = visiting.Pop();
                    }
                    else
                    {
                        focus = null;
                    }
                } while (focus != null);

                Done.Add(classEntry.ClassName, null);
                classEntry.Table = implementation;
            }

            foreach (var classEntry in GlobalScope.GetAll(Classification.Class))
            {
                classEntry.Link = classes[classEntry.ID].Table;
            }
        }
Beispiel #25
0
        public bool ConfirmUserAccount(User model, string userNewPassword, string userNewPasswordConfirm)
        {
            ResultManager.Clear();

            //system validations
            if (model == null)
            {
                ResultManager.Add(ErrorDefault, Trace + "UpdatePassword.111 No se recibio el modelo");
                return(false);
            }
            if (model.Id < 1)
            {
                ResultManager.Add(ErrorDefault, Trace + "UpdatePassword.111 El modelo no contiene un valor Id");
                return(false);
            }
            //business validations
            if (string.IsNullOrWhiteSpace(userNewPassword))
            {
                ResultManager.Add("Se debe indicar una contraseña", Trace + "UpdatePassword.311");
                return(false);
            }
            if (!Identity.IsValidPassWordFormat(Configurations.PasswordValidFormatPattern, userNewPassword))
            {
                ResultManager.Add(Configurations.PasswordInvalidFormatMessage);
                return(false);
            }
            if (!string.Equals(userNewPassword, userNewPasswordConfirm))
            {
                ResultManager.Add("La contraseña y la confirmación de contraseña no coinciden", Trace + "UpdatePassword.321");
                return(false);
            }

            Model.User newUser;
            try
            {
                //retrieve user from DB
                newUser = Repository.Users.Get(model.Id);

                if (newUser.Cat_UserStatus.IdB != "toconfirm")
                {
                    ResultManager.Add(ErrorDefault, Trace + "ConfirmUserAccount.311 The user '" + newUser.NickName + "' was attempted to be confirmed while being in an unexpected status. Status expected 'created', but current user status in DB is '" + newUser.Cat_UserStatus.IdB + "'");
                    ResultManager.IsCorrect = false;
                    return(false);
                }

                //update password info
                string auxSalt;
                newUser.Hash = PSD.Security.Identity.HashPassword(userNewPassword, out auxSalt);
                newUser.Salt = auxSalt;
                newUser.FailedLoginAttempts     = 0;
                newUser.LastLoginDate           = PSD.Common.Dates.Today;
                newUser.LastPasswordChangeDate  = PSD.Common.Dates.Today;
                newUser.LoginToken              = null;
                newUser.LoginTokenGeneratedDate = null;

                //default info

                //updated info
                //newUser.NickName = model.NickName;
                //newUser.Person.EMail = model.NickName;

                //Repository.RolesXUser.IsInRole(newUser.Id, "appadmin"))
                bool userRequiresInitialEdit = true;
                foreach (RolesXUser aUserRole in newUser.RolesXUser)
                {
                    switch (aUserRole.Cat_UserRole.IdB)
                    {
                    case "sysadmin":
                    case "appadmin":
                        userRequiresInitialEdit = false;
                        break;

                    case "employee-manager_view":
                    case "employee-rtv_view":
                    case "employee-manager_operation":
                    case "employee-rtv_operation":
                        break;
                    }
                }
                if (userRequiresInitialEdit)
                {
                    newUser.Cat_UserStatusId = Repository.UserStatuses.Get(5).Id;//user 'confirmed' ///TODO:change to dynamic get by 'IdB'
                }
                else
                {
                    newUser.Cat_UserStatusId = Repository.UserStatuses.Get(1).Id;//user 'active' ///TODO:change to dynamic get by 'IdB'
                }

                //update DB
                Repository.Complete();
                ResultManager.IsCorrect = true;
            }
            catch (Exception ex)
            {
                ErrorManager.Add(Trace + "CreateUser.531", ErrorDefault, "Exception thrown when trying to create user '" + model.NickName + "'", detailException: ex);
                return(false);
            }

            User = newUser;
            return(true);
        }
        public bool DeleteSubdistributor(int subdistributorId)
        {
            ResultManager.IsCorrect = false;

            // validate bayer contract associated
            bool hasBayerContract = Repository.ContractsSubdistributor.GetAll().Any(x => x.SubdistributorId == subdistributorId);

            if (hasBayerContract)
            {
                ResultManager.Add(ErrorDefault, Trace + "DeleteSubdistributor.### El Subdistribuidor seleccionado no se puede eliminar ya que existe un contracto con Bayer existente.");
                return(false);
            }

            // now proceed with the delete operation
            try
            {
                #region Subdistributor Contact Delete

                IEnumerable <int> subdistributorContactIds = Repository.SubdistributorContacts.GetAll().Where(x => x.SubdistributorId == subdistributorId).Select(y => y.Id);
                foreach (int contactId in subdistributorContactIds)
                {
                    Repository.SubdistributorContacts.Remove(contactId);
                }

                #endregion

                #region Subdistributor Crops x Municipality Delete

                IEnumerable <int> subdistributorCropsxMunicipalityIds = Repository.SubdistributorCropsXMunicipality.GetAll().Where(x => x.SubdistributorId == subdistributorId).Select(y => y.Id);
                foreach (int cropxMunicipalityId in subdistributorCropsxMunicipalityIds)
                {
                    Repository.SubdistributorCropsXMunicipality.Remove(cropxMunicipalityId);
                }

                #endregion

                #region Subdistributor Comercial Names Delete

                IEnumerable <int> subdistributorComercialNameIds = Repository.SubdistributorCommercialNames.GetAll().Where(x => x.SubdistributorId == subdistributorId).Select(y => y.Id);
                foreach (int comercialNameId in subdistributorComercialNameIds)
                {
                    Repository.SubdistributorCommercialNames.Remove(comercialNameId);
                }

                #endregion

                #region Distributor entity delete

                // rmeove address directly associated to distributor
                IEnumerable <AddressesXSubdistributor> adressesXSubdistributorList = Repository.AddressesXSubdistributor.GetAll().Where(x => x.SubdistributorId == subdistributorId);

                // address associated via AddressXSubdistributor entity delete
                IEnumerable <int> addressIds = adressesXSubdistributorList.Select(x => x.AddressId);
                foreach (int addressId in addressIds)
                {
                    Repository.Addresses.Remove(addressId);
                }

                IEnumerable <int> addressSubdistibutorIds = adressesXSubdistributorList.Select(x => x.Id);
                foreach (int addressSubdistributorId in addressSubdistibutorIds)
                {
                    Repository.AddressesXSubdistributor.Remove(addressSubdistributorId);
                }
                // address BN associated detete
                Subdistributor item = Repository.Subdistributors.Get(subdistributorId);
                Repository.Addresses.Remove(item.BNAddressId);

                // remove distributor entity itself
                Repository.Subdistributors.Remove(subdistributorId);

                // remove data from Person_DistributorEmployee entity
                IEnumerable <int> personIds = Repository.SubdistributorEmployees.GetAll().Where(x => x.SubdistributorId == subdistributorId).Select(y => y.Id);
                foreach (int personId in personIds)
                {
                    // delete from DistributorEmployees
                    Repository.SubdistributorEmployees.Remove(personId);
                    // delete from Person
                    Repository.Persons.Remove(personId);
                    // delete from User
                    Repository.Users.Remove(personId);
                    // delete from RolesXUser
                    Repository.RolesXUser.Remove(personId);
                }

                #endregion

                Repository.Complete();
                ResultManager.IsCorrect = true;
            }
            catch (Exception ex)
            {
                ErrorManager.Add(Trace + "", ErrorDefault, "Exception while deleting subdistributor", ex);
                ResultManager.IsCorrect = false;
            }

            return(ResultManager.IsCorrect);
        }
Beispiel #27
0
        public bool UpdateBayerEmployee(BayerEmployee model /*, int selectedZone*/)
        {
            if (model == null)
            {
                return(false);
            }

            if (IsMailAddressCurrentlyUsed(model.EMail, CurrentUser.Id))
            {
                ResultManager.Add(ErrorDefault, Trace + "La direccion de email '" + model.EMail + "' actualmente esta asignada a otro usuario, por favor ingresa una diferente.");
                return(false);
            }

            BayerEmployee auxEmployee = null;

            try
            {
                auxEmployee = Repository.BayerEmployees.Get(model.Id);
                auxEmployee.User.NickName = model.EMail;
                auxEmployee.EMail         = model.EMail;
                auxEmployee.Name          = model.Name;
                auxEmployee.LastNameF     = model.LastNameF;
                auxEmployee.LastNameM     = model.LastNameM;
                auxEmployee.PhoneNumber   = model.PhoneNumber;

                //if profile was not completed, complete
                if (auxEmployee.User.Cat_UserStatusId == 5)
                {
                    auxEmployee.User.Cat_UserStatusId = 1;
                }

                /*Deprecated: user won't have ability to change zone on it's own
                 * //update selected zones
                 * List<MunicipalitiesXEmployee> auxMXE = new List<MunicipalitiesXEmployee>();
                 * if (selectedZone == null || selectedZone == -1 || selectedZone == 0)//is there a zone selected on this last change?
                 * {//none selected, remove all
                 *  foreach (MunicipalitiesXEmployee item in auxEmployee.MunicipalitiesXEmployee)
                 *  {
                 *      //auxEmployee.MunicipalitiesXEmployee.Remove(item);
                 *      Repository.MunicipalitiesXEmployee.Remove(item.Id);
                 *  }
                 * }
                 * else
                 * {//zone selected, update
                 *  //identify records to delete (not selected anymore)
                 *  foreach (MunicipalitiesXEmployee item in auxEmployee.MunicipalitiesXEmployee)
                 *  {
                 *      if (item.Municipality.Cat_ZoneId == selectedZone)
                 *      {
                 *          auxMXE.Add(item);
                 *      }
                 *  }
                 *  //delete records (not selected anymore)
                 *  foreach (MunicipalitiesXEmployee item in auxMXE)
                 *  {
                 *      Repository.MunicipalitiesXEmployee.Remove(item.Id);
                 *  }
                 *  auxMXE.Clear();
                 *
                 *  //identify records to add (not yet in db)
                 *  List<AddressMunicipality> municipalitiesXZone = (List<AddressMunicipality>)Repository.AddressMunicipalities.GetByZoneId(selectedZone);
                 *  bool auxExist;
                 *  foreach (AddressMunicipality item in municipalitiesXZone)
                 *  {
                 *      auxExist = false;
                 *      foreach (MunicipalitiesXEmployee itemMXE in auxEmployee.MunicipalitiesXEmployee)
                 *      {
                 *          if (item.Id == itemMXE.AddressMunicipalityId)
                 *          {
                 *              auxExist = true;
                 *              break;
                 *          }
                 *      }
                 *      if (!auxExist)
                 *      {
                 *          auxMXE.Add(new MunicipalitiesXEmployee()
                 *          {
                 *              AddressMunicipalityAddressStateId = item.AddressStateId,
                 *              AddressMunicipalityId = item.Id,
                 *              BayerEmployeeId = auxEmployee.Id
                 *          });
                 *      }
                 *  }
                 *  //insert records (not yet in db)
                 *  foreach (MunicipalitiesXEmployee item in auxMXE)
                 *  {
                 *      auxEmployee.MunicipalitiesXEmployee.Add(item);
                 *  }
                 *  auxMXE.Clear();
                 * }
                 */

                Repository.Complete();
                ResultManager.Add("Perfil actualizado", "");
                ResultManager.IsCorrect = true;
                return(true);
            }
            catch (Exception ex)
            {
                //Repository.Dispose();
                ErrorManager.Add("", ErrorDefault, "", ex);
                ResultManager.Add(ErrorDefault, "");
                ResultManager.IsCorrect = false;
            }

            return(false);
        }
Beispiel #28
0
        public bool UpdateDistributorEmployee(DistributorEmployee model)
        {
            if (model == null)
            {
                return(false);
            }

            if (IsMailAddressCurrentlyUsed(model.EMail, model.Id))
            {
                ResultManager.Add(ErrorDefault, Trace + "La direccion de email '" + model.EMail + "' actualmente esta asignada a otro usuario, por favor ingresa una diferente.");
                return(false);
            }

            DistributorEmployee auxEmployee = null;

            try
            {
                auxEmployee = Repository.DistributorEmployees.Get(model.Id);
                auxEmployee.User.NickName = model.EMail;
                auxEmployee.EMail         = model.EMail;
                //auxEmployee.Name = model.Name;
                //auxEmployee.LastNameF = model.LastNameF;
                //auxEmployee.LastNameM = model.LastNameM;
                //auxEmployee.PhoneNumber = model.PhoneNumber;

                //auxEmployee.Distributor.IdB = model.Distributor.IdB;
                auxEmployee.Distributor.BusinessName   = model.Distributor.BusinessName;
                auxEmployee.Distributor.CommercialName = model.Distributor.CommercialName;
                auxEmployee.Distributor.WebSite        = model.Distributor.WebSite;

                //-address
                AddressColony auxColony = Repository.AddressColonies.Get((int)model.Distributor.Address.AddressColonyId);
                auxEmployee.Distributor.Address.AddressStateId        = auxColony.AddressStateId;
                auxEmployee.Distributor.Address.AddressMunicipalityId = auxColony.AddressMunicipalityId;
                auxEmployee.Distributor.Address.AddressPostalCodeId   = auxColony.AddressPostalCodeId;
                auxEmployee.Distributor.Address.AddressColonyId       = auxColony.Id;
                auxEmployee.Distributor.Address.Street    = model.Distributor.Address.Street;
                auxEmployee.Distributor.Address.NumberExt = model.Distributor.Address.NumberExt;
                auxEmployee.Distributor.Address.NumberInt = model.Distributor.Address.NumberInt;


                //if profile was not completed, complete
                if (auxEmployee.User.Cat_UserStatusId == 5)
                {
                    auxEmployee.User.Cat_UserStatusId = 1;
                }

                Repository.Complete();
                ResultManager.Add("Perfil actualizado", "");
                ResultManager.IsCorrect = true;
                return(true);
            }
            catch (Exception ex)
            {
                //Repository.Dispose();
                ErrorManager.Add("", ErrorDefault, "", ex);
                ResultManager.Add(ErrorDefault, "");
                ResultManager.IsCorrect = false;
            }

            return(false);
        }
        public override void Visit(ClassList classList)
        {
            while (true)
            {
                bool modifications = false;

                foreach (var classNode in classList.Classes)
                {
                    string entryName = classNode.ClassName;

                    // Make sure it doesn't exist first.
                    if (Sizes.ContainsKey(entryName))
                    {
                        continue;
                    }

                    int  size     = 0;
                    bool complete = true;
                    var  @class   = GlobalScope.Get(entryName, Classification.Class);

                    foreach (var entry in @class.Link.GetAll(Classification.Variable))
                    {
                        // Is the memory size already calculated?
                        if (entry.EntryMemorySize >= 0)
                        {
                            size += entry.EntryMemorySize;
                            continue;
                        }

                        // It's not. Let's try and figure it out.
                        // Get the base type
                        string type = entry.Type.Replace("[]", string.Empty);

                        // Is the base-type defined?
                        if (Sizes.ContainsKey(type))
                        {
                            entry.EntryMemorySize *= -Sizes[type];
                            entry.EntryMemorySize *= entry.MaxSizeDimensions.Aggregate(1, (a, b) => a * b);
                            size += entry.EntryMemorySize;
                        }
                        else
                        {
                            complete = false;
                            break;
                        }
                    }

                    // Is the type complete?
                    if (complete)
                    {
                        Sizes.Add(entryName, size);
                        modifications = true;

                        // Set the class size.
                        GlobalScope.Get(entryName, Classification.Class).EntryMemorySize = size;
                    }
                }

                if (!modifications)
                {
                    break;
                }
            }

            foreach (var entry in GlobalScope.GetAll(Classification.Class))
            {
                if (entry.EntryMemorySize == -1)
                {
                    ErrorManager.Add($"The size of the class {entry.ID} could not be established.", (0, 0));
                    Sizes.Add(entry.ID, -1);
                }
            }

            this.DoneClassList = true;
        }
        public override void Visit(Var var)
        {
            SymbolTable currentScope = new SymbolTable();

            currentScope.AddRange(this._functionScope.GetAll(), var.Location);
            currentScope.AddRange(this._globalScope.GetAll(), var.Location);
            currentScope.AddRange(this._classInstanceScope?.GetAll(), var.Location);

            foreach (var element in var.Elements)
            {
                if (element is AParams aparams)
                {
                    throw new System.Exception();
                }

                if (element is DataMember dataMember)
                {
                    TableEntry entry = null;
                    if (currentScope.Get($"{dataMember.Id}-{Classification.Variable}") is TableEntry vEntry)
                    {
                        entry = vEntry;
                    }
                    else if (currentScope.Get($"{dataMember.Id}-{Classification.Parameter}") is TableEntry pEntry)
                    {
                        entry = pEntry;
                    }
                    else
                    {
                        ErrorManager.Add($"The {Classification.Variable} {dataMember.Id} could not be resolved.", dataMember.Location);
                        break;
                    }

                    int actualNumParams;
                    if (dataMember.Indexes == null)
                    {
                        actualNumParams = 0;
                    }
                    else
                    {
                        actualNumParams = dataMember.Indexes.Expressions.Count;
                    }
                    int expectedNumParams = entry.Type.Count(val => val == '[');
                    int diffIndices       = expectedNumParams - actualNumParams;

                    if (diffIndices < 0)
                    {
                        ErrorManager.Add($"Too many indices for {dataMember.Id}. Got {actualNumParams}, expected {expectedNumParams}", dataMember.Location);
                        break;
                    }

                    for (int i = 0; i < actualNumParams && i < expectedNumParams; i++)
                    {
                        var exp = dataMember.Indexes.Expressions[i] as Node;
                        if (exp.SemanticalType != "int")
                        {
                            ErrorManager.Add($"Index must be of type int and not {exp.SemanticalType}.", exp.Location);
                        }
                    }

                    dataMember.SemanticalType = entry.Type.Replace("[]", string.Empty) + "[]".Repeat(diffIndices);
                    var.SemanticalType        = dataMember.SemanticalType;

                    currentScope = new SymbolTable();
                    currentScope.AddRange(_globalScope.Get($"{var.SemanticalType}-{Classification.Class}")?.Link?.GetAll(), var.Location);
                }

                if (element is FCall fcall)
                {
                    TableEntry entry = currentScope.Get($"{fcall.Id}-{Classification.Function}");

                    if (entry != null)
                    {
                        var    types      = entry.Type.Split('-');
                        string returnType = types[0];
                        var    parameters = types[1] == "" ? new string[0] : types[1].Split(',');

                        if (parameters.Length == fcall.Parameters.Expressions.Count)
                        {
                            for (int i = 0; i < parameters.Length; i++)
                            {
                                string expectedType = parameters[i];

                                var expression = fcall.Parameters.Expressions[i] as Node;
                                if (expression != null)
                                {
                                    string actualType = expression.SemanticalType;

                                    if (actualType != expectedType)
                                    {
                                        ErrorManager.Add($"Invalid parameter type: Expected {expectedType}, got {actualType}", expression.Location);
                                        break;
                                    }
                                }
                                else
                                {
                                    throw new System.Exception();
                                }
                            }

                            fcall.SemanticalType = returnType;
                            var.SemanticalType   = returnType;

                            if (entry.Link == null)
                            {
                                ErrorManager.Add($"The function {fcall.Id} is not linked.", fcall.Location);
                                //break;
                            }

                            currentScope = new SymbolTable();
                            currentScope.AddRange(_globalScope.Get($"{var.SemanticalType}-{Classification.Class}")?.Link?.GetAll(), var.Location);
                        }
                        else
                        {
                            ErrorManager.Add($"The function {fcall.Id} takes in {parameters.Length} arguments.", fcall.Location);
                            var.SemanticalType = returnType;
                            break;
                        }
                    }
                    else
                    {
                        ErrorManager.Add($"The function {fcall.Id} could not be found or does not exist.", fcall.Location);
                        break;
                    }
                }
            }
        }