一個(gè)項(xiàng)目又開(kāi)發(fā)完成了,雖然時(shí)間短問(wèn)題多,但還是有一,二總結(jié)
目前創(chuàng)新互聯(lián)建站已為1000多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站托管維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、霍州網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。
1、kendo中如果使用 data-role="datetimepicker"日期時(shí)間選擇器,時(shí)間選擇列表總是不能初始化,需要選擇兩次日期,才會(huì)出現(xiàn)時(shí)間選擇列表。第三方組件啊,讓人頭痛,一一排除后,竟然在這里。
Date.prototype.toString = function (formatStr) {
// --- //
return str;
}
自定義了日期類(lèi)型的方法toString("yyyy-MM-dd"),該方法本來(lái)是沒(méi)有錯(cuò)誤的,但是和kendo的日期時(shí)間沖突了,將 toString 換成 format 問(wèn)題解決,原來(lái)toString這個(gè)方法,kendo有另外的定義,看來(lái)自定義的名稱(chēng)還是要個(gè)性化。
2、項(xiàng)目開(kāi)發(fā)時(shí)間短,數(shù)據(jù)建模不是同一人完成的,缺乏了整體的規(guī)劃,在模塊數(shù)據(jù)交叉的地方,出現(xiàn)后期難以整合的問(wèn)題,看來(lái)以后建模和數(shù)據(jù)庫(kù)還是要整體規(guī)劃,功能開(kāi)發(fā)上可以各司其職。
3、JPUSH推送
JPUSH封裝后使用就非常簡(jiǎn)單了。
namespace JPush
{
public class JPushUtil
{
protected const string apiBaseUrl = "https://api.jpush.cn/v3/";
static JPushUtil()
{
appkeys = ConfigurationManager.AppSettings["OwnerAppkey"];
master_secret = ConfigurationManager.AppSettings["OwnerSecret"];
}
public static string appkeys
{
get;
set;
}
public static string master_secret
{
get;
set;
}
public static string GenerateQueryToken(string appKey, string masterSecret)
{
string s = string.Format("{0}:{1}", appKey, masterSecret);
Encoding encoding = Encoding.UTF8;
try
{
byte[] bytes = encoding.GetBytes(s);
return Convert.ToBase64String(bytes);
}
catch
{
return string.Empty;
}
}
public static string Send(string data,string url="")
{
string result = "";
url = apiBaseUrl + "push";
HttpWebRequest httpRequest = (HttpWebRequest)HttpWebRequest.Create(url);
httpRequest.Credentials = new NetworkCredential(appkeys, master_secret);
httpRequest.Headers[HttpRequestHeader.Authorization] = "Basic " + GenerateQueryToken(appkeys, master_secret);
byte[] byteArray = null;
byteArray = Encoding.UTF8.GetBytes(data);
httpRequest.Method = "POST";
httpRequest.ContentType = "text/xml; charset=utf-8";
httpRequest.ContentLength = byteArray.Length;
Stream dataStream = httpRequest.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = null;
try
{
response = httpRequest.GetResponse();
}
catch (WebException e)
{
response = e.Response;
}
string responseContent = string.Empty;
using (Stream responseStream = response.GetResponseStream())
{
StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
responseContent = streamReader.ReadToEnd();
}
response.Close();
if (!string.IsNullOrEmpty(responseContent))
{
result = responseContent;
}
return result;
}
static object lockObj = new object();
protected static int GenerateSendIdentity()
{
lock (lockObj)
{
return (int)(((DateTime.UtcNow - new DateTime(2014, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds) % Int32.MaxValue);
}
}
public static PushResponse DPdoSend(int receiverType, string receiverValue, string title, string n_content, string param,
int time_to_live = 864000, string apns_production = "False")
{
appkeys = ConfigurationManager.AppSettings["DPappkey"];
master_secret = ConfigurationManager.AppSettings["DPsecret"];
return doSend(receiverType, receiverValue, title, n_content, param, time_to_live, apns_production);
}
public static PushResponse OwnerdoSend(int receiverType, string receiverValue, string title, string n_content, string param,
int time_to_live = 864000, string apns_production = "False")
{
appkeys = ConfigurationManager.AppSettings["OwnerAppkey"];
master_secret = ConfigurationManager.AppSettings["OwnerSecret"];
return doSend(receiverType, receiverValue, title, n_content, param, time_to_live, apns_production);
}
public static PushResponse JYdoSend(int receiverType, string receiverValue, string title, string n_content, string param,
int time_to_live = 864000, string apns_production = "False")
{
appkeys = ConfigurationManager.AppSettings["JYappkey"];
master_secret = ConfigurationManager.AppSettings["JYsecret"];
return doSend(receiverType, receiverValue, title, n_content, param, time_to_live, apns_production);
}
public static PushResponse doSend( int receiverType, string receiverValue, string title, string n_content, string param,
int time_to_live = 864000,string apns_production="False")
{
StringBuilder sb=new StringBuilder();
sb.AppendLine("{");
sb.AppendLine("\"platform\": [\"android\",\"ios\"],");
sb.AppendLine("\"audience\":{");
if(receiverType==2)
{
sb.AppendLine(" \"tag\" : [\""+receiverValue+"\"]");
}
else
{
sb.AppendLine(" \"alias\" : [\""+receiverValue.Replace(",","\",\"")+"\"]");
}
sb.AppendLine("}");
sb.AppendLine(",\"message\": {");
sb.AppendFormat(" \"msg_content\":\"{0}\",",n_content.Replace("\"","") );
sb.AppendLine();
sb.AppendFormat(" \"title\":\"{0}\",",title.Replace("\"","") );
sb.AppendLine();
sb.AppendFormat(" \"extras\": {0} ",param );
sb.AppendLine();
sb.AppendLine(" }");
sb.AppendLine(",\"options\": {");
sb.AppendFormat(" \"sendno\":{0},",GenerateSendIdentity() );
sb.AppendLine();
sb.AppendFormat(" \"time_to_live\":{0},", time_to_live);
sb.AppendLine();
sb.AppendFormat(" \"apns_production\": \"{0}\"", apns_production);
sb.AppendLine();
sb.AppendLine(" }");
sb.AppendLine("}");
PushResponse result = new PushResponse();
result.ResponseCode = -1;
try
{
string result1 = Send(sb.ToString());
JToken root = JToken.Parse(result1);
try
{
result.MessageId = root.SelectToken("msg_id").Value
}
catch
{ }
var errorNode = root.SelectToken("error");
if (errorNode == null)
{
result.SendIdentity = root.SelectToken("sendno").Value
result.ResponseCode = 0;
}
else
{
result.ResponseMessage = errorNode.SelectToken("message").Value
result.ResponseCode = errorNode.SelectToken("code").Value
}
}
catch (Exception ex)
{
throw new ST.Exceptions.CanShowException(ex.Message);
}
return result;
}
}
}
在需要的地方直接調(diào)用就OK。
4、.net下操作redis的不明白地方
簡(jiǎn)寫(xiě)實(shí)例說(shuō)明
using (IRedisClient irc = ST.Cache.RedisManage.GetClient())
{
IRedisTypedClient
var lold = redis.Lists["KEY"];
var m1 = lold.Where(a => a.ID == id).SingleOrDefault();
if (m1 != null)
{
lold.RemoveValue(m1);
}
}
Redis中
5、MVC路由的一種實(shí)現(xiàn)
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"M_default",
"M/{controller}/{action}/{Token}",
new { action = "Index", Token = UrlParameter.Optional },
new string[] { "ST.WEB.Areas.M" }
).DataTokens["UseNamespaceFallback"] = true;
}
DataTokens["UseNamespaceFallback"] = true,前面命名空間沒(méi)有找到控制,其它地方繼續(xù)
false是只在列出的命名空間查找,命名空間是任意的,不一定都 設(shè)置在controlls下。