Beispiel #1
0
        public void LineGetPreferredWidthTestWithNoNull()
        {
            // Setup
            var profiles          = new List <LineProfile>();
            var dimensionsMapping = new Dictionary <ObjectAlign, double?>()
            {
                { ObjectAlign.l, 20 },
                { ObjectAlign.c, 30 },
                { ObjectAlign.r, 40 },
            };

            var menuHandlerMock = SetUpMenuHandlerMock(profiles, ((lineProfile, mock) =>
            {
                mock.Setup(e => e.GetPreferredWidth()).Returns(dimensionsMapping[lineProfile.Single().align]);
            }));

            var profile = new LineProfile()
            {
                GenerateObjectProfile(ObjectAlign.l),
                GenerateObjectProfile(ObjectAlign.c),
                GenerateObjectProfile(ObjectAlign.r),
            };

            this.lineUnderTest.Prepare(profile, menuHandlerMock.Object);

            // Act
            var width = this.lineUnderTest.GetPreferredWidth();

            // Assert
            Assert.AreEqual(100, width);
        }
Beispiel #2
0
        public void LineLogin([FromQuery] LineAuthorizeModel lineAuthorize)
        {
            string Uri = string.Empty;

            try
            {
                #region --登入發生錯誤--
                if (lineAuthorize.Error != null)
                {
                    //TODO:錯誤處理
                    Uri = "/Home/Error";
                }
                #endregion
                else
                {
                    LineLoginBLL lineLoginBLL = new LineLoginBLL(_settings, _resultModel, _httpClientFactory);
                    LineProfile  Data         = lineLoginBLL.GetLineAccount(lineAuthorize);
                    _sessionHelper.SetSession("Nickname", Data.displayName);
                    Uri = "/Home/Wellcome";
                }
            }
            catch (Exception ex)
            {
                Uri = "/Home/Error";
            }
            finally
            {
                Response.Redirect(Uri);
            }
        }
Beispiel #3
0
        private void AddAdditionalField(string key, string value)
        {
            var fieldMeta = this.supportedFields.Fields.FirstOrDefault(f => f.Id.Equals(key));

            if (fieldMeta != null)
            {
                var panel = (PanelObject)this.loadedMenu.GetFrameById(ProfileTabLabels.AdditionalFieldsPanel);

                var numberOfLines = panel.GetNumElements();
                if (numberOfLines == 0 || panel.GetElement(numberOfLines - 1).GetNumElements() == 2)
                {
                    var profile     = fieldMeta.GenerateProfile(ObjectAlign.l);
                    var lineProfile = new LineProfile()
                    {
                        profile
                    };
                    var newLine = (ILine)this.menuHandler.CreateRegion(lineProfile);
                    newLine.Prepare(lineProfile, this.menuHandler);
                    panel.AddElement(newLine);
                }
                else
                {
                    var line    = panel.GetElement(numberOfLines - 1);
                    var profile = fieldMeta.GenerateProfile(ObjectAlign.r);

                    line.AddObjectByProfile(profile, this.menuHandler);
                }

                this.loadedMenu.UpdatePosition();

                var obj = (IMenuObjectWithValue)panel.GetFrameById(fieldMeta.Id);
                obj.SetValue(value);
                this.shownAdditionalFields.Add(key);
            }
        }
Beispiel #4
0
 private static void GenerateAndAddObjectProfile(LineProfile parentProfile, ObjectAlign align, bool skip = false)
 {
     if (!skip)
     {
         parentProfile.Add(GenerateObjectProfile(align));
     }
 }
Beispiel #5
0
 public void Insert(LineProfile profile)
 {
     using (conn = new SqlConnection(connectionString))
     {
         string userid = HttpContext.Current.User.Identity.GetUserId();
         string sql    = "INSERT INTO StoreManager(LineID, AspNetUserId,Name,PictureUrl,Status) VALUES ( @LineID, @AspNetUserId,@Name,@PictureUrl,@Status)";
         conn.Execute(sql, new { LineID = profile.userId, AspNetUserId = userid, Name = profile.displayName, PictureUrl = profile.pictureUrl, Status = true });
     }
 }
        public static LineProfile UseTokenToGetProfile(string token)
        {
            var client  = new RestClient("https://api.line.me/v2/profile");
            var request = new RestRequest(Method.GET);

            request.AddHeader("Authorization", "Bearer " + token);
            IRestResponse response       = client.Execute(request);
            LineProfile   exangeResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <LineProfile>(response.Content);

            return(exangeResponse);
        }
