Beispiel #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",
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> Templates()
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            if (await _claimCheck.CheckClaim(CurrentUser, "ApplicationRight", this.ControllerContext.RouteData.Values["controller"].ToString() + "\\" + this.ControllerContext.RouteData.Values["action"].ToString()))
            {
                var ListOfProcessTypeGroups = await _frontProcessProvider.NewProcessShowTemplateGroup(CurrentUser.Id);

                var TemplateLogic      = new FrontProcessNewProcessLogic(_userProvider, _processProvider, _frontProcessProvider);
                var ListOfProcessTypes = await TemplateLogic.ReturnProcessTypeList(CurrentUser);


                // var  = await _frontProcessProvider.NewProcessShowTemplate(CurrentUser.Id);
                foreach (var group in ListOfProcessTypeGroups)
                {
                    var ProcessTypes = ListOfProcessTypes.FindAll(x => x.ProcessTypeGroupId == group.ProcessTypeGroupId);
                    group.templates = ProcessTypes;
                }
                return(Ok(ListOfProcessTypeGroups));
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
Beispiel #3
0
        public async Task <IActionResult> NewProcessGet(int ProcessTypeId)
        {
            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 == ProcessTypeId))
                {
                    //TOFIX PETER
                    return(Ok(await _processProvider.CreateGet(CurrentUser.Id, ProcessTypeId)));// CurrentUser.LanguageId));
                }
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights",
            }));
        }
