void queueManager_BatchSending(object sender, BatchEventArgs e)
 {
     if (BatchSending != null)
     {
         BatchSending(this, e);
     }
 }
 void queueManager_BatchSendSuccess(object sender, BatchEventArgs e)
 {
     if (BatchSendSuccess != null)
     {
         BatchSendSuccess(this, e);
     }
 }
 void queueManager_BatchSendFailed(object sender, BatchEventArgs e)
 {
     if (BatchSendFailed != null)
     {
         BatchSendFailed(this, e);
     }
 }
Exemple #4
0
        private void BatchForUI_EventHandler(object sender, BatchEventArgs e)
        {
            var    result  = e.Value;
            string rawData = e.RawData;

            if (result != null)
            {
                if (this.IsHandleCreated)
                {
                    //  导入数据库
                    BatchDataImport.Import(result);

                    //  更新界面
                    this.listView1.Invoke((Action) delegate
                    {
                        try
                        {
                            this.listView1.Items.Add(new ListViewItem()
                            {
                                Text = "接收数据 : " + rawData
                            });
                        }
                        catch (Exception exp) { Debug.WriteLine(exp.Message); }
                        try
                        {
                            this.listView1.Items.Add(new ListViewItem()
                            {
                                Text = "站点ID : " + result.StationID
                            });
                        }
                        catch (Exception exp) { Debug.WriteLine(exp.Message); }
                        try
                        {
                            this.listView1.Items.Add(new ListViewItem()
                            {
                                Text = "站点类型: " + result.StationType == "01" ? "水位" : "雨量"
                            });
                        }
                        catch (Exception exp) { Debug.WriteLine(exp.Message); }
                        foreach (var item in result.Datas)
                        {
                            try
                            {
                                this.listView1.Items.Add(new ListViewItem()
                                {
                                    Text = item.Time.ToString() + "    " + item.Data
                                });
                            }
                            catch (Exception exp) { Debug.WriteLine(exp.Message); }
                        }
                    });
                }
            }
        }
Exemple #5
0
        private void BatchForData_EventHandler(object sender, BatchEventArgs e)
        {
            try
            {
                batchMsg = new BatchMsg()
                {
                    Msg = e.RawData
                };
                CBatchStruct info = e.Value;
                if (info == null)
                {
                    return;
                }
                BatchData batchInfo = new BatchData();
                batchInfo.StationId = info.StationID;
                if (info.StationType == EStationType.ERainFall)
                {
                    batchInfo.StationType = true;
                }
                else
                {
                    batchInfo.StationType = false;
                }
                this.GetBatchList.Add(batchInfo);

                foreach (var v in info.Datas)
                {
                    BatchData dataInfo = new BatchData();
                    dataInfo.Time = v.Time.ToString();
                    dataInfo.Data = v.Data;
                    this.GetBatchList.Add(dataInfo);
                }

                BatchData endInfo = new BatchData();
                endInfo.StationId = endInfo.StationId;
                endInfo.End       = true;
                this.GetBatchList.Add(endInfo);
            }
            catch (Exception exp)
            {
                Debug.WriteLine("" + exp.Message);
            }
        }
Exemple #6
0
        private void EndSendBatch(object sender, BatchEventArgs batchEventArgs)
        {
            try
            {
                if (Interlocked.Decrement(ref this.requestCount) == 0)
                {
                    this.requestCompleted.Set();
                }

                // If the server returned an exception, throw a special purpose exception which packs up all the exceptions into a
                // list the caller to cycle through.  Processing the errors from a Batch execution is for generally more difficult
                // than ling a single error.
                if (batchEventArgs.Exception != null)
                {
                    throw batchEventArgs.Exception;
                }
            }
            catch (BatchException batchException)
            {
                // Display each error on the console.
                foreach (Exception exception in batchException.Exceptions)
                {
                    Console.WriteLine(exception.Message);
                }

                // This will signal the error exit from this loader.
                this.HasErrors = true;
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);

                // This will signal the error exit from this loader.
                this.HasErrors = true;
            }
        }
        private void BatchForData_EventHandler(object sender, BatchEventArgs e)
        {
            try
            {
                CBatchStruct info = e.Value;
                if (info == null)
                {
                    return;
                }
                if (BatchList.Bdata.Count != 0 && info.StationID == BatchList.StationId)
                {
                    return;
                }
                BatchList.RawInfo = e.RawData;
                if (info.StationType == EStationType.ERainFall)
                {
                    BatchList.SType = BatchList.Types.stationType.RainStation;
                }
                else if (info.StationType == EStationType.ERiverWater)
                {
                    BatchList.SType = BatchList.Types.stationType.WaterStation;
                }

                foreach (var v in info.Datas)
                {
                    BatchData dataInfo = new BatchData();
                    dataInfo.BatchTime  = v.Time.ToString();
                    dataInfo.BatchValue = v.Data;
                    BatchList.Bdata.Add(dataInfo);
                }
            }
            catch (Exception exp)
            {
                Debug.WriteLine("" + exp.Message);
            }
        }
