コード例 #1
0
        public string Scalar(T t, params string[] needcol)
        {
            SetDataHelper <T> .RemoveStrNull(t);

            var listsp = new List <SqlParameter>();
            var type   = t.GetType();
            //  var rank= type.GetArrayRank();
            var ignorelist = needcol.ToList();
            var Properties = type.GetProperties();

            foreach (var p in Properties)
            {
                var name = p.Name;
                if (ignorelist.FindIndex(a => a.Equals(name)) != -1)
                {
                    var value = p.GetValue(t, null);
                    var sp    = new SqlParameter("@" + p.Name, value);
                    listsp.Add(sp);
                }
            }
            var db   = new DBHelper(constr);
            var data = db.getSalar(procname, listsp.ToArray()) + "";

            return(data);
        }
コード例 #2
0
        private static string AndroidPushAll(string ticker, string title, string text, Dictionary <string, string> extra)
        {
            var p       = new Payload("notification", ticker, title, text, extra);
            var type    = DeviceType.Andriod;
            var url     = "http://msg.umeng.com/api/send";
            var android = new Android()
            {
                type = "broadcast", device_tokens = "", payload = p, description = "android推送", production_mode = "true", policy = new Policy()
                {
                    expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                }
            };

            SetDataHelper <Android> .RemoveStrNull(android);

            var sign     = YouMengHelper.GetSign(type, url, android);
            var postbody = JsonHelper <IPush> .GetJson(android);

            var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
            var data    = WebHelper.DoPost(fullurl, postbody);

            return(data);
        }
コード例 #3
0
        /// <summary>
        /// 苹果推送
        /// </summary>
        /// <param name="title"></param>
        /// <param name="text"></param>
        /// <param name="ticker"></param>
        /// <param name="category"></param>
        /// <param name="extra"></param>
        /// <returns></returns>
        private static string ApplePushAll(string title, string text, string ticker, string category, Dictionary <string, string> extra)
        {
            var url = "http://msg.umeng.com/api/send";
            var p   = new IOSPayLoad(title, text, ticker, category, extra);

            var ios = new IOS("broadcast")
            {
                payload         = p,
                description     = "苹果推送",
                production_mode = "true",
                policy          = new Policy()
                {
                    expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                }
            };

            SetDataHelper <IOS> .RemoveStrNull(ios);

            var sign     = YouMengHelper.GetSign(DeviceType.IOS_APPStore, url, ios);
            var postbody = JsonHelper <IPush> .GetJson(ios);

            var dt = new Dictionary <string, string>();

            var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;

            dt.Add("sign", sign);
            try
            {
                var data = WebHelper.DoPost(fullurl, postbody);
                return(data);
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
                return(string.Empty);
            }
        }