Beispiel #7
0
        protected override void OnUpdate()
        {
            var triangleBuffer     = GetBufferFromEntity <MeshTriangleData>();
            var vertexBuffer       = GetBufferFromEntity <MeshVertexData>();
            var knotBuffer         = GetBufferFromEntity <LineKnotData>(true);
            var defaultLineProfile = LineProfile.Default();

            var lineEntities = lineQuery.ToEntityArrayAsync(Allocator.TempJob, out var jh1);
            var lines        = lineQuery.ToComponentDataArrayAsync <Line>(Allocator.TempJob, out var jh2);

            Dependency = JobHandle.CombineDependencies(Dependency, jh1, jh2);

            var joinEntities = lineJoinsQuery.ToEntityArrayAsync(Allocator.TempJob, out jh1);
            var joinPoints   =
                lineJoinsQuery.ToComponentDataArrayAsync <LineJoinPoint>(Allocator.TempJob, out jh2);

            Dependency = JobHandle.CombineDependencies(Dependency, jh1, jh2);

            var ecb = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent();

            Dependency = Entities
                         .WithDeallocateOnJobCompletion(lineEntities)
                         .WithDeallocateOnJobCompletion(lines)
                         .WithDeallocateOnJobCompletion(joinEntities)
                         .WithDeallocateOnJobCompletion(joinPoints)
                         .ForEach((Entity entity, int entityInQueryIndex, ref MeshBuildData data) =>
            {
                ecb.DestroyEntity(entityInQueryIndex, entity);
                if (!lineEntities.Contains(data.LineEntity))
                {
                    return;
                }

                var line       = lines[lineEntities.IndexOf <Entity>(data.LineEntity)];
                var joinPointA =
                    joinPoints[joinEntities.IndexOf <Entity>(line.JoinPointA)];
                var joinPointB =
                    joinPoints[joinEntities.IndexOf <Entity>(line.JoinPointB)];

                new LineMeshRebuildJob
                {
                    Knots      = knotBuffer[data.LineEntity],
                    Triangles  = triangleBuffer[data.LineEntity],
                    VertexData = vertexBuffer[data.LineEntity],
                    // TODO: Load line profile
                    Profile       = defaultLineProfile,
                    EndDirections = new float3x2(joinPointA.Direction, joinPointB.Direction)
                }.Execute();
                ecb.AddComponent <MeshUpdated>(entityInQueryIndex, data.LineEntity);
            }).Schedule(Dependency);
            LineEndSimBufferSystem.Instance.AddJobHandleForProducer(Dependency);
        }
Beispiel #8
0
        protected override void OnUpdate()
        {
            var joinPoints   = GetComponentDataFromEntity <LineJoinPoint>(true);
            var lines        = GetComponentDataFromEntity <Line>(true);
            var knotBuffers  = GetBufferFromEntity <LineKnotData>(true);
            var linesToCheck = mergeCheckQuery.ToEntityArray(Allocator.TempJob);

            Dependency.Complete();
            LineEndSimBufferSystem.Instance
            .CreateCommandBuffer()
            .RemoveComponent <MergeCheck>(mergeCheckQuery);

            Dependency = new LineMergeJob
            {
                Lines          = lines,
                LineEntities   = linesToCheck,
                LineJoinPoints = joinPoints,
                LineProfiles   = GetComponentDataFromEntity <LineProfile>(),
                LineKnotData   = knotBuffers,
                Ecb            = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                DefaultProfile = LineProfile.Default()
            }.Schedule(linesToCheck.Length, 4, Dependency);

            // TODO only trigger this when lines are merged
            Dependency = new LineTriggerMeshRebuildJob
            {
                Ecb           = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                Lines         = GetComponentDataFromEntity <Line>(true),
                LineProfiles  = GetComponentDataFromEntity <LineProfile>(true),
                LineEntities  = linesToCheck,
                DefaultPrefab = LineDefaultMeshBuilderSystem.Prefab
            }.Schedule(linesToCheck.Length, 4, Dependency);

            Dependency = new LineSetDirtyJob
            {
                Ecb          = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                LineEntities = linesToCheck
            }.Schedule(linesToCheck.Length, 4, Dependency);

            Dependency = new DeallocateJob <Entity>
            {
                NativeArray1 = linesToCheck
            }.Schedule(Dependency);

            LineEndSimBufferSystem.Instance.AddJobHandleForProducer(Dependency);
        }
