private string ResponseEvent_WX20103(WXReceiveEventMessage receiveMessage) { string result = ""; int pageSize = 5; StringObjectDictionary filter = new { OpenId = receiveMessage.FromUserName }.ToStringObjectDictionary(); try { var datas = BuilderFactory.DefaultBulder().ListStringObjectDictionary("ServeDurationByServeMan_List", filter); if (datas.Count == 0) { result = FormatOutputText(receiveMessage.FromUserName, receiveMessage.ToUserName, "没有任何服务记录,无法统计"); } else { WXMessageTemplate template_MyServeDurationStatTitle = BuilderFactory.DefaultBulder().Load <WXMessageTemplate, WXMessageTemplatePK>(new WXMessageTemplatePK { TemplateId = GlobalManager.TemplateId_MyServeDurationStatTitle }); List <WXResponseNewsItem> items = datas.Select(item => new WXResponseNewsItem { Title = template_MyServeDurationStatTitle.TemplateContent.ReplaceWithKeys(new { ServeStationName = TypeConverter.ChangeString(item["ServeStationName"]), ServeItemBName = TypeConverter.ChangeString(item["ServeItemBName"]), ByDay = DateTimeAdapter.GetTimeSpanString(DateTimeAdapter.DateInterval.HR, long.Parse(TypeConverter.ChangeString(item["ByDay"]))), ByWeek = DateTimeAdapter.GetTimeSpanString(DateTimeAdapter.DateInterval.HR, long.Parse(TypeConverter.ChangeString(item["ByWeek"]))), ByMonth = DateTimeAdapter.GetTimeSpanString(DateTimeAdapter.DateInterval.HR, long.Parse(TypeConverter.ChangeString(item["ByMonth"]))) }.ToStringObjectDictionary(), false, "$") }).ToList(); if (datas.Count > pageSize) { WXMessageTemplate template_MyServeDurationStatMoreUrl = BuilderFactory.DefaultBulder().Load <WXMessageTemplate, WXMessageTemplatePK>(new WXMessageTemplatePK { TemplateId = GlobalManager.TemplateId_MyServeDurationStatMoreUrl }); items.Add(new WXResponseNewsItem { Title = "更多...", Url = template_MyServeDurationStatMoreUrl.TemplateContent.ReplaceWithKeys(new { DeployAreaCode = GlobalManager.GetDeployArea().code, OpenId = receiveMessage.FromUserName, TimeStamp = DateTimeAdapter.ConvertDateTimeUnix(DateTime.Now).ToString() }.ToStringObjectDictionary(), false, "$") }); } items.Insert(0, new WXResponseNewsItem { Title = "服务时长统计结果:" }); result = FormatOutputNews(receiveMessage.FromUserName, receiveMessage.ToUserName, items); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(result); }
private string ResponseEvent_WX20102(WXReceiveEventMessage receiveMessage) { string result = ""; int pageSize = 5; StringObjectDictionary filter = new { OpenId = receiveMessage.FromUserName }.ToStringObjectDictionary(); try { var datas = BuilderFactory.DefaultBulder().ListStringObjectDictionaryByPage("ServeRecordByServeMan_ListByPage", filter, new ListPager { OrderByClause = "ServeManArriveTime desc", PageNo = 1, PageSize = pageSize }); if (datas.Count == 0) { result = FormatOutputText(receiveMessage.FromUserName, receiveMessage.ToUserName, "没有任何服务记录"); } else { WXMessageTemplate template_MyServeRecordTitle = BuilderFactory.DefaultBulder().Load <WXMessageTemplate, WXMessageTemplatePK>(new WXMessageTemplatePK { TemplateId = GlobalManager.TemplateId_MyServeRecordTitle }); List <WXResponseNewsItem> items = datas.Select(item => new WXResponseNewsItem { Title = template_MyServeRecordTitle.TemplateContent.ReplaceWithKeys(new { ServeDate = DateTime.Parse(TypeConverter.ChangeString(item["ServeDate"])).ToString("yyyy-MM-dd"), ArriveTime = DateTime.Parse(TypeConverter.ChangeString(item["ArriveTime"])).ToString("HH:mm:ss"), LeaveTime = DateTime.Parse(TypeConverter.ChangeString(item["LeaveTime"])).ToString("HH:mm:ss"), OldManName = TypeConverter.ChangeString(item["OldManName"]), ServeItemBName = TypeConverter.ChangeString(item["ServeItemBName"]), ServeStationName = TypeConverter.ChangeString(item["ServeStationName"]) }.ToStringObjectDictionary(), false, "$").ReplaceEmoji() }).ToList(); if (BuilderFactory.DefaultBulder().GetRecordCount("Count_ScheduleByServeMan_ListByPage", filter) > pageSize) { WXMessageTemplate template_MyServeRecordMoreUrl = BuilderFactory.DefaultBulder().Load <WXMessageTemplate, WXMessageTemplatePK>(new WXMessageTemplatePK { TemplateId = GlobalManager.TemplateId_MyServeRecordMoreUrl }); items.Add(new WXResponseNewsItem { Title = "更多...", Url = template_MyServeRecordMoreUrl.TemplateContent.ReplaceWithKeys(new { DeployAreaCode = GlobalManager.GetDeployArea().code, OpenId = receiveMessage.FromUserName, TimeStamp = DateTimeAdapter.ConvertDateTimeUnix(DateTime.Now).ToString() }.ToStringObjectDictionary(), false, "$") }); } items.Insert(0, new WXResponseNewsItem { Title = "服务记录查询结果:" }); result = FormatOutputNews(receiveMessage.FromUserName, receiveMessage.ToUserName, items); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(result); }