コード例 #1
0
ファイル: Program.cs プロジェクト: MPD97/MAS-s16852-PJWSTK
        static void Main(string[] args)
        {
            string pathDesktop        = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            string pathJSONSerialized = Path.Combine(pathDesktop, "MP01", "serialized.json");

            if (File.Exists(pathJSONSerialized) == false)
            {
                Warehouse warehouse1 = new Warehouse("Orchidei 14A, 96-321 Słubica B", 350);
                Warehouse warehouse2 = new Warehouse("Samorządowa 26, 26-600 Radom", 221);
                Warehouse warehouse3 = new Warehouse("Południowa 4c, 26-613 Jedlnia-Letnisko", 445);
                Warehouse warehouse4 = new Warehouse("Bursztynowa 11, 26-660 Wsola", 775);

                Server server1 = new Server("Core I7", "Intel", new Storage(3000000000, 50000000000, 1700000000, 1300000000));
                Server server2 = new Server("Core I3", "Intel", new Storage(15000000000, 440000000000, 2888741908, 444440000));

                ObjectPlus.ShowExtent <Warehouse>();
                ObjectPlus.ShowExtent <Server>();


                FileInfo fileInfo = new FileInfo(pathJSONSerialized);
                if (!fileInfo.Directory.Exists)
                {
                    Directory.CreateDirectory(fileInfo.DirectoryName);
                }

                using (StreamWriter sw = new StreamWriter(pathJSONSerialized))
                {
                    ObjectPlus.WriteExtents(sw);
                }
            }
            else
            {
                using (StreamReader sr = new StreamReader(pathJSONSerialized))
                {
                    ObjectPlus.ReadExtents(sr);
                }

                ObjectPlus.ShowExtent <Warehouse>();
                ObjectPlus.ShowExtent <Server>();
            }

            Console.ReadLine();
        }
