Example #1
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);
            }
        }