示例#1
0
        public async Task Post_HelpdeskUserCannotAccess()
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            await User.AsHelpdesk();

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipLocationType(ApprenticeshipLocationType.EmployerBased);
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder()
                                 .ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-employer-locations?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
        }
示例#2
0
        public async Task Post_QAStatusNotValidReturnsBadRequest(ApprenticeshipQAStatus qaStatus)
        {
            // Arrange
            var provider = await TestData.CreateProvider(apprenticeshipQAStatus : qaStatus);

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipLocationType(ApprenticeshipLocationType.EmployerBased);
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder()
                                 .ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-employer-locations?providerId={provider.ProviderId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
        public async Task PostRemove_ValidRequest_UpdatesParentStateAndRedirects()
        {
            // Arrange
            var provider = await TestData.CreateProvider(providerType : ProviderType.Apprenticeships);

            var venueId = (await TestData.CreateVenue(provider.ProviderId)).Id;

            var parentMptxInstance = MptxManager.CreateInstance(new ParentFlow());
            var childMptxInstance  = MptxManager.CreateInstance <FlowModel, IFlowModelCallback>(
                parentMptxInstance.InstanceId,
                FlowModel.Edit(
                    provider.ProviderId,
                    venueId,
                    radius: 5,
                    new[] { ApprenticeshipDeliveryMode.BlockRelease }),
                new Dictionary <string, object>()
            {
                { "ReturnUrl", "callback" }
            });

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var requestContent = new FormUrlEncodedContentBuilder().ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"apprenticeships/remove-classroom-location?ffiid={childMptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.Found, response.StatusCode);
            Assert.Equal("callback", response.Headers.Location.OriginalString);

            Assert.Null(parentMptxInstance.State.VenueId);
            Assert.Null(parentMptxInstance.State.Radius);
            Assert.Null(parentMptxInstance.State.DeliveryModes);
        }
        public async Task Post_InvalidVenueId_RendersErrorMessage()
        {
            // Arrange
            var provider = await TestData.CreateProvider(providerType : ProviderType.Apprenticeships);

            var invalidVenueId = Guid.NewGuid();

            var parentMptxInstance = MptxManager.CreateInstance(new ParentFlow());
            var childMptxInstance  = MptxManager.CreateInstance <FlowModel, IFlowModelCallback>(
                parentMptxInstance.InstanceId,
                FlowModel.Add(provider.ProviderId, cancelable: true),
                new Dictionary <string, object>()
            {
                { "ReturnUrl", "callback" }
            });

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var requestContent = new FormUrlEncodedContentBuilder()
                                 .Add("VenueId", invalidVenueId)
                                 .Add("Radius", 15)
                                 .Add("DeliveryModes", ApprenticeshipDeliveryMode.DayRelease)
                                 .Add("DeliveryModes", ApprenticeshipDeliveryMode.BlockRelease)
                                 .ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"/apprenticeships/classroom-location?ffiid={childMptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);

            var doc = await response.GetDocument();

            doc.AssertHasError("VenueId", "Select the location");
        }
示例#5
0
        public void UnitOfWorkRepository()
        {
            foreach (var fsql in new[] { g.sqlite, /*g.mysql, g.pgsql, g.oracle, g.sqlserver*/ })
            {
                fsql.CodeFirst.ConfigEntity <FlowModel>(f =>
                {
                    f.Property(b => b.UserId).IsPrimary(true);
                    f.Property(b => b.Id).IsPrimary(true).IsIdentity(true);
                    f.Property(b => b.Name).IsNullable(false);
                });

                FlowModel flow = new FlowModel()
                {
                    CreateTime     = DateTime.Now,
                    Name           = "aaa",
                    LastModifyTime = DateTime.Now,
                    UserId         = 1,
                };
                var flowRepos = fsql.GetRepository <FlowModel>();
                flowRepos.Insert(flow);

                //事务添加
                flow = new FlowModel()
                {
                    CreateTime     = DateTime.Now,
                    Name           = "aaa",
                    LastModifyTime = DateTime.Now,
                    UserId         = 1,
                };
                using (var uow = fsql.CreateUnitOfWork())
                {
                    flowRepos = uow.GetRepository <FlowModel>();
                    flowRepos.Insert(flow);
                    uow.Commit();
                }
            }
        }
示例#6
0
        public void UnitOfWorkRepositoryWithDisableBeforeInsert()
        {
            foreach (var fsql in new[] { g.sqlite, })
            {
                fsql.CodeFirst.ConfigEntity <FlowModel>(f =>
                {
                    f.Property(b => b.UserId).IsPrimary(true);
                    f.Property(b => b.Id).IsPrimary(true).IsIdentity(true);
                    f.Property(b => b.Name).IsNullable(false);
                });

                var flowRepos = fsql.GetRepository <FlowModel>();

                var flow = new FlowModel()
                {
                    CreateTime     = DateTime.Now,
                    Name           = "aaa",
                    LastModifyTime = DateTime.Now,
                    UserId         = 1,
                };

                //清理掉数据库中已存在的数据,为了接下来的插入测试
                flowRepos.Delete(a => a.UserId == 1 && a.Name == "aaa");

                using (var uow = fsql.CreateUnitOfWork())
                {
                    //关闭工作单元(不会开始事务)
                    uow.Close();
                    var uowFlowRepos = uow.GetRepository <FlowModel>();
                    uowFlowRepos.Insert(flow);
                    //已关闭工作单元,提不提交都没影响,此处注释来确定工作单元开关是否生效:关闭了,不Commit也应该插入数据
                    //uow.Commit();
                }

                Assert.True(flowRepos.Select.Any(a => a.UserId == 1 && a.Name == "aaa"));
            }
        }
示例#7
0
        public async Task Post_NotApprenticeshipProvider_ReturnsBadRequest()
        {
            // Arrange
            var providerId = await TestData.CreateProvider(
                apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted,
                providerType : ProviderType.FE);

            var standardCode    = 123;
            var standardVersion = 1;
            var standard        = await TestData.CreateStandard(standardCode, standardVersion, standardName : "My standard");

            await User.AsProviderUser(providerId, ProviderType.FE);

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("Provider 1 rocks");
            flowModel.SetApprenticeshipStandardOrFramework(standard);
            flowModel.SetApprenticeshipDetails(
                marketingInformation: "My apprenticeship",
                website: "http://provider.com/apprenticeship",
                contactTelephone: "01234 5678902",
                contactEmail: "*****@*****.**",
                contactWebsite: "http://provider.com");
            flowModel.SetApprenticeshipLocationType(ApprenticeshipLocationType.EmployerBased);
            flowModel.SetApprenticeshipIsNational(true);
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder().ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-confirmation?providerId={providerId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
示例#8
0
        public void UnitOfWorkRepositoryWithoutDisable()
        {
            foreach (var fsql in new[] { g.sqlite, })
            {
                fsql.CodeFirst.ConfigEntity <FlowModel>(f =>
                {
                    f.Property(b => b.UserId).IsPrimary(true);
                    f.Property(b => b.Id).IsPrimary(true).IsIdentity(true);
                    f.Property(b => b.Name).IsNullable(false);
                });

                var flowRepos = fsql.GetRepository <FlowModel>();
                if (flowRepos.Select.Any(a => a.UserId == 1 && a.Name == "aaa"))
                {
                    flowRepos.Delete(a => a.UserId == 1);
                }


                var flow = new FlowModel()
                {
                    CreateTime     = DateTime.Now,
                    Name           = "aaa",
                    LastModifyTime = DateTime.Now,
                    UserId         = 1,
                };


                using (var uow = fsql.CreateUnitOfWork())
                {
                    var uowFlowRepos = uow.GetRepository <FlowModel>();
                    uowFlowRepos.Insert(flow);
                    //不调用commit将不会提交数据库更改
                    //uow.Commit();
                }
                Assert.False(flowRepos.Select.Any(a => a.UserId == 1 && a.Name == "aaa"));
            }
        }
示例#9
0
        public async Task Post_NotNationalMissingRadius_RendersErrorMessage()
        {
            // Arrange
            var provider = await TestData.CreateProvider(providerType : ProviderType.Apprenticeships);

            var venueId = (await TestData.CreateVenue(provider.ProviderId, createdBy: User.ToUserInfo())).VenueId;

            var parentMptxInstance = MptxManager.CreateInstance(new ParentFlow());
            var childMptxInstance  = MptxManager.CreateInstance <FlowModel, IFlowModelCallback>(
                parentMptxInstance.InstanceId,
                FlowModel.Add(provider.ProviderId, cancelable: true),
                new Dictionary <string, object>()
            {
                { "ReturnUrl", "callback" }
            });

            await User.AsProviderUser(provider.ProviderId, ProviderType.Apprenticeships);

            var requestContent = new FormUrlEncodedContentBuilder()
                                 .Add("VenueId", venueId)
                                 .Add("DeliveryModes", ApprenticeshipDeliveryMode.DayRelease)
                                 .Add("DeliveryModes", ApprenticeshipDeliveryMode.BlockRelease)
                                 .ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"/apprenticeships/classroom-location?ffiid={childMptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);

            var doc = await response.GetDocument();

            doc.AssertHasError("Radius", "Enter how far you are willing to travel from the selected venue");
        }
示例#10
0
        public async Task Get_StoresPassedStandardInState()
        {
            // Arrange
            var provider = await TestData.CreateProvider(
                apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var standard = await TestData.CreateStandard(standardCode : 123, version : 1, standardName : "My standard");

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipStandard(standard);
            var mptxInstance = CreateMptxInstance(flowModel);

            var request = new HttpRequestMessage(
                HttpMethod.Get,
                $"new-apprenticeship-provider/standard-selected?" +
                $"providerId={provider.ProviderId}&" +
                $"ffiid={mptxInstance.InstanceId}&" +
                $"standardCode=123&version=1");

            await User.AsHelpdesk();

            // Act
            var response = await HttpClient.SendAsync(request);

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.Found);
            response.Headers.Location.OriginalString.Should().Be(
                $"/new-apprenticeship-provider/apprenticeship-details?ffiid={mptxInstance.InstanceId}&providerId={provider.ProviderId}");

            using (new AssertionScope())
            {
                mptxInstance.State.ApprenticeshipStandard.StandardCode.Should().Be(123);
                mptxInstance.State.ApprenticeshipStandard.Version.Should().Be(1);
            }
        }
示例#11
0
        public async void TaskPrev()
        {
            var taskAggregate = new TaskAggregate();

            taskAggregate.Id   = Guid.NewGuid();
            taskAggregate.Name = "Test";

            var testFlow = new FlowModel {
                Id = Guid.NewGuid(), Name = "TestFlow"
            };

            testFlow.States = new List <FlowStateModel>();
            var state1 = new FlowStateModel();

            state1.Name    = "State1";
            state1.Order   = 1;
            state1.StateId = Guid.NewGuid();
            testFlow.States.Add(state1);
            var state2 = new FlowStateModel();

            state2.Name    = "State2";
            state2.Order   = 2;
            state2.StateId = Guid.NewGuid();
            testFlow.States.Add(state2);
            var state3 = new FlowStateModel();

            state3.Name    = "State3";
            state3.Order   = 3;
            state3.StateId = Guid.NewGuid();
            testFlow.States.Add(state3);
            taskAggregate.AssignFlow(testFlow);
            taskAggregate.Next();
            taskAggregate.Next();
            taskAggregate.Previous();
            Assert.Same(taskAggregate.ActiveState, state2);
        }
        public async Task Get_NoPersistedStateRendersExpectedOutput()
        {
            // Arrange
            var providerId = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            await User.AsProviderUser(providerId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetApprenticeshipLocationType(ApprenticeshipLocationType.EmployerBased);
            var mptxInstance = CreateMptxInstance(flowModel);

            // Act
            var response = await HttpClient.GetAsync(
                $"new-apprenticeship-provider/apprenticeship-employer-locations?providerId={providerId}&ffiid={mptxInstance.InstanceId}");

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            var doc = await response.GetDocument();

            Assert.Null(doc.GetElementById("National").GetAttribute("checked"));
            Assert.Null(doc.GetElementById("National-1").GetAttribute("checked"));
        }
示例#13
0
        public async Task PostConfirmation_ValidRequestWithRegionsAndVenue_CreatesValidApprenticeship()
        {
            // Arrange
            var providerId = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var standardCode    = 123;
            var standardVersion = 1;
            var standard        = await TestData.CreateStandard(standardCode, standardVersion, standardName : "My standard");

            var venueId = await TestData.CreateVenue(providerId);

            await User.AsProviderUser(providerId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("Provider 1 rocks");
            flowModel.SetApprenticeshipStandardOrFramework(standard);
            flowModel.SetApprenticeshipDetails(
                marketingInformation: "My apprenticeship",
                website: "http://provider.com/apprenticeship",
                contactTelephone: "01234 5678902",
                contactEmail: "*****@*****.**",
                contactWebsite: "http://provider.com");
            flowModel.SetApprenticeshipLocationType(ApprenticeshipLocationType.ClassroomBasedAndEmployerBased);
            flowModel.SetApprenticeshipLocationRegionIds(new[]
            {
                "E06000001", // County Durham
                "E10000009"  // Dorset
            });
            flowModel.SetClassroomLocationForVenue(
                venueId,
                originalVenueId: null,
                radius: 5,
                deliveryModes: new[] { ApprenticeshipDeliveryMode.BlockRelease });
            var mptxInstance = CreateMptxInstance(flowModel);

            Guid apprenticeshipId = default;

            CosmosDbQueryDispatcher.Callback <CreateApprenticeship, Success>(q => apprenticeshipId = q.Id);

            var requestContent = new FormUrlEncodedContentBuilder().ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-confirmation?providerId={providerId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            CosmosDbQueryDispatcher.Verify(mock => mock.ExecuteQuery(It.Is <CreateApprenticeship>(q =>
                                                                                                  q.ApprenticeshipLocations.Any(l =>
                                                                                                                                l.ApprenticeshipLocationType == ApprenticeshipLocationType.ClassroomBased &&
                                                                                                                                l.DeliveryModes.Single() == ApprenticeshipDeliveryMode.BlockRelease &&
                                                                                                                                l.Radius == 5 &&
                                                                                                                                l.VenueId == venueId) &&
                                                                                                  q.ApprenticeshipLocations.Any(l =>
                                                                                                                                l.ApprenticeshipLocationType == ApprenticeshipLocationType.EmployerBased &&
                                                                                                                                l.DeliveryModes.Single() == ApprenticeshipDeliveryMode.EmployerAddress &&
                                                                                                                                l.National == false &&
                                                                                                                                l.VenueId == null &&
                                                                                                                                l.Regions.Contains("E06000001") &&
                                                                                                                                l.Regions.Contains("E10000009")))));
        }
示例#14
0
        public ActionResult Execute(int number)
        {
            string id       = (string)RouteData.Values["id"];
            int    position = Int32.Parse(id);
            User   user     = (User)Session["users"];

            if (user == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            NH.NHibernateOperation operation = new NH.NHibernateOperation();

            List <int> users = operation.GetUsersByPosition(position);

            if (!users.Contains(user.Id_user))
            {
                ViewBag.Result = 403;
            }

            Position     p     = operation.FindPositionById(position);
            IList <Flow> flows = operation.GetUserActiveFlows(p);
            Flow         flow  = new Flow();

            foreach (Flow f in flows)
            {
                if (f.id_flow == number)
                {
                    ViewBag.Flow = f;
                    flow         = f;
                    break;
                }
            }
            FlowDefinition fl  = operation.GetFlowDefinition(flow.id_flowdefinition.id_flowDefinition);
            Document       doc = operation.GetDocumentByName(fl.Flow_name);

            byte[] data = doc.Data;
            string str2 = System.Text.Encoding.UTF8.GetString(data, 0, data.Length);
            string sub  = str2.Substring(1);

            XmlSerializer deserializer = new XmlSerializer(typeof(Items));
            XmlDocument   docxml       = new XmlDocument();

            docxml.LoadXml(sub);
            XmlNodeReader node    = new XmlNodeReader(docxml);
            object        obj     = deserializer.Deserialize(node);
            Items         XmlData = (Items)obj;

            node.Close();
            Dictionary <string, Item> itemMap = new Dictionary <string, Item>();

            foreach (Item it in XmlData.itemList)
            {
                if (it.id.name.Equals("Item "))
                {
                    it.id.name = "check";
                }
                itemMap.Add(it.id.name, it);
            }

            IList <Attributes> attrList = operation.GetAttributesByFlow(flow.id_flowdefinition.id_flowDefinition);
            FullFlowModel      model    = new FullFlowModel();

            model.list     = new List <FlowModel <string> >();
            model.list_int = new List <FlowModel <int> >();
            model.values   = new List <string>();
            model.items    = XmlData;
            foreach (Attributes a in attrList)
            {
                Access acc = operation.GetAttributeAccess(position, a.Id_attribute);
                if (acc.Read_property == 1 && (acc.Required_change == 1 || acc.Optional_change == 1))
                {
                    if (a.Type.Equals("int"))
                    {
                        FlowModel <int> f = new FlowModel <int>();
                        f.name     = a.Name;
                        f.required = acc.Required_change;
                        f.type     = a.Type;
                        f.item     = itemMap[a.Name];
                        model.list_int.Add(f);
                    }
                    else
                    {
                        FlowModel <string> f = new FlowModel <string>();
                        f.name     = a.Name;
                        f.required = acc.Required_change;
                        f.type     = a.Type;
                        f.item     = itemMap[a.Name];
                        if (a.Type.Equals("list"))
                        {
                            IList <ListElement> ll  = operation.GetAttributeList(a.Id_attribute);
                            List <string>       str = new List <string>();
                            str.Add(null);
                            foreach (ListElement l in ll)
                            {
                                str.Add(l.Name);
                            }
                            f.list = str;
                        }
                        model.list.Add(f);
                    }
                }
                else if (acc.Read_property == 1)
                {
                    FlowExtension ext = operation.FindExtension(flow.id_flow, a.Id_attribute);
                    if (ext != null)
                    {
                        model.values.Add(a.Id_attribute.ToString() + " = " + ext.Value);
                    }
                }
            }
            ViewBag.Test = model;

            int max = 0;

            foreach (Item i in XmlData.itemList)
            {
                if ((i.location.y + i.size.height) > max)
                {
                    max = (i.location.y + i.size.height);
                }
            }

            max         = max + 70;
            ViewBag.Max = max.ToString() + "px";

            ViewBag.Tekst = "";

            return(View(model));
        }
示例#15
0
 public LinkOption(FlowModel flow, MainUnitViewModel main, BlLink linkViewModel)
 {
     _flow          = flow;
     _main          = main;
     _linkViewModel = linkViewModel;
 }
示例#16
0
 public VCAController(FlowModel flow)
 {
     _flow = flow;
 }
示例#17
0
 public SliderValue(FlowModel flow, BlExtInput extInput)
 {
     _flow     = flow;
     _extInput = extInput;
 }
示例#18
0
        public static bool InsertFlowInfo(FlowModel model, string StepNo, string StepName, string StepActor)
        {
            ArrayList listADD = new ArrayList();
            bool      result  = false;

            try
            {
                #region  增加SQL语句
                StringBuilder sqlflow = new StringBuilder();
                sqlflow.AppendLine("INSERT INTO officedba.Flow");
                sqlflow.AppendLine("		(CompanyCD      ");
                sqlflow.AppendLine("		,DeptID         ");
                sqlflow.AppendLine("		,FlowNo         ");
                sqlflow.AppendLine("		,FlowName         ");
                sqlflow.AppendLine("		,BillTypeFlag         ");
                sqlflow.AppendLine("		,BillTypeCode         ");
                sqlflow.AppendLine("		,UsedStatus         ");
                sqlflow.AppendLine("		,IsMobileNotice     ");
                sqlflow.AppendLine("		,ModifiedDate         ");
                sqlflow.AppendLine("		,ModifiedUserID)        ");
                sqlflow.AppendLine("VALUES                  ");
                sqlflow.AppendLine("		(@CompanyCD,     ");
                sqlflow.AppendLine("		@DeptID ,     ");
                sqlflow.AppendLine("		@FlowNo ,     ");
                sqlflow.AppendLine("		@FlowName ,     ");
                sqlflow.AppendLine("		@BillTypeFlag,     ");
                sqlflow.AppendLine("		@BillTypeCode,     ");
                sqlflow.AppendLine("		@UsedStatus,     ");
                sqlflow.AppendLine("		@IsMobileNotice     ");
                sqlflow.AppendLine("		,@ModifiedDate     ");
                sqlflow.AppendLine("		,@ModifiedUserID)       ");
                SqlCommand comm = new SqlCommand();
                comm.CommandText = sqlflow.ToString();
                comm.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                comm.Parameters.Add(SqlHelper.GetParameter("@DeptID", model.DeptID));
                comm.Parameters.Add(SqlHelper.GetParameter("@FlowNo", model.FlowNo));
                comm.Parameters.Add(SqlHelper.GetParameter("@FlowName", model.FlowName));
                comm.Parameters.Add(SqlHelper.GetParameter("@BillTypeFlag", model.BillTypeFlag));
                comm.Parameters.Add(SqlHelper.GetParameter("@BillTypeCode", model.BillTypeCode));
                comm.Parameters.Add(SqlHelper.GetParameter("@UsedStatus", model.UsedStatus));
                comm.Parameters.Add(SqlHelper.GetParameter("@IsMobileNotice", model.IsMobileNotice));
                comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
                comm.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));
                listADD.Add(comm);
                #endregion

                #region 流程步骤添加SQL语句
                if (!String.IsNullOrEmpty(StepNo) && !String.IsNullOrEmpty(StepName) && !String.IsNullOrEmpty(StepActor))
                {
                    string[] dStepNo    = StepNo.Split(',');
                    string[] dStepName  = StepName.Split(',');
                    string[] dStepActor = StepActor.Split(',');
                    //页面上这些字段都是必填,数组的长度必须是相同的
                    if (dStepNo.Length >= 1)
                    {
                        for (int i = 0; i < dStepNo.Length; i++)
                        {
                            System.Text.StringBuilder cmdsql = new System.Text.StringBuilder();
                            cmdsql.AppendLine("INSERT INTO officedba.FlowStepActor");
                            cmdsql.AppendLine("           (CompanyCD");
                            cmdsql.AppendLine("           ,FlowNo");
                            cmdsql.AppendLine("           ,StepNo");
                            cmdsql.AppendLine("           ,StepName");
                            cmdsql.AppendLine("           ,Actor");
                            cmdsql.AppendLine("           ,ModifiedDate");
                            cmdsql.AppendLine("           ,ModifiedUserID)");
                            cmdsql.AppendLine("     VALUES");
                            cmdsql.AppendLine("           (@CompanyCD");
                            cmdsql.AppendLine("           ,@FlowNo");
                            cmdsql.AppendLine("           ,@StepNo");
                            cmdsql.AppendLine("           ,@StepName");
                            cmdsql.AppendLine("           ,@Actor");
                            cmdsql.AppendLine("           ,@ModifiedDate");
                            cmdsql.AppendLine("           ,@ModifiedUserID)");
                            SqlCommand comms = new SqlCommand();
                            comms.CommandText = cmdsql.ToString();
                            comms.Parameters.Add(SqlHelper.GetParameter("@CompanyCD", model.CompanyCD));
                            comms.Parameters.Add(SqlHelper.GetParameter("@FlowNo", model.FlowNo));
                            if (dStepNo[i].ToString().Length > 0)
                            {
                                if (!string.IsNullOrEmpty(dStepNo[i].ToString().Trim()))
                                {
                                    comms.Parameters.Add(SqlHelper.GetParameter("@StepNo", dStepNo[i].ToString()));
                                }
                            }
                            if (dStepName[i].ToString().Length > 0)
                            {
                                if (!string.IsNullOrEmpty(dStepName[i].ToString().Trim()))
                                {
                                    comms.Parameters.Add(SqlHelper.GetParameter("@StepName", dStepName[i].ToString()));
                                }
                            }
                            if (dStepActor[i].ToString().Length > 0)
                            {
                                if (!string.IsNullOrEmpty(dStepActor[i].ToString().Trim()))
                                {
                                    comms.Parameters.Add(SqlHelper.GetParameter("@Actor", dStepActor[i].ToString()));
                                }
                            }
                            comms.Parameters.Add(SqlHelper.GetParameter("@ModifiedDate", model.ModifiedDate));
                            comms.Parameters.Add(SqlHelper.GetParameter("@ModifiedUserID", model.ModifiedUserID));

                            listADD.Add(comms);
                        }
                    }
                }
                #endregion
                if (SqlHelper.ExecuteTransWithArrayList(listADD))
                {
                    result = true;
                }
                return(result);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#19
0
        /// <summary>
        ///流程信息插入
        /// </summary>
        /// <param name="model">流程信息</param>
        /// <returns>插入成功与否</returns>
        public static bool InsertFlowInfo(FlowModel model, string StepNo, string StepName, string StepActor)
        {
            if (model == null)
            {
                return(false);
            }
            if (model.FlowNo == "")
            {
                return(false);
            }
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];

            try
            {
                bool   succ        = false;
                string loginUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).UserID;

                LogInfoModel logModel = InitLogInfo(model.FlowNo);
                logModel.Element = ConstUtil.LOG_PROCESS_INSERT;

                succ = ApprovalFlowSetDBHelper.InsertFlowInfo(model, StepNo, StepName, StepActor);
                if (!succ)
                {
                    logModel.Remark = ConstUtil.LOG_PROCESS_FAILED;
                }
                else
                {
                    logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS;
                }
                LogDBHelper.InsertLog(logModel);
                return(succ);
            }
            catch (Exception ex)
            {
                WriteSystemLog(userInfo, ex);
                return(false);
            }



            //try
            //{
            //    StringBuilder sqlflow = new StringBuilder();
            //    sqlflow.AppendLine("INSERT INTO officedba.Flow");
            //    sqlflow.AppendLine("		(CompanyCD      ");
            //    sqlflow.AppendLine("		,DeptID         ");
            //    sqlflow.AppendLine("		,FlowNo         ");
            //    sqlflow.AppendLine("		,FlowName         ");
            //    sqlflow.AppendLine("		,BillTypeFlag         ");
            //    sqlflow.AppendLine("		,BillTypeCode         ");
            //    sqlflow.AppendLine("		,UsedStatus         ");
            //    sqlflow.AppendLine("		,ModifiedDate         ");
            //    sqlflow.AppendLine("		,ModifiedUserID)        ");
            //    sqlflow.AppendLine("VALUES                  ");
            //    sqlflow.AppendLine("		('"+model.CompanyCD+"',     ");
            //    sqlflow.AppendLine("		'" + model.DeptID + "',     ");
            //    sqlflow.AppendLine("		'" + model.FlowNo + "',     ");
            //    sqlflow.AppendLine("		'" + model.FlowName + "',     ");
            //    sqlflow.AppendLine("		'" + model.BillTypeFlag + "',     ");
            //    sqlflow.AppendLine("		'" + model.BillTypeCode + "',     ");
            //    sqlflow.AppendLine("		'" + model.UsedStatus + "'     ");
            //    sqlflow.AppendLine("		,getdate()     ");
            //    sqlflow.AppendLine("		,'" +model.ModifiedUserID+ "' )       ");
            //    #region 流程步骤SQL语句拼写
            //    string[] sql = null;
            //    try
            //    {
            //        #region 工艺明细添加SQL语句
            //        if (!string.IsNullOrEmpty(StepName))
            //        {
            //            int sql_index = 0;
            //            string[] Stepno = StepNo.Split(',');
            //            string[] Stepname = StepName.Split(',');
            //            string[] Stepactor = StepActor.Split(',');
            //            sql = new string[Stepname.Length + 1];

            //            if (Stepname.Length >= 1)
            //            {
            //                for (int i = 0; i < Stepname.Length; i++)
            //                {
            //                    System.Text.StringBuilder cmdsql = new System.Text.StringBuilder();
            //                    cmdsql.AppendLine(" Insert into  officedba.FlowStepActor(CompanyCD,FlowNo,StepNo,StepName,Actor,ModifiedDate,ModifiedUserID )");
            //                    cmdsql.AppendLine(" Values('" + model.CompanyCD + "','" + model.FlowNo + "'," + Stepno[i] + ",'" + Stepname[i].ToString() + "','" + Stepactor[i].ToString() + "','" + System.DateTime.Now + "','" + model.ModifiedUserID + "')");
            //                    sql[sql_index] = cmdsql.ToString();
            //                    sql_index++;
            //                }
            //            }

            //            sql[Stepname.Length] = sqlflow.ToString();
            //        #endregion

            //            if (ApprovalFlowSetDBHelper.InsertFlow(sql))
            //            {
            //                result = true;
            //            }
            //        }
            //        else
            //        {
            //            sql = new string[1];
            //            sql[0] = sqlflow.ToString();
            //            if (ApprovalFlowSetDBHelper.InsertFlow(sql))
            //            {
            //                result = true;
            //            }
            //        }
            //        return result;
            //    }
            //    catch (Exception ex)
            //    {
            //        throw ex;
            //    }
            //    #endregion
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
        }
示例#20
0
 public BlAmplifier(FlowModel flow)
 {
     _flow      = flow;
     Location.X = XLocation;
 }
示例#21
0
 public void ChangeTestActionTest(FlowModel _model)
 {
     m_testActionText.text = _model.m_curAction.m_desc;
 }
示例#22
0
 public BlToneControl(FlowModel flow)
 {
     _flow      = flow;
     Location.X = XLocation;
 }
示例#23
0
 public BlSpeakerPeq()
     : base(new MainUnitViewModel())
 {
     _flow = new FlowModel();
 }
示例#24
0
        public async Task PostConfirmation_ValidRequestWithNationalLocations_CreatesApprenticeshipQASubmissionUpdatesQAStatusAndReturnsConfirmation()
        {
            // Arrange
            var providerId = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var standardCode    = 123;
            var standardVersion = 1;
            var standard        = await TestData.CreateStandard(standardCode, standardVersion, standardName : "My standard");

            await User.AsProviderUser(providerId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("Provider 1 rocks");
            flowModel.SetApprenticeshipStandardOrFramework(standard);
            flowModel.SetApprenticeshipDetails(
                marketingInformation: "My apprenticeship",
                website: "http://provider.com/apprenticeship",
                contactTelephone: "01234 5678902",
                contactEmail: "*****@*****.**",
                contactWebsite: "http://provider.com");
            flowModel.SetApprenticeshipLocationType(ApprenticeshipLocationType.EmployerBased);
            flowModel.SetApprenticeshipIsNational(true);
            var mptxInstance = CreateMptxInstance(flowModel);

            Guid apprenticeshipId = default;

            CosmosDbQueryDispatcher.Callback <CreateApprenticeship, Success>(q => apprenticeshipId = q.Id);

            var requestContent = new FormUrlEncodedContentBuilder().ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-confirmation?providerId={providerId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            CosmosDbQueryDispatcher.Verify(mock => mock.ExecuteQuery(It.Is <CreateApprenticeship>(q =>
                                                                                                  q.ApprenticeshipTitle == "My standard" &&
                                                                                                  q.ApprenticeshipType == ApprenticeshipType.StandardCode &&
                                                                                                  q.ContactEmail == "*****@*****.**" &&
                                                                                                  q.ContactTelephone == "01234 5678902" &&
                                                                                                  q.ContactWebsite == "http://provider.com" &&
                                                                                                  q.CreatedByUser.UserId == User.UserId &&
                                                                                                  q.CreatedDate == Clock.UtcNow &&
                                                                                                  q.MarketingInformation == "My apprenticeship" &&
                                                                                                  q.ProviderId == providerId &&
                                                                                                  q.StandardOrFramework.Standard.StandardCode == standardCode &&
                                                                                                  q.StandardOrFramework.Standard.Version == standardVersion &&
                                                                                                  q.Url == "http://provider.com/apprenticeship" &&
                                                                                                  q.Status == 2)));

            SqlQuerySpy.VerifyQuery <CreateApprenticeshipQASubmission, int>(q =>
                                                                            q.Apprenticeships.Single().ApprenticeshipId == apprenticeshipId &&
                                                                            q.Apprenticeships.Single().ApprenticeshipMarketingInformation == "My apprenticeship" &&
                                                                            q.Apprenticeships.Single().ApprenticeshipTitle == "My standard" &&
                                                                            q.ProviderId == providerId &&
                                                                            q.ProviderMarketingInformation == "Provider 1 rocks" &&
                                                                            q.SubmittedByUserId == User.UserId &&
                                                                            q.SubmittedOn == Clock.UtcNow);

            SqlQuerySpy.VerifyQuery <SetProviderApprenticeshipQAStatus, None>(q =>
                                                                              q.ProviderId == providerId && q.ApprenticeshipQAStatus == ApprenticeshipQAStatus.Submitted);

            var doc = await response.GetDocument();

            Assert.Equal(
                "Quality assurance submitted",
                doc.GetElementsByClassName("govuk-panel__title").Single().TextContent.Trim());
        }
示例#25
0
        public static string UpdateFlow(string Flowstr)
        {
            string str = string.Empty;

            try
            {
                DateTime  now  = DateTime.Now;
                FlowModel tb   = JsonConvert.DeserializeObject <FlowModel>(Flowstr);
                tbFlow    Flow = new tbFlow();
                ObjectHelper.CopyValue(tb.Flow, Flow);
                List <tbFlowStep>             FlowStep     = tb.FlowStep;
                List <v_FlowStepUserViewInfo> FlowStepUser = tb.FlowStepUser;
                if (tb == null)
                {
                    throw new Exception("流程数据异常!");
                }
                if (FlowStep == null || FlowStep.Count <= 0)
                {
                    throw new Exception("流程步骤数据异常!");
                }
                if (FlowStepUser == null || FlowStepUser.Count <= 0)
                {
                    throw new Exception("流程步骤数据异常!");
                }
                AchieveDBEntities myDbContext = new AchieveDBEntities();
                tbFlow            newFlow     = myDbContext.tbFlow.Where(p => p.Code == Flow.Code).ToList().FirstOrDefault();
                string[]          keys        = { "Code" };
                ObjectHelper.CopyValueNotKey(Flow, newFlow, keys);
                newFlow.UpdateTime = now;
                if (FlowStep != null && FlowStep.Count > 0)
                {
                    string [] FlowStepCode = new string[FlowStep.Count];
                    int       count        = 0;
                    foreach (var st in FlowStep)
                    {
                        FlowStepCode[count] = st.Code;
                        count++;
                        tbFlowStep temp = myDbContext.tbFlowStep.Where(p => p.Code == st.Code).ToList().FirstOrDefault();
                        if (temp != null)
                        {
                            ObjectHelper.CopyValueNotKey(st, temp, keys);
                            temp.UpdateTime = now;
                        }
                        else
                        {
                            st.FlowCode   = Flow.Code;
                            st.UpdateTime = now;
                            myDbContext.tbFlowStep.Add(st);
                        }
                    }
                    List <tbFlowStep> tempList = myDbContext.tbFlowStep.Where(p => !(FlowStepCode).Contains(p.Code) && p.FlowCode == Flow.Code).ToList();
                    if (tempList != null && tempList.Count > 0)
                    {
                        foreach (var st in tempList)
                        {
                            myDbContext.tbFlowStep.Remove(st);
                        }
                    }
                }

                if (FlowStepUser != null && FlowStepUser.Count > 0)
                {
                    string[] FlowStepUserCode = new string[FlowStepUser.Count];
                    int      count            = 0;
                    foreach (var st in FlowStepUser)
                    {
                        FlowStepUserCode[count] = st.Code;
                        count++;
                        tbFlowStepUser temp = myDbContext.tbFlowStepUser.Where(p => p.Code == st.Code).ToList().FirstOrDefault();
                        if (temp != null)
                        {
                            ObjectHelper.CopyValue(st, temp);
                            temp.UpdateTime = now;
                        }
                        else
                        {
                            st.FlowCode   = Flow.Code;
                            st.UpdateTime = now;
                            tbFlowStepUser newtemp = new tbFlowStepUser();
                            ObjectHelper.CopyValue(st, newtemp);
                            myDbContext.tbFlowStepUser.Add(newtemp);
                        }
                    }
                    List <tbFlowStepUser> tempList = myDbContext.tbFlowStepUser.Where(p => !(FlowStepUserCode).Contains(p.Code) && p.FlowCode == Flow.Code).ToList();
                    if (tempList != null && tempList.Count > 0)
                    {
                        foreach (var st in tempList)
                        {
                            myDbContext.tbFlowStepUser.Remove(st);
                        }
                    }
                }
                myDbContext.SaveChanges();
                str = ResponseHelper.ResponseMsg("1", "保存成功", Flow.Code);
            }
            catch (Exception ex)
            {
                str = ResponseHelper.ResponseMsg("-1", ex.Message, "");
            }

            return(str);
        }
示例#26
0
        public async Task PostConfirmation_ValidRequestWithExistingApprenticeshipRegionsAndVenue_UpdatesApprenticeship()
        {
            // Arrange
            var ukprn            = 12347;
            var providerUserId   = $"{ukprn}-user";
            var adminUserId      = $"admin-user";
            var contactTelephone = "1111 111 1111";
            var contactWebsite   = "https://somerandomprovider.com";
            var marketingInfo    = "Providing Online training";
            var regions          = new List <string> {
                "123"
            };
            var standardCode    = 123;
            var standardVersion = 1;
            var providerId      = await TestData.CreateProvider(apprenticeshipQAStatus : ApprenticeshipQAStatus.NotStarted);

            var user = await TestData.CreateUser(providerUserId, "*****@*****.**", "Provider 1", "Person", providerId);

            var adminUser = await TestData.CreateUser(adminUserId, "*****@*****.**", "admin", "admin", null);

            var standard = await TestData.CreateStandard(standardCode, standardVersion, standardName : "My standard");

            var apprenticeshipId = await TestData.CreateApprenticeship(providerId,
                                                                       standard,
                                                                       createdBy : user,
                                                                       contactEmail : adminUser.Email,
                                                                       contactTelephone : contactTelephone,
                                                                       contactWebsite : contactWebsite,
                                                                       marketingInformation : marketingInfo,
                                                                       locations : new[]
            {
                CreateApprenticeshipLocation.CreateRegions(regions)
            });

            var venueId = await TestData.CreateVenue(providerId);

            await User.AsProviderUser(providerId, ProviderType.Apprenticeships);

            var flowModel = new FlowModel();

            flowModel.SetProviderDetails("Provider 1 rocks");
            flowModel.SetApprenticeshipStandardOrFramework(standard);
            flowModel.SetApprenticeshipDetails(
                marketingInformation: "My apprenticeship",
                website: "http://provider.com/apprenticeship",
                contactTelephone: "01234 5678902",
                contactEmail: "*****@*****.**",
                contactWebsite: "http://provider.com");
            flowModel.SetApprenticeshipLocationType(ApprenticeshipLocationType.ClassroomBasedAndEmployerBased);
            flowModel.SetApprenticeshipLocationRegionIds(new[]
            {
                "E06000001", // County Durham
                "E10000009"  // Dorset
            });
            flowModel.SetApprenticeshipId(apprenticeshipId);
            flowModel.SetClassroomLocationForVenue(
                venueId,
                originalVenueId: null,
                radius: 5,
                deliveryModes: new[] { ApprenticeshipDeliveryMode.BlockRelease });
            var mptxInstance = CreateMptxInstance(flowModel);

            var requestContent = new FormUrlEncodedContentBuilder().ToContent();

            // Act
            var response = await HttpClient.PostAsync(
                $"new-apprenticeship-provider/apprenticeship-confirmation?providerId={providerId}&ffiid={mptxInstance.InstanceId}",
                requestContent);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);

            CosmosDbQueryDispatcher.Verify(mock => mock.ExecuteQuery(It.Is <UpdateApprenticeship>(q =>
                                                                                                  q.ApprenticeshipLocations.Any(l =>
                                                                                                                                l.ApprenticeshipLocationType == ApprenticeshipLocationType.ClassroomBased &&
                                                                                                                                l.DeliveryModes.Single() == ApprenticeshipDeliveryMode.BlockRelease &&
                                                                                                                                l.Radius == 5 &&
                                                                                                                                l.VenueId == venueId) &&
                                                                                                  q.ApprenticeshipLocations.Any(l =>
                                                                                                                                l.ApprenticeshipLocationType == ApprenticeshipLocationType.EmployerBased &&
                                                                                                                                l.DeliveryModes.Single() == ApprenticeshipDeliveryMode.EmployerAddress &&
                                                                                                                                l.National == false &&
                                                                                                                                l.VenueId == null &&
                                                                                                                                l.Regions.Contains("E06000001") &&
                                                                                                                                l.Regions.Contains("E10000009")))));
        }
示例#27
0
 public LspLeftHeader(int line, CardModel card, MainUnitModel main)
     : base(0, line, card, main)
 {
     _flow = card.Flows.Skip(line).FirstOrDefault();
 }