Example #1
0
 public static bool SetLocalTimeByStr(string timestr)
 {
     try
     {
         bool       flag    = false;
         SystemTime sysTime = new SystemTime();
         DateTime   dt      = Convert.ToDateTime(timestr);
         sysTime.wYear   = Convert.ToUInt16(dt.Year);
         sysTime.wMonth  = Convert.ToUInt16(dt.Month);
         sysTime.wDay    = Convert.ToUInt16(dt.Day);
         sysTime.wHour   = Convert.ToUInt16(dt.Hour);
         sysTime.wMinute = Convert.ToUInt16(dt.Minute);
         sysTime.wSecond = Convert.ToUInt16(dt.Second);
         try
         {
             flag = SetSystemDateTime.SetLocalTime(ref sysTime);
         }
         catch (Exception e)
         {
             Console.WriteLine("SetSystemDateTime函数执行异常" + e.Message);
         }
         return(flag);
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #2
0
        private void frmFVSCell_Visteon_Load(object sender, EventArgs e)
        {
            notifyIcon.Text = "IRAP-FVS 线边客户端";

            WindowState = FormWindowState.Maximized;

            //pnlTop.Height = Height / 2;
            //pnlFirstQuadrant.Width = pnlTop.Width / 100 * 48;
            //pnlThirdQuadrant.Width = pnlBotton.Width / 100 * 45;

            splitContainerBody.SplitterPosition = splitContainerBody.Width / 100 * 45;

            int    errCode = 0;
            string errText = "";

            #region 获取服务器的当前时间,并设置当前的系统时间
            IRAPSystemClient.Instance.sfn_GetServerDateTime(
                ref serverTime,
                out errCode,
                out errText);
            if (errCode == 0)
            {
                SetSystemDateTime.SetSystemTime(serverTime);
            }
            #endregion

            HookStart();

            RefreshProductionLineInfo();
        }
Example #3
0
 private void QueryServerTime()
 {
     if (IsServerTimeChecked)
     {
         return;
     }
     try
     {
         var serverTime = GetDateTime(binanceClient.GetServerTime().Result.ServerTime);
         if ((DateTime.Now - serverTime).TotalSeconds >= 0.5)
         {
             Program.logger.LogInfo("Binance接口获取时间比本地时间慢超过0.5秒,本地时间{0}, Server时间{1}");
             SetSystemDateTime.SetLocalTimeByStr(serverTime.ToString());
             Program.logger.LogInfo("自动修正后本地时间{0}", DateTime.Now);
         }
         else
         {
             Program.logger.LogInfo("Binance接口获取时间{1},本地时间{2},时间验证正常。", AccountName, serverTime.ToString("HH:mm:ss fff"), DateTime.Now.ToString("HH:mm:ss fff"));
         }
         Thread.Sleep(stopMiniSeconds);
     }
     catch (Exception ex)
     {
         Program.logger.LogInfo("{0} 时间验证异常:{1}", AccountName, (ex.InnerException ?? ex).Message);
     }
     IsServerTimeChecked = true;
 }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="error"></param>
 /// <param name="dateTimePicker1"></param>
 /// <param name="dateTimePicker2"></param>
 public static void systemDate(ref string error, DateTimePicker dateTimePicker1 = null, DateTimePicker dateTimePicker2 = null)
 {
     try {
         SystemTime MySystemTime = new SystemTime();                  //创建系统时间类的对象
         DateTime   Year         = dateTimePicker1.Value;             //得到时间信息
         SetSystemDateTime.GetLocalTime(MySystemTime);                //得到系统时间
         MySystemTime.vYear   = (ushort)dateTimePicker1.Value.Year;   //设置年
         MySystemTime.vMonth  = (ushort)dateTimePicker1.Value.Month;  //设置月
         MySystemTime.vDay    = (ushort)dateTimePicker1.Value.Day;    //设置日
         MySystemTime.vHour   = (ushort)dateTimePicker2.Value.Hour;   //设置小时
         MySystemTime.vMinute = (ushort)dateTimePicker2.Value.Minute; //设置分
         MySystemTime.vSecond = (ushort)dateTimePicker2.Value.Second; //设置秒
         SetSystemDateTime.SetLocalTime(MySystemTime);                //设置系统时间
     } catch (Exception ex) {
         error = ex.ToString();
     }
 }
 private void button2_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("您真的確定更改系統目前日期嗎?",//設定系統目前日期時間
                         "訊息提示", MessageBoxButtons.OK) == DialogResult.OK)
     {
         DateTime   Year         = this.dateTimePicker1.Value;             //得到時間訊息
         SystemTime MySystemTime = new SystemTime();                       //建立系統時間類的對象
         SetSystemDateTime.GetLocalTime(MySystemTime);                     //得到系統時間
         MySystemTime.vYear   = (ushort)this.dateTimePicker1.Value.Year;   //設定年
         MySystemTime.vMonth  = (ushort)this.dateTimePicker1.Value.Month;  //設定月
         MySystemTime.vDay    = (ushort)this.dateTimePicker1.Value.Day;    //設定日
         MySystemTime.vHour   = (ushort)this.dateTimePicker2.Value.Hour;   //設定小時
         MySystemTime.vMinute = (ushort)this.dateTimePicker2.Value.Minute; //設定分
         MySystemTime.vSecond = (ushort)this.dateTimePicker2.Value.Second; //設定秒
         SetSystemDateTime.SetLocalTime(MySystemTime);                     //設定系統時間
         button1_Click(null, null);                                        //執行按鈕點擊事件
     }
 }
