/// <summary> /// 数据初始化 /// </summary> void InitData() { try { String _path = AppDomain.CurrentDomain.BaseDirectory + GlobalSet.appinifile; String _xmlpath = "Application.xml"; string _appname = WindowsAPIUtility.GetLocalSysParam("posset", "transfer_appname", "", _path); //GlobalSet.appname = _appname; Text = GlobalSet.appname; notifyIcon1.Text = GlobalSet.appname; notifyIcon1.BalloonTipText = GlobalSet.appname; notifyIcon1.ShowBalloonTip(100, GlobalSet.appname, GlobalSet.appname, ToolTipIcon.Info); String _applicationXml = WindowsAPIUtility.GetLocalSysParam("posset", "app_xml", _xmlpath, _path);; _xmlpath = AppDomain.CurrentDomain.BaseDirectory + _applicationXml; Dictionary <String, String> _dic = XMLUtility.Instance.GetNodesText(_xmlpath, new string[] { "//applicationConfig/BranchNo" }); if (_dic == null || _dic["//applicationConfig/BranchNo"] == null || _dic["//applicationConfig/BranchNo"].ToString() == string.Empty) { MessageBox.Show("POS机注册信息不存在或有误,请运行程序注册POS机!", GlobalSet.appname); Process.GetCurrentProcess().Kill(); } currentThread = new Thread(DoDealerWork); currentThread.Start(); Decimal _time = 1M; String _timespan = "1"; String _settimespan = WindowsAPIUtility.GetLocalSysParam("posset", "transfer_time", _timespan, _path); Decimal.TryParse(_settimespan, out _time); _time = _time < 1M ? 1M : _time; tbNum.Value = _time; } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", "FormMain--->InitData-->Error:" + ex.ToString(), LogEnum.ExceptionLog); } }
/// <summary> /// 查看日志按钮事件逻辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLog_Click(object sender, EventArgs e) { String _path = AppDomain.CurrentDomain.BaseDirectory + GlobalSet.appinifile; String _setfolder = "transferlog"; String _settimespan = WindowsAPIUtility.GetLocalSysParam("posset", "transfer_folder", _setfolder, _path); Process.Start(AppDomain.CurrentDomain.BaseDirectory + _settimespan); }
public Size MeasureText(string text, Font font) { IntPtr hgdiobj = font.ToHfont(); IntPtr ptr2 = WindowsAPIUtility.SelectObject(this.graphicsHandle, hgdiobj); Size size = this.MeassureTextInternal(text); WindowsAPIUtility.SelectObject(this.graphicsHandle, ptr2); WindowsAPIUtility.DeleteObject(hgdiobj); return(size); }
private Size MeassureTextInternal(string text) { WindowsAPIUtility.RECT lpRect = new WindowsAPIUtility.RECT { left = 0, right = 0, top = 0, bottom = 0 }; WindowsAPIUtility.DrawText(this.graphicsHandle, text, text.Length, ref lpRect, 0x420); return(new Size(lpRect.right, lpRect.bottom)); }
/// <summary> /// 设置按钮事件逻辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSet_Click(object sender, EventArgs e) { if (tbNum.Enabled)//可用情况下 { //TODO:设置同步时间 tbNum.Enabled = false; tbNum.ReadOnly = true; String _path = AppDomain.CurrentDomain.BaseDirectory + GlobalSet.appinifile; WindowsAPIUtility.WritePrivateProfileString("posset", "transfer_time", tbNum.Value.ToString(), _path); } else//不可用 { //TODO:可用 tbNum.Enabled = true; tbNum.ReadOnly = false; } }
private void FrmLogin_FormClosing(object sender, FormClosingEventArgs e) { int record = Gattr.Bll.GetNonUpdateFlow(); if (record > 0) { IntPtr intPtr = WindowsAPIUtility.FindWindow(null, Gattr.AppTitle + "数据传输"); if (intPtr != IntPtr.Zero) { WindowsAPIUtility.ShowWindow(intPtr, 1u); WindowsAPIUtility.SetForegroundWindow(intPtr); } if (MessageBox.Show("为确保数据能成功同步至服务器,请等待数据传输程序将数据传输完毕,\r\n或手动点击[即时处理]进行上传数据后再退出!\r\n\r\n 确定要退出前台吗? ", Gattr.AppTitle, MessageBoxButtons.YesNo) == DialogResult.No) { e.Cancel = true; } } }
/// <summary> /// 初始化数据下载 /// </summary> private static void InitSysIni() { string iniFile = Gattr.INI_FILE_PATH; string errorMessage = string.Empty; if (!File.Exists(iniFile)) { if (FileUtility.Instance.CreateFile(iniFile, false, ref errorMessage)) { //第一次初始化成最初的一个值 WindowsAPIUtility.WritePrivateProfileString("download", "t_product_food", Gattr.LAST_UPDATE_TIME, iniFile); WindowsAPIUtility.WritePrivateProfileString("download", "t_pos_branch_stock", Gattr.LAST_UPDATE_TIME, iniFile); WindowsAPIUtility.WritePrivateProfileString("download", "t_pos_branch_price", Gattr.LAST_UPDATE_TIME, iniFile); WindowsAPIUtility.WritePrivateProfileString("download", "barcode", Gattr.LAST_UPDATE_TIME, iniFile); } else { LoggerHelper.Log("MsmkLogger", "初始化系统配置文件失败:" + errorMessage, LogEnum.InitLog); } } }
public void DrawText(string text, Point point, Font font, Color foreColor) { WindowsAPIUtility.RECT rect = new WindowsAPIUtility.RECT(); IntPtr hgdiobj = font.ToHfont(); IntPtr ptr2 = WindowsAPIUtility.SelectObject(this.graphicsHandle, hgdiobj); int iBkMode = WindowsAPIUtility.SetBkMode(this.graphicsHandle, 1); int crColor = WindowsAPIUtility.SetTextColor(this.graphicsHandle, Color.FromArgb(0, foreColor.R, foreColor.G, foreColor.B).ToArgb()); Size size = this.MeassureTextInternal(text); rect = new WindowsAPIUtility.RECT { left = point.X, top = point.Y, right = rect.left + size.Width, bottom = rect.top + size.Height }; WindowsAPIUtility.DrawText(this.graphicsHandle, text, text.Length, ref rect, 0x20); WindowsAPIUtility.SetTextColor(this.graphicsHandle, crColor); WindowsAPIUtility.SetBkMode(this.graphicsHandle, iBkMode); WindowsAPIUtility.SelectObject(this.graphicsHandle, ptr2); WindowsAPIUtility.DeleteObject(hgdiobj); }
/// <summary> /// 调用服务更新数据库 /// </summary> /// <param name="mark"></param> /// <param name="isAll"></param> /// <returns></returns> bool InvokeServices(String mark, bool isAll) { bool result = false; //1、调用方法获取数据 //2、将数据导入到表 //bool isok = true; DataTable table = null; object obj; try { t_handle _t_handle = Gattr.Bll.SelectHandleData(); //obj = PosServiceProvider.Instance.InvokeService(Gattr.HttpAddress, Gattr.WebPosServicePath, mark, ref isok, Gattr.BranchNo); //obj = PosDownServiceProvider.Instance.InvokeService(Gattr.CONNECT_STRING, mark, ref isok, Gattr.BranchNo, "", 0, ""); Dictionary <string, object> _dic = Gfunc.GetServiceParameter(); _dic.Add("branch_no", Gattr.BranchNo); switch (mark) { case "Getiteminfo": string last_time = WindowsAPIUtility.GetLocalSysParam("download", "t_product_food", Gattr.LAST_UPDATE_TIME, Gattr.INI_FILE_PATH); _dic.Add("rid", _t_handle.t_product_food); _dic.Add("last_time", ExtendUtility.Instance.ParseToDateTime(last_time).ToString()); break; case "Getbrastock": string last_time1 = WindowsAPIUtility.GetLocalSysParam("download", "t_pos_branch_stock", Gattr.LAST_UPDATE_TIME, Gattr.INI_FILE_PATH); _dic.Add("rid", _t_handle.t_product_food_kc); _dic.Add("last_time", ExtendUtility.Instance.ParseToDateTime(last_time1).ToString()); break; case "Getbraprc": string last_time2 = WindowsAPIUtility.GetLocalSysParam("download", "t_pos_branch_price", Gattr.LAST_UPDATE_TIME, Gattr.INI_FILE_PATH); _dic.Add("rid", _t_handle.t_product_food_jg); _dic.Add("last_time", ExtendUtility.Instance.ParseToDateTime(last_time2).ToString()); break; case "Getbarcode": string last_time3 = WindowsAPIUtility.GetLocalSysParam("download", "barcode", Gattr.LAST_UPDATE_TIME, Gattr.INI_FILE_PATH); _dic.Add("rid", _t_handle.t_product_food_barcode); _dic.Add("last_time", ExtendUtility.Instance.ParseToDateTime(last_time3).ToString()); break; case "Getitemcls": //_dic.Add("rid", _t_handle.t_product_food_type); _dic.Add("rid", -1); break; case "Getbasecode": _dic.Add("rid", _t_handle.t_base_code_type); break; case "Getbase": _dic.Add("rid", _t_handle.t_base_code); break; case "Getoper": _dic.Add("rid", _t_handle.t_operator); break; case "Getpmaster": _dic.Add("rid", _t_handle.t_rm_plan_master); break; case "Getcomb": _dic.Add("rid", _t_handle.t_bd_item_combsplit); break; case "Getpdetail": _dic.Add("rid", _t_handle.t_rm_plan_detail); break; } string errorMessage = string.Empty; bool isok1 = true; obj = PServiceProvider.Instance.InvokeMethod(Gattr.serverUrl + "/" + mark, _dic, ref isok1, ref errorMessage); if (isok1) { //if (isok) //{ // //获取数据 // //插入数据 // if (mark != "GetPosSet") // { string result1 = ExtendUtility.Instance.ParseToString(obj); //if (!string.IsNullOrEmpty(result1)) { if (result1 != "-10" && result1 != "-20") { table = JsonUtility.Instance.JsonToDataTable(result1); if (!SIString.IsNullOrEmptyDataTable(table)) { decimal rid = 0M; switch (mark) { case "Getitemcls": result = Gattr.Bll.InsertItemClsData(table, _t_handle.t_product_food_type, ref rid); if (result) { _t_handle.t_product_food_type = rid; } break; case "Getbarcode": result = Gattr.Bll.InsertBarcodeData(table, _t_handle.t_product_food_barcode, ref rid); if (result) { _t_handle.t_product_food_barcode = rid; } break; case "Getiteminfo": result = Gattr.Bll.InsertItemData(table, _t_handle.t_product_food, ref rid); if (result) { _t_handle.t_product_food = rid; } break; case "Getoper": result = Gattr.Bll.InsertCashierData(table, _t_handle.t_operator, ref rid); if (result) { _t_handle.t_operator = rid; } break; case "Getbasecode": result = Gattr.Bll.InsertBaseTypeData(table, _t_handle.t_base_code_type, ref rid); if (result) { _t_handle.t_base_code_type = rid; } break; case "Getbase": result = Gattr.Bll.InsertBaseData(table, _t_handle.t_base_code, ref rid); if (result) { _t_handle.t_base_code = rid; } break; case "Getpayinfo": result = Gattr.Bll.InsertPaymentInfo(table); break; case "Getkey": result = Gattr.Bll.InsertFunction(table); break; case "Getbrninfo": result = Gattr.Bll.InsertBrancheList(table); break; case "Getbraprc": result = Gattr.Bll.UpdateItemPrice(table, ref rid); if (result) { _t_handle.t_product_food_jg = rid; } break; case "Getbrastock": result = Gattr.Bll.UpdateItemStock(table, ref rid); if (result) { _t_handle.t_product_food_kc = rid; } break; case "Getprule": result = Gattr.Bll.InsertPlanRule(table); break; case "Getpmaster": result = Gattr.Bll.InsertPlanMaster(table, _t_handle.t_rm_plan_master, ref rid); if (result) { _t_handle.t_rm_plan_master = rid; } break; case "Getpdetail": result = Gattr.Bll.InsertPlanDetail(table, _t_handle.t_rm_plan_detail, ref rid); if (result) { _t_handle.t_rm_plan_detail = rid; } break; case "Getcomb": result = Gattr.Bll.InsertItemComb(table, _t_handle.t_bd_item_combsplit, ref rid); if (result) { _t_handle.t_bd_item_combsplit = rid; } break; case "Getsup": result = Gattr.Bll.InsertSupinfo(table); break; default: break; } //如果数据更新成功则更新标识信息 if (result) { Gattr.Bll.UpdateHandleData(_t_handle); } } else { result = true; } } } // } // else // { // // List<t_sys_pos_set> sets = JsonUtility.Instance.JsonToObject<List<t_sys_pos_set>>(obj.ToString()); // // result = Gattr.Bll.InsertPosSysSet(sets); // } //} //else //{ // MessageBox.Show(SIString.TryStr(obj), Gattr.AppTitle); //} } else { MessageBox.Show(errorMessage, Gattr.AppTitle); } } catch (Exception ex) { LoggerHelper.Log("MsmkLogger", ex.ToString(), LogEnum.ExceptionLog); } return(result); }