/// <summary>
        /// Submit a job to Splunk to be scheduled immediately.
        /// </summary>
        /// <param name="job">Job object containing details of the search job.</param>
        /// <returns>Returns the string containing the Splunk job identifier.</returns>
        public string SubmitJob(SplunkDataQuery job)
        {
            string        path    = "/services/search/jobs";
            ServerRequest request = new ServerRequest(path, ServerRequest.HttpMethod.POST);

            request.Args.Add(new KeyValuePair <string, string>("search", job.Value));
            request.Args.Add(new KeyValuePair <string, string>("earliest_time", string.Format("{0}.000+00:00", job.EarliestTime.ToUniversalTime().ToString("s"))));
            request.Args.Add(new KeyValuePair <string, string>("latest_time", string.Format("{0}.000+00:00", job.LatestTime.ToUniversalTime().ToString("s"))));
            request.Args.Add(new KeyValuePair <string, string>("max_count", MaxCount.ToString()));
            request.Args.Add(new KeyValuePair <string, string>("timeout", SearchJobTtl.ToString()));

            ServerResponse response = this.Send(request);

            var doc = new XmlDocument();

            doc.LoadXml(response.Content);
            string sid;

            try
            {
                sid = doc.SelectSingleNode("/response/sid").InnerText;
            }
            catch (Exception)
            {
                throw new Exception(String.Format("Something went wrong while submitting the search to Splunk. The Splunk API returned:\n{0}", response.Content));
            }

            return(sid);
        }
Esempio n. 2
0
 /// <summary>
 /// returns the string representation of the statistics.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     lock (this)
     {
         System.Text.StringBuilder ret = new System.Text.StringBuilder();
         ret.Append("Stats[Sch:" + ClassName + ", Cnt:" + Count.ToString() + ", ");
         ret.Append("Hi:" + HiCount.ToString() + ", ");
         ret.Append("MxS:" + MaxSize.ToString() + ", ");
         ret.Append("MxC:" + MaxCount.ToString() + ", ");
         ret.Append("Hit:" + HitCount.ToString() + ", ");
         ret.Append("Miss:" + MissCount.ToString() + "]");
         return(ret.ToString());
     }
 }
Esempio n. 3
0
 public override Task Start(CancellationToken token)
 {
     Bind(BindingOptions.Value.EndPoint);
     _listener.Start(BindingOptions.Value.Backlog);
     Logger.LogInformation("Started, listening on {0}, protocol: {1}, max connections: {2}, backlog: {3}",
                           _listener.LocalEndpoint, Protocol, MaxCount == 0 ? "unlimited" : MaxCount.ToString(), BindingOptions.Value.Backlog);
     Logger.LogInformation($"Shark server {Remote}");
     token.Register(() => _listener.Stop());
     return(StartAccept());
 }
Esempio n. 4
0
        public async void UpdateSyncData()
        {
            var GetList = GetFileList(path, Id, pass, DrPath);   /// Add Network Credentials
            //  PTK async 2021-03-04
            bool UseAsync = true;
            var  lblini   = "";

            try
            {
                MaxCount             = 2;                                            // GetList.Count();//
                lblini               = " of " + MaxCount.ToString() + " Completed!"; //
                _Progressbar         = (System.Windows.Forms.ProgressBar)GetParentLbl(SenderParent).Controls.Find("progressBar1", true)[0];
                _Progressbar.Visible = true;
                _Progressbar.Enabled = true;
                _Progressbar.Maximum = 100;
                _Progressbar.Minimum = 0;
                _Progressbar.Value   = 0;
                _Progressbar.Step    = 1;
                //   _Progressbar.Text = "0" + lblini;

                _Progress         = (GetParentLbl(SenderParent).Controls.Find("lblProgress", true)[0] as System.Windows.Forms.Label);
                _Progress.Visible = true;
                _Progress.Text    = "0" + lblini;

                if (lblini == "")
                {
                    // MessageBox.Show("empty");
                    UseAsync = false;
                }
            }
            catch (Exception ex)
            {
                // MessageBox.Show(ex.StackTrace);
                UseAsync = false;
            }
            //  PTK async 2021-03-04
            if (GetList != null)
            {
                int cc = 0;
                // _Progressbar.Value = 50;// Convert.ToInt32((Convert.ToInt32(cc) / MaxCount) * 100);
                _Progressbar.PerformStep();
                _Progressbar.Update();
                try
                {
                    GetParentLbl(SenderParent).Refresh();
                }
                catch (Exception ex)
                {
                    // MessageBox.Show(ex.StackTrace);
                }
                foreach (string file in GetList)
                {
                    if (cc == 2)
                    {
                        break;
                    }
                    cc++;
                    if (UseAsync)
                    {
                        await Task.Run(() =>
                        {
                            try
                            {
                                UpdateText(_Progressbar, cc.ToString() + lblini);
                                UpdateText(_Progress, cc.ToString() + lblini);
                            }
                            catch { }
                        });
                    }
                    Download(file, path, Id, pass, DrPath);
                }
                MessageBox.Show("ダウンロードが終わりました", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                _Progressbar.Enabled = false;
                _Progressbar.Visible = false;
                _Progress.Text       = "";
                // System.Windows.Forms.Cursor.Current = Cursors.Default;
            }
        }