一个项目又开发完成了,虽然时间短问题多,但还是有一,二总结
目前创新互联建站已为1000多家的企业提供了网站建设、域名、虚拟主机、网站托管维护、企业网站设计、霍州网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
1、kendo中如果使用 data-role="datetimepicker"日期时间选择器,时间选择列表总是不能初始化,需要选择两次日期,才会出现时间选择列表。第三方组件啊,让人头痛,一一排除后,竟然在这里。
Date.prototype.toString = function (formatStr) {
// --- //
return str;
}
自定义了日期类型的方法toString("yyyy-MM-dd"),该方法本来是没有错误的,但是和kendo的日期时间冲突了,将 toString 换成 format 问题解决,原来toString这个方法,kendo有另外的定义,看来自定义的名称还是要个性化。
2、项目开发时间短,数据建模不是同一人完成的,缺乏了整体的规划,在模块数据交叉的地方,出现后期难以整合的问题,看来以后建模和数据库还是要整体规划,功能开发上可以各司其职。
3、JPUSH推送
JPUSH封装后使用就非常简单了。
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;
}
}
}
在需要的地方直接调用就OK。
4、.net下操作redis的不明白地方
简写实例说明
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路由的一种实现
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,前面命名空间没有找到控制,其它地方继续
false是只在列出的命名空间查找,命名空间是任意的,不一定都 设置在controlls下。
名称栏目:项目开发收尾总结(片段)
网页路径:http://lswzjz.com/article/jescei.html