示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
 public string FormatOutputNews(string toUserName, string fromUserName, List <WXResponseNewsItem> newsItems)
 {
     return(XmlSerializeAdapter.Serialize <WXResponseNewsMessage>(new WXResponseNewsMessage {
         ToUserName = toUserName, FromUserName = fromUserName, CreateTime = DateTimeAdapter.ConvertDateTimeUnix(DateTime.Now), MsgType = "news", ArticleCount = newsItems.Count, Articles = newsItems
     }, true));
 }
示例#4
0
        public string ResponseText(WXReceiveTextMessage receiveMessage)
        {
            string result = "";

            if (receiveMessage.Content.StartsWith("103/002/"))
            {
                string[] arrFields = receiveMessage.Content.Split("/".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                if (arrFields.Length == 12)
                {
                    string lat       = arrFields[3]; //当前位置纬度
                    string log       = arrFields[2]; //当前位置经度
                    string mapAPIKey = "00001";
                    if (!string.IsNullOrEmpty(GlobalManager.TheServiceAccount.MapAPI))
                    {
                        if (GlobalManager.TheMapAPIOfInverseAdressParse.ContainsKey(GlobalManager.TheServiceAccount.MapAPI))
                        {
                            mapAPIKey = GlobalManager.TheServiceAccount.MapAPI;
                        }
                    }
                    string antiGeocodingUrl = GlobalManager.TheMapAPIOfInverseAdressParse[mapAPIKey].ReplaceWithKeys(new { lat = lat, log = log }.ToStringObjectDictionary());


                    HttpAdapter.apiJ(antiGeocodingUrl, (ret, res) =>
                    {
                        if (ret.status == 0)
                        {
                            string detailAddress = ret.result.address;
                            if (mapAPIKey == "00002")
                            {
                                detailAddress = string.IsNullOrEmpty(ret.result.street_number) ? ret.result.formatted_address + "附近" : ret.result.formatted_address;
                            }
                            result = XmlSerializeAdapter.Serialize <WXResponseTextMessage>(new WXResponseTextMessage {
                                ToUserName = receiveMessage.FromUserName, FromUserName = receiveMessage.ToUserName, CreateTime = DateTimeAdapter.ConvertDateTimeUnix(DateTime.Now), MsgType = "text", Content = detailAddress
                            }, true);
                            //result = string.Format("<xml><ToUserName>{0}</ToUserName><FromUserName>{1}</FromUserName><CreateTime>{2}</CreateTime><MsgType>text</MsgType><Content>{3}</Content></xml>", requestMessage.FromUserName, requestMessage.ToUserName, DateTimeAdapter.ConvertDateTimeUnix(DateTime.Now), detailAddress);
                        }
                    });
                }
            }
            //else
            //{
            //    result = FormatOutputText(receiveMessage.FromUserName, receiveMessage.ToUserName, "/:coffee");
            //}
            return(result);
        }
示例#5
0
 public string FormatOutputText(string toUserName, string fromUserName, string content)
 {
     return(XmlSerializeAdapter.Serialize <WXResponseTextMessage>(new WXResponseTextMessage {
         ToUserName = toUserName, FromUserName = fromUserName, CreateTime = DateTimeAdapter.ConvertDateTimeUnix(DateTime.Now), MsgType = "text", Content = content.Replace(@"\\", @"\")
     }, true));
 }