Beispiel #9
0
        private void SetUpWithElements(double objectSpacing, params IMenuObject[] elements)
        {
            var profile = new LineProfile();

            profile.AddRange(elements.Select(e => new Mock <IObjectProfile>().Object));

            var menuHandlerMock = new Mock <IMenuHandler>();
            var layoutSettings  = new LayoutSettings()
            {
                lineSpacing = 5, objectSpacing = objectSpacing
            };

            menuHandlerMock.Setup(mh => mh.Layout).Returns(layoutSettings);
            menuHandlerMock.Setup(mh => mh.CreateRegion(It.IsAny <IObjectProfile>()))
            .Returns(new Func <IObjectProfile, IMenuRegion>(p => elements[profile.IndexOf(p)]));

            this.alignedBlockUnderTest.Prepare(profile, menuHandlerMock.Object);
        }
Beispiel #10
0
        public void LineSetPositionTestWithFlexibleHeight()
        {
            var dimensionsMapping = new Dictionary <ObjectAlign, double?>();

            dimensionsMapping.Add(ObjectAlign.l, null);
            dimensionsMapping.Add(ObjectAlign.c, null);
            dimensionsMapping.Add(ObjectAlign.r, null);

            var blockMocks      = new Dictionary <ObjectAlign, Mock <IAlignedBlock> >();
            var menuHandlerMock = SetUpMenuHandlerMock(null, ((lineProfile, mock) =>
            {
                var align = lineProfile.SingleOrDefault()?.align;
                if (align == null)
                {
                    return;
                }

                blockMocks.Add((ObjectAlign)align, mock);
                mock.Setup(e => e.GetPreferredHeight()).Returns(dimensionsMapping[(ObjectAlign)align]);
                mock.Setup(e => e.GetPreferredWidth()).Returns(10);
            }));

            var profile = new LineProfile();

            GenerateAndAddObjectProfile(profile, ObjectAlign.l);
            GenerateAndAddObjectProfile(profile, ObjectAlign.c);
            GenerateAndAddObjectProfile(profile, ObjectAlign.r);

            this.lineUnderTest.Prepare(profile, menuHandlerMock.Object);

            var parentMock = new Mock <IFrame>();

            // Act
            this.lineUnderTest.SetPosition(parentMock.Object, 2, 3, 100, 30);

            // Assert
            this.lineFrameMock.Verify(f => f.SetParent(parentMock.Object));
            this.lineFrameMock.Verify(f => f.SetWidth(100));
            this.lineFrameMock.Verify(f => f.SetHeight(30));
            this.lineFrameMock.Verify(f => f.SetPoint(FramePoint.TOPLEFT, parentMock.Object, FramePoint.TOPLEFT, 2, -3));
            blockMocks[ObjectAlign.l].Verify(b => b.SetPosition(this.lineFrameMock.Object, 0, 0, 10, 30));
            blockMocks[ObjectAlign.c].Verify(b => b.SetPosition(this.lineFrameMock.Object, 45, 0, 10, 30));
            blockMocks[ObjectAlign.r].Verify(b => b.SetPosition(this.lineFrameMock.Object, 90, 0, 10, 30));
        }
        public ActionResult LineCallback(string code, string state)
        {
            if (state == Properties.Settings.Default.Line_State_code)
            {
                #region Api變數宣告
                WebClient wc = new WebClient();
                wc.Encoding = Encoding.UTF8;
                wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                string result           = string.Empty;
                NameValueCollection nvc = new NameValueCollection();
                #endregion
                try
                {
                    //取回Token
                    string ApiUrl_Token = "https://api.line.me/oauth2/v2.1/token";
                    nvc.Add("grant_type", "authorization_code");
                    nvc.Add("code", code);
                    nvc.Add("redirect_uri", "http://localhost:61177" + Url.Action("LineCallback", "Login"));
                    nvc.Add("client_id", Properties.Settings.Default.Line_Channel_ID);
                    nvc.Add("client_secret", Properties.Settings.Default.Line_Channel_Secret);
                    string         JsonStr  = Encoding.UTF8.GetString(wc.UploadValues(ApiUrl_Token, "POST", nvc));
                    LineLoginToken ToKenObj = JsonConvert.DeserializeObject <LineLoginToken>(JsonStr);
                    wc.Headers.Clear();

                    //取回User Profile
                    string ApiUrl_Profile = "https://api.line.me/v2/profile";
                    wc.Headers.Add("Authorization", "Bearer " + ToKenObj.access_token);
                    string      UserProfile = wc.DownloadString(ApiUrl_Profile);
                    LineProfile ProfileObj  = JsonConvert.DeserializeObject <LineProfile>(UserProfile);

                    //return RedirectToAction("UserProfile", "Login", new { displayName = ProfileObj.displayName, pictureUrl = ProfileObj.pictureUrl });
                    ViewBag.DisplayName = ProfileObj.displayName;
                    ViewBag.PictureUrl  = ProfileObj.pictureUrl;
                    return(View());
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                    throw;
                }
            }
            return(View());
        }
