示例#1
0
        public void OnSuccess(Object response)
        {

            if ((response.GetType().ToString()).EndsWith("Storage"))
            {
                System.Diagnostics.Debug.WriteLine("received question " + i);
                Storage storage = (Storage)response;
                IList<Storage.JSONDocument> jsonDocList = storage.GetJsonDocList();
                Global.temp = jsonDocList[0].GetJsonDoc();
                string jsonString = @"{    'paramss': [" + Global.temp + "]  }";

                RootObject childlist = new RootObject();
                MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
                DataContractJsonSerializer ser = new DataContractJsonSerializer(childlist.GetType());
                childlist = ser.ReadObject(ms) as RootObject;

                foreach (var d in childlist.paramss)
                {
                    Global.s[i, 0] = "" + d.qid;
                    Global.s[i, 1] = d.o0;
                    Global.s[i, 2] = d.o1;
                    Global.s[i, 3] = d.o2;
                    Global.s[i, 4] = d.o3;
                    Global.s[i, 5] = d.ans + "";
                }
                ms.Close();
                System.Diagnostics.Debug.WriteLine("processing done - q" + i);
                i++;
                f();
            }

            else //if ((response.GetType().ToString()).EndsWith("Upload"))
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    System.Diagnostics.Debug.WriteLine("received clip url " + k);
                    Upload upload = (Upload)response;
                    IList<Upload.File> fileList = upload.GetFileList(); // This will have only single file fetched as user can have only one file with given name   

                    Global.links[k] = upload.GetFileList()[0].GetUrl().ToString();  //This will return file url info 
                     
                    if(k < 2)
                    {
                        System.Diagnostics.Debug.WriteLine("started clip " + k);
                        Global.MyAudio[k].Stop();
                        Global.MyAudio[k].Source = new Uri(Global.links[k], UriKind.Absolute);
                        Global.MyAudio[k].Stop();
                    }

                    /*Global.MyAudio[k].Stop();

                    string MediaUrl = "/Audio/B"+k+".mp3";
                    Global.MyAudio[k].Source = new Uri(MediaUrl, UriKind.RelativeOrAbsolute);

                    Global.MyAudio[k].Play();
                    Global.MyAudio[k].Stop();*/

                    k++;
                    g();

                });
            }

        }
示例#2
0
        public void OnSuccess(Object response)
        {
            if ((response.GetType().ToString()).EndsWith("Storage"))
            {
                System.Diagnostics.Debug.WriteLine("received question " + i);
                Storage storage = (Storage)response;
                IList <Storage.JSONDocument> jsonDocList = storage.GetJsonDocList();
                Global.temp = jsonDocList[0].GetJsonDoc();
                string jsonString = @"{    'paramss': [" + Global.temp + "]  }";

                RootObject   childlist         = new RootObject();
                MemoryStream ms                = new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
                DataContractJsonSerializer ser = new DataContractJsonSerializer(childlist.GetType());
                childlist = ser.ReadObject(ms) as RootObject;

                foreach (var d in childlist.paramss)
                {
                    Global.s[i, 0] = "" + d.qid;
                    Global.s[i, 1] = d.o0;
                    Global.s[i, 2] = d.o1;
                    Global.s[i, 3] = d.o2;
                    Global.s[i, 4] = d.o3;
                    Global.s[i, 5] = d.ans + "";
                }
                ms.Close();
                System.Diagnostics.Debug.WriteLine("processing done - q" + i);
                i++;
                f();
            }

            else //if ((response.GetType().ToString()).EndsWith("Upload"))
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    System.Diagnostics.Debug.WriteLine("received clip url " + k);
                    Upload upload = (Upload)response;
                    IList <Upload.File> fileList = upload.GetFileList();           // This will have only single file fetched as user can have only one file with given name

                    Global.links[k] = upload.GetFileList()[0].GetUrl().ToString(); //This will return file url info

                    if (k < 2)
                    {
                        System.Diagnostics.Debug.WriteLine("started clip " + k);
                        Global.MyAudio[k].Stop();
                        Global.MyAudio[k].Source = new Uri(Global.links[k], UriKind.Absolute);
                        Global.MyAudio[k].Stop();
                    }

                    /*Global.MyAudio[k].Stop();
                    *
                    *  string MediaUrl = "/Audio/B"+k+".mp3";
                    *  Global.MyAudio[k].Source = new Uri(MediaUrl, UriKind.RelativeOrAbsolute);
                    *
                    *  Global.MyAudio[k].Play();
                    *  Global.MyAudio[k].Stop();*/

                    k++;
                    g();
                });
            }
        }