コード例 #1
0
        public ContentCurlVModel()
        {
            // load IPAddress and UserAgent data
            IPManager.Load(App.FileIPAddressXml);
            UAManager.Load(App.FileUserAgentXml);
            SiteManager.Load(App.FileCurlXml);

            // load curl data
            SiteListOC = new ObservableCollection <SiteProfile>(SiteManager.SiteList);

            // set list display grouping
            CollectionView           collectionView   = (CollectionView)CollectionViewSource.GetDefaultView(SiteListOC);
            PropertyGroupDescription groupDescription = new PropertyGroupDescription("Website");

            collectionView.GroupDescriptions.Add(groupDescription);
        }
コード例 #2
0
        public void OnWindowClosing()
        {
            // save user-agent data if it has changes, when this window is closing
            if (UAManager.HasChangesToFile())
            {
                string title    = (string)Application.Current.FindResource("ua_title");
                string ask_save = (string)Application.Current.FindResource("ua_ask_save_changes");

                View.DialogButton dialog = new View.DialogButton(title, ask_save);
                dialog.ShowDialog();

                if (dialog.CancelableResult == true)
                {
                    UAManager.Save();
                }
                else
                {
                    UAManager.Reload();
                }
            }
        }
コード例 #3
0
        private string PlaySite(string arguments, FakeIP fakeip, FakeUA fakeua, bool readReponse)
        {
            // fake ip
            if (fakeip != null)
            {
                string ip;
                if (fakeip.FakeMethod == FakeIP.Method.Pick)
                {
                    ip = IPManager.GetRandom()?.IP;
                }
                else
                {
                    ip = IPManager.GetGenerate();
                }

                if (string.IsNullOrWhiteSpace(ip))
                {
                    throw new Exception(sr_fake_ip_error);
                }
                else
                {
                    arguments = arguments.Replace(fakeip.Replace, ip);
                }
            }

            // fake ua
            if (fakeua != null)
            {
                string ua = UAManager.GetRandom()?.Value;
                if (string.IsNullOrWhiteSpace(ua))
                {
                    throw new Exception(sr_fake_ua_error);
                }
                else
                {
                    arguments = arguments.Replace(fakeua.Replace, ua);
                }
            }

            // curl process
            Process process = new Process()
            {
                StartInfo =
                {
                    FileName               = Utility.CurlManager.PathCurlExe,
                    Arguments              = arguments,
                    WorkingDirectory       = App.PathCurl,
                    CreateNoWindow         = true,
                    UseShellExecute        = false,
                    RedirectStandardOutput = readReponse,
                },
            };

            string response;

            try
            {
                process.Start();

                response = process.StartInfo.RedirectStandardOutput ?
                           process.StandardOutput.ReadToEnd() :
                           $"{sr_complete} {DateTime.Now.ToString("yyyy.MM.dd-HH:mm:ss")}";
                process.WaitForExit();
            }
            catch
            {
                response = $"{sr_failed} {DateTime.Now.ToString("yyyy.MM.dd-HH:mm:ss")}";
            }
            finally
            {
                process.Dispose();
            }

            return(response);
        }
コード例 #4
0
 private void reloadData(object parameter)
 {
     UAManager.Reload();
     UserAgentList = UAManager.UAList;
     OnPropertyChanged("UserAgentList");
 }
コード例 #5
0
 private void saveData(object parameter)
 {
     UAManager.Save();
 }