/// <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); }
/// <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); }