Exemple #8
0
        private void BatchForUI_EventHandler(object sender, BatchEventArgs e)
        {
            //20170512改动过
            var    result  = e.Value;
            string rawData = e.RawData;

            BatchDataImport m_batchDataImport = new BatchDataImport();

            if (result != null)
            {
                if (this.IsHandleCreated)
                {
                    //  导入数据库
                    //BatchDataImport.Import(result);
                    DateTime DStartTime = new DateTime();
                    DateTime DEndTime   = new DateTime();
                    if (this.radioHour.Checked == true)
                    {
                        DateTime tmp = this.dtp_StartTime.Value;
                        //DateTime tmp_1 = this.dtp_EndTime.Value;
                        DStartTime = new DateTime(tmp.Year, tmp.Month, tmp.Day, tmp.Hour, 0, 0);
                        DEndTime   = this.dtp_EndTime.Value;
                    }
                    else if (this.radioDay.Checked == true)
                    {
                        DateTime tmp   = this.dtp_StartTime.Value;
                        DateTime tmp_1 = this.dtp_EndTime.Value;
                        DStartTime = new DateTime(tmp.Year, tmp.Month, tmp.Day, 8, 0, 0);
                        DEndTime   = new DateTime(tmp_1.Year, tmp_1.Month, tmp_1.Day, 23, 59, 59);
                    }
                    //DateTime DStartTime = this.dtp_StartTime.Value;
                    //DateTime DEndTime = this.dtp_EndTime.Value;
                    if (radioButton2.Checked)
                    {
                        m_batchDataImport.Import(result, DStartTime, DEndTime);
                    }
                    //m_batchDataImport.Import(result, DStartTime, DEndTime);
                    if (radioButtonSave.Checked)
                    {
                        if (result.StationType == EStationType.ERainFall)
                        {
                            string filePath = @"BatchData\\Rain.txt";//这里是你的已知文件
                            string strPath  = Path.GetDirectoryName(filePath);
                            if (!Directory.Exists(strPath))
                            {
                                Directory.CreateDirectory(strPath);
                            }
                            StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312"));
                            sw.Write("---------------------------------------------" + "\r\n");
                            sw.Write("接收数据 : " + rawData + "\r\n");          //写你的字符串。
                            sw.Write("站点ID : " + result.StationID + "\r\n"); //写你的字符串。
                            sw.Write("站点类型: " + "水位" + "\r\n");              //写你的字符串。
                            foreach (var item in result.Datas)
                            {
                                try
                                {
                                    sw.Write(item.Time.ToString() + "    " + item.Data + "\r\n");
                                }
                                catch (Exception exp) { Debug.WriteLine(exp.Message); }
                            }
                            sw.Close();
                        }
                        if (result.StationType == EStationType.ERiverWater)
                        {
                            string filePath = "BatchData\\Water.txt";//这里是你的已知文件
                            string strPath  = Path.GetDirectoryName(filePath);
                            if (!Directory.Exists(strPath))
                            {
                                Directory.CreateDirectory(strPath);
                            }
                            StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312"));
                            sw.Write("---------------------------------------------" + "\r\n");
                            sw.Write("接收数据 : " + rawData + "\r\n");          //写你的字符串。
                            sw.Write("站点ID : " + result.StationID + "\r\n"); //写你的字符串。
                            sw.Write("站点类型: " + "雨量" + "\r\n");              //写你的字符串。
                            foreach (var item in result.Datas)
                            {
                                try
                                {
                                    sw.Write(item.Time.ToString() + "    " + item.Data + "\r\n");
                                }
                                catch (Exception exp) { Debug.WriteLine(exp.Message); }
                            }
                            sw.Close();
                        }
                    }

                    //  更新界面

                    this.listView1.Invoke((Action) delegate
                    {
                        try
                        {
                            this.listView1.Items.Add(new ListViewItem()
                            {
                                Text = "接收数据 : " + rawData
                            });
                        }
                        catch (Exception exp) { Debug.WriteLine(exp.Message); }
                        try
                        {
                            this.listView1.Items.Add(new ListViewItem()
                            {
                                Text = "站点ID : " + result.StationID
                            });
                        }
                        catch (Exception exp) { Debug.WriteLine(exp.Message); }
                        try
                        {
                            if (result.StationType == EStationType.ERiverWater)
                            {
                                this.listView1.Items.Add(new ListViewItem()
                                {
                                    Text = "站点类型: " + "雨量"
                                });
                            }
                            else if (result.StationType == EStationType.ERainFall)
                            {
                                this.listView1.Items.Add(new ListViewItem()
                                {
                                    Text = "站点类型: " + "水位"
                                });
                            }
                        }
                        catch (Exception exp) { Debug.WriteLine(exp.Message); }
                        foreach (var item in result.Datas)
                        {
                            try
                            {
                                this.listView1.Items.Add(new ListViewItem()
                                {
                                    Text = item.Time.ToString() + "    " + item.Data
                                });
                            }
                            catch (Exception exp) { Debug.WriteLine(exp.Message); }
                        }
                    });
                }
            }
        }
 void queueManager_BatchSendSuccess(object sender, BatchEventArgs e)
 {
     if (BatchSendSuccess != null)
         BatchSendSuccess(this, e);
 }
 void queueManager_BatchSending(object sender, BatchEventArgs e)
 {
     if (BatchSending != null)
         BatchSending(this, e);
 }
 void queueManager_BatchSendFailed(object sender, BatchEventArgs e)
 {
     if (BatchSendFailed != null)
         BatchSendFailed(this, e);
 }
 private void _batch_OnDone(object sender, BatchEventArgs e)
 {
     Log.Debug("Batch {0} done.", e.Data);
 }
 private void _batch_OnMachineScanStart(object sender, BatchEventArgs e)
 {
     Log.Debug("Start scanning machine {0}", e.MachineName);
 }
 private void _batch_OnStart(object sender, BatchEventArgs e)
 {
     Log.Debug("Batch {0} started.", e.Data);
 }
Exemple #15
0
 private void converterService_OnBatchCompleted(BatchEventArgs args)
 {
     Invoke(new BatchCompletedEventHandler(BatchComplete), this, new EventArgs());
 }
 void Obj_Batch(object sender, BatchEventArgs e)
 {
     JCache.RemoveHierarchyCache(JCache.GetRootCacheKey(e.Type.FullName));
 }