コード例 #2
0
ファイル: PlayVideo.cs プロジェクト: thangk48cc/VietTV
        private async void GetDirectLink(string link)
        {
            HttpClient httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.IfModifiedSince = new DateTimeOffset?(DateTimeOffset.get_Now());
            if (PlayVideo.ChanelPlayer.typeChannel.EndsWith("TrucTiep"))
            {
                if (this._countLink > 0 && !link.Contains("m3u8"))
                {
                    string stringAsync = await httpClient.GetStringAsync(string.Concat("http://winphonevn.com/server/getlinkbongda.php?url=", link));

                    link = stringAsync;
                }
                this._countLink = this._countLink + 1;
            }
            this.Player.Source = null;
            string[] strArray = null;
            string   str      = "";

            this.Load.set_Visibility(0);
            if (link.Contains("!"))
            {
                strArray = link.Split(new char[] { '!' });
            }
            try
            {
                if (strArray != null)
                {
                    str = await httpClient.GetStringAsync(strArray[0]);
                }
                if (link.Contains("fptlive"))
                {
                    string str1     = link;
                    char[] chrArray = new char[] { '/' };
                    string str2     = str1.Split(chrArray)[1];
                    httpClient = new HttpClient();
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    dictionary.Add("id", str2);
                    dictionary.Add("quality", "3");
                    dictionary.Add("mobile", "web");
                    dictionary.Add("type", "newchannel");
                    FormUrlEncodedContent formUrlEncodedContent = new FormUrlEncodedContent(dictionary);
                    HttpRequestMessage    httpRequestMessage    = new HttpRequestMessage()
                    {
                        Method     = HttpMethod.Post,
                        RequestUri = new Uri("http://fptplay.net/show/getlinklivetv", 1),
                        Content    = formUrlEncodedContent
                    };
                    HttpRequestMessage uri = httpRequestMessage;
                    uri.Headers.Referrer = new Uri("http://fptplay.net/");
                    uri.Headers.Add("X-Requested-With", "XMLHttpRequest");
                    HttpResponseMessage httpResponseMessage = await httpClient.SendAsync(uri, HttpCompletionOption.ResponseContentRead);

                    string str3 = await httpResponseMessage.Content.ReadAsStringAsync();

                    if (str3 != null && str3.get_Length() > 0)
                    {
                        string item = (string)JObject.Parse(str3)["stream"];
                        if (item.get_Length() > 0)
                        {
                            this._str = item;
                        }
                    }
                }
                else if (strArray != null)
                {
                    Match match = (new Regex(strArray[1], 9)).Match(str);
                    if (match.get_Success() && match.get_Groups().get_Item(1).get_Value().StartsWith("http"))
                    {
                        this._str = HttpUtility.UrlDecode(match.get_Groups().get_Item(1).get_Value());
                    }
                }
                else if (link.Contains("app.101vn"))
                {
                    Dictionary <string, string> dictionary1 = new Dictionary <string, string>();
                    dictionary1.Add("talachua", "101vn");
                    dictionary1.Add("package", "duahau3");
                    dictionary1.Add("version", "10");
                    FormUrlEncodedContent formUrlEncodedContent1 = new FormUrlEncodedContent(dictionary1);
                    HttpResponseMessage   httpResponseMessage1   = await httpClient.PostAsync(link, formUrlEncodedContent1);

                    PlayVideo playVideo = this;
                    string    str4      = playVideo._str;
                    playVideo._str = await httpResponseMessage1.Content.ReadAsStringAsync();

                    playVideo = null;
                }
                else if (link.Contains("notfreeplus"))
                {
                    string str5 = await(new WebClient()).DownloadStringTaskAsync(new Uri("https://api.vtvplus.vn/pro/index.php/api/v1/channel/stream/88/?ip_address=0&[email protected]&type_device=android&type_network=wifi&app_name=VTVPlus"));
                    str = str5;
                    ObjectPlus objectPlu = JsonConvert.DeserializeObject <ObjectPlus>(str);
                    this._str = objectPlu.Data.get_Item(0).Url;
                }
                else if (!link.Contains("notfreemtv"))
                {
                    this._str = link;
                }
                else
                {
                    string[] strArray1 = link.Split(new char[] { '=' });
                    Random   random    = new Random();
                    Dictionary <string, string> dictionary2 = new Dictionary <string, string>();
                    str = await httpClient.GetStringAsync("http://api.mytvnet.vn//getToken");

                    JObject jObjects = JObject.Parse(str);
                    if (jObjects == null || jObjects["tid"] == null)
                    {
                        return;
                    }
                    else
                    {
                        long     num = Convert.ToInt64((new Fc()).DeCodeTid(jObjects["tid"].ToString()));
                        DateTime now = DateTime.get_Now();
                        Fc       fc  = new Fc();
                        dictionary2.Add("tid", fc.GetTid(num, now));
                        Dictionary <string, string> dictionary3 = dictionary2;
                        int num1 = random.Next(1, 10);
                        dictionary3.Add("device_type", num1.ToString());
                        Dictionary <string, string> dictionary4 = dictionary2;
                        num1 = random.Next(1, 99);
                        dictionary4.Add("app_v", num1.ToString());
                        dictionary2.Add("lang", "vn");
                        dictionary2.Add("channel_id", strArray1[1]);
                        dictionary2.Add("mf_code", strArray1[2]);
                        Dictionary <string, string> dictionary5 = dictionary2;
                        num1 = random.Next(1, 10);
                        dictionary5.Add("profile", num1.ToString());
                        Dictionary <string, string> dictionary6 = dictionary2;
                        num1 = random.Next(1, 100000);
                        dictionary6.Add("member_id", num1.ToString());
                        Dictionary <string, string> dictionary7 = dictionary2;
                        num1 = random.Next(1, 1000000);
                        dictionary7.Add("manufacturer_id", num1.ToString());
                        Dictionary <string, string> dictionary8 = dictionary2;
                        num1 = random.Next(0, 100000);
                        dictionary8.Add("device_id", num1.ToString());
                        FormUrlEncodedContent formUrlEncodedContent2 = new FormUrlEncodedContent(dictionary2);
                        HttpResponseMessage   httpResponseMessage2   = await httpClient.PostAsync("http://ott.mytvnet.vn/v5/channel/mobile/url", formUrlEncodedContent2);

                        string str6 = await httpResponseMessage2.Content.ReadAsStringAsync();

                        jObjects = JObject.Parse(str6);
                        if (jObjects["result"].ToString() == "-1")
                        {
                            Dictionary <string, string> dictionary9 = new Dictionary <string, string>();
                            dictionary9.Add("tid", fc.GetTid(num, now));
                            num1 = random.Next(1, 10);
                            dictionary9.Add("device_type", num1.ToString());
                            num1 = random.Next(1, 99);
                            dictionary9.Add("app_v", num1.ToString());
                            dictionary9.Add("lang", "vn");
                            dictionary9.Add("channel_id", strArray1[1]);
                            dictionary9.Add("mf_code", strArray1[2]);
                            num1 = random.Next(1, 10);
                            dictionary9.Add("profile", num1.ToString());
                            num1 = random.Next(1, 100000);
                            dictionary9.Add("member_id", num1.ToString());
                            num1 = random.Next(1, 1000000);
                            dictionary9.Add("manufacturer_id", num1.ToString());
                            num1 = random.Next(1, 100000);
                            dictionary9.Add("device_id", num1.ToString());
                            dictionary2            = dictionary9;
                            formUrlEncodedContent2 = new FormUrlEncodedContent(dictionary2);
                            HttpResponseMessage httpResponseMessage3 = await httpClient.PostAsync("http://api.mytvnet.vn/v5/channel/mobile/url", formUrlEncodedContent2);

                            string str7 = await httpResponseMessage3.Content.ReadAsStringAsync();

                            jObjects  = JObject.Parse(str7);
                            this._str = jObjects["data"]["url"].ToString();
                        }
                        else
                        {
                            this._str = jObjects["data"]["url"].ToString();
                        }
                        strArray1   = null;
                        random      = null;
                        dictionary2 = null;
                        fc          = null;
                    }
                }
                this.Player.Source = new Uri(this._str.Trim(), 0);
                this.Player.Play();
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                EasyTracker.GetTracker().SendException(string.Concat(this._str, " :", exception.get_Message()), false);
                this.Player.Source = new Uri(this._str, 0);
                this.Player.Play();
                this.Load.set_Visibility(1);
            }
            this.Load.set_Visibility(1);
        }