Example #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("您真的确定更改系统当前日期吗?",//设置系统当前日期时间
                         "信息提示", MessageBoxButtons.OK) == DialogResult.OK)
     {
         DateTime   Year         = this.dateTimePicker1.Value;             //得到时间信息
         SystemTime MySystemTime = new SystemTime();                       //创建系统时间类的对象
         SetSystemDateTime.GetLocalTime(MySystemTime);                     //得到系统时间
         MySystemTime.vYear   = (ushort)this.dateTimePicker1.Value.Year;   //设置年
         MySystemTime.vMonth  = (ushort)this.dateTimePicker1.Value.Month;  //设置月
         MySystemTime.vDay    = (ushort)this.dateTimePicker1.Value.Day;    //设置日
         MySystemTime.vHour   = (ushort)this.dateTimePicker2.Value.Hour;   //设置小时
         MySystemTime.vMinute = (ushort)this.dateTimePicker2.Value.Minute; //设置分
         MySystemTime.vSecond = (ushort)this.dateTimePicker2.Value.Second; //设置秒
         SetSystemDateTime.SetLocalTime(MySystemTime);                     //设置系统时间
         button1_Click(null, null);                                        //执行按钮点击事件
     }
 }
Example #7
0
        private void frmOEEDashboard_Load(object sender, EventArgs e)
        {
            WindowState = FormWindowState.Maximized;

            int    errCode = 0;
            string errText = "";

            #region 获取服务器的当前时间,并设置当前的系统时间
            IRAPSystemClient.Instance.sfn_GetServerDateTime(
                ref serverTime,
                out errCode,
                out errText);
            if (errCode == 0)
            {
                SetSystemDateTime.SetSystemTime(serverTime);
            }
            #endregion


            if (stationUser == null || stationUser.SysLogID <= 0)
            {
                #region 获取当前站点的登录信息
                stationUser = PadLogin(ref errCode, ref errText);
                if (errCode != 0)
                {
                    //ShowErrorMessage(errText);
                    return;
                }
                else
                {
                    //HideErrorMessage();
                }
                #endregion
            }

            if (stationUser != null && stationUser.SysLogID != 0)
            {
                SetTitle();
            }
        }