Beispiel #4
0
        public async Task <IActionResult> CreateNewProcess(NewProcessFromAPI ProcessesFromAPI)
        {
            var CurrentUser = await _userManager.GetUserAsync(User);

            var       testifallowed = new FrontProcessNewProcessLogic(_userProvider, _processProvider, _frontProcessProvider);
            DataTable ProcessFields = NewProcessField.CreateTable();

            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 == ProcessesFromAPI.ProcessTypeId))
                {
                    List <FrontProcessNewProcessField> ProcessesFromDB = await _processProvider.CreateGet(CurrentUser.Id, ProcessesFromAPI.ProcessTypeId);

                    int NoOfFields         = ProcessesFromDB.Count();
                    int EqualSequenceCount = 0;
                    if (ProcessesFromDB.Exists(z => z.ProcessTypeStageId == ProcessesFromAPI.ProcessTypeStageId) & ProcessesFromDB.Count() == ProcessesFromAPI.ProcessFields.Count())
                    {
                        foreach (var ProcessFromDB in ProcessesFromDB)
                        {
                            foreach (var ProcessFieldFromAPI in ProcessesFromAPI.ProcessFields)
                            {
                                if (ProcessFieldFromAPI.Sequence == ProcessFromDB.Sequence & ProcessFieldFromAPI.ProcessTypeFieldId == ProcessFromDB.ProcessTypeFieldId)
                                {
                                    EqualSequenceCount++;
                                    switch (ProcessFromDB.ProcessTypeFieldTypeId)
                                    {
                                    case 12:     //User
                                    case 13:     //Sec user
                                        if (!await _checkProvider.CheckUser(ProcessFieldFromAPI.StringValue) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "User does not exist",
                                            }));
                                        }
                                        break;

                                    case 30:    //role
                                    case 31:    //sec role
                                        if (!await _checkProvider.CheckRole(ProcessFieldFromAPI.StringValue) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Role does not exist",
                                            }));
                                        }
                                        break;

                                    case 34:     // organization role
                                        if (!await _checkProvider.CheckOrganizationRole(ProcessFieldFromAPI.StringValue) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Organization role does not exist",
                                            }));
                                        }
                                        break;

                                    case 35:     // project role
                                        if (!await _checkProvider.CheckProjectRole(ProcessFieldFromAPI.StringValue) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Project role does not exist",
                                            }));
                                        }
                                        break;


                                    case 3:     //Number
                                    case 14:    //Organization
                                    case 15:    //Sec org
                                        if (!await _checkProvider.CheckOrganization((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Orgnization does not exist",
                                            }));
                                        }
                                        break;

                                    case 16:    //Project
                                    case 17:    //Sec project
                                        if (!await _checkProvider.CheckProject((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Project does not exist",
                                            }));
                                        }
                                        break;

                                    case 18:    //Language
                                    case 19:    //Sec lang
                                        if (!await _checkProvider.CheckLanguage((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Language does not exist",
                                            }));
                                        }
                                        break;

                                    case 20:    //Classification
                                    case 21:    //Sec class
                                        if (!await _checkProvider.CheckClassification((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Classification does not exist",
                                            }));
                                        }
                                        break;

                                    case 22:    //Classification value
                                    case 23:    //Sec class value
                                        if (!await _checkProvider.CheckClassificationValue((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Classification value does not exist",
                                            }));
                                        }
                                        break;

                                    case 24:    //Content
                                    case 25:    //Sec contentt
                                        if (!await _checkProvider.CheckContent((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Content does not exist",
                                            }));
                                        }
                                        break;

                                    case 26:    //Country
                                    case 27:    //Sec country
                                        if (!await _checkProvider.CheckCountry((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Country does not exist",
                                            }));
                                        }
                                        break;

                                    case 28:    //security level
                                    case 29:    //sec security level
                                        if (!await _checkProvider.CheckSecurityLevel((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Security level does not exist",
                                            }));
                                        }
                                        break;

                                    case 33:     //user has specific relation to user field
                                        if (!await _checkProvider.CheckUserRelation((ProcessFieldFromAPI.IntValue ?? 0)) & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "User relation does not exist",
                                            }));
                                        }
                                        break;
                                        //case 4: //Date
                                        //case 5:
                                        //case 6:
                                        //case 7:
                                        //case 8:
                                        //case 9:

                                        //case 10: //button
                                        //case 11:
                                    }
                                    switch (ProcessFromDB.ProcessTypeFieldTypeId)
                                    {
                                    case 1:     //Text - Subject
                                    case 2:     //text
                                    case 12:    //User
                                    case 13:    //Sec user
                                    case 30:    //role
                                    case 31:    //sec role
                                    case 32:    // html
                                    case 34:    // organization role
                                    case 35:    // project role
                                        if (ProcessFromDB.ProcessTypeStageFieldStatusId == 4 & ProcessFieldFromAPI.StringValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Required value is missing 1",
                                            }));
                                        }

                                        break;

                                    case 3:     //Number
                                    case 14:    //Organization
                                    case 15:    //Sec org
                                    case 16:    //Project
                                    case 17:    //Sec project
                                    case 18:    //Language
                                    case 19:    //Sec lang
                                    case 20:    //Classification
                                    case 21:    //Sec class
                                    case 22:    //Classification value
                                    case 23:    //Sec class value
                                    case 24:    //Content
                                    case 25:    //Sec contentt
                                    case 26:    //Country
                                    case 27:    //Sec country
                                    case 28:    //security level
                                    case 29:    //sec security level
                                    case 33:    //user has specific relation to user field
                                        if (ProcessFromDB.ProcessTypeStageFieldStatusId == 4 & ProcessFieldFromAPI.IntValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Required value is missing 2",
                                            }));
                                        }

                                        break;

                                    case 4:     //Date
                                    case 5:
                                    case 6:
                                    case 7:
                                    case 8:
                                    case 9:
                                        if (ProcessFromDB.ProcessTypeStageFieldStatusId == 4 & ProcessFieldFromAPI.DateTimeValue == null)
                                        {
                                            return(BadRequest(new
                                            {
                                                IsSuccess = false,
                                                Message = "Required value is missing 3",
                                            }));
                                        }

                                        break;

                                        //case 10: //button
                                        //case 11:
                                    }
                                }
                            }
                        }

                        foreach (var ProcessFieldFromAPI in ProcessesFromAPI.ProcessFields)
                        {
                            ProcessFields.Rows.Add(ProcessFieldFromAPI.ProcessTypeId, ProcessFieldFromAPI.ProcessTypeFieldId, ProcessFieldFromAPI.StringValue, ProcessFieldFromAPI.IntValue, ProcessFieldFromAPI.DateTimeValue);
                        }

                        //   SqlParameter Parameters = cmd.Parameters.AddWithValue("@FieldsTable", ProcessFields);
                        //    System.Data.SqlClient.SqlParameter[] Parameters =  {
                        //    new System.Data.SqlClient.SqlParameter("@User", CurrentUser.Id)
                        //    , new System.Data.SqlClient.SqlParameter("@ProcessTypeID", ProcessesFromAPI.ProcessTypeId)
                        //    , new System.Data.SqlClient.SqlParameter("@ProcessTypeStageID", ProcessesFromAPI.ProcessTypeStageId)
                        //    , new System.Data.SqlClient.SqlParameter("@FieldsTable", ProcessFields)
                        //};
                        await _processProvider.CreatePost("usp_CreateProcess @User, @ProcessTypeId, @ProcessTypeStageId, @FieldsTable", CurrentUser.Id, ProcessesFromAPI.ProcessTypeId, ProcessesFromAPI.ProcessTypeStageId, ProcessFields);

                        return(Ok());
                    }
                }
            }
            return(BadRequest(new
            {
                IsSuccess = false,
                Message = "No rights 1",
            }));
            //            return Ok();
        }
Beispiel #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",
            }));
        }