Beispiel #12
0
        public void Execute(int index)
        {
            // If index is different, this means this line entity was already in the
            // array, there for this is a duplicate and we can skip it.
            if (LineEntities.IndexOf <Entity>(LineEntities[index]) != index)
            {
                return;
            }

            newKnotData = Ecb.SetBuffer <LineKnotData>(index, LineEntities[index]);

            line = Lines[LineEntities[index]];

            lineProfile = LineProfiles.Exists(line.Profile) ? LineProfiles[line.Profile] : LineProfile.Default();

            var b1 = BezierData[index].B1;
            var b2 = BezierData[index].B2;

            SetKnotsForBezier(b1);

            if (!b1.c2.IsCloseTo(b2.c2, lineProfile.KnotSpacing))
            {
                SetKnotsForBezier(new float3x3(b1.c2, math.lerp(b1.c2, b2.c2, 0.5f), b2.c2));
            }

            SetKnotsForBezier(b2, true);

            AdjustHeight(HeightBezierData[index]);

            var jpA = LineJoinPoints[index].A;
            var jpB = LineJoinPoints[index].B;

            if (newKnotData.Length > 0)
            {
                jpA.Pivot = newKnotData[0].Position;
                jpB.Pivot = newKnotData[newKnotData.Length - 1].Position;
            }

            LineJoinPoints[index] = new JoinPointPair {
                A = jpA, B = jpB
            };
        }
Beispiel #13
0
        public void LinePrepareTest()
        {
            // Setup
            var profiles        = new List <LineProfile>();
            var menuHandlerMock = SetUpMenuHandlerMock(profiles);
            var c1 = GenerateObjectProfile(ObjectAlign.c);
            var c2 = GenerateObjectProfile(ObjectAlign.c);
            var c3 = GenerateObjectProfile(ObjectAlign.c);
            var l1 = GenerateObjectProfile(ObjectAlign.l);
            var l2 = GenerateObjectProfile(ObjectAlign.l);
            var r1 = GenerateObjectProfile(ObjectAlign.r);
            var r2 = GenerateObjectProfile(ObjectAlign.r);

            var profile = new LineProfile()
            {
                c1, l1, c2, r1, c3, r2, l2
            };

            // Act
            this.lineUnderTest.Prepare(profile, menuHandlerMock.Object);

            // Assert
            Assert.AreEqual(3, profiles.Count);
            var leftProfile = profiles[0];

            Assert.AreEqual(2, leftProfile.Count);
            Assert.AreEqual(l1, leftProfile[0]);
            Assert.AreEqual(l2, leftProfile[1]);
            var centerProfile = profiles[1];

            Assert.AreEqual(3, centerProfile.Count);
            Assert.AreEqual(c1, centerProfile[0]);
            Assert.AreEqual(c2, centerProfile[1]);
            Assert.AreEqual(c3, centerProfile[2]);
            var rightProfile = profiles[2];

            Assert.AreEqual(2, rightProfile.Count);
            Assert.AreEqual(r1, rightProfile[0]);
            Assert.AreEqual(r2, rightProfile[1]);
        }
    public LineProfile GetUserProfile(Source eventSource, string sourceType, string channelAccessToken)
    {
        LineProfile result = null;

        switch (sourceType)
        {
        case "group":
            result = new LineGroupUserProfile(eventSource, channelAccessToken);
            break;

        case "room":
            result = new LineRoomUserProfile(eventSource, channelAccessToken);
            break;

        case "user":
            result = new LineUserProfile(eventSource, channelAccessToken);
            break;

        default:
            break;
        }

        return(result);
    }
Beispiel #15
0
        public static void InsertStoreManager(LineProfile profile)
        {
            var sm_repo = new StoreManagerRepository();

            sm_repo.Insert(profile);
        }
Beispiel #16
0
        protected override void OnUpdate()
        {
            var eventCount = eventQuery.CalculateEntityCount();

            var lineJoinPoints =
                new NativeArray <JoinPointPair>(eventCount, Allocator.TempJob);

            var eventData =
                eventQuery.ToComponentDataArrayAsync <NewLineUpdateEvent>(
                    Allocator.TempJob, out var jh1);

            var joinPoints = GetComponentDataFromEntity <LineJoinPoint>();


            var lineEntities = new NativeArray <Entity>(eventCount, Allocator.TempJob);

            Dependency = new GatherLineWithJoinPointData
            {
                EventData      = eventData,
                JoinPoints     = joinPoints,
                LineJoinPoints = lineJoinPoints,
                LineEntities   = lineEntities,
                Lines          = GetComponentDataFromEntity <Line>()
            }.Schedule(eventCount, 4, JobHandle.CombineDependencies(Dependency, jh1));

            // This job only runs if UpdateJoinPoints is set in event data
            Dependency = new NewLineGetUpdatedJoinPoints
            {
                Ecb            = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                EventData      = eventData,
                LineJoinPoints = lineJoinPoints,
                JoinPoints     = joinPoints,
                Lines          = GetComponentDataFromEntity <Line>()
            }.Schedule(eventCount, 4, Dependency);

            var updatedNewLines = new NativeArray <NewLine>(eventCount, Allocator.TempJob);

            Dependency = new NewLineUpdateModifiersJob
            {
                Ecb             = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                NewLines        = GetComponentDataFromEntity <NewLine>(),
                LineEntities    = lineEntities,
                LineJoinPoints  = lineJoinPoints,
                UpdateEvents    = eventData,
                UpdatedNewLines = updatedNewLines
            }.Schedule(eventCount, 4, Dependency);

            var heightBeziers = new NativeArray <float2x4>(eventCount, Allocator.TempJob);

            Dependency = new NewLineCreateHeightBezierJob
            {
                UpdatedNewLines = updatedNewLines,
                LineJoinPoints  = lineJoinPoints,
                HeightBeziers   = heightBeziers
            }.Schedule(eventCount, 4, Dependency);

            var bezierData = new NativeArray <BezierData>(eventCount, Allocator.TempJob);

            Dependency = new NewLineGetBezierJob
            {
                BezierData     = bezierData,
                JoinPoints     = GetComponentDataFromEntity <LineJoinPoint>(),
                LineTool       = GetSingleton <LineTool>(),
                LineJoinPoints = lineJoinPoints
            }.Schedule(eventCount, 4, Dependency);

            var boundsArray = new NativeArray <float3x2>(eventCount, Allocator.TempJob);

            Dependency = new NewLineGetBoundsFromBezierJob
            {
                BezierData  = bezierData,
                BoundsArray = boundsArray
            }.Schedule(eventCount, 4, Dependency);

            Dependency = new NewLineUpdateLineEntityJob
            {
                LineEntities   = lineEntities,
                BoundsArray    = boundsArray,
                Lines          = GetComponentDataFromEntity <Line>(true),
                LineProfiles   = GetComponentDataFromEntity <LineProfile>(),
                Ecb            = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                DefaultProfile = LineProfile.Default()
            }.Schedule(eventCount, 4, Dependency);

            Dependency = new NewLineGenerateKnotsJob
            {
                Ecb              = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                BezierData       = bezierData,
                HeightBezierData = heightBeziers,
                KnotData         = GetBufferFromEntity <LineKnotData>(),
                LineEntities     = lineEntities,
                LineProfiles     = GetComponentDataFromEntity <LineProfile>(),
                LineJoinPoints   = lineJoinPoints,
                Lines            = GetComponentDataFromEntity <Line>()
            }.Schedule(eventCount, 4, Dependency);

            Dependency = new NewLineUpdateJoinPointsJob
            {
                Ecb            = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                LineEntities   = lineEntities,
                Lines          = GetComponentDataFromEntity <Line>(),
                LineJoinPoints = lineJoinPoints
            }.Schedule(eventCount, 4, Dependency);

            Dependency = new LineSetDirtyJob
            {
                LineEntities = lineEntities,
                Ecb          = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent()
            }.Schedule(eventCount, 4, Dependency);

            Dependency = new LineTriggerMeshRebuildJob
            {
                Ecb           = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(),
                LineEntities  = lineEntities,
                LineProfiles  = GetComponentDataFromEntity <LineProfile>(),
                Lines         = GetComponentDataFromEntity <Line>(true),
                DefaultPrefab = LineDefaultMeshBuilderSystem.Prefab
            }.Schedule(eventCount, 4, Dependency);

            new DeallocateJob <Entity, JoinPointPair, NewLineUpdateEvent, float3x2>
            {
                NativeArray1 = lineEntities,
                NativeArray2 = lineJoinPoints,
                NativeArray3 = eventData,
                NativeArray4 = boundsArray
            }.Schedule(Dependency);

            new DeallocateJob <NewLine, float2x4, BezierData>
            {
                NativeArray1 = updatedNewLines,
                NativeArray2 = heightBeziers,
                NativeArray3 = bezierData
            }.Schedule(Dependency);

            LineEndSimBufferSystem.Instance.CreateCommandBuffer().DestroyEntity(eventQuery);

            LineEndSimBufferSystem.Instance.AddJobHandleForProducer(Dependency);
        }
Beispiel #17
0
        void button1_Click(object sender, ImageClickEventArgs e)
        {
            //System.Web.Security.FormsAuthentication.RedirectFromLoginPage(this.UserID.Text, false);

            String ip1 = KIPBU.GetIPs();

            if (String.IsNullOrEmpty(ip1) == false)
            {
                String[]      ips   = ip1.Split(',');
                List <String> list1 = new List <string>();
                foreach (String m in ips)
                {
                    if (list1.Contains(m) == false)
                    {
                        list1.Add(m);
                    }
                }

                String soureceIP = Request.UserHostAddress;
                if (list1.Contains(soureceIP))
                {
                    if (String.IsNullOrEmpty(this.UserID.Text) == false &&
                        String.IsNullOrEmpty(this.PassWord.Text) == false)
                    {
                        MyUserName user1 = new MyUserName();
                        bool       succ  = user1.Login(this.UserID.Text, this.PassWord.Text);
                        if (succ)
                        {
                            FrameLib.UserID   = this.UserID.Text;
                            FrameLib.DepartID = "DepartID";



                            //基础数据初始化
                            //基础数据发生变化时,重写这些数据;

                            ChexianBianZhuData.Init();
                            LiChengProfile.Init();
                            LiChengJianRate.Init();
                            JiaKuaiProfile.Init();
                            LineProfile.Init();
                            // QianYinFeeProfile.Init();
                            CheXianProfile.Init();
                            HighTrainProfile.Init();
                            TrainLineKindProfile.Init();
                            TrainProfile.Init();
                            PersonGZProfile.Init();
                            RiChangFeeProfile.Init();
                            A2A3FeeProfile.Init();

                            //调整夏冬切换的线路
                            TrainLine.ExchangeSpringAndWinter();

                            //处理系统的升级
                            AppCode.Upgrade.Go();

                            Response.Redirect("TrainWeb/MainFrame.aspx", true);
                        }
                        else
                        {
                            JAjax.Alert("错误:用户名或密码不正确!");
                        }
                    }
                }
                else
                {
                    Response.Redirect("/GenericErrorPage.htm", true);
                }
            }
            else
            {
                Response.Redirect("/GenericErrorPage.htm", true);
            }
        }
Beispiel #18
0
        private void PerformSetPositionTestWithWidth(Tuple <double?, double?, double?> widths, Tuple <double, double, double> expectedXOff, Tuple <double, double, double> expectedWidths)
        {
            // Setup
            this.lineUnderTest = new Line(new Mock <IWrapper>().Object);
            var profiles          = new List <LineProfile>();
            var dimensionsMapping = new Dictionary <ObjectAlign, double?>();

            dimensionsMapping.Add(ObjectAlign.l, widths.Item1);
            dimensionsMapping.Add(ObjectAlign.c, widths.Item2);
            dimensionsMapping.Add(ObjectAlign.r, widths.Item3);

            var blockMocks      = new Dictionary <ObjectAlign, Mock <IAlignedBlock> >();
            var menuHandlerMock = SetUpMenuHandlerMock(profiles, ((lineProfile, mock) =>
            {
                var align = lineProfile.SingleOrDefault()?.align;
                if (align == null)
                {
                    return;
                }

                blockMocks.Add((ObjectAlign)align, mock);
                mock.Setup(e => e.GetPreferredWidth()).Returns(dimensionsMapping[(ObjectAlign)align]);
                mock.Setup(e => e.GetPreferredHeight()).Returns(15);
            }));

            var profile = new LineProfile();

            GenerateAndAddObjectProfile(profile, ObjectAlign.l, widths.Item1 == 0);
            GenerateAndAddObjectProfile(profile, ObjectAlign.c, widths.Item2 == 0);
            GenerateAndAddObjectProfile(profile, ObjectAlign.r, widths.Item3 == 0);
            this.lineUnderTest.Prepare(profile, menuHandlerMock.Object);

            var parentMock = new Mock <IFrame>();

            // Act
            this.lineUnderTest.SetPosition(parentMock.Object, 0, 0, 100, 15);

            // Assert
            foreach (var blockMockPair in blockMocks)
            {
                blockMockPair.Value.Verify(
                    b =>
                    b.SetPosition(
                        It.IsAny <IFrame>(),
                        It.IsAny <double>(),
                        It.IsAny <double>(),
                        It.IsAny <double>(),
                        It.IsAny <double>()),
                    Times.Once(),
                    $"No invocations for align '{blockMockPair.Key}'. Widths: {widths.Item1}, {widths.Item2}, {widths.Item3}.");
                var xOff  = SelectFromTuple(expectedXOff, blockMockPair.Key);
                var width = SelectFromTuple(expectedWidths, blockMockPair.Key);
                blockMockPair.Value.Verify(
                    b =>
                    b.SetPosition(
                        this.lineFrameMock.Object,
                        xOff,
                        0,
                        width,
                        15),
                    Times.Once(),
                    $"Incorrect values for align '{blockMockPair.Key}'. Widths: {widths.Item1}, {widths.Item2}, {widths.Item3}."
                    + $"\nExpected (Object, {xOff}, 0, {width}, 15)");
            }
        }