/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_SYS_0201.cs
* 2.功能描述:系统主界面
* 编辑履历:
* 作者 日期 版本 修改内容
* 张国印 2014/08/27 1.00 新建
*******************************************************************************/
using System;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Basics.DockPanel;
using Dongke.IBOSS.PRD.Basics.Library;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
namespace Dongke.IBOSS.PRD.Client
{
///
/// 系统主界面
///
public partial class F_SYS_0201 : Form
{
#region 成员变量
// 系统导航栏窗体
private F_SYS_0202 _frmSYS0202;
// 是否切换用户
private bool _isChange = false;
#endregion
#region 构造函数
///
/// 构造函数
///
public F_SYS_0201()
{
InitializeComponent();
this.SetFromTitleInfo();
}
#endregion
#region 事件
///
/// 窗体加载事件
///
///
///
private void F_SYS_0201_Load(object sender, EventArgs e)
{
try
{
#region 追加心跳程序,以便客户端与服务器端保持联系
System.Timers.Timer timer = new System.Timers.Timer(Constant.M_SYSTEM_HEARTBEAT_INTERVAL);
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
timer.AutoReset = true;
timer.Enabled = true;
#endregion
#region 系统菜单栏悬浮处理
this._frmSYS0202 = new F_SYS_0202(this.dockpnlMain);
if (!this._frmSYS0202.Visible)
{
this._frmSYS0202.Show(this.dockpnlMain);
}
#endregion
#region 对状态栏中的标签进行赋值
this.tssrlblProcess.Text = Constant.M_NETWORK_CONNECT_TEXT;
this.tssrlblBlank.Text = string.Empty;
this.tssrlblAccount.Text = string.Format(Constant.M_CURRENT_ACCOUNT_TEXT,
LogInUserInfo.CurrentUser.CurrentUserEntity.AccountCode,
LogInUserInfo.CurrentUser.CurrentUserEntity.AccountName);
this.tssrlblUser.Text = string.Format(Constant.M_CURRENT_USER_TEXT,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserCode,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserName);
DateTime isLinkWebServer = CommonModuleProxy.Service.GetAccountDate();
this.tssrlblAccountDate.Text = string.Format(Constant.M_CURRENT_ACCOUNT_DATE_TEXT,
isLinkWebServer.ToString("yyyy-MM-dd"));
tssrlblValidityEnd.Text = null;
#endregion
}
catch (Exception ex)
{
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 菜单栏--关于
///
///
///
private void tsmiAbout_Click(object sender, EventArgs e)
{
//try
//{
// F_SYS_0203 frmSYS0203 = new F_SYS_0203();
// frmSYS0203.ShowDialog();
//}
//catch (Exception ex)
//{
// ExceptionManager.HandleEventException(this.ToString(),
// MethodBase.GetCurrentMethod().Name, this.Text, ex);
//}
}
///
/// 工具栏 -- 退出
///
///
///
private void tsbtnExit_Click(object sender, EventArgs e)
{
this._isChange = false;
this.Close();
}
///
/// 菜单栏--切换用户
///
///
///
private void tsmiChangeUser_Click(object sender, EventArgs e)
{
try
{
this._isChange = true;
this.Close();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 菜单栏--退出
///
///
///
private void tsmiExit_Click(object sender, EventArgs e)
{
this._isChange = false;
this.Close();
}
///
/// 工具栏-- 导航菜单
///
///
///
private void tsbtnNavigation_Click(object sender, EventArgs e)
{
try
{
if (this._frmSYS0202.IsDisposed)
{
this._frmSYS0202 = new F_SYS_0202(this.dockpnlMain);
}
this._frmSYS0202.Show(this.dockpnlMain);
if (this._frmSYS0202.DockState == DockState.DockLeft)
{
this._frmSYS0202.DockState = DockState.DockLeftAutoHide;
}
else if (this._frmSYS0202.DockState == DockState.DockLeftAutoHide)
{
this._frmSYS0202.DockState = DockState.DockLeft;
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 修改密码
///
///
///
private void tsbtnEditPassword_Click(object sender, EventArgs e)
{
try
{
F_SYS_0210 frmSYS0209 = F_SYS_0210.Instance;
frmSYS0209.ShowDialog();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 修改密码
///
///
///
private void tsmiEditPassword_Click(object sender, EventArgs e)
{
this.tsbtnEditPassword_Click(sender, e);
}
///
/// 窗体关闭时提醒用户是否退出
///
///
///
private void F_SYS_0201_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult dialogResult = DialogResult.Yes;
if (_isChange)
{
// 提示用户确认退出系统
dialogResult = MessageBox.Show(Messages.MSG_SYS_Q001, Messages.MSG_TITLE_Q01,
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dialogResult == DialogResult.Yes)
{
Process.Start(Constant.S_SYSTEM_CLIENT_NAME, "IsChangedUser");
return;
}
}
else
{
// 提示用户确认退出系统
dialogResult = MessageBox.Show(Messages.MSG_SYS_Q002, Messages.MSG_TITLE_Q01,
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
if (dialogResult != DialogResult.Yes)
{
e.Cancel = true;
}
}
///
/// 刷新菜单按钮事件
///
///
///
private void tsbRefresh_Click(object sender, EventArgs e)
{
try
{
this._frmSYS0202.RefreshViewTree();
this._frmSYS0202.Close();
#region 系统菜单栏悬浮处理
this._frmSYS0202 = new F_SYS_0202(this.dockpnlMain);
if (!this._frmSYS0202.Visible)
{
this._frmSYS0202.Show(this.dockpnlMain);
}
#endregion
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 菜单栏-刷新菜单按钮事件
///
///
///
private void tsmiRefresh_Click(object sender, EventArgs e)
{
tsbRefresh_Click(null, null);
}
///
/// 切换按钮事件
///
///
///
private void tsbtnChangeUser_Click(object sender, EventArgs e)
{
tsmiChangeUser_Click(null, null);
}
///
/// 画面打开
///
///
///
private void F_SYS_0201_Shown(object sender, EventArgs e)
{
try
{
if (!string.IsNullOrEmpty(LogInUserInfo.LoginMessage))
{
MessageBox.Show(LogInUserInfo.LoginMessage, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
if (LogInUserInfo.CurrentUser.CurrentLicenseInfo != null)
{
DateTime vEnd = Convert.ToDateTime(LogInUserInfo.CurrentUser.CurrentLicenseInfo.Tables["Info"].Rows[0]["ValidityEnd"]);
DateTime n = DateTime.Now.Date.AddMonths(1);
if (n >= vEnd)
{
MessageBox.Show(string.Format("授权将在{0}天后过期【{1}】,请尽快更换新授权。",
(vEnd-DateTime.Now.Date).TotalDays + 1,
vEnd.ToString("yyyy-MM-dd")),
this.Text,
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
tssrlblValidityEnd.ForeColor = System.Drawing.Color.Red;
tssrlblValidityEnd.Text = string.Format("授权截止【{0}】 ", vEnd.ToString("yyyy-MM-dd"));
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 打开缓存路径
///
///
///
private void tsmiCachePath_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(LocalPath.RootPath);
}
///
/// 打开日志路径
///
///
///
private void tsmiLogPath_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(LocalPath.LogRootPath);
}
///
/// 更新履历
///
///
///
private void tsmiCheckUpgradeInfo_Click(object sender, EventArgs e)
{
try
{
DockPanelBase fSYS0211 = F_SYS_0211.Instance;
if (fSYS0211 == null)
{
return;
}
fSYS0211.Show(this.dockpnlMain, DockState.Document);
fSYS0211.Activate();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 设置窗体按钮的文本信息
///
private void SetFromTitleInfo()
{
this.WindowState = FormWindowState.Maximized;
this.Text = FormTitles.F_SYS_0201;
//设置按钮文本
this.tsmiEditPassword.Text = ButtonText.TSMI_EDITPASSWORD;
this.tsmiChangeUser.Text = ButtonText.TSMI_CHANGEUSER;
this.tsmiNavigation.Text = ButtonText.TSMI_NAVIGATION;
this.tsmiRefresh.Text = ButtonText.TSMI_REFRESH;
this.tsmiExit.Text = ButtonText.TSMI_EXIT;
this.tsbtnEditPassword.Text = ButtonText.TSBTN_EDITPASSWORD;
this.tsbtnChangeUser.Text = ButtonText.TSBTN_CHANGEUSER;
this.tsbtnNavigation.Text = ButtonText.TSBTN_NAVIGATION;
this.tsbtnRefresh.Text = ButtonText.TSBTN_REFRESH;
this.tsbtnExit.Text = ButtonText.TSBTN_EXIT;
this.tssrlblIPpost.Text = string.Format("{0}:{1}【{2}】", ProxySettings.IP, ProxySettings.Port, ProxySettings.IPPostName);
}
///
/// 心跳程序
///
///
///
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
bool isLinkWebServer = Dongke.IBOSS.PRD.WCF.Proxys.DKIBOSSPRDProxy.Service.GetServiceState();
if (isLinkWebServer)
{
this.tssrlblProcess.Image = global::Dongke.IBOSS.PRD.Client.Properties.Resources.online;
this.tssrlblProcess.Text = Constant.M_NETWORK_CONNECT_TEXT;
}
else
{
this.tssrlblProcess.Image = global::Dongke.IBOSS.PRD.Client.Properties.Resources.outline;
this.tssrlblProcess.Text = Constant.M_NETWORK_DISCONNECT_TEXT;
}
}
catch (Exception ex)
{
// 写错误日志
OutputLog.Trace(LogPriority.Warning, this.ToString(),
MethodBase.GetCurrentMethod().Name, ex.ToString());
this.tssrlblProcess.Text = Constant.M_NETWORK_DISCONNECT_TEXT;
}
}
#endregion
}
}