public void changeWndDgvText2(DataGridView RecordDetailDgv, RecordDetail rd, float manualWriteValue, bool del)
 {
     if (del)
     {
         RecordDetailDgv.Rows.Clear();
         return;
     }
     RecordDetailDgv.Rows.Add(1);
     if (rd.Percent == -1)
     {
         RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["percent"].Value = "-";
     }
     else
     {
         RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["percent"].Value = rd.Percent.ToString("0.00");
     }
     RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["result1"].Value = rd.Result == 1 ? "合格" : "不合格";
     RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["Lower"].Value   = rd.Lower;
     RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["upper"].Value   = rd.Upper;
     //手动输入的数值
     RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["ManualWriteValue"].Value = manualWriteValue;
     RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["testValue"].Value        = rd.TestValue.ToString("0.00");
     RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["standard"].Value         = rd.Standard.ToString("0.00");
     RecordDetailDgv.Rows[RecordDetailDgv.Rows.Count - 2].Cells["difference"].Value       = rd.Difference.ToString("0.00");
 }
Esempio n. 2
0
        private void GetSQLData()
        {
            DataTable dt = new DataTable();

            string sql = "select * from recordlist";

            SingletonInfo.GetInstance().DataBase.FromSql(sql, out dt);
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    RecordDetail pp = new RecordDetail();
                    pp.AreaCode      = item["AreaCode"].ToString();
                    pp.DealFlag      = Convert.ToInt32(item["DealFlag"].ToString());
                    pp.EventType     = item["EventType"].ToString();
                    pp.MediumType    = item["MediumType"].ToString();
                    pp.MsgEndTime    = item["MsgEndTime"].ToString();
                    pp.MsgStartTime  = item["MsgStartTime"].ToString();
                    pp.RecordId      = item["RecordId"].ToString();
                    pp.SavePath      = item["SavePath"].ToString();
                    pp.Severity      = item["Severity"].ToString();
                    pp.SourceTar     = item["SourceTar"].ToString();
                    pp.SourceTarPath = item["SourceTarPath"].ToString();
                    pp.TextContent   = item["TextContent"].ToString();
                    pp.MsgTitle      = item["MsgTitle"].ToString();
                    pp.SenderCode    = item["SenderCode"].ToString();
                    pp.SenderName    = item["SenderName"].ToString();
                    pp.SendTime      = item["SendTime"].ToString();

                    SetDataGridviewControlPropertyValue(this.skinDataGridView_Main, pp);
                    SingletonInfo.GetInstance().RecordDetailList.Add(pp);
                }
            }
        }
Esempio n. 3
0
        void ContentClick(RecordDetail ea)
        {
            if (this.WindowState == FormWindowState.Minimized)
            {
                WindowState = FormWindowState.Normal;
                //激活窗体并给予它焦点
                this.Activate();
                //任务栏区显示图标
                this.ShowInTaskbar = true;

                skinDataGridView_Record.Rows.Clear();
                panel1.Visible = false;
                skinDataGridView_Main.Visible = true;
            }


            foreach (DataGridViewRow item in skinDataGridView_Main.Rows)
            {
                RecordDetail pp = (RecordDetail)item.Tag;
                if (pp.RecordId == ea.RecordId)
                {
                    //  item.Selected = true;

                    item.DefaultCellStyle.BackColor = Color.Green;
                }
            }
        }
 /// <summary>
 /// get records by query
 /// </summary>
 /// <param name="infoCenter"></param>
 /// <param name="query"></param>
 /// <param name="recordDetail"></param>
 /// <param name="rowAccess"></param>
 /// <param name="chunkSize"></param>
 /// <param name="tableInfo"></param>
 /// <returns></returns>
 public VisionMessage GetRecordsByQuery(VisionInfoCenters infoCenter,
                                        string query,
                                        RecordDetail recordDetail = RecordDetail.Empty,
                                        bool rowAccess            = false,
                                        int chunkSize             = 100,
                                        XElement tableInfo        = null)
 {
     return(GetRecordsByQuery(infoCenter.GetValueName(), query, recordDetail, rowAccess, chunkSize, tableInfo));
 }
 /// <summary>
 /// get records by key
 /// </summary>
 /// <param name="infoCenter"></param>
 /// <param name="keys"></param>
 /// <param name="recordDetail"></param>
 /// <param name="rowAccess"></param>
 /// <param name="chunkSize"></param>
 /// <param name="tableInfo"></param>
 /// <returns></returns>
 public VisionMessage GetRecordsByKey(VisionInfoCenters infoCenter,
                                      VisionKeyList keys,
                                      RecordDetail recordDetail = RecordDetail.Empty,
                                      bool rowAccess            = false,
                                      int chunkSize             = 100,
                                      XElement tableInfo        = null)
 {
     return(GetRecordsByKey(infoCenter.GetValueName(), keys, recordDetail, rowAccess, chunkSize, tableInfo));
 }
Esempio n. 6
0
 public void RecordDetailDgv(RecordDetail rd, float manualWriteValue, bool del)
 {
     if (wnd.InvokeRequired)
     {
         wnd.Invoke(new Action <RecordDetail, float, bool>(RecordDetailDgv), rd, manualWriteValue, del);
         return;
     }
     changeWndDgvText2(wnd.RecordDetailDgv, rd, manualWriteValue, del);
 }
 public void initRecordDetail(TechnologyDetail techDetail)
 {
     currentRecordDetail          = new RecordDetail();
     currentRecordDetail.RecordId = currentRecord.Id;
     currentRecordDetail.Standard = techDetail.Standard;
     currentRecordDetail.Lower    = techDetail.Lower;
     currentRecordDetail.Upper    = techDetail.Upper;
     //新增
     currentRecordDetail.ManualWriteValue = 0;
 }
Esempio n. 8
0
        public static string GetValueName(this RecordDetail recordDetail)
        {
            string _retval = Enum.GetName(typeof(RecordDetail), recordDetail);

            if (_retval == "Empty")
            {
                _retval = "";
            }
            return(_retval);
        }
 /// <summary>
 /// get records by key (singular)
 /// </summary>
 /// <param name="infoCenter"></param>
 /// <param name="key"></param>
 /// <param name="recordDetail"></param>
 /// <param name="rowAccess"></param>
 /// <param name="chunkSize"></param>
 /// <param name="tableInfo"></param>
 /// <returns></returns>
 public VisionMessage GetRecordsByKey(string infoCenter,
                                      VisionKey key,
                                      RecordDetail recordDetail = RecordDetail.Empty,
                                      bool rowAccess            = false,
                                      int chunkSize             = 100,
                                      XElement tableInfo        = null)
 {
     return(GetRecordsByKey(infoCenter, new VisionKeyList()
     {
         key
     }, recordDetail, rowAccess, chunkSize, tableInfo));
 }