Example #8
0
            public static bool SetLocalTimeByStr(DateTime dt)
            {
                bool       flag    = false;
                SystemTime sysTime = new SystemTime();

                sysTime.wYear        = Convert.ToUInt16(dt.Year);
                sysTime.wMonth       = Convert.ToUInt16(dt.Month);
                sysTime.wDay         = Convert.ToUInt16(dt.Day);
                sysTime.wHour        = Convert.ToUInt16(dt.Hour);
                sysTime.wMinute      = Convert.ToUInt16(dt.Minute);
                sysTime.wSecond      = Convert.ToUInt16(dt.Second);
                sysTime.wMiliseconds = Convert.ToUInt16(dt.Millisecond);
                try
                {
                    flag = SetSystemDateTime.SetLocalTime(ref sysTime);
                }
                catch (Exception e)
                {
                    WriteLog("Failed to set system date time with exception " + e.Message);
                }

                return(flag);
            }
Example #9
0
 private void BtnChange_Click(object sender, RoutedEventArgs e)
 {
     SetSystemDateTime.SetLocalTimeByStr(TxtMyTime.Text);
 }
Example #10
0
 private void TbNetworkTimeShow_MouseUp(object sender, MouseButtonEventArgs e)
 {
     SetSystemDateTime.SetLocalTimeByStr(TbNetworkTimeShow.Text);
 }
Example #11
0
        private void frmSPCOMain_Shown(object sender, EventArgs e)
        {
            WindowState = FormWindowState.Maximized;
            Application.DoEvents();

            int    errCode = 0;
            string errText = "";

            #region 获取服务器的当前时间,并设置当前的系统时间
            IRAPSystemClient.Instance.sfn_GetServerDateTime(
                ref serverTime,
                out errCode,
                out errText);
            if (errCode == 0)
            {
                SetSystemDateTime.SetSystemTime(serverTime);
            }
            #endregion

            if (stationUser == null || stationUser.SysLogID <= 0)
            {
                #region 获取当前站点的登录信息
                stationUser = PadLogin(ref errCode, ref errText);
                if (errCode != 0)
                {
                    ShowErrorMessage(errText);
                    return;
                }
                else
                {
                    HideErrorMessage();
                }
                #endregion
            }

            if (stationUser != null)
            {
                lblStationID.Text = stationUser.HostName;

                #region 获取当前站点监管的工位列表,并根据工位列表生成控制图
                if (stationUser.SysLogID > 0)
                {
                    if (!xtraScrollableControl.Visible)
                    {
                        xtraScrollableControl.Visible = true;
                    }

                    if (workUnits.Count == 0)
                    {
                        btnClose.Visible = false;
                        try
                        {
                            tcMain.TabPages.Clear();
                            workUnits = GetWorkUnits(ref errCode, ref errText);

                            if (errCode == 0)
                            {
                                HideErrorMessage();
                                List <string> filters = new List <string>();
                                foreach (WIPStationProductionStatus workUnit in workUnits)
                                {
#if DEBUG
                                    //workUnit.T47LeafID = 373564;
#endif

                                    XtraTabPage page = tcMain.TabPages.Add();
                                    page.Text = workUnit.T107Name;
                                    page.Tag  = workUnit;

                                    ucUncontrolChart chartNone = new ucUncontrolChart();
                                    chartNone.Dock   = DockStyle.Fill;
                                    chartNone.Parent = page;
                                    filters.Add(workUnit.T107Code);

                                    ucCharts.Add(chartNone);
                                }

                                if (tcMain.TabPages.Count > 0)
                                {
                                    tcMain_SelectedPageChanged(
                                        tcMain,
                                        new TabPageChangedEventArgs(
                                            null,
                                            tcMain.TabPages[0]));
                                }
                                foreach (string filter in filters)
                                {
                                    InitConsumer(filter);
                                }
                                InitConsumer(stationUser.SysLogID.ToString());
                            }
                            else
                            {
                                ShowErrorMessage(errText);
                            }
                        }
                        finally
                        {
                            btnClose.Visible = true;
                        }
                    }
                }
                #endregion
            }
        }