Exemplo n.º 1
0
        void mainService_OnSetConfig(object sender, HDCPProtocol2.HDCP.HDCPParserArgs e)
        {
            try
            {
                var configPro = e.MessageData.Components.Where(p => p.Name == HDCPCommand.SET_CONFIG.ToString()).FirstOrDefault();
                if (configPro != null)
                {
                    FieldComponent component = new FieldComponent();
                    component.FromXml(configPro.Value);

                    bool needRestart = false;

                    #region Config
                    var proDBStation = component.Components.Where(c => c.ID == configDBStationID).FirstOrDefault() as FieldOne;
                    if (proDBStation != null && proDBStation.Value != null && proDBStation.Value.ToString() != config.DBStationConnectionString)
                    {
                        config.DBStationConnectionString = proDBStation.Value.ToString();
                        needRestart = true;
                    }

                    var proAsRunLogFolder = component.Components.Where(c => c.ID == configAsRunLogFolderID).FirstOrDefault() as FieldOne;
                    if (proAsRunLogFolder != null)
                    {
                        config.AsRunLogFolder = proAsRunLogFolder.Value as string;
                    }

                    var proAdTypes = component.Components.Where(c => c.ID == configAdTypeID).FirstOrDefault() as FieldOne;
                    if (proAdTypes != null)
                    {
                        config.AdTypes = proAdTypes.Value as string;
                    }

                    var proAdMaxDuration = component.Components.Where(c => c.ID == configAdMaxDurationID).FirstOrDefault() as FieldOne;
                    if (proAdMaxDuration != null)
                    {
                        config.MaxAdDuration = (long)proAdMaxDuration.Value;
                    }

                    var proVODFolder = component.Components.Where(c => c.ID == configVODFolderID).FirstOrDefault() as FieldOne;
                    if (proVODFolder != null)
                    {
                        config.VODFolder = proVODFolder.Value as string;
                    }

                    var proVODXmlFolder = component.Components.Where(c => c.ID == configVODXmlFolderID).FirstOrDefault() as FieldOne;
                    if (proVODXmlFolder != null)
                    {
                        config.VODXmlFolder = proVODXmlFolder.Value as string;
                    }

                    var proSessionStr = component.Components.Where(c => c.ID == configSessionStrID).FirstOrDefault() as FieldOne;
                    if (proSessionStr != null)
                    {
                        config.sessionStr = proSessionStr.Value as string;
                    }

                    var proImportTime = component.Components.Where(c => c.ID == configImportTimeID).FirstOrDefault() as FieldOne;
                    if (proImportTime != null)
                    {
                        config.ImportTime = (int)proImportTime.Value;
                    }

                    var proExportTime = component.Components.Where(c => c.ID == configExportTimeID).FirstOrDefault() as FieldOne;
                    if (proExportTime != null)
                    {
                        config.ExportTime = (int)proExportTime.Value;
                    }

                    var proLastExportDay = component.Components.Where(c => c.ID == configLastExportDay).FirstOrDefault() as FieldOne;
                    if (proLastExportDay != null)
                    {
                        config.LastExportDay = (int)proLastExportDay.Value;
                    }

                    var proLastExportHour = component.Components.Where(c => c.ID == configLastExportHour).FirstOrDefault() as FieldOne;
                    if (proLastExportHour != null)
                    {
                        config.LastExportHour = (int)proLastExportHour.Value;
                    }

                    var proEmail = component.Components.Where(c => c.ID == configEmailID).FirstOrDefault() as FieldOne;
                    if (proEmail != null)
                    {
                        config.EmailSend = proEmail.Value as string;
                    }

                    config.SaveObject(configPath);
                    #endregion

                    if (needRestart)
                    {
                        mainService.Restart();
                    }

                    SendLogToAll("Đặt cấu hình thành công");
                }
            }
            catch (Exception ex)
            {
                SendLogToAll("Lỗi đặt cấu hình:" + ex.Message);
            }
        }
Exemplo n.º 2
0
        void mainService_OnGetConfig(object sender, HDCPProtocol2.HDCP.HDCPParserArgs e)
        {
            try
            {
                HDCPParserArgs Command = new HDCPParserArgs()
                {
                    RemoteHostState = e.RemoteHostState,
                    Command         = HDCPCommand.CONFIG,
                    MessageData     = new MessageData()
                };

                FieldComponent component = new FieldComponent();

                #region Config
                component.AddComponent(new FieldOne()
                {
                    ID          = configDBStationID,
                    DisplayText = "Chuỗi kết nối DB Station",
                    Value       = config.DBStationConnectionString
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configAsRunLogFolderID,
                    DisplayText = "As run log xml folder",
                    Value       = config.AsRunLogFolder
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configAdTypeID,
                    DisplayText = "Thể loại của quảng cáo(mỗi thể loại cách nhau bằng dấu ;)",
                    Value       = config.AdTypes
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configAdMaxDurationID,
                    DisplayText = "Thời lượng tối đa của quảng cáo(frame)",
                    Type        = FieldType.Long,
                    EditMark    = "n0",
                    Value       = config.MaxAdDuration
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configVODFolderID,
                    DisplayText = "VOD folder",
                    Value       = config.VODFolder
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configVODXmlFolderID,
                    DisplayText = "VOD XML Folder",
                    Value       = config.VODXmlFolder
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configSessionStrID,
                    DisplayText = "Session String",
                    Value       = config.sessionStr
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configImportTimeID,
                    DisplayText = "Thời gian quét As run log(giây)",
                    Type        = FieldType.Int,
                    EditMark    = "n0",
                    MinValue    = 10,
                    MaxValue    = 36000,
                    Value       = config.ImportTime
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configExportTimeID,
                    DisplayText = "Thời gian xuất VOD(giây)",
                    Type        = FieldType.Int,
                    EditMark    = "n0",
                    MinValue    = 10,
                    MaxValue    = 36000,
                    Value       = config.ExportTime
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configLastExportDay,
                    DisplayText = "Ngày cuối cùng xuất VOD",
                    Type        = FieldType.Int,
                    EditMark    = "f0",
                    MinValue    = -10,
                    MaxValue    = 0,
                    Value       = config.LastExportDay
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configLastExportHour,
                    DisplayText = "Giờ cuối cùng xuất VOD",
                    Type        = FieldType.Int,
                    EditMark    = "f0",
                    MinValue    = -23,
                    MaxValue    = 0,
                    Value       = config.LastExportHour
                });

                component.AddComponent(new FieldOne()
                {
                    ID          = configEmailID,
                    DisplayText = "Email",
                    Value       = config.EmailSend
                });
                #endregion

                Command.MessageData.AddComponent(HDCPCommand.CONFIG.ToString(), component.ToXml());

                SendTo(Command, e.RemoteHostState);
            }
            catch (Exception ex)
            {
                SendLogToAll("Lỗi gửi cấu hình:" + ex.Message);

                HDCPParserArgs Command = new HDCPParserArgs()
                {
                    RemoteHostState = e.RemoteHostState,
                    Command         = HDCPCommand.CONFIG,
                    MessageData     = new MessageData()
                };
                SendTo(Command, e.RemoteHostState);
            }
        }