public Stream CheckNew2(string applicationId) { dynamic apps = win.core.utils.FileAdapter.GetJSONFromFile(HttpContext.Current.Server.MapPath("~/CheckNew2.json")); dynamic app = null; foreach (dynamic theOne in apps) { if (theOne.ApplicationId == applicationId) { app = theOne; break; } } if (app == null) { WebOperationContext.Current.OutgoingResponse.ContentType = "text/plain"; return(new MemoryStream(Encoding.UTF8.GetBytes("无效的AppId"))); } //检查主程序 string exeFileName = app.ApplicationCode; string exeDir = HttpContext.Current.Server.MapPath("~/" + applicationId); string exeFilePath = exeDir + @"\" + exeFileName; if (FileAdapter.Exists(exeFilePath)) { //Assembly asm = Assembly.LoadFile(exeFilePath);会锁定 Assembly asm = Assembly.Load(System.IO.File.ReadAllBytes(exeFilePath)); string version = asm.GetName().Version.ToString(); Product product = new Product { ApplicationId = applicationId, ApplicationName = app.ApplicationName, Version = version, Description = "更新说明" }; string appRoot = GetAppRootPath(); if (appRoot.EndsWith("/")) { appRoot = appRoot.Substring(0, appRoot.Length - 1); } product.FileList = new UpdateFilesInfo { SourcePath = appRoot + "/" + applicationId + "/" }; string[] files = Directory.GetFiles(exeDir, "*", SearchOption.AllDirectories); product.FileList.FileItems = new List <FileItem>(); foreach (string file in files) { string itemName = file.Replace(exeDir + @"\", "").Replace(@"\", "/"); product.FileList.FileItems.Add(new FileItem { Name = itemName }); } product.FileList.Count = product.FileList.FileItems.Count.ToString(); byte[] resultBytes = Encoding.UTF8.GetBytes(XmlSerializeAdapter.Serialize <Product>(product)); WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml"; return(new MemoryStream(resultBytes)); } return(null); }
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)); }