Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
b796dce5
Commit
b796dce5
authored
Oct 30, 2016
by
季圣华
Browse files
No commit message
No commit message
parent
c9e03495
Changes
146
Show whitespace changes
Inline
Side-by-side
WebRoot/js/jdigiclock/lib/proxy/asp/README.txt
0 → 100644
View file @
b796dce5
.NET proxy version
written by Alessandro Benedetti
You need the open source Newtonsoft.Json to compile.
\ No newline at end of file
WebRoot/js/jdigiclock/lib/proxy/asp/WeatherProxy.aspx
0 → 100644
View file @
b796dce5
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WeatherProxy.aspx.cs" Inherits="MultiConsultCRM.Web.Resources.WeatherProxy" %>
\ No newline at end of file
WebRoot/js/jdigiclock/lib/proxy/asp/WeatherProxy.aspx.cs
0 → 100644
View file @
b796dce5
using
System
;
using
System.Collections
;
using
System.Configuration
;
using
System.Data
;
using
System.Web
;
using
System.Web.Security
;
using
System.Web.UI
;
using
System.Web.UI.HtmlControls
;
using
System.Web.UI.WebControls
;
using
System.Web.UI.WebControls.WebParts
;
using
System.Xml
;
using
System.Collections.Generic
;
using
System.Net
;
using
System.IO
;
namespace
MultiConsultCRM.Web.Resources
{
public
partial
class
WeatherProxy
:
System
.
Web
.
UI
.
Page
{
protected
void
Page_Load
(
object
sender
,
EventArgs
e
)
{
string
_location
=
Request
.
QueryString
[
"location"
];
string
_metric
=
Request
.
QueryString
[
"metric"
];
//string _url = string.Format("http://rainmeter.accu-weather.com/widget/rainmeter/weather-data.asp?location={0}&metric={1}", _location, _metric);
string
_url
=
string
.
Format
(
"http://wwwa.accuweather.com/adcbin/forecastfox/weather_data.asp?location={0}&metric={1}"
,
_location
,
_metric
);
string
_xml
=
DownloadWebPage
(
_url
);
XmlDocument
_xmlDocument
=
new
XmlDocument
();
_xmlDocument
.
LoadXml
(
_xml
);
XmlNamespaceManager
_mgr
=
new
XmlNamespaceManager
(
_xmlDocument
.
NameTable
);
_mgr
.
AddNamespace
(
"pf"
,
_xmlDocument
.
DocumentElement
.
NamespaceURI
);
Weather
_weather
=
new
Weather
();
_weather
.
city
=
_xmlDocument
.
SelectSingleNode
(
"/pf:adc_database/pf:local/pf:city"
,
_mgr
).
InnerText
;
_weather
.
curr_temp
=
Convert
.
ToInt32
(
_xmlDocument
.
SelectSingleNode
(
"/pf:adc_database/pf:currentconditions/pf:temperature"
,
_mgr
).
InnerText
);
_weather
.
curr_text
=
_xmlDocument
.
SelectSingleNode
(
"/pf:adc_database/pf:currentconditions/pf:weathertext"
,
_mgr
).
InnerText
;
_weather
.
curr_icon
=
Convert
.
ToInt32
(
_xmlDocument
.
SelectSingleNode
(
"/pf:adc_database/pf:currentconditions/pf:weathericon"
,
_mgr
).
InnerText
);
XmlNodeList
_xmlNodeList
=
_xmlDocument
.
SelectNodes
(
"/pf:adc_database/pf:forecast/pf:day"
,
_mgr
);
int
_day
=
_xmlNodeList
.
Count
;
int
i
=
0
;
foreach
(
XmlNode
_dayItem
in
_xmlNodeList
)
{
Forecast
_forecast
=
new
Forecast
();
_forecast
.
day_date
=
_dayItem
[
"obsdate"
].
InnerXml
;
_forecast
.
day_text
=
_dayItem
.
SelectSingleNode
(
"pf:daytime"
,
_mgr
)[
"txtshort"
].
InnerXml
;
_forecast
.
day_icon
=
Convert
.
ToInt32
(
_dayItem
.
SelectSingleNode
(
"pf:daytime"
,
_mgr
)[
"weathericon"
].
InnerXml
);
_forecast
.
day_htemp
=
Convert
.
ToInt32
(
_dayItem
.
SelectSingleNode
(
"pf:daytime"
,
_mgr
)[
"hightemperature"
].
InnerXml
);
_forecast
.
day_ltemp
=
Convert
.
ToInt32
(
_dayItem
.
SelectSingleNode
(
"pf:daytime"
,
_mgr
)[
"lowtemperature"
].
InnerXml
);
_weather
.
forecast
.
Add
(
_forecast
);
i
++;
// 5 day forecast
if
(
i
==
5
)
break
;
}
Response
.
Write
(
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
_weather
));
}
/// <summary>
/// Returns the content of a given web adress as string.
/// </summary>
/// <param name="Url">URL of the webpage</param>
/// <returns>Website content</returns>
public
string
DownloadWebPage
(
string
Url
)
{
// Open a connection
HttpWebRequest
WebRequestObject
=
(
HttpWebRequest
)
HttpWebRequest
.
Create
(
Url
);
// You can also specify additional header values like
// the user agent or the referer:
WebRequestObject
.
UserAgent
=
".NET Framework/2.0"
;
WebRequestObject
.
Referer
=
"http://www.example.com/"
;
// Request response:
WebResponse
Response
=
WebRequestObject
.
GetResponse
();
// Open data stream:
Stream
WebStream
=
Response
.
GetResponseStream
();
// Create reader object:
StreamReader
Reader
=
new
StreamReader
(
WebStream
);
// Read the entire stream content:
string
PageContent
=
Reader
.
ReadToEnd
();
// Cleanup
Reader
.
Close
();
WebStream
.
Close
();
Response
.
Close
();
return
PageContent
;
}
}
public
class
Weather
{
public
string
city
;
public
int
curr_temp
;
public
string
curr_text
;
public
int
curr_icon
;
public
List
<
Forecast
>
forecast
=
new
List
<
Forecast
>();
}
public
class
Forecast
{
public
string
day_date
;
public
string
day_text
;
public
int
day_icon
;
public
int
day_htemp
;
public
int
day_ltemp
;
}
}
WebRoot/js/jdigiclock/lib/proxy/asp/WeatherProxy.aspx.designer.cs
0 → 100644
View file @
b796dce5
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.4927
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace
MultiConsultCRM.Web.Resources
{
public
partial
class
WeatherProxy
{
}
}
WebRoot/js/jdigiclock/lib/proxy/empty.gitkeep
0 → 100644
View file @
b796dce5
# Ignore everything in this directory
*
# Except this file !.gitkeep
\ No newline at end of file
WebRoot/js/jdigiclock/lib/proxy/php/proxy.php
0 → 100644
View file @
b796dce5
<?php
$location
=
$_GET
[
'location'
];
$metric
=
(
int
)
$_GET
[
'metric'
];
$url
=
'http://wwwa.accuweather.com/adcbin/forecastfox/weather_data.asp?location='
.
$location
.
'&metric='
.
$metric
;
//$url = 'http://rainmeter.accu-weather.com/widget/rainmeter/weather-data.asp?location=' . $location . '&metric=' . $metric;
$ch
=
curl_init
();
$timeout
=
0
;
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_CONNECTTIMEOUT
,
$timeout
);
$file_contents
=
curl_exec
(
$ch
);
curl_close
(
$ch
);
$xml
=
simplexml_load_string
(
$file_contents
);
$weather
[
'city'
]
=
(
string
)
$xml
->
local
->
city
;
$weather
[
'curr_temp'
]
=
(
int
)
$xml
->
currentconditions
->
temperature
;
$weather
[
'curr_text'
]
=
(
string
)
$xml
->
currentconditions
->
weathertext
;
$weather
[
'curr_icon'
]
=
(
int
)
$xml
->
currentconditions
->
weathericon
;
// forecast
//$day = count($xml->forecast->day);
$day
=
5
;
for
(
$i
=
0
;
$i
<
$day
;
$i
++
)
{
$weather
[
'forecast'
][
$i
][
'day_date'
]
=
(
string
)
$xml
->
forecast
->
day
[
$i
]
->
obsdate
;
$weather
[
'forecast'
][
$i
][
'day_text'
]
=
(
string
)
$xml
->
forecast
->
day
[
$i
]
->
daytime
->
txtshort
;
$weather
[
'forecast'
][
$i
][
'day_icon'
]
=
(
int
)
$xml
->
forecast
->
day
[
$i
]
->
daytime
->
weathericon
;
$weather
[
'forecast'
][
$i
][
'day_htemp'
]
=
(
int
)
$xml
->
forecast
->
day
[
$i
]
->
daytime
->
hightemperature
;
$weather
[
'forecast'
][
$i
][
'day_ltemp'
]
=
(
int
)
$xml
->
forecast
->
day
[
$i
]
->
daytime
->
lowtemperature
;
}
echo
json_encode
(
$weather
);
?>
\ No newline at end of file
Prev
1
…
4
5
6
7
8
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment