项目开发收尾总结(片段)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了项目开发收尾总结(片段)相关的知识,希望对你有一定的参考价值。

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

    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<string>();
                }
                catch
                { }
                var errorNode = root.SelectToken("error");
                if (errorNode == null)
                {
                    result.SendIdentity = root.SelectToken("sendno").Value<string>();
                    result.ResponseCode = 0;
                }
                else
                {
                    result.ResponseMessage = errorNode.SelectToken("message").Value<string>();
                    result.ResponseCode = errorNode.SelectToken("code").Value<int>();
                }
            }
            catch (Exception ex)
            {
               
                throw new ST.Exceptions.CanShowException(ex.Message);
            }
           
            
            return result;
        }
      }
  }

  在需要的地方直接调用就OK。

  4、.net下操作Redis的不明白地方

     简写实例说明

      using (IRedisClient irc = ST.Cache.RedisManage.GetClient())
            {

                IRedisTypedClient<MY_View> redis = irc.As<MY_View>();
                var lold = redis.Lists["KEY"];

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

         Redis中<key,value>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下。

本文出自 “开发日记” 博客,请务必保留此出处http://9760247.blog.51cto.com/9750247/1749484

以上是关于项目开发收尾总结(片段)的主要内容,如果未能解决你的问题,请参考以下文章

[高项]行政收尾VS合同收尾

五大过程组及九大知识领域总结

系统分析与设计收尾

学系统集成项目管理工程师(中项)系列09_收尾管理

信息系统项目管理-结束项目

信管3.2项目执行监控与收尾