コード例 #4
0
        /// <summary>
        /// 推送
        /// </summary>
        /// <param name="alert"></param>
        /// <param name="category"></param>
        /// <param name="type"></param>
        /// <param name="device_tokens"></param>
        /// <param name="ticker"></param>
        /// <param name="title"></param>
        /// <param name="text"></param>
        /// <param name="extra"></param>
        /// <returns></returns>
        public static string makePush(string alert, string category, DeviceType type, string device_tokens, string ticker, string title, string text, Dictionary <string, string> extra)
        {
            var url = "http://msg.umeng.com/api/send";

            if (type == DeviceType.IOS)
            {
                var p = new IOSPayLoad(title, text, ticker, category);

                var ios = new IOS()
                {
                    device_tokens   = device_tokens,
                    payload         = p,
                    description     = "苹果推送",
                    production_mode = "false",
                    policy          = new Policy()
                    {
                        expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                    }
                };
                SetDataHelper <IOS> .RemoveStrNull(ios);

                var sign     = YouMengHelper.GetSign(DeviceType.IOS, url, ios);
                var postbody = JsonHelper <IPush> .GetJson(ios);

                var dt = new Dictionary <string, string>();

                var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
                dt.Add("sign", sign);
                var data = WebHelper.DoPost(fullurl, postbody);
                return(data);
            }
            else if (type == DeviceType.YZK_IOS_APPStore)
            {
                var p = new IOSPayLoad(title, text, ticker, category, extra);

                var ios = new IOS(type)
                {
                    device_tokens   = device_tokens,
                    payload         = p,
                    description     = "苹果推送",
                    production_mode = "false",
                    policy          = new Policy()
                    {
                        expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                    }
                };
                SetDataHelper <IOS> .RemoveStrNull(ios);

                var sign     = YouMengHelper.GetSign(type, url, ios);
                var postbody = JsonHelper <IPush> .GetJson(ios);

                var dt = new Dictionary <string, string>();

                var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
                dt.Add("sign", sign);
                var data = WebHelper.DoPost(fullurl, postbody);
                return(data);
            }
            else if (type == DeviceType.Andriod)
            {
                var p = new Payload("notification", ticker, title, text, extra);

                var android = new Android()
                {
                    type = "listcast", device_tokens = device_tokens, payload = p, description = "android推送", production_mode = "false", policy = new Policy()
                    {
                        expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                    }
                };
                SetDataHelper <Android> .RemoveStrNull(android);

                var sign     = YouMengHelper.GetSign(type, url, android);
                var postbody = JsonHelper <IPush> .GetJson(android);

                var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
                var data    = WebHelper.DoPost(fullurl, postbody);
                return(data);
            }
            else if (type == DeviceType.Android_Center)
            {
                var p = new Payload("notification", ticker, title, text, extra);

                var android = new Android(type)
                {
                    type = "listcast", device_tokens = device_tokens, payload = p, description = "android推送", production_mode = "false", policy = new Policy()
                    {
                        expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                    }
                };
                SetDataHelper <Android> .RemoveStrNull(android);

                var sign     = YouMengHelper.GetSign(type, url, android);
                var postbody = JsonHelper <IPush> .GetJson(android);

                var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
                var data    = WebHelper.DoPost(fullurl, postbody);
                return(data);
            }

            return(string.Empty);
        }
コード例 #5
0
        /// <summary>
        /// 推送
        /// </summary>
        /// <param name="alert"></param>
        /// <param name="category"></param>
        /// <param name="type"></param>
        /// <param name="device_tokens"></param>
        /// <param name="ticker"></param>
        /// <param name="title"></param>
        /// <param name="text"></param>
        /// <param name="extra"></param>
        /// <returns></returns>
        /// //                        (alert, categrory, typex, dtoken.devicetoken, ticker, title, text, extra_typex, mac, localip, action);
        public static string makePush(string alert, string category, DeviceType type, string device_tokens, string ticker, string title, string text, ExtraType extraType, params string[] extradatas)
        {
            var extra = new Dictionary <string, string>();

            if (extraType == ExtraType.CommonPush)
            {
                extra.Add("type", "0");
                extra.Add("servertime", TimeHelper.JavaTime(DateTime.Now) + "");
            }
            else if (extraType == ExtraType.ASKHelp)
            {
                if (extradatas.Length == 3)
                {
                    //增加conver_img 铭牌照片 component_img 零件照片, 点击消息可选择查看铭牌照片  零件照片
                    extra.Add("conver_img", extradatas[0]);
                    extra.Add("component_img", extradatas[1]);
                    extra.Add("skuid", extradatas[2]);
                    extra.Add("type", "3");
                    extra.Add("servertime", TimeHelper.JavaTime(DateTime.Now) + "");
                }

                else if (extradatas.Length == 7)
                {
                    //增加conver_img 铭牌照片 component_img 零件照片, 点击消息可选择查看铭牌照片  零件照片
                    extra.Add("conver_img", extradatas[0]);
                    extra.Add("component_img", extradatas[1]);
                    extra.Add("skuid", extradatas[2]);
                    extra.Add("type", "3");
                    extra.Add("price", extradatas[3]);
                    extra.Add("brand", extradatas[4]);
                    extra.Add("bigclass", extradatas[5]);
                    extra.Add("name", extradatas[6]);
                    extra.Add("servertime", TimeHelper.JavaTime(DateTime.Now) + "");
                }
            }
            else if (extraType == ExtraType.ADPush)
            {
                if (extradatas.Length == 1)
                {
                    extra.Add("url", extradatas[0]);
                    extra.Add("type", "2");
                    extra.Add("servertime", TimeHelper.JavaTime(DateTime.Now) + "");
                }
            }
            else if (extraType == ExtraType.OrderPush)
            {
                if (extradatas.Length == 1)
                {
                    extra.Add("orderno", extradatas[0]);
                    extra.Add("type", "1");
                    extra.Add("servertime", TimeHelper.JavaTime(DateTime.Now) + "");
                }
            }
            else if (extraType == ExtraType.CenterNotify_3)
            {
                ///3个参数
                if (extradatas.Length == 3)
                {
                    extra.Add("sync_notify_type", extradatas[0]);
                    extra.Add("record_id", extradatas[1]);
                    extra.Add("action", extradatas[2]);
                    extra.Add("type", "1");
                    extra.Add("servertime", TimeHelper.JavaTime(DateTime.Now) + "");
                }
            }
            else if (extraType == ExtraType.CenterNotify_online_4)
            {
                if (extradatas.Length >= 4)
                {
                    extra.Add("sync_notify_type", extradatas[0]);
                    extra.Add("mac", extradatas[1]);
                    extra.Add("localip", extradatas[2]);
                    extra.Add("action", extradatas[3]);
                    extra.Add("type", "1");
                    extra.Add("servertime", TimeHelper.JavaTime(DateTime.Now) + "");
                }
            }


            var url = "http://msg.umeng.com/api/send";

            if (type == DeviceType.IOS)
            {
                var p = new IOSPayLoad(title, text, ticker, category, extra);

                var ios = new IOS()
                {
                    device_tokens   = device_tokens,
                    payload         = p,
                    description     = "苹果推送",
                    production_mode = "true",
                    policy          = new Policy()
                    {
                        expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                    }
                };
                SetDataHelper <IOS> .RemoveStrNull(ios);

                var sign     = YouMengHelper.GetSign(DeviceType.IOS, url, ios);
                var postbody = JsonHelper <IPush> .GetJson(ios);

                var dt = new Dictionary <string, string>();

                var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
                dt.Add("sign", sign);
                try
                {
                    var data = WebHelper.DoPost(fullurl, postbody);
                    return(data);
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(string.Empty);
                }
            }
            else if (type == DeviceType.Andriod)
            {
                var p       = new Payload("notification", ticker, title, text, extra);
                var android = new Android()
                {
                    type = "listcast", device_tokens = device_tokens, payload = p, description = "android推送", production_mode = "true", policy = new Policy()
                    {
                        expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                    }
                };
                SetDataHelper <Android> .RemoveStrNull(android);

                var sign     = YouMengHelper.GetSign(type, url, android);
                var postbody = JsonHelper <IPush> .GetJson(android);

                var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
                var data    = WebHelper.DoPost(fullurl, postbody);
                return(data);
            }

            ///中控设备
            else if (type == DeviceType.Android_Center)
            {
                var cust_json = JsonHelper <Dictionary <string, string> > .GetJson(extra);

                var p = new Payload("message", ticker, title, text, extra, cust_json);
                ///中控设备的推送
                var appkey  = "595312d182b63512f90019bc";
                var android = new Android(appkey)
                {
                    type            = "listcast",
                    device_tokens   = device_tokens,
                    payload         = p,
                    description     = "android推送",
                    production_mode = "true",
                    policy          = new Policy()
                    {
                        expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                    }
                };
                SetDataHelper <Android> .RemoveStrNull(android);

                var sign     = YouMengHelper.GetSign(type, url, android);
                var postbody = JsonHelper <IPush> .GetJson(android);

                var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
                var data    = WebHelper.DoPost(fullurl, postbody);
                return(data);
            }
            else if (type == DeviceType.IOS_APPStore)
            {
                var p = new IOSPayLoad(title, text, ticker, category, extra);

                var ios = new IOS_AppStore()
                {
                    device_tokens   = device_tokens,
                    payload         = p,
                    description     = "苹果推送",
                    production_mode = "true",
                    policy          = new Policy()
                    {
                        expire_time = DateTime.Now.AddDays(3).ToString("yyyy-MM-dd HH:mm:ss")
                    }
                };
                SetDataHelper <IOS_AppStore> .RemoveStrNull(ios);

                var sign     = YouMengHelper.GetSign(DeviceType.IOS_APPStore, url, ios);
                var postbody = JsonHelper <IPush> .GetJson(ios);

                var dt = new Dictionary <string, string>();

                var fullurl = "http://msg.umeng.com/api/send?sign=" + sign;
                dt.Add("sign", sign);
                try
                {
                    var data = WebHelper.DoPost(fullurl, postbody);
                    return(data);
                }
                catch
                {
                    return(string.Empty);
                }
            }
            return(string.Empty);
        }