Esempio n. 10
0
        private void skinDataGridView_Main_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                switch (e.ColumnIndex)
                {
                case 0:
                    MessageShowDlg = new MessageShowForm {
                        label1 = { Text = @"确认处理?" }
                    };
                    MessageShowDlg.ShowDialog();
                    if (MessageShowDlg.IsSure)
                    {
                        DataGridViewRow dgvR = skinDataGridView_Main.Rows[e.RowIndex];
                        dgvR.DefaultCellStyle.BackColor = Color.FromArgb(40, 36, 36);
                        RecordDetail selectone = (RecordDetail)dgvR.Tag;
                        selectone.DealFlag = 1;
                        //更新数据库
                        SingletonInfo.GetInstance().DataBase.UpdateRecorde(selectone);
                        dgvR.Cells[0].Value    = "已处理";
                        dgvR.Cells[0].ReadOnly = true;
                    }

                    break;

                case 2:
                    DataGridViewRow dgvRS    = skinDataGridView_Main.Rows[e.RowIndex];
                    RecordDetail    selected = (RecordDetail)dgvRS.Tag;

                    EBMDetailShowDlg = new EBMDetailShowForm(selected);
                    EBMDetailShowDlg.ShowDialog();
                    break;

                case 9:
                    MessageShowDlg = new MessageShowForm {
                        label1 = { Text = @"打开链接?" }
                    };
                    MessageShowDlg.ShowDialog();
                    if (MessageShowDlg.IsSure)
                    {
                        DataGridViewRow dgvR      = skinDataGridView_Main.Rows[e.RowIndex];
                        RecordDetail    selectone = (RecordDetail)dgvR.Tag;
                        string          path      = Path.GetDirectoryName(selectone.SavePath);
                        System.Diagnostics.Process.Start(path);
                    }
                    break;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 public void MapInputPipeDelimitedStringToRecordDetail()
 {
     string input = "last|first|M|black|02/04/1999|X";
     RecordDetail expected = new RecordDetail
     {
         LastName = "last",
         DateOfBirth = Convert.ToDateTime("02/04/1999"),
         FavColor = "black",
         FirstName = "first",
         Gender = "M"
     };
     RecordDetail actual = RecordDetailMapper.MapDelimitedFileLineToRecordDetail(input);
     Assert.AreEqual(AreEqual(expected, actual), true);
 }
 public void MapInputCommaDelimitedStringToRecordDetail()
 {
     string input = "last,first,M,black,";
     RecordDetail expected = new RecordDetail
     {
         LastName = "last",
         DateOfBirth = default(DateTime),
         FavColor = "black",
         FirstName = "first",
         Gender = "M"
     };
     RecordDetail actual = RecordDetailMapper.MapDelimitedFileLineToRecordDetail(input);
     Assert.AreEqual(AreEqual(expected, actual), true);
 }
 public void MapInputStringToRecordDetail()
 {
     string input = "test";
     RecordDetail expected = new RecordDetail
     {
         LastName = "test",
         DateOfBirth = default(DateTime),
         FavColor = default(string),
         FirstName = default(string),
         Gender = default(string)
     };
     RecordDetail actual = RecordDetailMapper.MapDelimitedFileLineToRecordDetail(input);
     Assert.AreEqual(AreEqual(expected, actual), true);
 }
Esempio n. 14
0
        /// <summary>
        /// 外部测试数据,模拟开锁数据
        /// </summary>
        /// <param name="id"></param>
        /// <param name="inData"></param>
        public void SimDateInTest(string simMac, string id, string inData)
        {
            EventClass.GetInstance()._ConnectBleAddress = simMac;

            RecordDetail recordDetail = new RecordDetail()
            {
                _opendatetime = DateTime.Parse(inData.Split(',')[0]).ToString("yyyy/MM/dd HH:mm:ss"),
                _userOpenType = inData.Split(',')[1]
            };

            string msg = string.Empty;

            RedvelopRecord.GetInstance().WriteData(out msg, id.ToString(), recordDetail, null, "record");
        }
Esempio n. 15
0
        private void ShowData(object obj)
        {
            RecordDetail dd = (RecordDetail)obj;

            SetDataGridviewControlPropertyValue(this.skinDataGridView_Main, dd);

            int UnhandledMsgCount = 0;

            UnhandledMsgCount = SingletonInfo.GetInstance().RecordDetailList.FindAll(s => s.DealFlag == 0).Count;


            this.Invoke(new Action(() =>
            {
                taskbarNotifier3.Show(dd, UnhandledMsgCount);
            }));
        }
Esempio n. 16
0
 public RecordDetail Details(int id)
 {
     var record = ds.MailRecords.Find(id);
     RecordDetail d = new RecordDetail
     {
         Body = record.Body,
         Subject = record.Subject,
         TimeStamp = record.TimeStamp.ToString()
     };
     d.Emails = new List<string>();
     foreach (var e in ds.Mails)
     {
         if (e.RecordId == id)
         {
             d.Emails.Add(e.Mail.ToString());
         }
     }
     return d;
 }
        /// <summary>
        /// get records by query
        /// </summary>
        /// <param name="infoCenter"></param>
        /// <param name="query"></param>
        /// <param name="recordDetail"></param>
        /// <param name="rowAccess"></param>
        /// <param name="chunkSize"></param>
        /// <param name="tableInfo"></param>
        /// <returns></returns>
        public VisionMessage GetRecordsByQuery(string infoCenter,
                                               string query,
                                               RecordDetail recordDetail = RecordDetail.Empty,
                                               bool rowAccess            = false,
                                               int chunkSize             = 100,
                                               XElement tableInfo        = null)
        {
            try
            {
                VisionMessage _retval    = new VisionMessage();
                int           _nextChunk = 1;
                bool          _lastChunk = false;
                string        _sessionId = "";
                string        _connInfo  = GetConnectionInfo();
                XElement      _xQuery    = new XElement("Queries", new XElement("Query", query, new XAttribute("ID", 1)));

                do
                {
                    string _xmlretval = service.GetRecordsByQuery(
                        _connInfo,
                        GetInfoCenterXML(infoCenter, rowAccess, _nextChunk, chunkSize, tableInfo),
                        _xQuery.ToString(),
                        recordDetail.GetValueName()
                        );

                    //read loop moved into separate method...
                    _lastChunk = ReadResult(ref _sessionId, _xmlretval, ref _retval);
                    if (string.IsNullOrEmpty(_sessionId) == false)
                    {
                        _connInfo = GetVisionConnInfoXML(database, username, password, _sessionId);
                    }
                    _nextChunk += 1;
                } while (_lastChunk == false);

                return(_retval);
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"GetRecordsByQuery() with query [{query}] call failed");
                return(VisionMessage.FromException(ex));
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 批量更新设备在线状态    需修改语法
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        //public bool UpdateSrvEquipmentStatusBatch(DataTable dt)
        //{
        //    if (dt == null || dt.Rows.Count == 0) return false;

        //    MySqlDataAdapter sd = null;
        //    DataTable dataTable = new DataTable();
        //    int reslut = -1;
        //    try
        //    {
        //        if (conn.State != ConnectionState.Open)
        //            conn.Open();
        //       // sd = new MySqlDataAdapter("SELECT SRV_ID,SRV_RMT_TIME,SRV_RMT_STATUS,SRV_PHYSICAL_CODE FROM Srv WITH(NOLOCK)", conn);
        //        sd = new MySqlDataAdapter("SELECT SRV_ID,SRV_RMT_TIME,SRV_RMT_STATUS,SRV_PHYSICAL_CODE FROM Srv", conn);
        //        MySqlCommandBuilder scb = new MySqlCommandBuilder(sd);
        //        sd.UpdateCommand = scb.GetUpdateCommand();
        //        sd.UpdateCommand = new MySqlCommand("update Srv set SRV_RMT_TIME=@SRV_RMT_TIME, SRV_RMT_STATUS=@SRV_RMT_STATUS where SRV_PHYSICAL_CODE=@SRV_PHYSICAL_CODE", conn);
        //        sd.UpdateCommand.Parameters.Add("@SRV_RMT_TIME", MySqlDbType.DateTime, 6, "SRV_RMT_TIME");
        //        sd.UpdateCommand.Parameters.Add("@SRV_RMT_STATUS", MySqlDbType.VarChar, 255, "SRV_RMT_STATUS");
        //        sd.UpdateCommand.Parameters.Add("@SRV_PHYSICAL_CODE", MySqlDbType.VarChar, 255, "SRV_PHYSICAL_CODE");
        //        sd.UpdateCommand.UpdatedRowSource = UpdateRowSource.None;


        //        sd.UpdateBatchSize = 0;
        //        sd.Fill(dataTable);


        //        if (dataTable.Rows.Count>0)//添加于20180116  SRV表中的数据来源?
        //        {
        //           for (int i = 0; i < dt.Rows.Count; i++)
        //        {
        //            dataTable.Rows[i].BeginEdit();
        //            var rows = dataTable.Select("SRV_PHYSICAL_CODE='" + dt.Rows[i]["srv_physical_code"] + "'");
        //            if (rows != null && rows.Length > 0)
        //            {
        //                rows[0]["SRV_RMT_TIME"] = DateTime.Parse(dt.Rows[i]["srv_time"].ToString());
        //                rows[0]["SRV_RMT_STATUS"] = "在线";
        //            }
        //            dataTable.Rows[i].EndEdit();
        //        }
        //        reslut = sd.Update(dataTable);
        //        }

        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("批量更新设备在线状态发生异常", ex);
        //    }
        //    finally
        //    {
        //        dataTable.Clear();
        //        sd.Dispose();
        //        dataTable.Dispose();
        //        conn.Close();
        //    }
        //    return reslut != -1;
        //}


        //public void BulkEquipmentDetail(DataTable dt)
        //{
        //    if (dt == null || dt.Rows.Count == 0) return;

        //    try
        //    {
        //        if (conn.State != ConnectionState.Open)
        //            conn.Open();
        //        foreach (DataRow row in dt.Rows)
        //        {
        //            try
        //            {

        //                MySqlCommand mySqlCommandPro = new MySqlCommand("UporInsertSrv_Status", conn);
        //                mySqlCommandPro.CommandType = CommandType.StoredProcedure;//设置调用的类型为存储过程

        //                MySqlParameter sqlParme;
        //                //参数1
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@PCODE", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["srv_physical_code"].ToString();
        //                //参数2
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Powersupplystatus", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["powersupplystatus"].ToString();
        //                //参数2
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Powervoltage", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["powervoltage"].ToString();
        //                //参数3
        //                //sqlParme = mySqlCommandPro.Parameters.AddWithValue("@textTime", SqlDbType.NText);
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Controlfrequency", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["controlfrequency"].ToString();
        //                //参数4
        //                //sqlParme = mySqlCommandPro.Parameters.AddWithValue("@textTime", SqlDbType.NText);
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Cflevel", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["cflevel"].ToString();
        //                //参数5
        //                //sqlParme = mySqlCommandPro.Parameters.AddWithValue("@textTime", SqlDbType.NText);
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Audiofrequency", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["audiofrequency"].ToString();
        //                //参数6
        //                //sqlParme = mySqlCommandPro.Parameters.AddWithValue("@textTime", SqlDbType.NText);
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Aflevel", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["aflevel"].ToString();
        //                //参数7
        //                //sqlParme = mySqlCommandPro.Parameters.AddWithValue("@textTime", SqlDbType.NText);
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Devlogicid", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["devlogicid"].ToString();
        //                //参数8
        //                //sqlParme = mySqlCommandPro.Parameters.AddWithValue("@textTime", SqlDbType.NText);
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Devphyid", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["devphyid"].ToString();
        //                //参数9
        //                //sqlParme = mySqlCommandPro.Parameters.AddWithValue("@textTime", SqlDbType.NText);
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Srv_time", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["srv_time"].ToString();


        //                mySqlCommandPro.ExecuteNonQuery();//执行存储过程
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("更新设备信息异常", ex);
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("更新设备信息数据库异常", ex);
        //    }
        //    finally { conn.Close(); }
        //}



        //public void BulkNewEquipmentDetail(DataTable dt)
        //{
        //    if (dt == null || dt.Rows.Count == 0) return;

        //    try
        //    {
        //        if (conn.State != ConnectionState.Open)
        //            conn.Open();
        //        foreach (DataRow row in dt.Rows)
        //        {
        //            try
        //            {
        //                MySqlCommand mySqlCommandPro = new MySqlCommand("UporInsertSrv_StatusGxNew", conn);
        //                mySqlCommandPro.CommandType = CommandType.StoredProcedure;//设置调用的类型为存储过程

        //                MySqlParameter sqlParme;
        //                //参数1
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@PCODE", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["srv_physical_code"].ToString();
        //                //参数2
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Broadcaststate", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["broadcaststate"].ToString();
        //                //参数3
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Voltage220", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["voltage220"].ToString();
        //                //参数4
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Fm_frelist1", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["fm_frelist1"].ToString();
        //                //参数5
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Fm_signalstrength1", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["fm_signalstrength1"].ToString();
        //                //参数6
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Fm_frelist2", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["fm_frelist2"].ToString();
        //                //参数7
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Fm_signalstrength2", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["fm_signalstrength2"].ToString();
        //                //参数8
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Logicaladdress", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["logicaladdress"].ToString();
        //                //参数9
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Physicaladdress", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["physicaladdress"].ToString();
        //                //参数10
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Srv_time", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["srv_time"].ToString();
        //                //参数11
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Playtype", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["playtype"].ToString();
        //                //参数12
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Versions", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["versions"].ToString();
        //                //参数13
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Digitaltv_radiofrequencymode", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["digitaltv_radiofrequencymode"].ToString();
        //                //参数14
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Digitaltv_radiofrequencyfre", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["digitaltv_radiofrequencyfre"].ToString();
        //                //参数15
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Broadcast_volume", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["broadcast_volume"].ToString();
        //                //参数16
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Currentmode_signalquality", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["currentmode_signalquality"].ToString();
        //                //参数17
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Currentmode_signalstrength", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["currentmode_signalstrength"].ToString();
        //                //参数18
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Remotecontrolcenter_ip", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["remotecontrolcenter_ip"].ToString();
        //                //参数19
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Remotecontrolcenter_port", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["remotecontrolcenter_port"].ToString();
        //                //参数20
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Audioserver_ip", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["audioserver_ip"].ToString();
        //                //参数21
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Audioserver_port", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["audioserver_port"].ToString();
        //                //参数22
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Callway", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["callway"].ToString();
        //                //参数23
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Filename", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["filename"].ToString();
        //                //参数24
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Recording_duration", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["recording_duration"].ToString();
        //                //参数25
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Packs_totalnumber", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["packs_totalnumber"].ToString();
        //                //参数26
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Rebackfiletype", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["rebackfiletype"].ToString();
        //                //参数27
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Packstartindex", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["packstartindex"].ToString();
        //                //参数28
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Lastpacksnumber", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["lastpacksnumber"].ToString();
        //                //参数29
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Terminaltype", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["terminaltype"].ToString();
        //                //参数30
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Longitude", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["longitude"].ToString();
        //                //参数31
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Latitude", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["latitude"].ToString();
        //                //参数32
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Rebackmode", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["rebackmode"].ToString();
        //                //参数33
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Networkmode", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["networkmode"].ToString();
        //                //参数34
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Voltage24", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["voltage24"].ToString();
        //                //参数35
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Voltage12", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["voltage12"].ToString();
        //                //参数36
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Amplifierelectric_current", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["amplifierelectric_current"].ToString();
        //                //参数37
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Localhost", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["localhost"].ToString();
        //                //参数38
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Subnetmask", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["subnetmask"].ToString();
        //                //参数39
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Defaultgateway", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["defaultgateway"].ToString();
        //                //参数40
        //                sqlParme = mySqlCommandPro.Parameters.AddWithValue("@Manufacturer_information", "");
        //                sqlParme.Direction = ParameterDirection.Input;
        //                sqlParme.Value = row["manufacturer_information"].ToString();

        //                mySqlCommandPro.ExecuteNonQuery();//执行存储过程
        //            }
        //            catch (Exception ex)
        //            {
        //                log.Error("更新设备信息异常", ex);
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        log.Error("更新设备信息时数据库异常", ex);
        //    }
        //    finally { conn.Close(); }

        //}

        /// <summary>
        /// 更新或插入录音记录
        /// </summary>
        /// <param name = "detail" ></ param >
        public int InsertRecorde(RecordDetail detail)
        {
            if (detail == null)
            {
                return(-1);
            }
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection = conn;
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                string sqlUpdate = "";

                detail.SourceTarPath = detail.SourceTarPath.Replace(@"\", @"\\");
                detail.SavePath      = detail.SavePath.Replace(@"\", @"\\");

                sqlUpdate = string.Format("insert into RecordList " +
                                          "(SourceTar,SourceTarPath,MediumType,MsgStartTime,MsgEndTime,AreaCode,SavePath,Severity,EventType,TextContent,DealFlag,SenderName,SenderCode,SendTime,MsgTitle) " +
                                          "values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}','{9}',{10},'{11}','{12}','{13}','{14}')",
                                          detail.SourceTar, detail.SourceTarPath, detail.MediumType, detail.MsgStartTime,
                                          detail.MsgEndTime, detail.AreaCode, detail.SavePath, detail.Severity, detail.EventType, detail.TextContent, detail.DealFlag, detail.SenderName, detail.SenderCode, detail.SendTime, detail.MsgTitle);

                cmd.CommandText = sqlUpdate;
                if (cmd.ExecuteNonQuery() > 0)
                {
                    string sql = "select max(RecordId) from RecordList";
                    cmd.CommandText = sql;
                    var rowCount = cmd.ExecuteScalar();
                    return(Convert.ToInt32(rowCount.ToString()));
                }
                return(-1);
            }
            catch (Exception ex)
            {
                log.Error("更新或插入录音记录异常", ex);
                return(-1);
            }
            finally { conn.Close(); }
        }
Esempio n. 19
0
        /// <summary>
        /// Get record for editing
        /// </summary>
        public void Detail(int id)
        {
            RecordDetail record = Database.QueryOne <RecordDetail>(@"SELECT NameAddress.*, Sum(Outstanding) AS Outstanding
FROM NameAddress
LEFT JOIN Journal ON NameAddressId = idNameAddress
AND AccountId = " + (int)LedgerAccount + @"
AND Outstanding <> 0
WHERE idNameAddress = " + id
                                                                   );

            if (record.Id == null)
            {
                record.Type = NameType;
            }
            else
            {
                checkNameType(record.Type, NameType);
                addNameToMenuOptions((int)record.Id);
                Title += " - " + record.Name;
            }
            Record = record;
        }
Esempio n. 20
0
        public int UpdateRecorde(RecordDetail detail)
        {
            if (detail == null)
            {
                return(-1);
            }
            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection = conn;
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }
                string sqlUpdate = "";

                sqlUpdate = string.Format("update  RecordList set " +
                                          "DealFlag={0} where RecordId={1}", detail.DealFlag, detail.RecordId);

                cmd.CommandText = sqlUpdate;
                if (cmd.ExecuteNonQuery() > 0)
                {
                    string sql = "select max(RecordId) from RecordList";
                    cmd.CommandText = sql;
                    var rowCount = cmd.ExecuteScalar();
                    return(Convert.ToInt32(rowCount.ToString()));
                }
                return(-1);
            }
            catch (Exception ex)
            {
                log.Error("更新或插入录音记录异常", ex);
                return(-1);
            }
            finally { conn.Close(); }
        }
        /// <summary>
        /// retrieves record by UID
        /// </summary>
        /// <param name="udicName"></param>
        /// <param name="id"></param>
        /// <param name="recordDetail"></param>
        /// <returns></returns>
        public VisionMessage GetUDICRecordsByKey(string udicName, string id, RecordDetail recordDetail = RecordDetail.Empty)
        {
            try
            {
                VisionMessage _retval    = new VisionMessage();
                int           _nextChunk = 1;
                bool          _lastChunk = false;
                string        _sessionId = "";
                string        _connInfo  = GetConnectionInfo();

                do
                {
                    string _xmlretval = service.GetUDICByKey(
                        _connInfo,
                        udicName,
                        id,
                        recordDetail.GetValueName()
                        );

                    //read loop moved into separate method...
                    _lastChunk = ReadResult(ref _sessionId, _xmlretval, ref _retval);
                    if (string.IsNullOrEmpty(_sessionId) == false)
                    {
                        _connInfo = GetVisionConnInfoXML(database, username, password, _sessionId);
                    }
                    _nextChunk += 1;
                } while (_lastChunk == false);

                return(_retval);
            }
            catch (Exception ex)
            {
                logger.Error(ex, $"GetUDICRecordsByKey() for {udicName} with key [{id}] call failed");
                return(VisionMessage.FromException(ex));
            }
        }
Esempio n. 22
0
 public FrmMsglist(RecordDetail wq)
 {
     InitializeComponent();
     Webqq = wq;
 }
Esempio n. 23
0
        private static void AddRecordToYear(IDictionary <string, List <string> > recordsByYear, RecordDetail record)
        {
            var recordLite = $"{record.Country},{record.Medal.Substring(0, 1)}";

            if (recordsByYear.ContainsKey(record.Year))
            {
                recordsByYear[record.Year].Add(recordLite);
            }
            else
            {
                recordsByYear.Add(record.Year, new List <string> {
                    recordLite
                });
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 显示弹窗和时间参数
        /// </summary>
        /// <param name="strTitle">弹窗标题</param>
        /// <param name="strContent">弹窗正文</param>
        /// <param name="nTimeToShow">延迟时间(毫秒)</param>
        /// <param name="nTimeToStay">停留时间(毫秒)</param>
        /// <param name="nTimeToHide">消失时间(毫秒)</param>
        /// <returns></returns>
        public void Show(RecordDetail recorddetail, int UnhandledMsgCount)
        {
            int nTimeToShow = 500;
            int nTimeToStay = 3600000;
            int nTimeToHide = 500;

            //再次打开前先把上次的隐藏
            Hide();
            recordDetail_     = recorddetail;
            WorkAreaRectangle = Screen.GetWorkingArea(WorkAreaRectangle);
            titleText         = "江津区应急广播消息";
            contentText       = "来源:" + recorddetail.SenderName;
            MediumType        = "媒体类型:" + recorddetail.MediumType;
            UnhandledMsg      = "未处理消息数量:" + UnhandledMsgCount.ToString();
            nVisibleEvents    = nTimeToStay;
            CalculateMouseRectangles();

            // We calculate the pixel increment and the timer value for the showing animation
            int nEvents;

            if (nTimeToShow > 10)
            {
                nEvents        = Math.Min((nTimeToShow / 10), BackgroundBitmap.Height);
                nShowEvents    = nTimeToShow / nEvents;
                nIncrementShow = BackgroundBitmap.Height / nEvents;
            }
            else
            {
                nShowEvents    = 10;
                nIncrementShow = BackgroundBitmap.Height;
            }

            // We calculate the pixel increment and the timer value for the hiding animation
            if (nTimeToHide > 10)
            {
                nEvents        = Math.Min((nTimeToHide / 10), BackgroundBitmap.Height);
                nHideEvents    = nTimeToHide / nEvents;
                nIncrementHide = BackgroundBitmap.Height / nEvents;
            }
            else
            {
                nHideEvents    = 10;
                nIncrementHide = BackgroundBitmap.Height;
            }

            switch (taskbarState)
            {
            case TaskbarStates.hidden:                  //检测状态隐藏时
                taskbarState = TaskbarStates.appearing; //设置正在弹出
                SetBounds(WorkAreaRectangle.Right - BackgroundBitmap.Width - 17, WorkAreaRectangle.Bottom - 1, BackgroundBitmap.Width, 0);
                timer.Interval = nShowEvents;
                timer.Start();
                // We Show the popup without stealing focus
                ShowWindow(this.Handle, 4);
                break;

            case TaskbarStates.appearing:    //检测状态正在弹出时
                Refresh();
                break;

            case TaskbarStates.visible:    //检测状态为可见
                timer.Stop();
                timer.Interval = nVisibleEvents;
                timer.Start();
                Refresh();
                break;

            case TaskbarStates.disappearing:    //检测状态为正在消失时
                timer.Stop();
                taskbarState = TaskbarStates.visible;
                SetBounds(WorkAreaRectangle.Right - BackgroundBitmap.Width - 17, WorkAreaRectangle.Bottom - BackgroundBitmap.Height - 1, BackgroundBitmap.Width, BackgroundBitmap.Height);
                timer.Interval = nVisibleEvents;
                timer.Start();
                Refresh();
                break;
            }
        }
Esempio n. 25
0
        private void skinDataGridView_Record_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                switch (e.ColumnIndex)
                {
                case 0:
                    MessageShowDlg = new MessageShowForm {
                        label1 = { Text = @"确认处理?" }
                    };
                    MessageShowDlg.ShowDialog();
                    if (MessageShowDlg.IsSure)
                    {
                        DataGridViewRow dgvR      = skinDataGridView_Record.Rows[e.RowIndex];
                        RecordDetail    selectone = (RecordDetail)dgvR.Tag;
                        selectone.DealFlag = 1;
                        //更新数据库
                        SingletonInfo.GetInstance().DataBase.UpdateRecorde(selectone);
                        dgvR.Cells[0].Value    = "已处理";
                        dgvR.Cells[0].ReadOnly = true;


                        //通知到主显示表skinDataGridView_Main
                        this.Invoke(new Action(() =>
                        {
                            foreach (DataGridViewRow item in skinDataGridView_Main.Rows)
                            {
                                if (item.Cells[1].Value.ToString() == selectone.RecordId)
                                {
                                    item.Tag            = selectone;
                                    item.Cells[0].Value = "已处理";
                                }
                            }
                        }));
                    }

                    break;

                case 2:
                    DataGridViewRow dgvRS    = skinDataGridView_Record.Rows[e.RowIndex];
                    RecordDetail    selected = (RecordDetail)dgvRS.Tag;

                    EBMDetailShowDlg = new EBMDetailShowForm(selected);
                    EBMDetailShowDlg.ShowDialog();
                    break;

                case 9:
                    MessageShowDlg = new MessageShowForm {
                        label1 = { Text = @"打开链接?" }
                    };
                    MessageShowDlg.ShowDialog();
                    if (MessageShowDlg.IsSure)
                    {
                        DataGridViewRow dgvR      = skinDataGridView_Record.Rows[e.RowIndex];
                        RecordDetail    selectone = (RecordDetail)dgvR.Tag;
                        string          path      = Path.GetDirectoryName(selectone.SavePath);
                        System.Diagnostics.Process.Start(path);
                    }
                    break;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
 public EBMDetailShowForm(RecordDetail record)
 {
     InitializeComponent();
     record_    = record;
     this.Load += EBMDetailShowForm_Load;
 }
Esempio n. 27
0
        private void SetDataGridviewControlPropertyValueNew(DataGridView oControl, RecordDetail task)
        {
            if (oControl.InvokeRequired)  // InvokeRequired 当前线程不是创建控件的线程时为true
            {
                //任务的增删改
                SetDataGridviewControlValueCallback d = new SetDataGridviewControlValueCallback(SetDataGridviewControlPropertyValueNew);
                oControl.Invoke(d, new object[] { oControl, task });
            }
            else
            {
                //原先没有,表示该任务为新加的
                DataGridViewRow dgvR = new DataGridViewRow();
                dgvR.CreateCells(skinDataGridView_Record);
                if (task.DealFlag == 1)
                {
                    dgvR.Cells[0].Value    = "已处理";
                    dgvR.Cells[0].ReadOnly = true;
                    // dgvR.Cells[0].Style.ForeColor = Color.Green;
                }
                else
                {
                    dgvR.Cells[0].Value = "未处理";
                    //  dgvR.Cells[0].Style.ForeColor = Color.Red;
                }


                dgvR.Cells[1].Value = task.RecordId;
                dgvR.Cells[2].Value = "详情";
                dgvR.Cells[3].Value = task.MediumType;
                dgvR.Cells[4].Value = task.EventType;

                switch (task.Severity)
                {
                case "0":
                    dgvR.Cells[5].Value = "未知级别";
                    break;

                case "1":
                    dgvR.Cells[5].Value           = "1级";
                    dgvR.Cells[5].Style.ForeColor = Color.Red;
                    break;

                case "2":
                    dgvR.Cells[5].Value           = "2级";
                    dgvR.Cells[5].Style.ForeColor = Color.Orange;
                    break;

                case "3":
                    dgvR.Cells[5].Value           = "3级";
                    dgvR.Cells[5].Style.ForeColor = Color.Yellow;
                    break;

                case "4":
                    dgvR.Cells[5].Value           = "4级";
                    dgvR.Cells[5].Style.ForeColor = Color.Blue;
                    break;
                }
                dgvR.Cells[6].Value = task.MsgStartTime;
                dgvR.Cells[7].Value = task.MsgEndTime;
                dgvR.Cells[8].Value = task.AreaCode;
                dgvR.Cells[9].Value = task.SavePath;
                dgvR.Height         = 30;
                dgvR.Tag            = task;
                skinDataGridView_Record.Rows.Add(dgvR);
            }
        }
Esempio n. 28
0
 public RecordDetail SaveRecord(RecordDetail record)
 {
     Records.Add(record);
     return record;
 }
 private bool AreEqual(RecordDetail expected, RecordDetail actual)
 {
     return expected.LastName == actual.LastName
         && expected.DateOfBirth == actual.DateOfBirth
         && expected.FirstName == actual.FirstName
         && expected.Gender == actual.Gender
         && expected.FavColor == actual.FavColor;
 }
Esempio n. 30
0
        private async void Work(object sender, ElapsedEventArgs e)
        {
            if (conf == null)
            {
                return;
            }
            timer.Interval = conf.Interval * 60 * 1000;
            if (Interlocked.Read(ref runFlag) == 0)
            {
                return;
            }
            Log.Info($"[{Name}] do work ...");
            try
            {
                //获取本机公网IP
                string realIp = "";
                if (conf.GetIpUrls.Count == 0 && conf.IsIpV6)
                {
                    //IPCONFIG
                    realIp = NetWorkUtils.GetLocalIpV6Address();
                }
                if (conf.GetIpUrls.Count == 0 && !conf.IsIpV6)
                {
                    conf.GetIpUrls.Add(DEFAULT_IP_V4_URL);
                }
                if (conf.GetIpUrls.Count > 0)
                {
                    foreach (string url in conf.GetIpUrls)
                    {
                        var getRes = await url.Get();

                        if (!getRes.Ok)
                        {
                            Log.Info($"[{Name}] fetch real internet ip from {url} fail , try next url");
                            continue;
                        }
                        Match mc;
                        //提取IPV6地址
                        if (conf.IsIpV6)
                        {
                            mc = IpV6Regex.Match(getRes.HttpResponseString);
                        }
                        //提取IPV4地址
                        else
                        {
                            mc = IpV4Regex.Match(getRes.HttpResponseString);
                        }
                        if (mc.Success && mc.Groups.Count > 0)
                        {
                            realIp = mc.Groups[0].Value;
                            Log.Info($"[{Name}] fetch real internet ip from ( {url} ) success, current ip is ( {realIp} )");
                            break;
                        }
                    }
                }
                if (string.IsNullOrWhiteSpace(realIp))
                {
                    Log.Info($"[{Name}] fetch real internet ip all failed, skip");
                    return;
                }
                // double check
                if (!realIp.IsIpAddress())
                {
                    Log.Info($"[{Name}] fetch real internet ip [{realIp}] is not a valid ip address, skip");
                    return;
                }
                //double check
                if (conf.IsIpV6 && !realIp.IsIpV6Address())
                {
                    Log.Info($"[{Name}] fetch real internet ip [{realIp}] is not a valid ipv6 address, skip");
                    return;
                }
                //获取阿里云记录
                var describeRes = await new DescribeDomainRecordsRequest(conf.AccessKeyId, conf.AccessKeySecret)
                {
                    DomainName  = conf.DomainName,
                    RRKeyWord   = conf.SubDomainName,
                    TypeKeyWord = conf.Type,
                }.Execute();
                if (describeRes.HasError)
                {
                    Log.Info($"[{Name}] describe domain records fail ( {describeRes.Message} ) , skip");
                    return;
                }
                //未查到记录,添加
                if (describeRes.TotalCount == 0)
                {
                    goto ADD;
                }
                //数量多于1个时删除所有匹配的重新添加
                else if (describeRes.TotalCount > 1)
                {
                    foreach (var record in describeRes.DomainRecords.Records)
                    {
                        var deleteRes = await new DeleteDomainRecordRequest(conf.AccessKeyId, conf.AccessKeySecret)
                        {
                            RecordId = record.RecordId
                        }.Execute();
                        if (deleteRes.HasError)
                        {
                            Log.Info($"[{Name}] delete domain records fail ( {deleteRes.Message} ) , skip");
                            continue;
                        }
                        Log.Info($"[{Name}] delete domain records sucess");
                    }
                    //重新添加
                    goto ADD;
                }
                else
                {
                    RecordDetail record = describeRes.DomainRecords.Records[0];
                    if (record.Value == realIp)
                    {
                        Log.Info($"[{Name}] ip not chanage , skip");
                        return;
                    }
                    //update
                    Log.Info($"[{Name}] prepare to update domain record ...");
                    var updateRes = await new UpdateDomainRecordRequest(
                        conf.AccessKeyId, conf.AccessKeySecret)
                    {
                        RecordId = record.RecordId,
                        RR       = conf.SubDomainName,
                        Type     = conf.Type,
                        Value    = realIp,
                        TTL      = conf.TtlV,
                        Line     = conf.Line,
                    }.Execute();
                    Log.Info(updateRes.HasError
                        ? $"[{Name}] update domain record fail ( {updateRes.Message} ) , skip"
                        : $"[{Name}] update domain record ok , now  record value is {realIp}");
                    if (updateRes.HasError)
                    {
                        return;
                    }
                    //更新成功后,暂停解析->启用解析,以此来解决更新后不立即生效的问题
                    var disableRes = await new SetDomainRecordStatusRequest(
                        conf.AccessKeyId, conf.AccessKeySecret)
                    {
                        RecordId = record.RecordId,
                        Enable   = false
                    }.Execute();
                    Log.Info(disableRes.HasError
              ? $"[{Name}] set domain records tatus to diable error ( {disableRes.Message} ) , skip"
              : $"[{Name}] set domain records tatus to diable ok , now enable it");
                    if (disableRes.HasError)
                    {
                        return;
                    }
                    var enableRes = await new SetDomainRecordStatusRequest(
                        conf.AccessKeyId, conf.AccessKeySecret)
                    {
                        RecordId = record.RecordId,
                        Enable   = true
                    }.Execute();
                    Log.Info(enableRes.HasError
              ? $"[{Name}] set domain records tatus to enable error ( {enableRes.Message} ) , skip"
              : $"[{Name}] set domain records tatus to enable ok , just enjoy it :)");
                    return;
                }

ADD:
                {
                    //add
                    Log.Info($"[{Name}] prepare to add domain record ...");
                    var addRes = await new AddDomainRecordRequest(
                        conf.AccessKeyId, conf.AccessKeySecret)
                    {
                        DomainName = conf.DomainName,
                        RR         = conf.SubDomainName,
                        Type       = conf.Type,
                        Value      = realIp,
                        TTL        = conf.TtlV,
                        Line       = conf.Line,
                    }.Execute();
                    Log.Info(addRes.HasError
                        ? $"[{Name}] add domain record fail ( {addRes.Message} ) , skip"
                        : $"[{Name}] add domain record ok , now  record value is {realIp}");
                }
            }
            catch (Exception ex)
            {
                Log.Warn($"[{ Name}] do work exception : {ex.Message}");
            }
        }
Esempio n. 31
0
        /// <summary>
        /// 收包及反馈
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="PlatformVerifySignatureresule"></param>
        public void DealTarBack(string filepath, out bool PlatformVerifySignatureresule)
        {
            List <string> AudioFileListTmp = new List <string>(); //收集的音频文件列表

            PlatformVerifySignatureresule = false;                //验签是否通过
            EBD    ebdb     = null;
            string PlayType = "";

            if (File.Exists(filepath))
            {
                try
                {
                    #region 先删除预处理解压缩包中的文件
                    foreach (string xmlfiledel in Directory.GetFileSystemEntries(mainForm.strBeUnTarFolder))
                    {
                        if (File.Exists(xmlfiledel))
                        {
                            FileInfo fi = new FileInfo(xmlfiledel);
                            if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                            {
                                fi.Attributes = FileAttributes.Normal;
                            }
                            File.Delete(xmlfiledel);//直接删除其中的文件
                        }
                    }
                    #endregion End

                    mainForm.tar.UnpackTarFiles(filepath, mainForm.strBeUnTarFolder);                    //把压缩包解压到专门存放接收到的XML文件的文件夹下

                    string[] xmlfilenames      = Directory.GetFiles(mainForm.strBeUnTarFolder, "*.xml"); //从解压XML文件夹下获取解压的XML文件名
                    string   sTmpFile          = string.Empty;
                    string   sAnalysisFileName = "";
                    string   sSignFileName     = "";


                    //签名模块  20180820
                    //if (mainForm.m_UsbPwsSupport == "1")
                    //{
                    //    if (xmlfilenames.Length < 2)//没有签名文件
                    //        PlatformVerifySignatureresule = false;
                    //}

                    for (int i = 0; i < xmlfilenames.Length; i++)
                    {
                        sTmpFile = Path.GetFileName(xmlfilenames[i]);
                        if (sTmpFile.ToUpper().IndexOf("EBDB") > -1 && sTmpFile.ToUpper().IndexOf("EBDS_EBDB") < 0)
                        {
                            sAnalysisFileName = xmlfilenames[i];
                        }
                        //else if (sTmpFile.ToUpper().IndexOf("EBDS_EBDB") > -1)//签名文件
                        //{
                        //    sSignFileName = xmlfilenames[i];//签名文件
                        //}
                    }
                    if (!string.IsNullOrWhiteSpace(sAnalysisFileName))
                    {
                        using (FileStream fsr = new FileStream(sAnalysisFileName, FileMode.Open))
                        {
                            StreamReader sr      = new StreamReader(fsr, Encoding.UTF8);
                            string       xmlInfo = sr.ReadToEnd();
                            xmlInfo = xmlInfo.Replace("xmlns:xs", "xmlns");
                            sr.Close();
                            xmlInfo = XmlSerialize.ReplaceLowOrderASCIICharacters(xmlInfo);
                            xmlInfo = XmlSerialize.GetLowOrderASCIICharacters(xmlInfo);
                            ebdb    = XmlSerialize.DeserializeXML <EBD>(xmlInfo);
                        }
                    }
                    string myEBDType = string.Empty;
                    if (ebdb != null)
                    {
                        myEBDType = ebdb.EBDType;
                    }
                    //   if (!string.IsNullOrWhiteSpace(sSignFileName) && myEBDType != "ConnectionCheck")
                    if (myEBDType != "ConnectionCheck")
                    {
                        //读取xml中的文件,转换为byte字节
                        byte[] xmlArray = File.ReadAllBytes(sAnalysisFileName);
                        PlatformVerifySignatureresule = true; //验签结果
                        #region 签名处理  暂时先注释   20180820
                        //Console.WriteLine("开始验证签名文件!");
                        //using (FileStream SignFs = new FileStream(sSignFileName, FileMode.Open))
                        //{
                        //    StreamReader signsr = new StreamReader(SignFs, Encoding.UTF8);
                        //    string xmlsign = signsr.ReadToEnd();
                        //    signsr.Close();
                        //    responseXML signrp = new responseXML();//签名回复
                        //    XmlDocument xmlSignDoc = new XmlDocument();
                        //    try
                        //    {
                        //        int nDeviceHandle = (int)mainForm.mainFrm.phDeviceHandle;
                        //        xmlsign = XmlSerialize.ReplaceLowOrderASCIICharacters(xmlsign);
                        //        xmlsign = XmlSerialize.GetLowOrderASCIICharacters(xmlsign);
                        //        Signature sign = XmlSerialize.DeserializeXML<Signature>(xmlsign);
                        //        xmlsign = XmlSerialize.ReplaceLowOrderASCIICharacters(xmlsign);
                        //        xmlsign = XmlSerialize.GetLowOrderASCIICharacters(xmlsign);
                        //        string PucStr = sign.SignatureValue;
                        //        byte[] pucsingVi = Encoding.UTF8.GetBytes(sign.SignatureValue);

                        //        //0是签名通过
                        //        var result = mainForm.mainFrm.usb.PlatformVerifySignature(nDeviceHandle, 1, xmlArray, xmlArray.Length, pucsingVi);
                        //        PlatformVerifySignatureresule = result == 0;
                        //        Log.Instance.LogWrite(PlatformVerifySignatureresule ? "签名验证成功" : "签名验证失败-" + result);
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        Log.Instance.LogWrite("签名文件错误:" + ex.Message);
                        //    }
                        //}
                        //Console.WriteLine("结束验证签名文件!");
                        #endregion End

                        #region 通用反馈
                        CurrencyTarBack(ebdb);
                        #endregion
                    }
                    mainForm.DeleteFolder(mainForm.strBeSendFileMakeFolder);//删除原有XML发送文件的文件夹下的XML
                    #region  最老版本的针对各类消息的反馈
                    if (ebdb != null)
                    {
                        if (ebdb.EBDType == "EBM")
                        {
                            string strMsgType       = ebdb.EBM.MsgBasicInfo.MsgType; //播发类型
                            string strAuxiliaryType = "";
                            if (ebdb.EBM.MsgContent != null)
                            {
                                if (ebdb.EBM.MsgContent.Auxiliary != null)
                                {
                                    strAuxiliaryType = ebdb.EBM.MsgContent.Auxiliary.AuxiliaryType; //实时流播发
                                    if (strAuxiliaryType == "61")
                                    {
                                        PlayType = "1";
                                    }
                                    else
                                    {
                                        PlayType = "2";
                                    }
                                }
                                else
                                {
                                    //有两种情况 停播 文转语
                                    ebdb.EBM.MsgContent.Auxiliary = new Auxiliary();
                                    ebdb.EBM.MsgContent.Auxiliary.AuxiliaryType = "3";
                                    strAuxiliaryType = "3";
                                    ebdb.EBM.MsgContent.Auxiliary.AuxiliaryDesc = "文本转语";
                                    PlayType = "1";
                                }

                                //文转语的情况  只考虑播放
                                if (strMsgType == "1" && PlayType == "1" && ebdb.EBM.MsgContent.Auxiliary.AuxiliaryDesc == "文本转语")
                                {
                                    string[]     pathee = filepath.Split('\\');
                                    string       fill   = pathee[pathee.Length - 1].Split('.')[0];
                                    string       pp     = mainForm.sAudioFilesFolder + "\\" + fill;
                                    RecordDetail tmp    = new RecordDetail();
                                    tmp.SourceTar     = pathee[pathee.Length - 1];
                                    tmp.SourceTarPath = filepath;
                                    tmp.MediumType    = "文本";
                                    tmp.MsgStartTime  = ebdb.EBM.MsgBasicInfo.StartTime;
                                    tmp.MsgEndTime    = ebdb.EBM.MsgBasicInfo.EndTime;
                                    tmp.AreaCode      = ebdb.EBM.MsgContent.AreaCode;
                                    tmp.EventType     = ebdb.EBM.MsgBasicInfo.EventType;
                                    tmp.Severity      = ebdb.EBM.MsgBasicInfo.Severity;
                                    tmp.TextContent   = ebdb.EBM.MsgContent.MsgDesc;
                                    tmp.DealFlag      = 0;
                                    tmp.SenderName    = ebdb.EBM.MsgBasicInfo.SenderName;
                                    tmp.SenderCode    = ebdb.EBM.MsgBasicInfo.SenderCode;
                                    tmp.SendTime      = ebdb.EBM.MsgBasicInfo.SendTime;
                                    tmp.MsgTitle      = ebdb.EBM.MsgContent.MsgTitle;

                                    SingletonInfo.GetInstance().RecordDetailList.Add(tmp);
                                    if (!Directory.Exists(pp))
                                    {
                                        Directory.CreateDirectory(pp);//不存在该路径就创建
                                    }

                                    string docfilepath = pp + "\\" + fill + ".doc";


                                    CreatWord.CreateWordFile(docfilepath, tmp.TextContent);

                                    //FileStream fs = File.Create(pp + "\\" + fill+".txt");    //创建文件
                                    //fs.Close();
                                    //Thread.Sleep(500);
                                    //StreamWriter sw = new StreamWriter(pp + "\\" + fill + ".txt");
                                    //sw.Write(ebdb.EBM.MsgContent.MsgDesc);
                                    //sw.Flush();
                                    //sw.Close();
                                    tmp.SavePath = pp + "\\" + fill + ".doc";
                                    int returncode = SingletonInfo.GetInstance().DataBase.InsertRecorde(tmp);
                                    if (returncode != -1)
                                    {
                                        tmp.RecordId = returncode.ToString();
                                    }
                                    HttpProcessor.MyEvent(tmp);
                                }

                                if (strMsgType == "1" && PlayType == "2")
                                {
                                    string[]     pathee = filepath.Split('\\');
                                    string       fill   = pathee[pathee.Length - 1].Split('.')[0];
                                    string       pp     = mainForm.sAudioFilesFolder + "\\" + fill;
                                    RecordDetail tmp    = new RecordDetail();
                                    tmp.SourceTar     = pathee[pathee.Length - 1];
                                    tmp.SourceTarPath = filepath;
                                    tmp.MediumType    = "mp3";
                                    tmp.MsgStartTime  = ebdb.EBM.MsgBasicInfo.StartTime;
                                    tmp.MsgEndTime    = ebdb.EBM.MsgBasicInfo.EndTime;
                                    tmp.AreaCode      = ebdb.EBM.MsgContent.AreaCode;
                                    tmp.EventType     = ebdb.EBM.MsgBasicInfo.EventType;
                                    tmp.Severity      = ebdb.EBM.MsgBasicInfo.Severity;
                                    tmp.TextContent   = ebdb.EBM.MsgContent.MsgDesc;
                                    tmp.DealFlag      = 0;
                                    tmp.SenderName    = ebdb.EBM.MsgBasicInfo.SenderName;
                                    tmp.SenderCode    = ebdb.EBM.MsgBasicInfo.SenderCode;
                                    tmp.SendTime      = ebdb.EBM.MsgBasicInfo.SendTime;
                                    tmp.MsgTitle      = ebdb.EBM.MsgContent.MsgTitle;
                                    SingletonInfo.GetInstance().RecordDetailList.Add(tmp);
                                    if (!Directory.Exists(pp))
                                    {
                                        Directory.CreateDirectory(pp);//不存在该路径就创建
                                    }
                                    string[] mp3files = Directory.GetFiles(mainForm.strBeUnTarFolder, "*.mp3");
                                    AudioFileListTmp.AddRange(mp3files);
                                    string[] wavfiles = Directory.GetFiles(mainForm.strBeUnTarFolder, "*.wav");
                                    AudioFileListTmp.AddRange(wavfiles);
                                    string savetmp = pp + "\\" + Path.GetFileName(AudioFileListTmp[0]);
                                    System.IO.File.Copy(AudioFileListTmp[0], savetmp, true);
                                    tmp.SavePath = savetmp;
                                    int returncode = SingletonInfo.GetInstance().DataBase.InsertRecorde(tmp);
                                    if (returncode != -1)
                                    {
                                        tmp.RecordId = returncode.ToString();
                                    }
                                    HttpProcessor.MyEvent(tmp);
                                }
                            }
                        }
                    }

                    #endregion
                }
                catch (Exception ep)
                {
                    LogHelper.WriteLog(typeof(HttpProcessor), "处理http异常" + Environment.NewLine + ep.Message);
                }
            }
        }
        private static void AddOrUpdateMedalDetailPerCountry(Dictionary <string, MedalCount> medalsPerCountry, RecordDetail record)
        {
            if (medalsPerCountry.ContainsKey(record.Country))
            {
                switch (record.Medal)
                {
                case "Gold":
                    medalsPerCountry[record.Country].Gold++;
                    break;

                case "Silver":
                    medalsPerCountry[record.Country].Silver++;
                    break;

                case "Bronze":
                    medalsPerCountry[record.Country].Bronze++;
                    break;
                }
            }
            else
            {
                medalsPerCountry.Add(
                    record.Country,
                    new MedalCount
                {
                    Gold   = record.Medal == "Gold" ? 1 : 0,
                    Silver = record.Medal == "Silver" ? 1 : 0,
                    Bronze = record.Medal == "Bronze" ? 1 : 0
                });
            }
        }