Ejemplo n.º 1
0
        private bool LoadConfig()
        {
            // config.json 읽기
            String jsonString;

            try
            {
                vo.JsonConfig jsonConfig = vo.JsonConfig.getInstance();
                if (!File.Exists(jsonConfig.configFileName))
                {
                    MessageBox.Show("config.json 파일이 없습니다.\n환경설정 파일을 읽지 못했습니다.\n기본값으로 설정합니다.", "경고", MessageBoxButton.OK);
                    jsonConfig.eventId = 0;
                    TbEventID.Text     = "0";

                    jsonString = JsonSerializer.Serialize(jsonConfig);
                    File.WriteAllText(jsonConfig.configFileName, jsonString);
                }
                else
                {
                    jsonString = File.ReadAllText(jsonConfig.configFileName);
                    jsonConfig = JsonSerializer.Deserialize <vo.JsonConfig>(jsonString);

                    TbIpaddr.Text = jsonConfig.ipAddr;
                    TbPort.Text   = jsonConfig.port.ToString();
                    //TbEventID.Text = jsonConfig.eventId.ToString();
                    TbEventID.Text = jsonConfig.eventId.ToString();
                    //_event_id = jsonConfig.eventId;
                    TbEventID.Text       = jsonConfig.eventId.ToString();
                    TbUnqProgramID.Text  = jsonConfig.uniquePid.ToString();
                    TbPreroolTime.Text   = jsonConfig.preRollTime.ToString();
                    TbBreakDuration.Text = jsonConfig.breakDuration.ToString();

                    /*
                     * TxtBoxInputPath.Text = jsonConfig.CurrentInputPath;
                     * TxtBoxOutputPath.Text = jsonConfig.CurrentOutputPath;
                     * ChkIsInputPathReculsive.IsChecked = jsonConfig.IsRecursive;
                     */
                }
            }
            catch (FileLoadException e)
            {
                MessageBox.Show(e.ToString() + "\n\n프로그램을 종료합니다.", "경고", MessageBoxButton.OK);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private void BtnCue_Click(object sender, RoutedEventArgs e)
        {
            var    button  = sender as Button;
            String btnName = button.Name;

            List <vo.LvLog> lvLogItem;

            vo.LvLog lvLog = new vo.LvLog();

            switch (btnName)
            {
            case "BtnCue_1":
                TbEventID.Text = (Convert.ToInt32(TbEventID.Text) + 4).ToString();
                //_event_id += + 4;
                //Byte[] payload = File.ReadAllBytes(@"message/spliceStart_immediate.bin");
                Byte[] payload = MakePayload();

                //tcp
                util.Network conn = new util.Network();
                conn.SetConnection(TbIpaddr.Text, Convert.ToInt32(TbPort.Text));
                conn.SetPayload(payload);
                if (conn.Connect())
                {
                    lvLog.status = "Completed";
                }
                else
                {
                    lvLog.status = "Error";
                }

                //Clock clk = new Clock();

                lvLog.eventTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                //lvLog.eventTime = clk.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");
                //log.ipAddress = common.Util.GetLocalIpAddress();
                lvLog.ipAddress = TbIpaddr.Text;
                lvLog.port      = Convert.ToInt32(TbPort.Text);
                //lvLog.eventType = cbEventType_1.Text;
                lvLog.eventType     = _eventType;
                lvLog.eventId       = TbEventID.Text;
                lvLog.uniquePid     = TbUnqProgramID.Text;
                lvLog.prerollTime   = TbPreroolTime.Text;
                lvLog.breakDuration = TbBreakDuration.Text;

                lvLogItem = (List <vo.LvLog>)m_logList[0];
                lvLogItem.Add(lvLog);
                lvLog.WriteLvLog();

                LvLog_1.ItemsSource = null;
                LvLog_1.ItemsSource = lvLogItem;
                LvLog_1.ScrollIntoView(LvLog_1.Items[LvLog_1.Items.Count - 1]);

                vo.JsonConfig jsonConfig = vo.JsonConfig.getInstance();
                jsonConfig.ipAddr        = TbIpaddr.Text;
                jsonConfig.port          = Convert.ToInt32(lvLog.port);
                jsonConfig.eventId       = Convert.ToInt32(lvLog.eventId);
                jsonConfig.uniquePid     = Convert.ToInt32(lvLog.uniquePid);
                jsonConfig.preRollTime   = Convert.ToInt32(lvLog.prerollTime);
                jsonConfig.breakDuration = Convert.ToInt32(lvLog.breakDuration);

                String jsonString = JsonSerializer.Serialize(jsonConfig);
                File.WriteAllText(jsonConfig.configFileName, jsonString);
                break;

            case "BtnOther":
                /*
                 * logitem = (List<vo.Log>)m_logList[1];
                 * logitem.Add(log);
                 * LvLog_2.ItemsSource = null;
                 * LvLog_2.ItemsSource = logitem;
                 */
                break;
            }
        }