⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srv_parse.pl.svn-base

📁 sigmadesign smp8623 gui source code ,bingo
💻 SVN-BASE
字号:
#!/usr/bin/perlrequire "srv_vcl.pm";require "srv_alarm_func.pm";require "srv_configure.pm";use IO::Socket;use IO::Select;use DBI;# Load configuration from cfg fileour %conf_hash;&LoadConfig();our $wake_up_time_split_sec = 1800;&ParseText(@ARGV[0]);#LOGGER(@ARGV[0]);sub ParseText {  my ($m_date, $m_time, $dbh);  my %all = ("MI", 0, "MS", " ", "MP", 0);  $dbh = DBI->connect("dbi:mysql:database=$conf_hash{database};host=$conf_hash{hostname};", $conf_hash{username}, $conf_hash{password});  die "$!" unless $dbh;  LOGGER("Message from PMS");  my (@str) = split(/\|/, @_[0]);  my ($command) = substr($str[0], 0, 2);  LOGGER("PMS Command: $command");  foreach $st (@str) {    my ($field) = substr($st, 0, 2);    $all{$field} = substr($st, 2, length($st) - 2);  }  # execute PMS command  if($command eq "WR") {  # check for wake up now  #  $m_date = $all{"DA"};  #  $m_time = $all{"TI"};    #k my ($seconds, $minutes, $hours, $day, $month, $year) = (substr($m_time, 4, 2), substr($m_time, 2, 2), substr($m_time, 0, 2), substr($m_date, 4, 2), scalar(substr($m_date, 2, 2)) -1, scalar ("20".substr($m_date, 0, 2)) - 1900);    #k $m_now = timegm($seconds, $minutes, $hours, $day, $month, $year);    #k $m_now = abs($m_now - time());    #if($m_now <= $wake_up_time_split_sec)    #k{    #k  system("perl srv_as_room_alarm.pl $set_alarms{$_} &");    #k}    LOGGER("Not Such command");  } elsif ($command eq "WD") {                                                                                         # update alarm  # update wake up time    $m_date = MakeDate($all{"DA"});    $m_time = MakeTime($all{"TI"});    if(DB_SetAlarm($dbh, $all{"RN"}, $m_date, $m_time) == 0) {      LOGGER("Update alarm RoomID: $all{'RN'}");    }    UpdateAlarmServer();  } elsif ($command eq "WC") {                                                                        # delete alarm    if(DB_StopAlarm($dbh, $all{"RN"})) {      print "alarm stopped\n";    }  } elsif ($command eq "XL") {                                                                                # new message    $sth = $dbh->prepare("SELECT * FROM `Room` WHERE RoomID = ?");    $sth->execute($all{'RN'});    if(@row = $sth->fetchrow_array()) { # have room with this ID      $sth->finish();      # get next message ID      $sth = $dbh->prepare("SELECT `MsgID` FROM `Message` WHERE RoomID = ? ORDER BY `MsgID` DESC");      $sth->execute($all{'RN'});      if(@row = $sth->fetchrow_array()) {        # $all{'MI'} = scalar(@row[0]) + 1;      } else {        # $all{'MI'} = 0;      }        $sth->finish();      # format date and time        $m_date = MakeDate($all{"DA"});        $m_time = MakeTime($all{"TI"});      # message priority                0 - min priority      if(substr($all{'MT'}, 0, 1) eq "*") {        $all{'MP'} = 2;      } elsif (substr($all{'MT'}, 0, 1) eq "!") {        $all{'MP'} = 1;      } else {        $all{'MP'} = 0;      }      # save message to DB      # print $all{'RN'}, $all{'MI'}, $all{'MP'}, $all{'MS'}, $all{'MT'}, "\n";      $sth = $dbh->prepare("INSERT INTO `Message` ( `RoomID` , `MsgID` , `Priority` , `Subject` , `Text` , `Status` , `PostDate` , `OpenDate` , `PostEmpID` , `PMSMsgID` )         VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");      $sth->execute($all{'RN'}, $all{'MI'}, $all{'MP'}, $all{'MS'}, $all{'MT'}, "0", $m_date." ".$m_time, "0000-00-00 00:00:00", "0", $all{'MI'});      $sth->finish();      # check message      $sth = $dbh->prepare("SELECT * FROM `Message` WHERE `RoomID` = ? AND `MsgID` = ?;");      $sth->execute($all{"RN"}, $all{"MI"});      if($sth->fetchrow_array()) {        if($all{"MP"} == 2) {          SendMessage($all{"RN"}, $conf_hash{st_port}, "$conf_hash{st_serv_ip}/Page/new/message_urgent.php?MsgID=$all{'MI'}");        } else {          SendMessage($all{"RN"}, $conf_hash{st_port}, $all{"MP"});        }      } else {        LOGGER("Message not added");      }      $sth->finish();    }  } elsif ($command eq "XD") {                                                                        # delete message    my $sth = $dbh->prepare("DELETE FROM `Message`  WHERE `RoomID` = ? AND `MsgID` = ?;");    $sth->execute($all{"RN"}, $all{"MI"});  } elsif ($command eq "XM") {  } elsif ($command eq "XT") {  }  $dbh->disconnect();}sub MakeDate {  my ($m_date) = @_[0];  if(($m_date =~ /\D/) or (length($m_date) != 6)) {    $m_date = "000000";    LOGGER("Date from PMS is not correct");  }  $m_date = "20".substr($m_date, 0, 2)."-".substr($m_date, 2, 2)."-".substr($m_date, 4, 2);  return $m_date;}sub MakeTime {  my ($m_time) = @_[0];  if(($m_time =~ /\D/)  or (length($m_time) != 6)) {    $m_time = "000000";    LOGGER("Time from PMS is not correct");  }  $m_time = substr($m_time, 0, 2).":".substr($m_time, 2, 2).":".substr($m_time, 4, 2);}sub FilterKHTypes () {#-------------------------------------------------------# Called in load_configure.pm # Must be declared# Empty here, but used in server.pl#-------------------------------------------------------  return  "";}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -