Esempio n. 1
0
        public async Task <IActionResult> Create(FrontProcessNewProcessWithMaster Fields)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            var testifallowed = new FrontProcessNewProcessLogic(_userProvider, _processProvider, _frontProcessProvider);

            Fields.UserId = CurrentUser.Id;
            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))              //11
            {
                //Check if the template is allowed to be created
                var Condition = await testifallowed.ReturnProcessTypeList(CurrentUser);

                var Pass = await testifallowed.ReturnProcessTypeFlowPass(CurrentUser, Fields);

                if (Condition.Any(x => x.ProcessTypeId == Fields.ProcessTypeId) && Pass != 0)
                {
                    Fields.ProcessTypeFlowId = Pass;
                    _frontProcessProvider.FrontProcessCreatePost(Fields);
                    return(Ok(Fields));// CurrentUser.LanguageId));
                }
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create(FrontProcessNewProcessWithMaster Fields, string submit)
        {
            var token = HttpContext.Session.GetString("Token"); if (token == null)
            {
                return(RedirectToAction("Login", "FrontAuth"));
            }
            await _client.PostProtectedAsync <FrontProcessNewProcessWithMaster>($"{_configuration["APIUrl"]}api/FrontProcess/Create", Fields, token);

            return(RedirectToAction("Templates"));
        }
Esempio n. 3
0
        public async Task <bool> FrontProcessCreatePost(FrontProcessNewProcessWithMaster Process)
        {
            DataTable ProcessFieldValueTable = new DataTable();

            ProcessFieldValueTable.Columns.Add("ProcessTypeId", typeof(Int32));
            ProcessFieldValueTable.Columns.Add("ProcessTypeFieldId", typeof(Int32));
            ProcessFieldValueTable.Columns.Add("StringValue", typeof(string));
            ProcessFieldValueTable.Columns.Add("IntValue", typeof(Int32));
            ProcessFieldValueTable.Columns.Add("DateTimeValue", typeof(DateTime));
            //var xy = new List<DataTable>();

            foreach (var x in Process.ProcessFields)
            {
                if (x.ProcessTypeFieldTypeId == 32)
                {
                    x.StringValue = x.HTMLStringValue;
                }
                //if (x.ProcessTypeFieldId != null && x.ClassificationValueId != 0)
                //{
                DateTime NewDate;
                int      NewInt;
                if (1 == 1)//x.ProcessTypeFieldId
                {
                    if (new[] { 4, 5, 6, 7, 8, 9 }.Contains(x.ProcessTypeFieldTypeId))
                    {
                        if (x.DateTimeValue.ToString() == "1/1/0001 12:00:00 AM")
                        {
                            NewDate = DateTime.Now;
                        }
                        else
                        {
                            NewDate = x.DateTimeValue;
                        }
                    }
                    else
                    {
                        NewDate = DateTime.Now;
                    }
                    if (new[] { 3, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 36, 37 }.Contains(x.ProcessTypeFieldTypeId))
                    {
                        NewInt = x.IntValue ?? 0;
                    }
                    else
                    {
                        NewInt = 0;
                    }
                    ProcessFieldValueTable.Rows.Add(

                        Process.ProcessTypeId
                        , x.ProcessTypeFieldId
                        , x.StringValue
                        , NewInt
                        , NewDate     //DateTime.Now //
                        );
                    //}
                }
            }
            string usp = "usp_ProcessCreatePost @UserId, @ProcessTypeId , @ProcessTypeFlowId , @ProcessFieldValueTable ";

            _sqlDataAccess.SaveData <dynamic>(usp, new {
                UserId                   = Process.UserId
                , ProcessTypeId          = Process.ProcessTypeId
                , ProcessTypeFlowId      = Process.ProcessTypeFlowId
                , ProcessFieldValueTable = ProcessFieldValueTable.AsTableValuedParameter("udt_ProcessFieldsNew")
            });
            return(true);
        }
Esempio n. 4
0
        public async Task <int> ReturnProcessTypeFlowPass(SipUser CurrentUser, FrontProcessNewProcessWithMaster NewProcess)
        {
            var Flows = await _frontProcessProvider.FrontProcessNewReturnFlows(NewProcess.ProcessTypeId);

            foreach (var FlowId in Flows)
            {
                string From   = "SELECT ProcessTypeFlowId FROM ProcessTypeFlowPasses";
                string Where  = " WHERE ProcessTypeFlowId = " + FlowId + " AND ";
                var    Passes = await _frontProcessProvider.FrontProcessNewReturnFlowPasses(FlowId);

                foreach (var Pass in Passes)
                {
                    if (Pass.ProcessTypeFlowConditionTypeId == 1) //Creator is user
                    {
                        //                    From = From + NewProcess. '  '
                        //Have to check if this can be used in general or only new processes
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 2) //  Field
                    {
                        if (!new[] { 1, 2, 12, 13, 30, 31, 32 }.Contains(Pass.ProcessTypeFieldTypeId))
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 3) //  Security level user
                    {
                        var UserSecurityLevel = await _userProvider.UserSecurityLevel(CurrentUser.Id);

                        var ProcessSecurityLevel = NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldId).IntValue;
                        if (ProcessSecurityLevel == null || ProcessSecurityLevel == 0)
                        {
                            ProcessSecurityLevel = Pass.StageFieldIntValue;
                        }
                        if (Pass.ComparisonOperatorID == 1)  //Comparison blank
                        {
                            Where = Where + " 1=2 ";
                        }
                        if (Pass.ComparisonOperatorID == 2 && UserSecurityLevel != ProcessSecurityLevel) //Equal
                        {
                            Where = Where + " 1=2 ";
                        }
                        if (Pass.ComparisonOperatorID == 3 && UserSecurityLevel <= ProcessSecurityLevel) //
                        {
                            Where = Where + " 1=2 ";
                        }
                        if (Pass.ComparisonOperatorID == 4 && UserSecurityLevel >= ProcessSecurityLevel)
                        {
                            Where = Where + " 1=2 ";
                        }
                        if (Pass.ComparisonOperatorID == 5 && UserSecurityLevel < ProcessSecurityLevel)
                        {
                            Where = Where + " 1=2 ";
                        }
                        if (Pass.ComparisonOperatorID == 6 && UserSecurityLevel > ProcessSecurityLevel)
                        {
                            Where = Where + " 1=2 ";
                        }
                        if (Pass.ComparisonOperatorID == 7 && UserSecurityLevel == ProcessSecurityLevel)
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 4) // Role user
                    {
                        var Roles = await _userProvider.UserRoles(CurrentUser.Id);

                        if (!Roles.Contains(NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldId).StringValue ?? ""))
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    //PETER not sure yet
                    if (Pass.ProcessTypeFlowConditionTypeId == 5) //  Manager user field
                    {
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 6) //  Organization user
                    {
                        var Organizations = await _userProvider.UserOrganizations(CurrentUser.Id);

                        if (!Organizations.Contains(NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldId).IntValue ?? 0))
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 7) //  Organization role user
                    {
                        var RoleId        = NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldIDRole).StringValue ?? "";
                        var Organizations = await _userProvider.UserRoleOrganizations(CurrentUser.Id, RoleId);

                        if (!Organizations.Contains(NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldId).IntValue ?? 0))
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    //PETER TODO
                    if (Pass.ProcessTypeFlowConditionTypeId == 8) //  Organization parent user
                    {
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 9) //  Organization parent role user
                    {
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 10) // Project user
                    {
                        var Projects = await _userProvider.UserProjects(CurrentUser.Id);

                        if (!Projects.Contains(NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldId).IntValue ?? 0))
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 11) //Project role user
                    {
                        var RoleId   = NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldIDRole).StringValue ?? "";
                        var Projects = await _userProvider.UserRoleProjects(CurrentUser.Id, RoleId);

                        if (!Projects.Contains(NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldId).IntValue ?? 0))
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 12) //Project parent user
                    {
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 13) //Project parent role user
                    {
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 14) //Default organization user
                    {
                        var Organization = await _userProvider.UserDefaultOrganization(CurrentUser.Id);

                        var OrganizationInField = NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldId).IntValue ?? 0;
                        if (Organization != OrganizationInField)
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 15) //Open bracket
                    {
                        Where = Where + " ( ";
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 16) //and
                    {
                        Where = Where + " AND ";
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 17) //or
                    {
                        Where = Where + " OR ";
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 18) //Close bracket
                    {
                        Where = Where + " ) ";
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 19) //User
                    {
                        var UserInField = NewProcess.ProcessFields.Find(x => x.ProcessTypeFieldId == Pass.ProcessTypeFieldId).StringValue ?? "";
                        if (CurrentUser.Id != UserInField)
                        {
                            Where = Where + " 1=2 ";
                        }
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 20) //Relation to creator
                    {
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 21) //Relation to user field
                    {
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 22) //Classification relation
                    {
                    }
                    if (Pass.ProcessTypeFlowConditionTypeId == 23) //Classification relation type
                    {
                    }
                }
                if (Where == " WHERE ProcessTypeFlowId = " + FlowId + " AND ")
                {
                    Where = " WHERE ProcessTypeFlowId = " + FlowId;
                }
                var SQLStatement = From + Where;
                var x            = await _frontProcessProvider.ReturnProcessTypeFlowPass(CurrentUser.Id, SQLStatement);

                if (x.Count() > 0)
                {
                    return(x.First());
                }
                else
                {
                    return(0);
                }
            }
            return(0);
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(int Id)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            var testifallowed = new FrontProcessNewProcessLogic(_userProvider, _processProvider, _frontProcessProvider);

            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))              //11
            {
                List <NewProcessTypeList> x = await testifallowed.ReturnProcessTypeList(CurrentUser);

                if (x.Exists(x => x.ProcessTypeId == Id))
                {
                    //TOFIX PETER
                    var newprocess = await _processProvider.CreateGet(CurrentUser.Id, Id);

                    var newProcessWithMaster = new FrontProcessNewProcessWithMaster();

                    newProcessWithMaster.ProcessTypeId = Id;
                    newProcessWithMaster.ProcessFields = newprocess;
                    foreach (var y in newprocess)
                    {
                        if (y.ProcessTypeStageFieldStatusId == 4)
                        {
                            var xd = @$ "function {y.ControlIdOnFocusOutFunction.Trim()} {{var x = document.getElementById('{y.ControlId.Trim()}');console.log(x);if (x.value==='') {{ document.getElementById('{y.ControlIdWarning.Trim()}').style.display = 'block';}}else{{ document.getElementById('{y.ControlIdWarning.Trim()}').style.display = 'none';}}}}";
                            //var xd = @$"function {y.ControlIdOnFocusOutFunction.Trim()} {{var x = document.getElementById('{y.ControlId.Trim()}');if (x.value==='') {{alert('{y.MissingValueText.Trim()}a');}}else{{alert('{y.MissingValueText.Trim()}b');}}}}";
                            // var xe = String.Format($"function {0} {{var x = document.getElementById(\"{1}\");if (x.value===\"\") {{alert(\"{2}\");}}}}", y.ControlIdOnFocusOutFunction.Trim(), y.ControlId.Trim(), y.MissingValueText.Trim());
                            newProcessWithMaster.ErrorHandlingScript = newProcessWithMaster.ErrorHandlingScript + xd;
                            //@"function " +
                            //y.ControlIdOnFocusOutFunction + @" {var x = document.getElementById("""+
                            //y.ControlId + "\");if (x.value===\"\") {alert(\"" +
                            //y.MissingValueText + "\");}}";
                        }
                    }
                    //for(int i = 0; i < newprocess.Count; i++)
                    //{
                    //if(newprocess[i].ValueUpdateTypeId==2 && new[] { 1, 2 }.Contains(newprocess[i].ProcessTypeFieldTypeId))
                    //    {
                    //        newprocess[i].StringValue
                    //    }

                    //}
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 12) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 13))
                    {
                        var Users = await _userProvider.List();

                        newProcessWithMaster.Users = Users;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 14) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 15))
                    {
                        var organizations = await _organizationProvider.List(CurrentUser.Id);

                        newProcessWithMaster.Organizations = organizations;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 16) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 17))
                    {
                        var projects = await _projectProvider.List(CurrentUser.Id);

                        newProcessWithMaster.Projects = projects;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 18) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 19))
                    {
                        var Languages = await _languageProvider.List(CurrentUser.Id);

                        newProcessWithMaster.Languages = Languages;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 20) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 21))
                    {
                        var Classifications = await _classificationProvider.List(CurrentUser.Id);

                        newProcessWithMaster.Classifications = Classifications;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 22) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 23))
                    {
                        var ClassificationValues = await _classificationValueProvider.List(CurrentUser.Id);

                        newProcessWithMaster.ClassificationValues = ClassificationValues;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 24) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 25))
                    {
                        var Contents = await _contentProvider.List();

                        newProcessWithMaster.Contents = Contents;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 26) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 27))
                    {
                        var Countries = await _masterListProvider.CountryList(CurrentUser.Id);

                        newProcessWithMaster.Countries = Countries;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 28) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 29))
                    {
                        var SecurityLevels = await _securityLevelProvider.List(CurrentUser.Id);

                        newProcessWithMaster.SecurityLevels = SecurityLevels;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 30) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 31))
                    {
                        var Roles = await _roleProvider.List(CurrentUser.Id);

                        newProcessWithMaster.Roles = Roles;
                    }
                    if (newprocess.Exists(x => x.ProcessTypeFieldTypeId == 36) || newprocess.Exists(x => x.ProcessTypeFieldTypeId == 37))
                    {
                        var Persons = await _personProvider.List();

                        newProcessWithMaster.Persons = Persons;
                    }
                    return(Ok(newProcessWithMaster));// CurrentUser.LanguageId));
                }
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }