Esempio n. 1
0
        public void NewTest()
        {
            XRay xray = new XRay();

            xray.ImageId = 1;
            xray.UserId  = "";
            xray.Title   = "title";
            var imageFile = new Mock <HttpPostedFileBase>();

            imageFile.Setup(m => m.FileName).Returns("filename");
            xray.ImageFile = imageFile.Object;
            var dbSetMock       = new Mock <DbSet <XRay> >();
            var dbContextMock   = new Mock <ApplicationDbContext>();
            var fakeIdentity    = new GenericIdentity("User");
            var principal       = new GenericPrincipal(fakeIdentity, null);
            var fakeHttpContext = new Mock <HttpContextBase>();

            fakeHttpContext.Setup(t => t.User).Returns(principal);
            var controllerContext = new Mock <ControllerContext>();

            controllerContext.Setup(t => t.HttpContext).Returns(fakeHttpContext.Object);
            dbSetMock.Setup(m => m.Add(xray));
            dbContextMock.Setup(m => m.XRays).Returns(dbSetMock.Object);
            dbContextMock.Setup(m => m.XRays.Add(xray));
            XRayController controller = new XRayController(dbContextMock.Object, new TestPathProvider());

            controller.ControllerContext = controllerContext.Object;
            controller.New(xray);
            dbContextMock.Verify(m => m.XRays.Add(xray), Times.Once());
        }
Esempio n. 2
0
        static void Main()
        {
            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                string strd = System.IO.Path.Combine(FDHelper.RunningDir(),
                                                     System.IO.Path.GetFileName(
                                                         FDHelper.RgGetUserProfilePath()));


                var isRunCheckDigestInfo = false;
                if (FDHelper.RgGetTechlinkAppDataPath() == string.Empty || FDHelper.RgGetUserProfilePath() == string.Empty || !System.IO.File.Exists(strd))
                {
                    isRunCheckDigestInfo = true;
                    Application.Run(new frmCheckDigestInfo());
                }
                else
                {
                    var bone   = BoneReader.GetBoneInfo(FDHelper.RgGetUserProfilePath());
                    var coccyx =
                        BoneReader.GetBoneInfo(strd);

                    if (bone.Length == 0)
                    {
                        isRunCheckDigestInfo = true;
                        Application.Run(new frmCheckDigestInfo());
                    }
                    else
                    {
                        var s   = XRayController.TranslateBoneInformation(bone);
                        var coc = XRayController.TranslateBoneInformation(coccyx);

                        string[] ss  = s.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                        string[] sss = coc.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                        StringBuilder sb = new StringBuilder();

                        for (int i = 0; i < 6; i++)
                        {
                            sb.AppendLine(ss[i]);
                        }

                        // Set company name
                        if (ss[1] != null)
                        {
                            GlobalInfo.CompanyName = ss[1].ToString();
                        }

                        var xray  = XRayController.CreateFeatureOfHuman(sb.ToString());
                        var xray1 = XRayController.CreateFeatureOfHuman(xray);

                        var ts = FDHelper.RgGetTimeStamp().ToString();

                        if (sss.Length > 1 && ts == sss[1] && sss[0] == xray1)
                        {
                            Coccyx.IsAtTheEndOfCoccyx = true;
                        }
                    }
                }

                if (Coccyx.IsAtTheEndOfCoccyx)
                {
                    RegisterSuccess();
                }
                else
                {
                    //MessageBox.Show("Bạn chưa đăng ký sử dụng phần mềm!");
                    //Application.Exit();
                    if (!isRunCheckDigestInfo)
                    {
                        Application.Run(new frmCheckDigestInfo());
                    }
                    RegisterSuccess();
                }
                mutex.ReleaseMutex();
            }
            else
            {
                //If the application is started, show the message to warning and...
                MessageBox.Show("GS1 đã được khởi động. Bạn hãy kiểm tra lại cửa sổ đang mở!", "ECustom",
                                MessageBoxButtons.OK, MessageBoxIcon.Stop);
                //Then post a message to show the opened windows
                NativeMethods.PostMessage(
                    (IntPtr)NativeMethods.HWND_BROADCAST,
                    NativeMethods.WM_SHOWME,
                    IntPtr.Zero,
                    IntPtr.Zero);
            }
        }