using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections.Specialized; using System.IO; using GeneralLib; using System.Drawing; using System.Windows.Forms; using System.Reflection; using ProService; using System.Diagnostics; //using RealVote; namespace SunVoteARSPPT { /// /// SDK操作类型 /// public enum OperateType { otWrite = 1, otRead = 2 } /// /// OEM的Logo类型 /// 创建:杨斌 2012-05-15 /// 修改:杨斌 2017-10-17 /// public enum OEMLogos { /// /// 标准版 /// SunVote = 0, /// /// 中性版 /// ZX, /// /// 日本木村公司 /// oem3eAnalyzer, /// /// 美国Tony /// oemMyVote, /// /// 美国Tony的RealVote /// oemRealVote, /// /// 匈牙利Mekka Interaktív Kft. /// oemApaczaiKiado, /// /// 印度EasyTest-C1826 /// 杨斌 2013-05-03 /// oemEasyTest, /// /// 信德服务版。杨斌 2014-07-07 /// oemXDServer, /// /// 墨西哥 SmartVote 杨斌 2016-01-25 /// oemSmartVote, /// /// 巴西 Option Maker 杨斌 2014-12-22 /// 隐藏图表,后台发报表邮件 /// oemOptionMaker, /// /// 西班牙CustomVote /// 杨斌 2015-01-26 /// oemCustomVote, /// /// 波兰ACTRONIX /// oemACTRONIX, /// /// 法国PowerVote,C2579 /// oemPowerVote, /// /// 法国i-Pericles /// 杨斌 2016-04-28 /// oemiPericles, /// /// 西班牙Clickmaster /// 杨斌 2016-09-20 /// oemClickmaster, /// /// 美国ShoutPoll /// oemShoutPoll, /// /// 沙特阿拉伯SolutionsBox /// oemSolutionsBox, /// /// 成都六韬?PowerCom,目前只修改ToolKit键盘型号 /// oemPowerCom, /// /// C4002-Ministr贴牌定制 /// oemMinistr, /// /// C4058-BOAVC,广州捷思通,博安至高 /// oemBOAVC, /// /// Klickr贴牌定制。杨斌 2017-10-17 /// oemKlickrQuiz, /// /// 深圳艾博德科技股份有限公司 /// oemDrawViewVote, /// /// C3897定制WeVote贴牌。杨斌 2018-01-22 /// oemWeVote, /// /// C3677法国Vote-Explorer的OEM。杨斌 2018-03-06 /// oemVoteExplorer, /// /// C2579-原来的PowerVote改成Angage,不知什么原因改品牌名字了。杨斌 2018-03-22 /// oemAngage, /// /// C4108-20180518-D001贴牌QResponse Audience Response System;EDU ASSE是TURNING印度经销商。杨斌 2018-05-31 /// oemQResponse, /// /// 自定义OEM,根据配置文件设置About等信息。杨斌 2018-09-19 /// 新增配置:WolfPoll PPT Plugin贴牌定制。C2972-20190124-PI002-D001 定制。2019-05-29 /// oemCustom, } /// /// 标准版或Oem的子版本类型。 /// public enum OEMLogos2 { /// /// 标准版 /// SunVote = 0, /// /// 中国/福建/龙岩/龙阳市金创新电子技术有限公司 /// oem龙阳市金创新, /// /// PowerVote特定版本MRC Quiz /// oemPowerVoteMRCQuiz, /// /// 定制M52+功能的多人选举,C3322北京顺义三中的先进党员选举 ///// //oemSunVoteMultiPoll, /// /// 新加坡HumanspherePte Ltd新增定制报表Polling Data Report Example;定制个人明细与成绩报表格式,加批注 /// oemSunVoteOEMReportAddComment, /// /// EasyTest关于详细信息为空。杨斌 2016-12-23 /// oemEasyTestBlank, /// /// 是否显示老版本的报表。杨斌 2017-04-11 /// oemSunVoteOldReportVoterDetail, /// /// PowerVote特殊定制评分表决。杨斌 2017-05-31 /// oemPowerVoteForORPI, /// /// C1082-AVATAR,分组对比图表显示堆积图,百分比时,柱状图高度一致。杨斌 2017-06-13 /// oemAVATAR, /// /// 河北鑫考,增加如从SQLServer导入名单功能,安装包包含iVote,eTest。杨斌 2018-06-28 /// oemHBXK, /// /// 湖南沃阿汇网络科技有限公司,成绩数据上传 /// oemWoAHuiUpload, /// /// 隐藏数据查看权限。i-Pericles定制。杨斌 2020-03-06 /// oemHideData, /// /// C5282- Inno Vietnam。杨斌 2020-04-01 /// oemINNO, /// /// C5641-东莞松山湖网络。显示表决项目名单。杨斌 2020-04-29 /// oemShowVoteNameList, } public class GlobalInfo { /// /// OEM标志Logo /// 创建:杨斌 2012-05-23 /// 隐藏主界面帮助按钮,根据OEM类型调用对应的关于窗体 /// 注意工程名改为:Angage Quiz Plus /// public static OEMLogos OEMLogo = OEMLogos.SunVote;//oemCustom /// /// OEM标志2,不修改Logo,在标准版基础上修改一些关于信息 /// 杨斌 2016-01-05 /// public static OEMLogos2 OEMLogo2 = OEMLogos2.SunVote;//oemINFO /// /// 版本补充信息,与标准版Logo一样,但功能不同,以此做区分 /// 杨斌 2014-08-20 /// -Alpha -Beta -2-3..l /// public static string VerInfo { get { if (OEMLogo == OEMLogos.oemOptionMaker) return "-Option Maker"; else if (OEMLogo == OEMLogos.oemACTRONIX) return "-ACTRONIX"; else return "";//第4位版本为0则是正式版。杨斌 2015-01-05 } } /// /// 键盘限制个数,限制版投票表决时只允许有限个键盘提交数据,=0时不限制 /// 创建:杨斌 2012-11-05 /// public static int LIMITED_EDITION = 0; /// /// 获取SDK类型。0=ARS/EVS/CRS,1=PVS。杨斌 2015-03-05 /// /// public static int GetSdkType() { //杨斌 2015-03-13 //switch (hardwareManage.KeyModel) switch (SystemConfig.KeypadType) { case "M52": case "M50": case "M52Plus": case "M52Li"://杨斌 2015-06-17 case "M30"://杨斌 2017-02-07 case "F00": case "M40L": case "S50": case "S50Li": case "S70": return 0; break; case "W52": case "W00": case "W40": return 1; break; default://其他OEM定制的型号,默认ARS return 0; break; } } /// /// RealVote的软件狗。 /// 杨斌 2015-01-22 /// public static object RealVoteSoftDog = null; /// /// 软件狗是否验证成功,在使用硬件投票时判断。 /// 杨斌 2015-01-22 /// public static bool SoftDogOK = false; /// /// 软件狗失败提示信息。 /// 杨斌 2015-01-22 /// /// public static string DogFailedMsg { get { return GlobalInfo.SysLanguage.LPT.ReadString("Other", "DogFailed", "软件狗验证失败,不能使用键盘反馈功能。"); } } /// /// 启动反馈时判断软件狗是否失败 /// 杨斌 2015-01-22 /// /// public static bool JudgeDogFailed() { bool res = false; if ((GlobalInfo.OEMLogo == OEMLogos.oemRealVote) && (!GlobalInfo.SoftDogOK) && (!GlobalInfo.sysConfig.DemoEnable)) res = true; return res; } /// /// 是否启用了SN /// 杨斌 2015-01-14 /// public static bool EnabledSN { get { bool res = false; if (GlobalInfo.baseConnect.BaseList.Count > 0) res = (GlobalInfo.baseConnect[0].BaseMatchMode >= 4); return res; } } /// /// 判断键盘支持的反馈类型,杨斌 2017-08-18;Globals.SunVoteARSAddIn.PPTShow.ResponseType /// public static bool IsSupportVoteType(ResponseType rType = ResponseType.None) { bool res = true; if (rType == ResponseType.None) rType = Globals.SunVoteARSAddIn.PPTShow.ResponseType; if (GlobalInfo.hardwareManage.KeyModel == "S60") { switch (rType) { //不支持的 case ResponseType.Number: case ResponseType.Text: case ResponseType.Score: case ResponseType.Order: case ResponseType.Poll: res = false; break; } } return res; } /// /// 最大选项个数。杨斌 2018-10-16 /// public static int MaxOptionCount = 10; /// /// 最大选项个数,高级定制版。杨斌 2018-02-02 /// public static int MaxOptionCountAdv { get { int res = 10; switch(GlobalInfo.OEMLogo) { case OEMLogos.oemShoutPoll://高级定制版 case OEMLogos.SunVote: case OEMLogos.oemAngage://2018-10-16 res = 20; break; } return res; } } /// /// 基站连接类 /// public static BaseConnect baseConnect = null; /// /// 硬件管理类 /// public static HardwareManageARS hardwareManage = null; /// /// 系统语言类 /// public static Language SysLanguage = null; /// /// 系统指定字体 /// 杨斌 2015-02-27 /// public static string SysFontName = ""; /// /// 是否显示调试信息 /// 杨斌 2015-03-12 /// public static bool ShowDebug = false; /// /// 调试模式 /// 杨斌 2015-05-21 /// public static bool DebugMode = false; /// /// 配置文件类 /// public static SysConfig sysConfig = null; /// /// 反馈接口类 /// public static Response response = null; /// /// 最小基站编号 /// public static int minBaseID = 1; /// /// 最大基站编号 /// public static int maxBaseID = 8; /// /// 最小频点号 /// public static int minChannel = 1; /// /// 最大频点号 /// public static int maxChannel = 80;//有的基站频点最大80.杨斌 2016-04-18 /// /// 北京顺义数字选举的可选人数最大值60。 /// 杨斌 2016-04-28 /// 2020-04-03支持255 /// public static int maxNumberPollSelect = 255;//60 /// /// 项目根目录 /// public static string APP_DIR = new DirectoryInfo(GetAppWorkDir()).Parent.FullName; /// ///系统错误日志文件路径 /// public static string SYSTEM_LOG = APP_DIR + @"\Resources\SystemLog\"; /// /// 键盘配置文件路径 /// public static string KEYPAD_CONFIG_PATH = APP_DIR + @"\Resources\SystemConfig\KeypadConfig.ini"; /// /// 系统配置文件路径 /// public static string SYSTEM_CONFIG_PATH = APP_DIR + @"\Resources\SystemConfig\System.ini"; /// /// 备份信息文件路径 /// public static string SYSTEM_BACKUP = APP_DIR + @"\Resources\SystemConfig\"; /// ///多基站模式,基站列表路径 /// public static string BASELIST_PATH = APP_DIR + @"\Resources\SystemConfig\BaseList.ini"; /// /// 数据库路径 /// public static string DB_PATH = APP_DIR + @"\Resources\DataBase\"; /// /// 数据库临时文件夹 /// public static string DBTEMP_PATH = APP_DIR + @"\Resources\DBTemp\"; //public static string DB_PATH = APP_DIR + @"\Resources\DataBase\SunVote.mdb"; /// /// 数据库模板文件路径 /// 修改:杨斌 2012-05-23,改成中性的名称 /// public static string ACCESS_DATASOUREMODE = APP_DIR + @"\Resources\SystemConfig\TempDB.mdb";//原来是SunVote.mdb /// /// 图片临时文件夹 /// public static string PICTURETEMP_PATH = APP_DIR + @"\Resources\PictureTemp\"; /// /// 图标图片文件夹。杨斌 2020-02-13 /// public static string IMAGE_VoteBar_DIR = APP_DIR + @"\Resources\Image\VoteBar\"; /// /// 音效文件的目录 /// public static string SOUND_DIR = APP_DIR + @"\Resources\Sound\"; /// /// Excel报表导出的目录 /// public static string Reports_DIR = APP_DIR + @"\Reports\"; /// /// OEM贴牌配置信息的目录。杨斌 2018-09-19 /// public static string OEMInfoDir = APP_DIR + @"\Resources\AppInfo\"; /// /// OEM贴牌配置信息。杨斌 2018-09-19 /// public static string OEMInfoFile = APP_DIR + @"\Resources\AppInfo\About.xml"; /// /// OEM贴牌配置信息的Logo图片。杨斌 2018-09-19 /// public static string OEMInfoLogo = APP_DIR + @"\Resources\AppInfo\Logo.png"; /// /// 播放背景音效的键 /// public const string Sound_Key_Back = "Back"; /// /// 播放投票按键音效的键 /// public const string Sound_Key_Vote = "Vote"; /// /// 播放背景音效的键,在幻灯片中设置的。杨斌 2015-04-10 /// public const string Sund_Key_BackSlide = "BackSlide"; /// /// 显示结果图表提示音,停止投票后手动显示结果或者投票停止后自动显示结果。杨斌 2019-01-07 /// public const string Sund_Key_SlideShowResult = "SlideShowResult"; /// /// 显示正确答案提示音。杨斌 2019-01-07 /// public const string Sund_Key_ShowCorrectAnswer = "ShowCorrectAnswer"; /// /// 播放音效的对象 /// public static PLSound DXSoundPlay = null;//杨斌 2012-06-25 public static DBOper DBOperation = null; /// /// 数据库名称 /// public static string DBName = ""; /// /// 获取程序集名称 /// 创建:杨斌 2012-05-15 /// /// public static string GetAppName() { return Assembly.GetExecutingAssembly().GetName().Name; } /// /// 获取软件名称 /// 创建:杨斌 2012-11-13 /// /// public static string GetAppTitle() { string appName = Assembly.GetExecutingAssembly().GetName().Name; switch (GlobalInfo.OEMLogo) { case OEMLogos.oemApaczaiKiado: appName = "Apáczai Kiadó";//工程名叫:Interaktivtabla,因为安装工厂文件名不支持匈牙利语,显示乱码 break; case OEMLogos.oemCustomVote: appName = "CustomVote " + DateTime.Now.Year; break; case OEMLogos.oemiPericles: if (GlobalInfo.OEMLogo2== OEMLogos2.oemHideData) { appName += "(private)"; } break; default: break; } return appName; } /// /// 获取工作目录,即VSTO文件的目录 /// 安装VSTO后,真正执行的工程DLL位于“C:\Documents and Settings\用户名\....”下面 /// 创建:杨斌 2010-08-18 /// 修改:杨斌 2012-05-15 /// /// public static string GetAppWorkDir() { string path = ""; try { path = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Office\PowerPoint\Addins\" + GlobalInfo.GetAppName()).GetValue("Manifest", "").ToString(); if (path.Length > 0) { //TODO:路径字符串"/"必须从系统环境中获取,如日本的为"¥" path = path.Replace(@"/", @"\"); path = path.Replace(@"file:\\\", @""); path = path.Remove(path.LastIndexOf(@"\") + 1); } } catch (Exception ex) { SystemLog.WriterLog(ex); } return path; } /// /// 系统内置图表颜色表,只读 /// 修改:杨斌 2012-03-20 /// public static Color[] ChartColors { get { //Color[] res = new Color[] //{ // Color.FromArgb(65, 140, 240), // Color.FromArgb(224, 64, 10), // Color.FromArgb(252, 180, 65), // Color.FromArgb(5, 100, 146), // Color.FromArgb(191, 191, 191), // Color.FromArgb(26, 59, 105), // Color.FromArgb(255, 227, 130), // Color.FromArgb(18, 156, 221), // Color.FromArgb(202, 107, 75), // Color.FromArgb(0, 92, 219) //}; //颜色表修改,PowerVote提出修改的,也同iVote。杨斌 2018-07-26 Color[] res = new Color[] { Color.FromArgb(18, 177, 90), Color.FromArgb(255, 12, 26), Color.FromArgb(253, 215, 108), Color.FromArgb(0, 68, 205), Color.FromArgb(0, 189, 189), Color.FromArgb(241, 48, 243), Color.FromArgb(102, 205, 52), Color.FromArgb(155, 102, 0), Color.FromArgb(4, 227, 229), Color.FromArgb(247, 56, 133), }; //if (GlobalInfo.OEMLogo == OEMLogos.oemACTRONIX) //{ // res[0] = Color.FromArgb(65, 140, 240); // res[1] = Color.FromArgb(224, 64, 10); // res[2] = Color.FromArgb(252, 180, 65); //} return res; } } /// /// 获取ppt文件名不含后缀名 /// 杨斌 2016-07-28 /// /// /// public static string GetPPTFileName(Microsoft.Office.Interop.PowerPoint.Presentation Pres) { string res = ""; try { res = Pres.Name; res = Path.GetFileNameWithoutExtension(res); } catch (Exception ex) { SystemLog.WriterLog(ex); } return res; } public static string GetNewDBName(Microsoft.Office.Interop.PowerPoint.Presentation Pres, string defName = "") { string res = ""; try { string name = defName; if (name.Length < 1) name = GetPPTFileName(Pres); res = name + "[" + DateTime.Now.ToString("yyyyMMddHHmmss") + DateTime.Now.Millisecond + "]" + ".mdb"; } catch (Exception ex) { SystemLog.WriterLog(ex); } return res; } /// /// 复制数据库 /// public static void CopySystemDB(Microsoft.Office.Interop.PowerPoint.Presentation Pres) { try { string sourcePath = ACCESS_DATASOUREMODE; //杨斌 2016-07-28 bool beCopyNew = false; if (DBName == "") { //DBName = System.Guid.NewGuid() + ".mdb"; DBName = GetNewDBName(Pres); beCopyNew = true; } string targetPath = DB_PATH + DBName; bool isrewrite = true; // true=覆盖已存在的同名文件,false则反之 System.IO.File.Copy(sourcePath, targetPath, isrewrite); //连接数据库。杨斌 2018-06-28 DBOperation.InitConnStrAccess(DB_PATH + DBName, ""); DBOperation.OpenConn(); UpdateDB();//杨斌 2015-01-05 if (beCopyNew) PPTEdit.UpdatePresPathToDB(Pres); if (!Directory.Exists(DBTEMP_PATH)) Directory.CreateDirectory(DBTEMP_PATH);//路径不存在则创建,否则下面删除目录中文件时报错 foreach (string str in System.IO.Directory.GetFiles(DBTEMP_PATH)) { FileInfo info = new FileInfo(str); info.Attributes = FileAttributes.Normal; info.Delete(); } } catch (Exception ex) { SystemLog.WriterLog(ex); } } /// /// 将数据库暂存到临时文件夹 /// public static void CopyTempDB() { if (!System.IO.Directory.Exists(DBTEMP_PATH)) { // 目录不存在,建立目录 System.IO.Directory.CreateDirectory(DBTEMP_PATH); } string sourcePath = DB_PATH + DBName; string targetPath = DBTEMP_PATH + DBName; System.IO.File.Copy(sourcePath, targetPath, true); DBOperation.CloseConn(); System.IO.File.SetAttributes(DB_PATH + DBName, FileAttributes.Normal); System.IO.File.Delete(DB_PATH + DBName); } /// /// 更新数据库结构 /// 杨斌 2015-03-31 /// public static void UpdateDB(DBOper dbOperation) { dbOperation.SetTableColumnType("ST_Voter", "V_KeypadID", "Text(255)"); //杨斌 2020-04-03。选举999选255的按键值字段不够长 dbOperation.SetTableColumnType("ST_Response", "R_Result", "Memo"); dbOperation.SetTableColumnType("ST_Response2", "R_Result", "Memo"); string sql = "SELECT TT_ID FROM ST_TopicType WHERE (TT_ID='Text')"; if (!dbOperation.RecordIsExist(sql)) { sql = "INSERT INTO ST_TopicType (TT_ID, TT_Code, TT_Note)" + " VALUES ('Text', 11, '文本')"; dbOperation.ExecuteNonQuery(sql); } //杨斌 2015-07-13 string sTable = "ST_Response2"; if (!TableExists(dbOperation, sTable))//外键约束,参照完整性,级联更新删除 { try { //sql = "create table " + sTable + " (" // + " T_ID varchar(255) CONSTRAINT ARS_ResponseT_ID REFERENCES ST_Topic(T_ID) not null," // + " V_ID long CONSTRAINT ARS_ResponseV_ID not null," // + " R_ID identity primary key," // + " R_KeypadID varchar(255) not null," // + " R_Result varchar(255)," // + " R_Speed double," // + " R_Time Datetime" // + ")"; sql = "create table " + sTable + " (" + " T_ID varchar(255) REFERENCES ST_Topic(T_ID) ON UPDATE CASCADE ON DELETE CASCADE not null," + " V_ID long REFERENCES ST_Voter (V_ID) not null," + " R_ID identity," + " R_KeypadID varchar(255) not null," + " R_Result varchar(255)," + " R_Speed double," + " R_Time Datetime," + " CONSTRAINT PrimaryKey primary key (R_ID))"; dbOperation.ExecuteNonQuery(sql); sql = "create index" + " ARS_ResponseT_ID on " + sTable + " (T_ID)"; dbOperation.ExecuteNonQuery(sql); sql = "create index" + " ARS_ResponseV_ID on " + sTable + " (V_ID)"; dbOperation.ExecuteNonQuery(sql); } catch (Exception ex) { SystemLog.WriterLog(ex); } } dbOperation.AddTableColumn("ST_Response2", "R_Score", "Double", 0);//杨斌 2016-01-08 } public static bool TableExists(DBOper dbOperation, string sTable) { bool res = false; string[] red = new string[4]; red[2] = sTable; System.Data.DataTable dt = dbOperation.DBConnection.GetSchema("Tables", red); if (dt != null) res = dt.Rows.Count > 0; return res; } /// /// 更新数据库结构 /// 杨斌 2015-01-05 /// public static void UpdateDB() { UpdateDB(DBOperation);//杨斌 2015-03-31 } public static INIControl IniCtlSystem = null;//杨斌 2014-07-24 /// /// ToolKit服务 /// public static MyService Servive = null; private static bool RunInitMain = false; public static void InitMain() { try { if (RunInitMain) return;//只运行一次 RunInitMain = true; //杨斌 2015-03-13 SystemConfig.KeypadType = INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH).ReadString("Device", "KeypadType", "M52Plus"); //CopySystemDB(); SystemLog.LogFile = new DirectoryInfo(GlobalInfo.GetAppWorkDir()).Parent.FullName + @"\Resources\SystemLog\"; //暂时不能屏蔽,应屏蔽SDK相关。杨斌 2017-04-19 baseConnect = new BaseConnect(); hardwareManage = new HardwareManageARS(baseConnect); DBOperation = new DBOper(); SysLanguage = new Language(APP_DIR); SysLanguage.LoadLanguage();//在sysConfig.iniSystemInfo中调用,但这里不能省,暂多调用一次。杨斌 2012-03-26 sysConfig = new SysConfig(); response = new Response(); sysConfig.iniSystemInfo(); IniCtlSystem = INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH);//杨斌 2014-07-24 Servive = MyService.GetService(GetSevName()); GlobalInfo.RunToolKit("RunBack");//杨斌 2017-12-21 RefreshConnectState(); //杨斌 2017-12-08 VoteServer.ServerInit(); } catch (Exception ex) { SystemLog.WriterLog(ex); } } public static string GetSevName(bool reverse = false) { string res = ""; if (GlobalInfo.GetSdkType() == (reverse ? 1 : 0)) res = "ToolKitArsSev"; else res = "ToolKitPvsSev"; return res; } static List LstServerRequestException = new List(); /// /// 检查连接状态。杨斌 2016-10-26 /// public static string GetBaseConnectOkIDs() { string res = ""; Param e = new Param(); Param p = ServerRequest(e); if (p.Pa.ContainsKey("BaseConnectOkIDs")) { res = p.Pa["BaseConnectOkIDs"].ToString(); } if (p.Pa.ContainsKey("KeypadTypeSet")) { string keypadType = p.Pa["KeypadTypeSet"].ToString(); FrmKeypadType.UpdateKeypadType(keypadType); } //杨斌 2018-03-09 if (e.Pa.ContainsKey(KeyServerRequestException)) { LstServerRequestException.Add(e.Pa[KeyServerRequestException]); if (LstServerRequestException.Count >= 10) { LstServerRequestException.Clear(); RunToolKit("RunBack"); } } return res; } /// /// 刷新连接状态。杨斌 2016-10-24 /// public static void RefreshConnectState() { string baseIDs = GetBaseConnectOkIDs(); bool isOK = (baseIDs.Length > 0); Globals.Ribbons.rbSunVoteARS.SetBaseConnectStatus(isOK); } public static void InitRemontControl() { Param p = new Param(); switch (GlobalInfo.sysConfig.RemontControl) { case "50R": case "R51": case "R52"://杨斌 2019-07-02 case "R53"://杨斌 2020-03-20 p.Pa.Add("EnableRequest", "1"); break; default: p.Pa.Add("EnableRequest", "0"); break; } GlobalInfo.ServerRequest(p); } public static string KeyServerRequestException = "ServerRequestException"; /// /// 服务请求。杨斌 2016-10-24 /// public static Param ServerRequest(Param e) { Param res = new Param(); try { if (Globals.SunVoteARSAddIn.IsExitApp)//杨斌 2017-03-02 return res; res = Servive.Request(e); } catch (Exception ex) { if (!e.Pa.ContainsKey(KeyServerRequestException)) e.Pa.Add(KeyServerRequestException, ex + ""); //杨斌 2017-12-09 string s = ex.ToString(); } return res; } /// /// 立即显示ToolKit,若服务未启动,则后台模式启动ToolKit并显示。杨斌 2017-12-19 /// public static void ShowToolKit(string args = "") { Param res = new Param(); try { if (Globals.SunVoteARSAddIn.IsExitApp)//杨斌 2017-03-02 return; Param e = new Param(); e.Pa.Add("ShowToolKit", ""); if (!string.IsNullOrEmpty(args))//杨斌 2019-12-06 e.Pa.Add(args, ""); res = Servive.Request(e); } catch (Exception ex) { //杨斌 2017-12-09 string s = ex.ToString(); if (!string.IsNullOrEmpty(args))//杨斌 2019-12-06 args = " " + args; RunToolKit("RunBack Show" + args); } } public static string ToolKitName { get { string res = "SunVote ARS Tool Kit"; string toolKey = ""; if (GlobalInfo.GetSdkType() == 0) toolKey = "ToolName"; else toolKey = "ToolNamePvs"; res = INIControl.GetInstances(GlobalInfo.SYSTEM_CONFIG_PATH).ReadString("SoftInfo", toolKey, "Tool Kit"); return res; } } /// /// 启动ToolKit,参数可以是:"RunBack", "Show" /// /// /// public static bool RunToolKit(string arg) { bool res = false; Process[] process = Process.GetProcessesByName(ToolKitName); if ((process == null) || (process.Length < 1))//杨斌 2017-12-19 { string toolName = ToolKitName; string path = GlobalInfo.APP_DIR + @"\" + toolName + @"\" + toolName + ".exe"; if (File.Exists(path)) { Process.Start(path, arg); res = true; } } return res; } /// /// 颜色对话框的自定义颜色缓存 /// 杨斌 2014-10-16 /// public static int[] MyCustomColors = null; /// /// 打开文件对话框选择单个文件 /// sFilter = "Excel(*.xls;*.xlsx)|*.xls;*.xlsx"; /// public static string OpenFileDialog(string sFilter = "(*.*)|*.*", string dir = "") { string res = ""; try { OpenFileDialog dlg = new OpenFileDialog(); if (dir == "") { dir = AppDomain.CurrentDomain.BaseDirectory; dlg.InitialDirectory = dir; } dlg.Filter = sFilter;//"Excel(*.xls;*.xlsx)|*.xls;*.xlsx"; if (dlg.ShowDialog() == DialogResult.OK) { res = dlg.FileName; } } catch (Exception ex) { string sErr = ex + ""; //FrmError.DoErr(ex); } return res; } /// /// 保存文件对话框 /// sFilter = "Excel(*.xls;*.xlsx)|*.xls;*.xlsx"; /// public static string SaveFileDialog(string sFilter = "(*.*)|*.*", string dir = "") { string res = ""; try { SaveFileDialog dlg = new SaveFileDialog(); if (dir == "") dir = AppDomain.CurrentDomain.BaseDirectory; dlg.InitialDirectory = dir; dlg.Filter = sFilter;//杨斌 2012-05-23 dlg.AddExtension = true; dlg.OverwritePrompt = true; dlg.ValidateNames = true; if (dlg.ShowDialog() == DialogResult.OK) res = dlg.FileName; } catch (Exception ex) { string sErr = ex + ""; //FrmError.DoErr(ex); } return res; } } /// /// 硬件信息 /// 创建:杨斌 2010-08-09 /// class HardWareInfo { /// /// 键盘型号W52 /// public const string KeypadType_W52 = "W52"; /// /// 键盘型号W00 /// public const string KeypadType_W00 = "W00"; /// /// 键盘型号W40 /// public const string KeypadType_W40 = "W40"; /// /// 键盘型号M52 /// public const string KeypadType_M52 = "M52"; /// /// 键盘型号M52+ /// 杨斌 2013-05-08 /// public const string KeypadType_M52Plus = "M52Plus"; /// /// 键盘型号M30 /// 杨斌 2017-02-07 /// public const string KeypadType_M30 = "M30"; /// /// 键盘型号M52Li /// 杨斌 2015-06-17 /// public const string KeypadType_M52Li = "M52Li"; /// /// 键盘型号M50 /// public const string KeypadType_M50 = "M50"; /// /// 键盘型号Su30 /// public const string KeypadType_Su30 = "Su30"; /// /// 键盘型号F00 /// public const string KeypadType_F00 = "F00"; /// /// 键盘型号M40L /// 杨斌 2014-02-21 /// public const string KeypadType_M40L = "M40L"; /// /// 键盘型号S50 /// 杨斌 2014-10-20 /// public const string KeypadType_S50 = "M40L"; /// /// 基站最小编号 /// public const int BaseID_Min = 1; /// /// 基站最大编号 /// public const int BaseID_Max = 255; /// /// 基站最小频点 /// public const int BaseChannel_Min = 1; /// /// 基站最大频点 /// public const int BaseChannel_Max = 80; /// /// 最小键盘编号 /// public const int KeypadID_Min = 0; /// /// 最大键盘编号 /// public const int KeypadID_Max = 9999; /// /// 键盘最小自动关机时间秒 /// public const int KeypadAtuoOff_Min = 0; /// /// 键盘最大自动关机时间秒 /// public const int KeypadAtuoOff_Max = 255; } }