private void getData() { if (residentBaseInfos == null) { residentBaseInfos = new List <ResidentBaseInfo>(); } else { residentBaseInfos.Clear(); } StringObjectDictionary param = new { OrderByClause = " OperatedOn desc ", AreaIdSub = "", KeyWord = "", PageNo = 1, PageSize = 30 }.ToStringObjectDictionary(); HttpAdapter.postSyncAsJSON(GovVar.DataPointOfManage + "/Bas/ResidentBaseInfoService/GetResidentBaseInfo", param, (ret, res) => { if ((bool)ret.Success) { foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); ResidentBaseInfo dtItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <ResidentBaseInfo>(); residentBaseInfos.Add(dtItem); } } }); }
public void Alter() { var testObj = new TypedObject(); var dict = new DynamicAdapter(testObj, new MapOptions { CanAlterProperties = false }); dynamic dyn = dict; Assert.Throws<InvalidOperationException>(() => { dyn.newprop = "newdata"; }, "Can't add a prop"); Assert.Throws<InvalidOperationException>(() => { dict.Remove("Stringprop"); }, "Can't rmove a prop"); // we can update with just CanAlterProprerties=false but IsReadOnly=true dyn.stringprop = "stringdata"; dict.Options.CanAlterProperties = true; dyn.newprop = "newdata"; Assert.AreEqual("newdata",dict["Newprop"]); Assert.IsTrue(dict.ContainsKey("stringprop")); dict.Remove("Stringprop"); Assert.IsFalse(dict.ContainsKey("stringprop")); }
private void FetchData() { if (!isFetchingData) { if (datas == null) { datas = new List <WorkOrderInfo>(); } else { datas.Clear(); } new Action(() => { isFetchingData = true; if (MerchantVar.CurrentMerchant.AuthNodeInfos.Count > 0) { foreach (var nodeInfo in MerchantVar.CurrentMerchant.AuthNodeInfos) { //string url = nodeInfo.AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/GetWorkOrderToResponse"; string url = nodeInfo.AccessPoint + "/Oca/WorkOrderService/GetWorkOrderToResponse"; HttpAdapter.getSyncTo(url, null, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = nodeInfo.StationId }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); WorkOrderInfo dataItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <WorkOrderInfo>(); dataItem.DoStatusName = WorkOrderInfo.getDoStatusName(int.Parse(item.StringObjectDictionary.DoStatus)); dataItem.AccessPoint = nodeInfo.AccessPoint; dataItem.StationId = nodeInfo.StationId; datas.Add(dataItem); } } }); } } }).BeginInvoke(new AsyncCallback((ar) => { //AsyncResult result = (AsyncResult)ar; this.UIInvoke(() => { xLoadingPanel.Stop(); xSource.DataSource = datas; xSource.ResetBindings(false); }); isFetchingData = false; }), null); xLoadingPanel.Start(); } }
private void getData(string areaIdSub) { if (residentBaseInfos == null) { residentBaseInfos = new List <ResidentBaseInfo>(); } else { residentBaseInfos.Clear(); } StringObjectDictionary param = new { Order = " desc ", Sort = " OperatedOn ", AreaId = areaIdSub, KeyWord = txbKeyWord.Text.Trim(), PageNo = _pageCurrent, PageSize = _pageSize }.ToStringObjectDictionary(); HttpAdapter.postSyncAsJSON(GovVar.DataPointOfManage + "/Bas/ResidentBaseInfoService/GetResidentBaseInfo", param, new { ConnectId = GovVar.ConnectId }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); ResidentBaseInfo dtItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <ResidentBaseInfo>(); residentBaseInfos.Add(dtItem); } var total = ret.total.Value; _nMax = (int)total; _pageCount = _nMax / _pageSize; _pageCount = (_nMax % _pageSize) == 0 ? _pageCount : _pageCount + 1; } else { _nMax = 0; _pageCount = 0; } }); dgvResidentBaseInfo.DataSource = null; dgvResidentBaseInfo.DataSource = residentBaseInfos; dgvResidentBaseInfo.ScrollBars = ScrollBars.Both; txbPageTo.Text = _pageCurrent.ToString(); lblPageCount.Text = "共 " + _pageCount.ToString() + " 页"; lblRecordCount.Text = "总共 " + _nMax + " 条;当前第 " + _pageCurrent + " 页;共 " + _pageCount + " 页,每页 " + _pageSize + " 条"; //bdngBaseInfo.BindingSource = null; //bdngBaseInfo.BindingSource = residentBaseInfos; }
private bool checkIDNo() { bool result = false; string strIDNo = txbIDNo.Text.Trim(); //新增和修改之前查看身份证号位数是否正确 if ((strIDNo.Length != 15) && (strIDNo.Length != 18)) { //MessageBox.Show("输入的身份证号位数错误"); } else { HttpAdapter.getSyncTo(GovVar.DataPointOfManage + "/Bas/ResidentBaseInfoService/IDNoDuplicatesForCS", null, new { ConnectId = GovVar.ConnectId, IDNo = strIDNo, Status = 0 }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success.Value) { string strResidentId = lblResidentId.Text; string strOldManName = ""; for (int i = 0; i < ret.rows.Count; i++) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(ret.rows[i].ToString())); ResidentBaseInfo dtItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <ResidentBaseInfo>(); if (dtItem.ResidentId.ToLower() != strResidentId.ToLower()) { strOldManName += dtItem.ResidentName; } } if (strOldManName == "") { result = true; } else { MessageBox.Show(strOldManName + "已使用此身份证号码"); } } else { MessageBox.Show("身份证号码验证失败"); } }); } return(result); }
public void Add() { var testObj = new TypedObject(); var dict = new DynamicAdapter(testObj); dict.Options.CanAlterProperties = true; dynamic dyn = dict; Assert.AreEqual(13, dict.Count); dyn.stringfield = "New string data"; Assert.AreEqual(13, dict.Count); Assert.AreEqual("New string data", dyn.Stringfield); Assert.AreEqual("New string data", testObj.StringField); dyn.MyNewProp = "added data"; Assert.AreEqual(14, dict.Count); Assert.AreEqual("added data", dyn.mynewprop); }
//号码整合以批次实现发送 private void QueuedSendSms(dynamic rows, string url, object token, object NodeId) { //按批次号实现号码整合 List <SmsSendInfo> sendlist = new List <SmsSendInfo>(); IDictionary <string, object> tmpdic; int count = 0; SmsSendInfo smsSendInfo; foreach (var row in rows) { dynamic list = new ExpandoObject(); DynamicAdapter.Parse(list, System.Xml.Linq.XElement.Parse(row.ToString())); tmpdic = list.StringObjectDictionary as IDictionary <string, object>; smsSendInfo = new SmsSendInfo(); smsSendInfo.SerialNumber = e0571.web.core.Utils.TypeConverter.ChangeString(tmpdic["BatchNum"]); smsSendInfo.ScheduleTime = e0571.web.core.Utils.TypeConverter.ChangeString(tmpdic["ScheduleTime"], ""); smsSendInfo.SendCatalog = e0571.web.core.Utils.TypeConverter.ChangeString(tmpdic["SendCatalog"]); smsSendInfo.UserNumber = e0571.web.core.Utils.TypeConverter.ChangeString(tmpdic["Mobile"]); if (e0571.web.core.Utils.TypeConverter.ChangeString(tmpdic["SendCatalog"]) == "0") { smsSendInfo.MessageContent = e0571.web.core.Utils.TypeConverter.ChangeString(tmpdic["SourceCatalog"]) + ":"; } smsSendInfo.MessageContent += e0571.web.core.Utils.TypeConverter.ChangeString(tmpdic["SendContent"]); count = sendlist.Count(s => s.SerialNumber == smsSendInfo.SerialNumber); if (sendlist.Count == 0 || count == 0) { sendlist.Add(smsSendInfo); } if (count > 0) { sendlist.FirstOrDefault(s => s.SerialNumber == smsSendInfo.SerialNumber).UserNumber += "," + smsSendInfo.UserNumber; } } if (sendlist.Count > 0) { SendSms(sendlist, url, token, NodeId); } }
private void ReloadBookMeals() { this.UIDoOnceTask(() => { HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManBookMealForToday", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { Data.BookMeals = new List <BookMealInfo>(); foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); Data.BookMeals.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <BookMealInfo>()); } MessageBoxAdapter.ShowInfo("更新配餐信息成功!"); } else { lblTip.Text = "更新配餐信息失败:" + (string)ret.ErrorCode; } }); }); }
public override string Call(string input) => DynamicAdapter.NewMethod(input);
public void WrapperBasic() { var testObj = new TypedObject { StringProp="quick brown fox", IntArray =new int[] { 1, 2, 4, 8 }, DoubleProp = 3.14, StringList = new List<string> { "a","b","c" } }; dynamic dict = new DynamicAdapter(testObj); Assert.AreEqual("quick brown fox", dict.StringProp); Assert.AreEqual(4, ((int[])dict.IntArray)[2]); Assert.AreEqual(3.14, dict.DoubleProp); Assert.AreEqual("b", ((IList<string>)dict.StringList)[1]); }
public void Updating() { var testObj = new TypedObject(); dynamic dict = new DynamicAdapter(testObj); Assert.AreEqual(0d, testObj.DoubleProp); dict.doubleprop = 3.14; Assert.AreEqual(3.14, testObj.DoubleProp); Assert.Throws<InvalidCastException>(() => { dict.doubleprop = "abc"; }, "Can't assign bad data type"); }
public void Remove() { var testObj = new TypedObject(); var dict = new DynamicAdapter(testObj); dynamic dyn=dict; int count = dict.Count; dyn.newprop = "newdata"; Assert.AreEqual(count + 1, dict.Count, "Added a property"); Assert.IsTrue(dict.Remove("stringprop")); Assert.AreEqual(count, dict.Count, "Removed a property"); dict["doubleprop"] = 5.67; Assert.IsFalse(dict.Remove(new KeyValuePair<string,object>("doubleprop",1.23)), "Can't remove KVP with diff value"); Assert.IsTrue(dict.ContainsKey("DoubleProp")); Assert.IsTrue(dict.Remove(new KeyValuePair<string,object>("doubleprop",5.67)), "Removed KVP with wrong case"); Assert.IsFalse(dict.ContainsKey("DoubleProp")); Assert.AreEqual(count - 1, dict.Count, "Count is correct at end"); }
private Thread InitAccessPointThread(AccessPointPart app) { return(ThreadAdapter.DoCircleTask( () => { if (lbResponseLog.Items.Count > 1000) { lbResponseLog.Items.Clear(); } if (lbResponseLog.Items.Count > 1000) { lbResponseLog.Items.Clear(); } #region 执行任务=》请求objectId对应的AccessPoint string url = app.Url + "/Pam/PamService/LoadRemindersWorkExecute"; this.UIInvoke(() => { lbRequestLog.Items.Add("[" + app.ObjectId + "] " + url + " " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); }); HttpAdapter.postSyncAsJSON(url, (result, response) => { if ((bool)result.Success) { dynamic item; //执行发送信息 IList <YYReminder> yyReminders = new List <YYReminder>(); YYReminder yyReminder; //更新信息 Dictionary <string, string> IdCallNoDic = new Dictionary <string, string>(); foreach (var row in result.rows) { item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); yyReminder = new YYReminder(); yyReminder.dest = item.StringObjectDictionary.CallNo; yyReminder.roomNum = item.StringObjectDictionary.RoomNo; yyReminder.sickbedNum = string.IsNullOrEmpty(item.StringObjectDictionary.SickBedNo) ? "0" : item.StringObjectDictionary.SickBedNo; yyReminder.repeatTimes = item.StringObjectDictionary.PlayRepeats; yyReminder.warnType = "13001" + item.StringObjectDictionary.WorkItem; IdCallNoDic.Add(item.StringObjectDictionary.Id, item.StringObjectDictionary.CallNo); yyReminders.Add(yyReminder); } if (yyReminders.Count == 0) { return; } HttpAdapter.postAsyncAsJSON(sendReminderUrl, new { info = yyReminders }.ToStringObjectDictionary(), (ret, res) => { if (ret != null) { //暂时不做处理 默认发送成功 /*item = Newtonsoft.Json.JsonConvert.DeserializeObject(ret); * Dictionary<string, string> successSendDic = new Dictionary<string, string>(); * foreach (var key in item) * { * if((string)key.result!="+OK") * { * successSendDic = IdCallNoDic.Where(s => s.Value == (string)key.dest) as Dictionary<string, string>; * } * } */ if (IdCallNoDic.Count > 0) { HttpAdapter.postAsyncAsJSON(app.Url + "/Pam/PamService/UpdateWorkExecute", new { Ids = IdCallNoDic.Keys.ToArray() }.ToStringObjectDictionary(), (ret1, res1) => { this.UIInvoke(() => { lbResponseLog.Items.Insert(0, "[" + app.ObjectId + "] : " + app.Url + "/Pam/PamService/UpdateWorkExecute"); }); }); } } }); } else { this.UIInvoke(() => { lbResponseLog.Items.Insert(0, "[" + app.ObjectId + "] ErrorMessage: " + result.ErrorMessage); }); } }); #endregion }, 60000, () => { return false;//永远执行 }, () => { return string.IsNullOrEmpty(sendReminderUrl);//空URL 跳过,否则执行 })); }
private void FetchData() { if (!isFetchingData) { if (datas == null) { datas = new List <WorkOrderInfo>(); } else { datas.Clear(); } new Action(() => { isFetchingData = true; if (MerchantVar.CurrentMerchant.AuthNodeInfos.Count > 0) { foreach (var nodeInfo in MerchantVar.CurrentMerchant.AuthNodeInfos) { //string url = nodeInfo.AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/GetWorkOrderFinished"; //string url = nodeInfo.AccessPoint + "/Oca/WorkOrderService/GetWorkOrderFinished"; string url = "http://localhost/SmartLife.CertManage.MerchantServices/Oca/WorkOrderService/GetWorkOrderFinished"; //string OldManName = txbOldManName.Text.Trim(); //string ServeManArriveTime = dateTimePickerArrivalTime.Text; //string ServeManLeaveTime = dateTimePickerLeaveTime.Text; //设置传递的参数 StringObjectDictionary postPram = new StringObjectDictionary(); if (txbOldManName.Text.Trim() != "") { postPram["OldManName"] = txbOldManName.Text.Trim(); } else { postPram["OldManName"] = null; } //满意度 IEnumerable <RadioButton> rbsOfReturnVisit = pnlFeedbackToOldManName.Controls.OfType <RadioButton>().Where(x => x.Checked == true); if (rbsOfReturnVisit != null) { foreach (var rb in rbsOfReturnVisit) { if (rb.Name.Remove(0, 2).Remove(5) != "00000") { postPram["FeedbackToServiceStation"] = rb.Name.Remove(0, 2).Remove(5); } else { postPram["FeedbackToServiceStation"] = null; } } } else { postPram["FeedbackToServiceStation"] = null; } //服务人员到达时间 postPram["ServeManArriveTime_Start"] = dateTimePickerArrivalTime.Text; HttpAdapter.postSyncAsJSON(url, postPram, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = nodeInfo.StationId }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { System.TimeSpan ts = new TimeSpan(); foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); WorkOrderInfo dataItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <WorkOrderInfo>(); dataItem.DoStatusName = WorkOrderInfo.getDoStatusName(int.Parse(item.StringObjectDictionary.DoStatus)); dataItem.AccessPoint = nodeInfo.AccessPoint; dataItem.StationId = nodeInfo.StationId; ts = DateTime.Parse(dataItem.ServeManLeaveTime).Subtract(DateTime.Parse(dataItem.ServeManArriveTime)); dataItem.ServiceTime = ts.TotalHours.ToString("0.00") + "小时"; if (numUDServiceTimeFrom.Text.Trim() != "" && numUDServiceTimeTo.Text.Trim() != "") { if (int.Parse(numUDServiceTimeFrom.Text.Trim()) <= float.Parse(ts.TotalHours.ToString("0.00")) && float.Parse(ts.TotalHours.ToString("0.00")) <= int.Parse(numUDServiceTimeTo.Text.Trim())) { datas.Add(dataItem); } } else if (numUDServiceTimeFrom.Text.Trim() == "" && numUDServiceTimeTo.Text.Trim() != "") { if (float.Parse(ts.TotalHours.ToString("0.00")) <= int.Parse(numUDServiceTimeTo.Text.Trim())) { datas.Add(dataItem); } } else if (numUDServiceTimeFrom.Text.Trim() != "" && numUDServiceTimeTo.Text.Trim() == "") { if (int.Parse(numUDServiceTimeFrom.Text.Trim()) <= float.Parse(ts.TotalHours.ToString("0.00"))) { datas.Add(dataItem); } } else if (numUDServiceTimeFrom.Text.Trim() == "" && numUDServiceTimeTo.Text.Trim() == "") { datas.Add(dataItem); } } } }); } } }).BeginInvoke(new AsyncCallback((ar) => { //AsyncResult result = (AsyncResult)ar; this.UIInvoke(() => { xLoadingPanel.Stop(); xSource.DataSource = datas; xSource.ResetBindings(false); }); isFetchingData = false; }), null); xLoadingPanel.Start(); } }
public void NullValues() { var testObj = new TypedObject(); var dict = new DynamicAdapter(testObj); dynamic dyn = dict; dict.Options.CanAlterProperties = true; int count = dict.Count; testObj.ObjectProp = null; dyn.NewProp = null; Assert.AreEqual(count + 1, dict.Count, "New property added"); Assert.IsNull(dict["objectprop"]); Assert.IsNull(dict["newprop"]); Assert.AreEqual(Undefined.Value,dict["noprop"]); testObj.ObjectProp = 1; dict["newprop"] = 2; Assert.AreEqual(1,dict["objectprop"]); Assert.AreEqual(2,dict["newprop"]); }
private void DoLogin(string userCode, string password) { // btnOK.SafeButtonEnable(false); this.UIDoStepTasks(new List <Func <bool> >() { () => { #region 检查硬件环境 lblLoadItems.Text = _LoadItem = "检查硬件环境"; Application.DoEvents(); API icAPI = new API(); icAPI.InitIC(); if (icAPI.IcDev < 0) { if (MessageBoxAdapter.ShowConfirm("初始化IC读卡设备失败,请确认是否已连接IC读卡设备!是否要跳过该步骤?") == System.Windows.Forms.DialogResult.OK) { btnOK.SafeButtonEnable(true); isBreak = false; } else { isBreak = true; return(false); } } else { icAPI.ExitIC(); } isBreak = false; return(true); #endregion }, () => { #region 读取服务机构编码 lblLoadItems.Text = _LoadItem = "读取服务机构编码"; isBreak = false; Application.DoEvents(); if (string.IsNullOrEmpty(SettingsVar.BindingPACode)) { frmBindingPA frm = new frmBindingPA(); frm.ShowDialog(); if (frm.DialogResult != System.Windows.Forms.DialogResult.OK) { isBreak = true; this.DialogResult = System.Windows.Forms.DialogResult.Cancel; btnOK.SafeButtonEnable(true); return(false); } else { this.Activate(); } } return(true); #endregion }, () => { #region 用户认证 lblLoadItems.Text = _LoadItem = "用户认证"; isBreak = false; Application.DoEvents(); string authEndPoint = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_END_POINT, Common.CFG_FILE_PATH); string objectId = SettingsVar.BindingPACode.Substring(2, 6); HttpAdapter.postSyncAsJSON(authEndPoint, new { RunMode = SettingsVar.RunMode, ObjectId = objectId, UserCode = userCode, PasswordHash = MD5Provider.Generate(password) }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { Data.UserId = Guid.Parse((string)ret.ret.UserId); SettingsVar.DataExchangePoint = (string)ret.ret.AccessPoint; INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_USER_NAME_SINCE_LAST, userCode, Common.INI_FILE_PATH); } else { MessageBoxAdapter.ShowError((string)ret.ErrorMessage); isBreak = true; btnOK.SafeButtonEnable(true); } }); if (isBreak) { return(false); } return(true); #endregion }, () => { #region 更新老人数据 lblLoadItems.Text = _LoadItem = "更新老人数据"; isBreak = false; Application.DoEvents(); HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManInfoForSelfServiceMachine", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { Data.OldMans = new List <OldManInfo>(); foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); Data.OldMans.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <OldManInfo>()); } //MessageBoxAdapter.ShowInfo("老人:" + Data.OldMans.Count.ToString()); } else { isBreak = true; lblError.Text = ret.ErrorCode; } }); if (isBreak) { return(false); } return(true); #endregion }, () => { #region 更新配餐数据 lblLoadItems.Text = _LoadItem = "更新配餐数据"; isBreak = false; Application.DoEvents(); HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManBookMealForToday", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { Data.BookMeals = new List <BookMealInfo>(); foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); Data.BookMeals.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <BookMealInfo>()); } //MessageBoxAdapter.ShowInfo("订餐:" + Data.BookMeals.Count.ToString()); } else { isBreak = true; lblError.Text = ret.ErrorCode; } }); if (isBreak) { return(false); } return(true); #endregion }, () => { allLoaded = true; this.DialogResult = System.Windows.Forms.DialogResult.OK; return(true); } }, Common.msDelay); lblLoadItems.UIDoCircleTask(() => { if (dotNum == 3) { lblLoadItems.Text = _LoadItem; dotNum = 0; } else { lblLoadItems.Text += "."; dotNum++; } }, Common.msDot, () => { return(allLoaded || isBreak); }); }
private void FetchData() { new Action(() => { //string url = AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/GetWorkOrderInfo/" + WorkOrderId; string url = AccessPoint + "/Oca/WorkOrderService/GetWorkOrderInfo/" + WorkOrderId; HttpAdapter.getSyncTo(url, null, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = StationId }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(ret.ret.ToString())); LastError = null; } else { LastError = ret.ErrorMessage; } }); }).BeginInvoke(new AsyncCallback((ar) => { //AsyncResult result = (AsyncResult)ar; this.UIInvoke(() => { if (item != null) { int doStatus = int.Parse(item.StringObjectDictionary.DoStatus); IDictionary <string, object> dataItem = (item.StringObjectDictionary as IDictionary <string, object>); if (doStatus > 0 && doStatus < 4) { if (e0571.web.core.Utils.TypeConverter.ChangeString(dataItem["ServeResult"]) == "" || e0571.web.core.Utils.TypeConverter.ChangeString(dataItem["FeedbackToOldMan"]) == "" ) { //处置督办 txtServeManName.Visible = true; dtpServeBeginTime.Visible = true; dtpServeEndTime.Visible = true; IEnumerable <RadioButton> rbsOfServeResultName = pnlServeResultName.Controls.OfType <RadioButton>(); foreach (var rb in rbsOfServeResultName) { rb.Visible = true; } txtServeResultRemark.Visible = true; IEnumerable <RadioButton> rbsOfFeedbackToOldManName = pnlFeedbackToOldManName.Controls.OfType <RadioButton>(); foreach (var rb in rbsOfFeedbackToOldManName) { rb.Visible = true; } txtFeedbackRemarkToOldMan.Visible = true; } } else if (doStatus == 4) { btnOK.Visible = false; } else { btnPrint.Visible = false; btnOK.Text = "响应"; } lblWorkOrderNo.Text = item.StringObjectDictionary.WorkOrderNo; lblDoStatus.Text = WorkOrderInfo.getDoStatusName(doStatus); foreach (var key in dataItem.Keys) { Control[] controlsOfInfo = tlpInfo.Controls.Find("lbl" + key, true); if (controlsOfInfo.Length == 1) { (controlsOfInfo[0] as Label).Text = e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]); if (key == "Gender") { (controlsOfInfo[0] as Label).Text = WorkOrderInfo.getGenderName(e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key])); } } //查找process内的主动控件 if (txtServeManName.Visible && txtServeManName.Name == ("txt" + key)) { txtServeManName.Text = e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]); txtServeManName.BackColor = Color.LightGreen; } if (dtpServeBeginTime.Visible && dtpServeBeginTime.Name == ("dtp" + key)) { dtpServeBeginTime.Text = e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]); } if (dtpServeEndTime.Visible && dtpServeEndTime.Name == ("dtp" + key)) { dtpServeEndTime.Text = e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]); } if (pnlServeResultName.Name == ("pnl" + key + "Name")) { IEnumerable <RadioButton> rbsOfServeResult = pnlServeResultName.Controls.OfType <RadioButton>().Where(x => x.Visible == true); if (rbsOfServeResult.Count() > 0) { pnlServeResultName.BackColor = Color.LightGreen; } foreach (var rb in rbsOfServeResult) { if (rb.Name == "rb" + e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]) + "Of11016") { rb.Checked = true; break; } } } if (txtServeResultRemark.Visible && txtServeResultRemark.Name == ("txt" + key)) { txtServeResultRemark.Text = e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]); } if (pnlFeedbackToOldManName.Name == ("pnl" + key + "Name")) { IEnumerable <RadioButton> rbsOfReturnVisit = pnlFeedbackToOldManName.Controls.OfType <RadioButton>().Where(x => x.Visible == true); if (rbsOfReturnVisit.Count() > 0) { pnlFeedbackToOldManName.BackColor = Color.LightGreen; } foreach (var rb in rbsOfReturnVisit) { if (rb.Name == "rb" + e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]) + "Of11017") { rb.Checked = true; break; } } } if (txtFeedbackRemarkToOldMan.Visible && txtFeedbackRemarkToOldMan.Name == ("txt" + key)) { txtFeedbackRemarkToOldMan.Text = e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]); } } } xLoadingPanel.Stop(); if (!string.IsNullOrEmpty(LastError)) { MessageBoxAdapter.ShowError(LastError); } }); }), null); xLoadingPanel.Start(); }
private void FetchData() { new Action(() => { //string url = AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/GetWorkOrderInfo/" + WorkOrderId; string url = AccessPoint + "/Oca/WorkOrderService/GetWorkOrderInfo/" + WorkOrderId; HttpAdapter.getSyncTo(url, null, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = StationId }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(ret.ret.ToString())); LastError = null; } else { LastError = ret.ErrorMessage; } }); }).BeginInvoke(new AsyncCallback((ar) => { //AsyncResult result = (AsyncResult)ar; this.UIInvoke(() => { if (item != null) { int doStatus = int.Parse(item.StringObjectDictionary.DoStatus); IDictionary <string, object> dataItem = (item.StringObjectDictionary as IDictionary <string, object>); lblWorkOrderNo.Text = item.StringObjectDictionary.WorkOrderNo; lblOperatedByName.Text = item.StringObjectDictionary.OperatedByName; lblDoStatus.Text = WorkOrderInfo.getDoStatusName(doStatus); foreach (var key in dataItem.Keys) { Control[] controlsOfInfo = tlpInfo.Controls.Find("lbl" + key, true); if (controlsOfInfo.Length == 1) { (controlsOfInfo[0] as Label).Text = e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]); if (key == "Gender") { (controlsOfInfo[0] as Label).Text = WorkOrderInfo.getGenderName(e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key])); } else if (key == "ServeFee" || key == "ServeFeeByGov" || key == "ServeFeeBySelf") { if (e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]) != "") { (controlsOfInfo[0] as Label).Text = e0571.web.core.Utils.TypeConverter.ChangeString(dataItem[key]) + "/小时"; } } } } } xLoadingPanel.Stop(); if (!string.IsNullOrEmpty(LastError)) { MessageBoxAdapter.ShowError(LastError); } }); }), null); xLoadingPanel.Start(); }
public override string Call(string input) => DynamicAdapter.Run(input);
private void FetchReminderData() { if (MerchantVar.CurrentMerchant.AuthNodeInfos.Count > 0) { foreach (var nodeInfo in MerchantVar.CurrentMerchant.AuthNodeInfos) { string url = nodeInfo.AccessPoint + "/Pub/ReminderService/GetReminderStatGroupBySourceType"; if (SettingsVar.CurrentRemindType == RemindType.详细信息) { url = nodeInfo.AccessPoint + "/Pub/ReminderService/GetReminderItems"; } url += "/Oca_ServiceWorkOrder,WorkOrderId"; HttpAdapter.getSyncTo(url, null, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationId = nodeInfo.StationId }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); if (SettingsVar.CurrentRemindType == RemindType.详细信息) { WorkOrderReminderInfo dataItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <WorkOrderReminderInfo>(); if (queuesOfWorkOrderReminderInfo.Count(it => it.SourceType == dataItem.SourceType && it.SourceKey == dataItem.SourceKey) == 0) { //不存在 dataItem.AccessPoint = nodeInfo.AccessPoint; dataItem.StationId = nodeInfo.StationId; queuesOfWorkOrderReminderInfo.Enqueue(dataItem); } } else if (SettingsVar.CurrentRemindType == RemindType.统计信息) { WorkOrderReminderStatInfo dataItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <WorkOrderReminderStatInfo>(); if (queuesOfWorkOrderReminderStatInfo.Count(it => it.SourceType == dataItem.SourceType) == 0) { dataItem.AccessPoint = nodeInfo.AccessPoint; dataItem.StationId = nodeInfo.StationId; queuesOfWorkOrderReminderStatInfo.Enqueue(dataItem); } else { WorkOrderReminderStatInfo xItem = queuesOfWorkOrderReminderStatInfo.SingleOrDefault(it => it.SourceType == dataItem.SourceType); if (xItem != null) { if (xItem.StationId == nodeInfo.StationId) { xItem.ReminderNum = dataItem.ReminderNum; } else { //不同区域 dataItem.AccessPoint = nodeInfo.AccessPoint; dataItem.StationId = nodeInfo.StationId; queuesOfWorkOrderReminderStatInfo.Enqueue(dataItem); } } } } } } }); } } }
public void Options() { TypedObject test = GetTestObject(); dynamic target = new DynamicAdapter(test,new MapOptions { CaseSensitive = true, CanAlterProperties = false, CanAccessMissingProperties = false }); // todo move this test to poco2dict //Assert.AreEqual(ObjectMapper.DefaultOptions.DynamicObjectType, target.GetType(), "Default dynamic type is created"); Assert.AreEqual(true, target.BoolProp); Assert.Throws<RuntimeBinderException>(() => { var t = target.boolProp; }); Assert.Throws<InvalidOperationException>(() => { target.newProp = "test"; }); // change to allow accessing missing target = new DynamicAdapter(test, new MapOptions { CaseSensitive = true, CanAlterProperties = false, CanAccessMissingProperties = true }); Assert.AreEqual(Undefined.Value, target.boolprop); // most permissive target = new DynamicAdapter(test, new MapOptions { CaseSensitive = false, UndefinedValue = null }); Assert.AreEqual(1.2, target.doubleprop); target.newProp = "test"; Assert.AreEqual("test", target.newprop, "Created property & accessed it with different case"); Assert.AreEqual(null, target.missingprop, "The custom undefined value was used for a missing property."); }
//发送短信 private void _LoopForSendSms() { SendSms_CircleThread = ThreadAdapter.DoCircleTask(() => { string strUrl, strToken, strNodeId; foreach (var item in smsPointDic) { strUrl = item.Value.Url; strToken = item.Value.Token; strNodeId = item.Value.NodeId; HttpAdapter.getSyncTo(strUrl + "/Pub/SmsSendService/QueuedUnSendSms", null, new { ApplicationId = "CS001", Token = strToken, NodeId = strNodeId }.ToStringObjectDictionary(), (smsret, smsres) => { if ((bool)smsret.Success) { StringObjectDictionary sod; IDictionary <string, object> dic; string strItem = ""; DateTime scheduleTime = DateTime.Now; foreach (var row in smsret.rows) { sod = new StringObjectDictionary(); dynamic list = new ExpandoObject(); DynamicAdapter.Parse(list, System.Xml.Linq.XElement.Parse(row.ToString())); dic = list.StringObjectDictionary; strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["SendCatalog"]); if (strItem == "0") { sod = sod.Union2(txtDictionary.ToStringObjectDictionary()); } strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["Mobiles"]); if (string.IsNullOrEmpty(strItem)) { continue; } //跳过 sod.Add("UserNumber", strItem); //是否有预约时间 是-转化yyyyMMddHHmmss;否-空 strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["ScheduleTime"], ""); sod.Add("ScheduleTime", strItem); if (!string.IsNullOrEmpty(strItem)) { if (DateTime.TryParse(strItem, out scheduleTime)) { sod["ScheduleTime"] = scheduleTime.ToString("yyyyMMddHHmmss"); } } strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["SendContent"]); sod.Add("MessageContent", HttpUtility.UrlEncode(strItem, Encoding.GetEncoding("GBK"))); //批次号 strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["BatchNum"]); sod.Add("SerialNumber", strItem); //发送HttpAdapter.postSyncAsForm Common.postSyncAsForm(smsEndPoint + "/Send.do", sod, null, (ret, res) => { Dictionary <string, string> retdict = Common.StrToDictionary(ret, '&'); if (retdict["result"] == "0") { this.Invoke(new Action <string, string>((p1, p2) => { lb_Send.Items.Add("[" + p1 + "] 成功发送 [" + p2 + "]"); }), new object[] { sod["UserNumber"], HttpUtility.UrlDecode((string)sod["MessageContent"], Encoding.GetEncoding("GBK")) }); //需要回执的短信 StringObjectDictionary sod2; if (!sendSmsDic.TryGetValue(strItem, out sod2)) { sod2 = new { SmsNodeId = strNodeId, SmsToken = strToken, SmsUrl = strUrl }.ToStringObjectDictionary(); sendSmsDic.TryAdd(strItem, sod2); } //更新成功发送数据 UpdateSmsSendStatus(new { Status = 1, Mobiles = ((string)sod["UserNumber"]), BatchNum = sod["SerialNumber"] }.ToStringObjectDictionary(), strUrl, strToken, strNodeId, 0); //发送成功 检查是否有发送失败数据 if (!string.IsNullOrEmpty(retdict["faillist"])) { string[] strMobiles = retdict["faillist"].Split(','); string mobiles = "'" + string.Join("','", strMobiles.Where(s => !string.IsNullOrEmpty(s))) + "'"; this.Invoke(new Action <string>(p1 => { lb_Send.Items.Add("[" + p1 + "] 无效号码"); }), new object[] { retdict["faillist"] }); UpdateSmsSendStatus(new { Status = 2, Mobiles = mobiles, BatchNum = sod["SerialNumber"] }.ToStringObjectDictionary(), strUrl, strToken, strNodeId, 0); } } else { this.Invoke(new Action <string, string>((p1, p2) => { lb_Send.Items.Add("[" + p1 + "] 发送失败[" + (smsRetCodeDic.ContainsKey(p2) ? smsRetCodeDic[p2] : "发送异常") + "]"); }), new object[] { (string)sod["UserNumber"], retdict["result"] }); //发送失败 UpdateSmsSendStatus(new { Status = 2, Mobiles = ((string)sod["UserNumber"]), BatchNum = sod["SerialNumber"] }.ToStringObjectDictionary(), strUrl, strToken, strNodeId, 0); } }); //回执 } } }); } }, 5000, () => { return(false); },//永远不停止 () => { return(!(smsPointDic.Count > 0)); }//未获取到节点时跳过 ); }
private void frmSplash_Load(object sender, EventArgs e) { InitForm(); this.UIDoStepTasks(new List <Func <bool> >() { () => { #region 检查硬件环境 lblLoadItems.Text = _LoadItem = "检查硬件环境"; Application.DoEvents(); API icAPI = new API(); icAPI.InitIC(); if (icAPI.IcDev < 0) { if (MessageBoxAdapter.ShowConfirm("初始化IC读卡设备失败,请确认是否已连接IC读卡设备!是否要跳过该步骤?") == System.Windows.Forms.DialogResult.OK) { isBreak = false; } else { isBreak = true; this.DialogResult = System.Windows.Forms.DialogResult.Cancel; return(false); } } else { icAPI.ExitIC(); } isBreak = false; return(true); #endregion }, () => { #region 获取业务服务器地址 lblLoadItems.Text = _LoadItem = "获取业务服务器地址"; isBreak = false; Application.DoEvents(); if (string.IsNullOrEmpty(SettingsVar.DataExchangePoint)) { frmBindingPA frm = new frmBindingPA(); frm.ShowDialog(); if (frm.DialogResult != System.Windows.Forms.DialogResult.OK) { isBreak = true; this.DialogResult = System.Windows.Forms.DialogResult.Cancel; return(false); } else { this.Activate(); } } return(true); #endregion }, () => { #region 连接到业务服务器 lblLoadItems.Text = _LoadItem = "连接到业务服务器"; isBreak = false; Application.DoEvents(); int errorCode = 0; HttpAdapter.postSyncAsJSON(SettingsVar.DataExchangePoint + "/Pam/PamService/PADeviceBindingForSelfServiceTerminal", new { PACode = SettingsVar.BindingPACode, MachineKey = Common.MachineKey, Action = "check" }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) => { if (!(bool)ret.Success) { errorCode = (int)ret.ErrorCode; lblError.Text = ret.ErrorCode; } }); if (errorCode == 53010 || errorCode == 53011) { //设备未绑定或已解绑 frmBindingPA frm = new frmBindingPA(); frm.ShowDialog(); if (frm.DialogResult != System.Windows.Forms.DialogResult.OK) { isBreak = true; this.DialogResult = System.Windows.Forms.DialogResult.Cancel; return(false); } } else if (errorCode == 53012) { //失效 MessageBoxAdapter.ShowError("您的设备使用期已到,请联系管理员!"); isBreak = true; this.DialogResult = System.Windows.Forms.DialogResult.Cancel; return(false); } return(true); #endregion }, () => { #region 更新机构信息 lblLoadItems.Text = _LoadItem = "更新机构信息"; isBreak = false; Application.DoEvents(); HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetPAStationInfo", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(ret.ret.ToString())); PAStationInfo stationInfo = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <PAStationInfo>(); SettingsVar.BindingPAName = stationInfo.StationName; INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_BINDING_PA_NAME, SettingsVar.BindingPAName, Common.INI_FILE_PATH); } else { isBreak = true; lblError.Text = ret.ErrorCode; } }); if (isBreak) { return(false); } return(true); #endregion }, () => { #region 更新老人数据 lblLoadItems.Text = _LoadItem = "更新老人数据"; isBreak = false; Application.DoEvents(); HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManInfoForSelfServiceMachine", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { Data.OldMans = new List <OldManInfo>(); foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); Data.OldMans.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <OldManInfo>()); } } else { isBreak = true; lblError.Text = ret.ErrorCode; } }); if (isBreak) { return(false); } return(true); #endregion }, () => { #region 更新配餐数据 lblLoadItems.Text = _LoadItem = "更新配餐数据"; isBreak = false; Application.DoEvents(); HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManBookMealForToday", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { Data.BookMeals = new List <BookMealInfo>(); foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); Data.BookMeals.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <BookMealInfo>()); } //MessageBoxAdapter.ShowInfo("订餐:" + Data.BookMeals.Count.ToString()); } else { isBreak = true; lblError.Text = ret.ErrorCode; } }); if (isBreak) { return(false); } return(true); #endregion }, () => { #region 更新课程数据 lblLoadItems.Text = _LoadItem = "更新课程数据"; isBreak = false; Application.DoEvents(); HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/LoadStationCourseList", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) => { if ((bool)ret.Success) { Data.Courses = new List <CourseInfo>(); foreach (var row in ret.rows) { dynamic item = new ExpandoObject(); DynamicAdapter.Parse(item, XElement.Parse(row.ToString())); Data.Courses.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <CourseInfo>()); } //MessageBoxAdapter.ShowInfo("订餐:" + Data.BookMeals.Count.ToString()); } else { isBreak = true; lblError.Text = ret.ErrorCode; } }); if (isBreak) { return(false); } return(true); #endregion }, () => { allLoaded = true; this.DialogResult = System.Windows.Forms.DialogResult.OK; return(true); } }, Common.msDelay); lblLoadItems.UIDoCircleTask(() => { if (dotNum == 3) { lblLoadItems.Text = _LoadItem; dotNum = 0; } else { lblLoadItems.Text += "."; dotNum++; } }, Common.msDot, () => { return(allLoaded || isBreak); }); }