重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

项目开发收尾总结(片段)-创新互联

    一个项目又开发完成了,虽然时间短问题多,但还是有一,二总结

成都创新互联公司是网站建设专家,致力于互联网品牌建设与网络营销,专业领域包括成都网站设计、网站制作、外贸营销网站建设、电商网站制作开发、成都微信小程序、微信营销、系统平台开发,与其他网站设计及系统开发公司不同,我们的整合解决方案结合了恒基网络品牌建设经验和互联网整合营销的理念,并将策略和执行紧密结合,且不断评估并优化我们的方案,为客户提供全方位的互联网品牌整合方案!

   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 redis = irc.As();
                var lold = redis.Lists["KEY"];

                var m1 = lold.Where(a => a.ID == id).SingleOrDefault();
                if (m1 != null)
                {
                    lold.RemoveValue(m1);
                }
              }

        Redis中value为列表的,采用 RemoveValue,或  redis.RemoveItemFromList(lold, m1)均不能删除,最后还是改为删除整个键,然后再重新添加列表,费时费力,现在功能是完成熬,还没找到问题症结。只有用这个折中的办法。

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下。

创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。


新闻名称:项目开发收尾总结(片段)-创新互联
URL链接:http://cqcxhl.com/article/djippc.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP