// 调用内部方法请求url网页的内容
 private void url_Click(object sender, RoutedEventArgs e)
 {
     new BmobWindows().Request("http://www.baidu.com", "GET", "", new byte[0], new Dictionary <string, string>(), (resp, status, ex) =>
     {
         BmobDebug.Log(resp);
     });
 }
Esempio n. 2
0
        private void fetchAndUpdateNotifactionUri()
        {
            fetchNotifactionUri((objectId) =>
            {
                if (objectId == null)
                {
                    new BmobWindowsPhone().Create(installaction, (resp, ex) =>
                    {
                        if (ex == null && resp != null)
                        {
                            MY_INST_OBJECTID = resp.objectId;

                            BmobDebug.D("Installaction设置成功, 对象ID为: " + MY_INST_OBJECTID + "; MPNS: " + NotificationUri);
                        }
                    });
                }
                else
                {
                    new BmobWindowsPhone().Update(BmobInstallation.TABLE, MY_INST_OBJECTID, new BmobKV().Put("notificationUri", NotificationUri), (resp, ex) =>
                    {
                        if (ex == null)
                        {
                            BmobDebug.D("Installaction更新成功, 对象ID为: " + MY_INST_OBJECTID + "; MPNS: " + NotificationUri);
                            BmobDebug.D("Update NotificationUri success.");
                        }
                        else
                        {
                            BmobDebug.E(ex);
                        }
                    });
                }
            });
        }
Esempio n. 3
0
        protected void onPostExecute(String result, Status status, BmobException exception, BmobCallback <T> fCallback)
        {
            T             data;
            BmobException ex;

            if (exception != null)
            {
                data = default(T);
                if (result == null)
                {
                    ex = exception;
                }
                else
                {
                    ex = new BmobException(exception.Message + ", and response content is " + result, exception.InnerException);
                }
            }
            else
            {
                BmobResponseParser <T> parser = getResponseParser(status);
                parser.parse(result);

                data = parser.data;
                ex   = parser.exception;
            }

            if (ex != null)
            {
                BmobDebug.T("[ BmobCommand ] after parse response, error: '" + ex.Message + "'");
            }

            fCallback(data, ex);
        }
Esempio n. 4
0
        /// <summary>
        /// authorized:
        ///  ID_CAP_PUSH_NOTIFICATION
        ///  ID_CAP_IDENTITY_DEVICE
        /// </summary>
        public void rebind()
        {
            HttpNotificationChannel channel = HttpNotificationChannel.Find(BmobWindowsPhone.PushChannel);

            //如果用户通过更改应用程序中的设置关闭了通知,如应用程序策略的第 2.9 节中所述,则您应该确保使用 Close()()()() 方法来关闭推送通道。

            if (channel == null)
            {
                // 感谢赵越大哥无私的贡献!
                channel = new HttpNotificationChannel(BmobWindowsPhone.PushChannel, "urn:wp-ac-hash-2:bchdqmkdpwamzk1umxagzovixy2mwp8-b9vfeea9l2c");
                registerPushChannelEvent(channel);

                channel.Open();

                /// 如果您想接收 Toast 通知,则应该调用 BindToShellToast()方法将通道绑定到 Toast 通知。
                channel.BindToShellToast();
                // 如果您想接收磁贴通知,则将通道绑定到磁贴通知,方法是:调用 BindToShellTile()方法以访问设备上的本地资源或调用
                // BindToShellTile(Collection<(Of <<'(Uri>)>>)) 方法以访问远程资源。若要访问远程资源,您必须提供从中访问远程图像的所允许域的集合。集合中的每个 URI 都限制为 256 个字符。
                channel.BindToShellTile();
            }
            else
            {
                registerPushChannelEvent(channel);
                NotificationUri = channel.ChannelUri.ToString();
                BmobDebug.Log("NotificationUri: " + NotificationUri);

                fetchAndUpdateNotifactionUri();
            }
        }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     // Bmob.initialize("4414150cb439afdf684d37dc184e0f9f", "e1deb317442129c125b228ddf78e5f22");
     BmobDebug.Register(print);
     BmobDebug.level = BmobDebug.Level.TRACE;
     Bmob            = gameObject.GetComponent <BmobUnity> ();
 }
Esempio n. 6
0
 public BmobBaseForm()
     : base()
 {
     bmob = new BmobWindows();
     Bmob.initialize("f69acbf2dd96fbaefdf9fd9793e93f66", "9a956445ff932b7d3f59b81af28cbe2a ");
     BmobDebug.Register(msg => { Debug.WriteLine(msg); });
 }
        // JSON解析测试
        private void json_Click(object sender, RoutedEventArgs e)
        {
            var data = new BmobApi();

            data.name = "winse";
            BmobDebug.Log(JsonAdapter.JSON.ToDebugJsonString(data));
        }
Esempio n. 8
0
 // Start is called before the first frame update
 void Start()
 {
     BmobDebug.Register(print);
     BmobDebug.level = BmobDebug.Level.TRACE;
     Bmob            = gameObject.GetComponent <BmobUnity>();
     createData();
 }
Esempio n. 9
0
        private IEnumerator RequestInternal(String url, String method, byte[] postData, IDictionary <String, String> headers, Action <String, Status, BmobException> callback)
        {
            var table = new Dictionary <String, String>();

            foreach (var header in headers)
            {
                table.Add(header.Key, header.Value);
            }
            WWW www = new WWW(url, method.Equals("GET") ? null : postData, table);

            yield return(www);

            var error = www.error;
            var text  = www.text;

            BmobDebug.T("[ BmobUnity ] after fetch www message, Response: '" + text + "', Error: ' " + error + "'");


            var status = new Status(200, error);

            // if (www.responseHeaders.ContainsKey("STATUS"))
            // {
            //     var respStatus = www.responseHeaders["STATUS"];
            //     var statusCode = Regex.Replace(respStatus, @"[^ ]* (\d*) .*", "$1");
            //     status.code = Convert.ToInt32(statusCode);
            // }
            try{
                if (www.responseHeaders.ContainsKey("STATUS"))
                {
                    var respStatus = www.responseHeaders["STATUS"];
                    var statusCode = Regex.Replace(respStatus, @"[^ ]* (\d*) .*", "$1");
                    status.code = Convert.ToInt32(statusCode);
                }
            }catch (NullReferenceException e) {
                BmobDebug.T("www.responseHeaders方法有问题: " + e);
                // Unity 2017.2.0f3 (64-bit) 版本,www.responseHeaders方法在真机上有问题。zq,2017.10.24
                if (error != null)
                {
                    foreach (Match match in Regex.Matches(error, @" *(\d*) *"))
                    {
                        status.code = Convert.ToInt32(match.Value);
                        break;
                    }
                }
            }


            if (error != null && error != "")
            {
                // 返回了错误的内容,不表示返回的内容就为空!!
                callback(text, status, new BmobException(error));
            }
            else
            {
                callback(text, status, null);
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Bmob初始化
 /// </summary>
 public BmobWindows BmobBuilder()
 {
     if (_bmobWindows == null)
     {
         _bmobWindows = new BmobWindows();
         _bmobWindows.initialize(PresetInfo.BmobApplicationId, PresetInfo.BmobRestApiKey);
         BmobDebug.Register(msg => { Debug.WriteLine("BmobDebug:" + msg); });
     }
     return(_bmobWindows);
 }
Esempio n. 11
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            BmobWindows Bmob = new BmobWindows();

            Bmob.initialize("69e01e36e091bee65ebeb8f93604f474", "8b0d500c09ff5c86cfcd3358b5104b05");
            BmobDebug.Register(msg => { Debug.WriteLine(msg); });   //注册调试工具
        }
Esempio n. 12
0
        /// <summary>
        /// Event handler for when the push channel Uri is updated.
        /// </summary>
        public void ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
        {
            NotificationUri = e.ChannelUri.ToString();
            installaction.notificationUri = NotificationUri;

            // Display the new URI for testing purposes.   Normally, the URI would be passed back to your web service at this point.
            BmobDebug.Log(String.Format("Channel Uri is {0}", NotificationUri));

            fetchAndUpdateNotifactionUri();
        }
Esempio n. 13
0
        public void HttpNotificationReceived(object sender, HttpNotificationEventArgs e)
        {
            string message;

            using (System.IO.StreamReader reader = new System.IO.StreamReader(e.Notification.Body))
            {
                message = reader.ReadToEnd();
            }
            BmobDebug.Log(String.Format("Received Notification {0}:\n{1}", DateTime.Now.ToShortTimeString(), message));
        }
Esempio n. 14
0
        public BmobInitializer()
            : base()
        {
            bmob = new BmobWindows();

            //初始化,这个ApplicationId/RestKey需要更改为你自己的ApplicationId/RestKey( http://www.bmob.cn 上注册登录之后,创建应用可获取到ApplicationId/RestKey)
            Bmob.initialize("69e01e36e091bee65ebeb8f93604f474", "8b0d500c09ff5c86cfcd3358b5104b05");

            //注册调试工具
            BmobDebug.Register(msg => { Debug.WriteLine(msg); });
        }
Esempio n. 15
0
        public BmobBaseForm()
            : base()
        {
            bmob = new BmobWindows();

            //初始化ApplicationId,这个ApplicationId需要更改为你自己的ApplicationId( http://www.bmob.cn 上注册登录之后,创建应用可获取到ApplicationId)
            Bmob.initialize("4414150cb439afdf684d37dc184e0f9f", "e1deb317442129c125b228ddf78e5f22");

            //注册调试工具
            BmobDebug.Register(msg => { Debug.WriteLine(msg); });
        }
Esempio n. 16
0
            // obj to IDictionary<String, Object>
            public override bool TrySerializeNonPrimitiveObject(object input, out object output)
            {
                try
                {
                    Type objectType = input.GetType();

                    if (/*typeof(IBmobWritable).IsAssignableFrom(objectType)*/ input is IBmobWritable)
                    {
                        IBmobWritable obj     = (IBmobWritable)input;
                        BmobOutput    tOutput = new BmobOutput();
                        obj.write(tOutput, isPrint);

                        output = tOutput.getData();
                        return(true);
                    }
                    else if (objectType == typeof(BmobInt) ||
                             objectType == typeof(BmobLong) ||
                             objectType == typeof(BmobDouble) ||
                             objectType == typeof(BmobBoolean) ||
                             objectType == typeof(BmobACL))
                    {
                        object value = 0;
                        if (input is BmobInt)
                        {
                            value = (input as BmobInt).Get();
                        }
                        else if (input is BmobLong)
                        {
                            value = (input as BmobLong).Get();
                        }
                        else if (input is BmobDouble)
                        {
                            value = (input as BmobDouble).Get();
                        }
                        else if (input is BmobBoolean)
                        {
                            value = (input as BmobBoolean).Get();
                        }
                        else if (input is BmobACL)
                        {
                            value = (input as BmobACL).Get();
                        }

                        output = value;
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    BmobDebug.Log(e);
                }

                return(base.TrySerializeNonPrimitiveObject(input, out output));
            }
 // start push
 private void installation_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Bmob.StartPush();
     }
     catch (Exception ex)
     {
         BmobDebug.Log(ex);
     }
 }
Esempio n. 18
0
 protected override void OnEnable()
 {
     base.OnEnable();
     //Debuger.EnableLog = Config.enableDebug;
     Screen.fullScreen  = false;
     Screen.orientation = ScreenOrientation.Portrait;
     //Window.onFrameRateCoolDown = CustomFrameRateCoolDown;
     LoadFonts();
     BmobDebug.Register(print);
     BmobDebug.level = BmobDebug.Level.TRACE;
 }
        public BmobBasePCForm()
            : base()
        {
            bmob     = new BmobWindows();
            _toolTip = new ToolTip();
            //初始化ApplicationId,这个ApplicationId需要更改为你自己的ApplicationId( http://www.bmob.cn 上注册登录之后,创建应用可获取到ApplicationId)
            Bmob.initialize("f8e94fde865de2270860606c30e4cdaa", "a586925dc4857f8f598ca6edbee17894");

            //注册调试工具
            BmobDebug.Register(msg => { Debug.WriteLine(msg); });
        }
Esempio n. 20
0
        public BmobBaseForm()
            : base()
        {
            bmob = new BmobWindows();

            //初始化ApplicationId,这个ApplicationId需要更改为你自己的ApplicationId( http://www.bmob.cn 上注册登录之后,创建应用可获取到ApplicationId)
            Bmob.initialize("69015a79796397f7701454336b84e0c4");

            //注册调试工具
            BmobDebug.Register(msg => { Debug.WriteLine(msg); });
        }
Esempio n. 21
0
        public BmobBaseForm() : base()
        {
            InitializeComponent();

            bmob = new BmobWindows();

            //初始化ApplicationId,这个ApplicationId需要更改为你自己的ApplicationId( http://www.bmob.cn 上注册登录之后,创建应用可获取到ApplicationId)
            Bmob.initialize("5fcf8cca1113b5136fca2007de03892d", "");

            //注册调试工具
            BmobDebug.Register(msg => { Debug.WriteLine(msg); });
        }
        // 构造函数
        public MainPage()
        {
            InitializeComponent();

            Bmob.initialize("4414150cb439afdf684d37dc184e0f9f", "e1deb317442129c125b228ddf78e5f22");

            BmobDebug.Register(msg => { Debug.WriteLine(msg); });

            BmobWindowsPhone.PushChannel = "your_app_name_en";

            // 用于本地化 ApplicationBar 的示例代码
            //BuildLocalizedApplicationBar();
        }
Esempio n. 23
0
 /// <summary>
 /// Limit查询语法,用于获取限定数量(limit)的记录列表
 ///
 /// 默认10条 最多1000条。地理位置查询,默认是100,最大是1000
 /// </summary>
 /// <param name="limit">记录数限制数</param>
 /// <returns>返回当前对象</returns>
 public BmobQuery Limit(int limit)
 {
     if (limit > 1000)
     {
         BmobDebug.E("设置的查询数据量 " + limit + " 将不会生效, 单次查询最大获取数量1000条. 查询数据量置为1000.");
         this.limit = 1000;
     }
     else
     {
         this.limit = limit;
     }
     return(this);
 }
Esempio n. 24
0
        static BmobPush()
        {
            DeviceType = BmobInstallation.DeviceType;

            try
            {
                var DeviceUniqueId = Microsoft.Phone.Info.DeviceExtendedProperties.GetValue("DeviceUniqueId") as byte[];
                DeviceId = DeviceUniqueId.ToHexString();
            }
            catch (Exception e)
            {
                BmobDebug.E("获取设备唯一ID失败!!! 请确认添加ID_CAP_IDENTITY_DEVICE功能? ");
                throw e;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// 获取列表
        /// </summary>
        /// <typeparam name="U">列表中对象的具体类型</typeparam>
        /// <param name="name">字段名</param>
        public List <U> getList <U>(String name)
        {
            IList raw = getListRaw(name);

            if (raw == null)
            {
                BmobDebug.D("获取" + name + "的列表数据为空!");
                return(null);
            }

            Type     type   = typeof(U);
            List <U> result = new List <U>(raw.Count);

            foreach (var element in raw)
            {
                result.Add(Parse <U>(element));
            }

            return(result);
        }
Esempio n. 26
0
        // /

        // / 私有核心方法

        /// <summary>
        /// 对象转换的公共类
        /// </summary>
        // <typeparam name="W">支持List<>/Dictionary<X,X>/int/long/double/:BmobWritable/:BmobValue的类型</typeparam>
        // <param name="value">SDK会把JSON解析为List<X,X>和Dictionary<X,X>。 值对象,可以传入null</param>
        public static W Parse <W>(object value)
        {
            if (value == null)
            {
                return(default(W));
            }

            W w = (W)convert(typeof(W), value);

            if (w == null)
            {
                BmobDebug.E("最外层对象**推荐**使用IBmobWritable对象,序列化定制化程度更高!");

                // 搞不定,使用反射方式重新解析
                string json = JsonAdapter.JSON.ToDebugJsonString(value);
                BmobDebug.E("反序列化不正确,使用默认的JSON反序列化方式再次处理! " + json);
                w = JsonAdapter.JSON.ToObject <W>(json);
            }

            return(w);
        }
Esempio n. 27
0
        private static double toDouble(Object data)
        {
            if (data is int)
            {
                return((int)data);
            }
            else if (data is long)
            {
                return((long)data);
            }
            else if (data is double)
            {
                return((double)data);
            }
            else
            {
                BmobDebug.Log("[ERROR] 获取数值类型失败,原值为:" + JsonAdapter.JSON.ToDebugJsonString(data));
            }

            return(0);
        }
Esempio n. 28
0
        protected R Execute <R>(Func <String, String, String, Byte[], IDictionary <String, String>, Action <String, Status, BmobException>, R> request,
                                String url, String contentType, Byte[] postData, IDictionary <String, String> headers, BmobCallback <T> fCallback)
        {
            BmobDebug.T("\r\n\t请求的URL : " + url
                        + "\r\n\t交互对象(以请求的数据为准): " + JsonAdapter.JSON.ToRawString(receiver)
                        + "\r\n\t请求的数据: " + JsonAdapter.JSON.ToJsonString(receiver.Data));

            return(request.Invoke(url, receiver.Method, contentType, postData, headers, (resp, status, ex) =>
            {
                if (BmobDebug.Debug)
                {
                    BmobDebug.D("返回数据内容为: " + resp);
                }
                else
                {
                    var rp = resp.Length > 400 ? resp.Substring(0, 200) + " ... ... ... ... ... ... " + resp.Substring(resp.Length - 200) : resp;
                    BmobDebug.I("返回数据内容为: " + rp);
                }

                onPostExecute(resp, status, ex, fCallback);
            }));
        }
Esempio n. 29
0
        void Start()
        {
            for (int i = 0; i < 25; i++)//利用tag将所有定义的游戏对象赋值
            {
                gameobject[i] = GameObject.FindWithTag(i.ToString());
            }
            for (int i = 0; i < 25; i++)                   //利用for循环获取每一个零件的原始x,y,z轴坐标位置,用于装配时直接归位
            {
                x[i] = gameobject[i].transform.position.x; //获取x轴坐标位置
                y[i] = gameobject[i].transform.position.y;
                z[i] = gameobject[i].transform.position.z;
            }
            gameobject[24].SetActive(false);
            liucheng = GameObject.Find("流程").GetComponent <Button>();
            chongzhi = GameObject.Find("Button").GetComponent <Button>();
            chongzhi.onClick.AddListener(() => OnClick(1));
            liucheng.onClick.AddListener(() => OnClick(2));
            chaizhuangtishi = GameObject.Find("拆装提示");

            BmobDebug.Register(print);
            BmobDebug.level = BmobDebug.Level.TRACE;
            Bmob            = gameObject.GetComponent <BmobUnity> ();
        }
        // 注册用户
        private void signup_Click(object sender, RoutedEventArgs e)
        {
            SignUser user = new SignUser();

            user.username    = "******";
            user.password    = "******";
            user.friendNames = "a ,b ,c ";

            Bmob.Signup <SignUser>(user, (resp, ex) =>
            {
                string status = "OK";
                if (ex != null)
                {
                    status = "ERROR";
                }
                BmobDebug.Log(JsonAdapter.JSON.ToDebugJsonString(resp));

                Dispatcher.BeginInvoke(() =>
                {
                    updateStatus(signup, status);
                });
            });
        }