374 lines
14 KiB
C#
374 lines
14 KiB
C#
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
|
|
using HL_FristAidPlatform_DTO;
|
|
using HL_FristAidPlatform_Public;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace HL_FristAidPlatform_Frame
|
|
{
|
|
public partial class Form_Message : XtraForm
|
|
{
|
|
#region 变量
|
|
/// <summary>
|
|
/// 当前用户编号
|
|
/// </summary>
|
|
private long Cur_UserID = 0;
|
|
|
|
/// <summary>
|
|
/// 消息编号
|
|
/// </summary>
|
|
private long Cur_NoticeID = 0;
|
|
|
|
/// <summary>
|
|
/// 是否更新阅读状态
|
|
/// </summary>
|
|
private bool IsUpdateReadState = false;
|
|
|
|
/// <summary>
|
|
/// 当前页
|
|
/// </summary>
|
|
public int curPage = 1;
|
|
|
|
/// <summary>
|
|
/// 每页大小
|
|
/// </summary>
|
|
public int pageSize = 100;
|
|
|
|
/// <summary>
|
|
/// 所有记录条数
|
|
/// </summary>
|
|
public int totalNumber = 0;
|
|
#endregion
|
|
|
|
|
|
//#region MultimediaManager
|
|
//private IMultimediaManager multimediaManager = MultimediaManagerFactory.GetSingleton();
|
|
//public IMultimediaManager MultimediaManager
|
|
//{
|
|
// get { return multimediaManager; }
|
|
//}
|
|
//#endregion
|
|
//#region RapidPassiveEngine
|
|
//private IRapidPassiveEngine rapidPassiveEngine = RapidEngineFactory.CreatePassiveEngine();
|
|
|
|
//public IRapidPassiveEngine RapidPassiveEngine
|
|
//{
|
|
// get { return rapidPassiveEngine; }
|
|
//}
|
|
//#endregion
|
|
|
|
//#region GroupOutter
|
|
//private DynamicGroupOutter groupOutter = new DynamicGroupOutter();
|
|
//public DynamicGroupOutter GroupOutter
|
|
//{
|
|
// get { return groupOutter; }
|
|
//}
|
|
//#endregion
|
|
|
|
//private CustomizeHandler customizeHandler;
|
|
|
|
|
|
long NoticeTypeID = -1;
|
|
#region 分页实现
|
|
public void ExportEvents(bool singlePage)//单页,所有
|
|
{
|
|
//导出GridControl代码写在这。
|
|
}
|
|
|
|
public void RefreshGridList()
|
|
{
|
|
FillGridListCtrlQuery(curPage);//自己实现FillGridListCtrlQuery函数。
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据源
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private void FillGridListCtrlQuery(int curPage)
|
|
{
|
|
try
|
|
{
|
|
if (LUEdit_NoticeType.EditValue != null && !string.IsNullOrEmpty(LUEdit_NoticeType.EditValue.ToString()))
|
|
NoticeTypeID = long.Parse(LUEdit_NoticeType.EditValue.ToString());
|
|
int readState = 0;
|
|
//已读
|
|
if (radioGroup_ReadState.SelectedIndex == 1)
|
|
readState = 1;
|
|
//未读
|
|
else if (radioGroup_ReadState.SelectedIndex == 2)
|
|
readState = 0;
|
|
//全部或者未选
|
|
else
|
|
readState = -1;
|
|
|
|
string Url = string.Format("api/service/T_Service_Notice/GetPageList?pageIndex={0}&pageSize={1}¬iceTypeID={2}&readState={3}&userID={4}&keyWord={5}", curPage, pageSize, NoticeTypeID, readState, Cur_UserID, txt_Key.Text.ToString().Trim());
|
|
|
|
DataTable ResultDT = DBHelpClass.Get(Url);
|
|
grid_Notice.DataSource = ResultDT;//显示分页结果
|
|
totalNumber = DBHelpClass.TotalNumber;
|
|
userControlForPage.RefreshPager(pageSize, totalNumber, curPage);//更新分页控件显示。
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PublicClass.WriteErrorLog("新消息提醒", "绑定列表:\r\n" + ex);
|
|
}
|
|
}
|
|
|
|
private void MyPagerEvents(int curPage, int pageSize)
|
|
{
|
|
this.curPage = curPage;
|
|
this.pageSize = pageSize;
|
|
FillGridListCtrlQuery(curPage);
|
|
}
|
|
|
|
private void userControlForPage_exportEvents(bool singlePage)
|
|
{
|
|
userControlForPage.exportEvents += ExportEvents;
|
|
}
|
|
|
|
private void userControlForPage_myPagerEvents(int curPage, int pageSize)
|
|
{
|
|
userControlForPage.myPagerEvents += MyPagerEvents;
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 消息详情/列表
|
|
/// </summary>
|
|
/// <param name="userID">当前用户编号</param>
|
|
/// <param name="noticeID">消息编号</param>
|
|
/// <param name="isUpdateReadState">是否更新阅读状态</param>
|
|
public Form_Message(long userID, long noticeID = 0, bool isUpdateReadState = false)
|
|
{
|
|
InitializeComponent();
|
|
Cur_UserID = userID;
|
|
Cur_NoticeID = noticeID;
|
|
IsUpdateReadState = isUpdateReadState;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗体加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void Form_Message_Load(object sender, EventArgs e)
|
|
{
|
|
#region 绘制窗体显示位置
|
|
//获取当前工作区宽度和高度(工作区不包含状态栏)
|
|
int ScreenWidth = Screen.PrimaryScreen.WorkingArea.Width;
|
|
int ScreenHeight = Screen.PrimaryScreen.WorkingArea.Height;
|
|
//计算窗体显示的坐标值,可以根据需要微调几个像素
|
|
int x = ScreenWidth - Width;
|
|
int y = ScreenHeight - Height - 5;
|
|
Location = new Point(x, y);
|
|
#endregion
|
|
|
|
BindData();
|
|
RefreshGridList();
|
|
|
|
|
|
BindDetail(Cur_NoticeID, 0, DateTime.Now.ToString(PublicClass.TimeToString), IsUpdateReadState);
|
|
|
|
//customizeHandler = new CustomizeHandler();
|
|
//if (Login())
|
|
//{
|
|
// MainForm mainForm = new MainForm();
|
|
// mainForm.Show();
|
|
// mainForm.Initialize(RapidPassiveEngine, multimediaManager, GroupOutter, Information.User.ID.ToString(), Cur_UserID.ToString());
|
|
// customizeHandler.Initialize(mainForm);
|
|
//}
|
|
}
|
|
|
|
private void txt_Key_TextChanged(object sender, EventArgs e)
|
|
{
|
|
RefreshGridList();
|
|
}
|
|
|
|
private void LUEdit_NoticeType_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
RefreshGridList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btn_Sel_Click(object sender, EventArgs e)
|
|
{
|
|
RefreshGridList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示消息
|
|
/// </summary>
|
|
/// <param name="NoticeID">消息编号</param>
|
|
/// <param name="TotalReading">阅读次数</param>
|
|
/// <param name="FirstReadingTime">首次阅读时间</param>
|
|
/// <param name="IsUpdateReadState">是否更新阅读状态</param>
|
|
private void BindDetail(long NoticeID, int TotalReading, string FirstReadingTime, bool IsUpdateReadState)
|
|
{
|
|
try
|
|
{
|
|
DataTable DetailDT = DBHelpClass.GetDataRow(string.Format("api/service/T_Service_Notice/{0}", NoticeID));
|
|
if (DetailDT != null && DetailDT.Rows.Count > 0)
|
|
{
|
|
txt_Detail.Text = DetailDT.Rows[0]["Content"].ToString();
|
|
|
|
if (IsUpdateReadState)
|
|
{
|
|
#region 更新阅读
|
|
List<T_Service_NoticeReceivingDTO> list = new List<T_Service_NoticeReceivingDTO>();
|
|
T_Service_NoticeReceivingDTO model = new T_Service_NoticeReceivingDTO();
|
|
//初始化两个工厂
|
|
ClientFactory<T_Service_NoticeReceivingDTO> httpClient = new HttpClientFactory<T_Service_NoticeReceivingDTO>();
|
|
Client<T_Service_NoticeReceivingDTO> client = httpClient.VisitFactory();
|
|
|
|
string Url = "api/service/T_Service_NoticeReceiving/UpdateReadState";
|
|
model.NoticeID = NoticeID;
|
|
model.UserID = Information.User.ID;
|
|
model.TotalReading = TotalReading;
|
|
model.FirstReadingTime = FirstReadingTime;
|
|
list.Add(model);
|
|
|
|
//访问
|
|
ListEntity<T_Service_NoticeReceivingDTO> t = client.Post(Url, list);
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PublicClass.WriteErrorLog("新消息提醒", "绑定列表与更新阅读状态:\r\n" + ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindData()
|
|
{
|
|
BindNoticeType();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定消息类型
|
|
/// </summary>
|
|
private void BindNoticeType()
|
|
{
|
|
try
|
|
{
|
|
DataTable ResultDT = DBHelpClass.Get("/api/base/T_Base_NoticeType/GetList?isUser=1");
|
|
PublicClass.SetLookUpList(ref LUEdit_NoticeType, ResultDT, 0, 2, true, "请选择");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PublicClass.WriteErrorLog("新消息提醒", "绑定消息类型:\r\n" + ex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示详情
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void grid_Notice_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridHitInfo hi = grv_Notice.CalcHitInfo(new Point(e.X, e.Y));
|
|
//单击数据行
|
|
if (hi.InRow)//单击的是列头 hi.InColumn
|
|
{
|
|
if (grv_Notice.DataRowCount > 0)
|
|
{
|
|
int selectRow = grv_Notice.GetSelectedRows()[0];
|
|
long NoticeID = PublicClass.ToInt64(grv_Notice.GetRowCellValue(selectRow, "ID").ToString(), 0);
|
|
int TotalReading = PublicClass.ToInt32(grv_Notice.GetRowCellValue(selectRow, "TotalReading").ToString(), 0);
|
|
string FirstReadingTime = PublicClass.ToString(grv_Notice.GetRowCellValue(selectRow, "FirstReadingTime").ToString(), "");
|
|
BindDetail(NoticeID, TotalReading, FirstReadingTime, true);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PublicClass.WriteErrorLog("新消息提醒", "显示详情:\r\n" + ex);
|
|
}
|
|
}
|
|
|
|
//private bool Login()
|
|
//{
|
|
// //ESFramework 业务逻辑
|
|
// this.rapidPassiveEngine.WaitResponseTimeoutInSecs = 30;
|
|
// this.rapidPassiveEngine.HeartBeatSpanInSecs = 5;
|
|
// this.rapidPassiveEngine.SecurityLogEnabled = false;
|
|
|
|
// groupOutter.TryP2PWhenGroupmateConnected = false;
|
|
// groupOutter.RapidPassiveEngine = this.rapidPassiveEngine;
|
|
// DynamicGroupPassiveHandler groupPassiveHandler = new DynamicGroupPassiveHandler();
|
|
// groupPassiveHandler.Initialize(groupOutter);
|
|
|
|
// NDiskPassiveHandler nDiskPassiveHandler = new NDiskPassiveHandler();
|
|
|
|
// ComplexCustomizeHandler handler = new ComplexCustomizeHandler(this.customizeHandler, groupPassiveHandler, nDiskPassiveHandler);
|
|
// LogonResponse result = this.rapidPassiveEngine.Initialize(Information.User.ID.ToString(), "", ConfigurationManager.AppSettings["ServerIP"], int.Parse(ConfigurationManager.AppSettings["ServerPort"]), handler);
|
|
|
|
// if (result.LogonResult != LogonResult.Succeed)
|
|
// {
|
|
// if (result.LogonResult == LogonResult.HadLoggedOn)
|
|
// {
|
|
// MessageBox.Show("已经在其它地方登录!");
|
|
// }
|
|
// else
|
|
// {
|
|
// MessageBox.Show("用户或者密码错误!");
|
|
// }
|
|
// return false;
|
|
// }
|
|
|
|
// groupOutter.Initialize(this.rapidPassiveEngine.CurrentUserID);
|
|
// nDiskPassiveHandler.Initialize(this.rapidPassiveEngine.FileOutter, null);
|
|
|
|
// //OMCS 语音视频 参数设置
|
|
// MultimediaManager.AutoReconnect = false;
|
|
// multimediaManager.SecurityLogEnabled = true;
|
|
// multimediaManager.AutoAdjustCameraEncodeQuality = false;
|
|
// multimediaManager.MicrophoneDeviceIndex = 0;
|
|
// multimediaManager.CameraDeviceIndex = 0;
|
|
// multimediaManager.CameraEncodeQuality = 8;
|
|
// multimediaManager.MaxCameraFrameRate = 12;
|
|
// multimediaManager.DesktopEncodeQuality = 3;
|
|
// multimediaManager.MaxDesktopFrameRate = 12;
|
|
// multimediaManager.Advanced.AllowDiscardFrameWhenBroadcast = true;
|
|
// multimediaManager.Advanced.MaxInterval4CameraKeyFrame = 20;
|
|
// multimediaManager.Advanced.MaxInterval4DesktopKeyFrame = 20;
|
|
|
|
// try
|
|
// {
|
|
// string[] cameraSizeStr = ConfigurationManager.AppSettings["CameraVideoSize"].Split(',');
|
|
// multimediaManager.CameraVideoSize = new System.Drawing.Size(int.Parse(cameraSizeStr[0]), int.Parse(cameraSizeStr[1]));
|
|
// }
|
|
// catch { }
|
|
|
|
// multimediaManager.Initialize(Information.User.ID.ToString(), "", ConfigurationManager.AppSettings["ServerIP"], int.Parse(ConfigurationManager.AppSettings["OmcsPort"]));
|
|
// multimediaManager.OutputAudio = true;
|
|
|
|
// return true;
|
|
//}
|
|
|
|
private void grv_Notice_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
|
|
{
|
|
if (e.Column.FieldName == "Content")
|
|
{
|
|
string value = e.Value.ToString();
|
|
if (value.Contains("|"))
|
|
e.DisplayText = value.Substring(0, value.LastIndexOf("|"));
|
|
}
|
|
}
|
|
}
|
|
}
|