/// <summary> /// Get the attribute value. /// </summary> /// <typeparam name="TAttributeValue">The attribute value generic type.</typeparam> /// <param name="attributeName">The attribute name.</param> /// <returns>The attribute value.</returns> public TAttributeValue GetAttributeValue <TAttributeValue>(string attributeName) { object attributeValue = default(TAttributeValue); if (typeof(TAttributeValue) == typeof(string)) { attributeValue = new SingleLineAdapter(this.SearchResult.Properties[attributeName]).Value; } else if (typeof(TAttributeValue) == typeof(byte[])) { attributeValue = new ByteArrayAdapter(this.SearchResult.Properties[attributeName]).Value; } else if (typeof(TAttributeValue) == typeof(DateTime)) { attributeValue = new DateTimeAdapter(this.SearchResult, attributeName).Value; } else if (typeof(TAttributeValue) == typeof(Guid)) { attributeValue = new GuidAdapter(this.SearchResult.Properties[attributeName]).Value; } else if (typeof(TAttributeValue) == typeof(int)) { attributeValue = new IntegerAdapter(this.SearchResult.Properties[attributeName]).Value; } else if (typeof(TAttributeValue) == typeof(IList <string>) || typeof(TAttributeValue) == typeof(List <string>)) { attributeValue = new MultipleLineAdapter(this.SearchResult.Properties[attributeName]).Value; } return((TAttributeValue)attributeValue); }
private void SetDbEnvironment(string connectString) { var optBuilder = new DbContextOptionsBuilder() .UseSqlServer(connectString); _dbContext = new HmmDataContext(optBuilder.Options); LookupRepo = new EfEntityLookup(_dbContext); var dateProvider = new DateTimeAdapter(); AuthorRepository = new AuthorEfRepository(_dbContext, LookupRepo); NoteRepository = new NoteEfRepository(_dbContext, LookupRepo, dateProvider); RenderRepository = new NoteRenderEfRepository(_dbContext, LookupRepo, dateProvider); CatalogRepository = new NoteCatalogEfRepository(_dbContext, LookupRepo, dateProvider); SubsystemRepository = new SubsystemEfRepository(_dbContext, LookupRepo, dateProvider); DateProvider = new DateTimeAdapter(); }
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); }
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); }
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)); }
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)); }
public void ProcessRequest(HttpContext context) { if (context.Request.HttpMethod == "POST") { string caller = context.Request.Form["caller"]; string called = context.Request.Form["called"]; string begin_time = context.Request.Form["begin_time"]; string end_time = context.Request.Form["end_time"]; string duration = context.Request.Form["duration"]; string record_path = context.Request.Form["record_path"]; string call_type = context.Request.Form["call_type"]; string trunk = context.Request.Form["trunk"]; string uuid = context.Request.Form["uuid"]; string hangupcause = context.Request.Form["hangupcause"]; string msg = string.Format("caller:{0},called:{1},begin_time:{2},end_time:{3},duration:{4},record_path:{5},call_type:{6},trunk:{7},uuid:{8},hangupcause:{9}", caller, called, begin_time, end_time, duration, record_path, call_type, trunk, uuid, hangupcause); Global.DebugInfo(msg); call_type = call_type.ToLower(); //85027666_192.168.1.18_5060 string[] trunk_array = trunk.Split("_".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); trunk = trunk_array[0]; bool bUpdateVoiceTime = false; if (call_type == "in") { //第一种需要回拨的情形 if (called == trunk) { bUpdateVoiceTime = true; //回拨模式呼入不计入时长 //当产生的通话记录中的被叫号码(called)和中继号码(trunk)是一样的则表示用户主动放弃来电,需要回拨 SPParam theSPParam = new { UuidOfIPCC = uuid }.ToSPParam(); BuilderFactory.DefaultBulder().ExecuteSPNoneQuery("SP_Api_AbandonByCaller_eComm", theSPParam); if (theSPParam.ErrorCode != 0) { msg = "SP_Api_AbandonByCaller_eComm ErrorCode:" + theSPParam.ErrorCode.ToString() + " ErrorMessage:" + theSPParam.ErrorMessage; } } } //计入通话时长 if (!bUpdateVoiceTime) { DateTime startTime = DateTimeAdapter.ConvertUnitToNormal(Int32.Parse(begin_time)); DateTime endTime = DateTimeAdapter.ConvertUnitToNormal(Int32.Parse(end_time)); int iCallSeconds = (endTime - startTime).Seconds; SPParam theSPParam = new { Caller = caller, CallSeconds = iCallSeconds }.ToSPParam(); if (call_type == "out")//回拨模式 { theSPParam["Caller"] = called; } BuilderFactory.DefaultBulder().ExecuteSPNoneQuery("SP_Api_RecordCallSeconds_eComm", theSPParam); if (theSPParam.ErrorCode != 0) { msg = "SP_Api_RecordCallSeconds_eComm ErrorCode:" + theSPParam.ErrorCode.ToString() + " ErrorMessage:" + theSPParam.ErrorMessage; } Global.DebugInfo(string.Format("caller:{0}---呼入时长:-------------->{1}", theSPParam["Caller"], iCallSeconds.ToString())); } context.Response.ContentType = "text/plain"; context.Response.Write(msg); } else { context.Response.ContentType = "text/plain"; context.Response.Write("invalid"); } }