示例#1
0
 public Control(string ServerAddress, int Port, ref CarverLab.Utility.Logger logger)
 {
     log = logger;
     m_sServerAddress = ServerAddress;
     m_iPort = Port;
     m_TCPClient = new System.Net.Sockets.TcpClient();
     m_EventChannelConnectionComplete = new System.Threading.ManualResetEvent(false);
     m_sLastError = "";
     m_EventReceivedFile = new System.Threading.AutoResetEvent(false);
 }
示例#2
0
 public PermissionsTool(CarverLab.Oyster.Permissions PermissionsDataSet)
 {
     //fill Permissions data from XML file
     _XMLPermissionsTempFile = Path.GetTempFileName();
     FileStream fs = new FileStream(_XMLPermissionsTempFile,FileMode.OpenOrCreate,FileAccess.ReadWrite);
     string sPermissionsXML = CarverLab.Utility.Resources.GetResourceText("Permissions.xml").ReadToEnd();
     byte[] stream = System.Text.ASCIIEncoding.ASCII.GetBytes(sPermissionsXML);
     fs.Write(stream,0,stream.Length);
     fs.Close();
     _Permissions = PermissionsDataSet;
     _Permissions.ReadXml(_XMLPermissionsTempFile);
     _Permissions.EnforceConstraints = true;
     _Permissions.PermissionsTable.DefaultView.Sort = "SectionName, PermissionName";
 }
示例#3
0
        public Encoder(int iChannel, string WMVDirectory, ref CarverLab.Utility.Logger logger)
        {
            log = logger;
            log.Context = "OysterEncoder.Encoder.Encoder";
            log.Context = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;
            if (iChannel < 1 || iChannel > 4)
            {
                log.WriteLog("OysterEncoder.Encoder.Encoder:" + " Invalid channel number specified: " + iChannel);
                throw (new ArgumentOutOfRangeException("iChannel",iChannel,"iChannel can only be between 1 and 4"));
            }
            m_iChannel = iChannel;
            m_bIsEncoderStreaming = false;
            m_bIsEncoderArchiving = false;
            m_sWMVDirectory = WMVDirectory;
            m_sWMVDefaultDirectory = m_sWMVDirectory;
            m_sProfileDirectory = MyPath + PROFILEDIRECTORY;
            if (!System.IO.Directory.Exists(m_sProfileDirectory))
            {
                throw (new ApplicationException("Profiles directory does not exist in " + m_sProfileDirectory + "."));
            }
            m_encoder = new WMEncoderLib.WMEncoderClass();
            m_encoder.OnError += new WMEncoderLib._IWMEncoderEvents_OnErrorEventHandler(m_encoder_OnError);
            m_encoder.OnClientConnect += new WMEncoderLib._IWMEncoderEvents_OnClientConnectEventHandler(m_encoder_OnClientConnect);
            m_encoder.OnClientDisconnect += new WMEncoderLib._IWMEncoderEvents_OnClientDisconnectEventHandler(m_encoder_OnClientDisconnect);

            try
            {
                UploadServer =
                    System.Configuration.ConfigurationSettings.AppSettings["UploadServer"];
                UploadPort = Convert.ToInt32(
                    System.Configuration.ConfigurationSettings.AppSettings["UploadPort"]);
                UploadUser =
                    System.Configuration.ConfigurationSettings.AppSettings["UploadUser"];
                UploadPassword =
                    System.Configuration.ConfigurationSettings.AppSettings["UploadPassword"];
            }
            catch (System.Exception e)
            {
                log.WriteLog("AppConfig is invalid. Exiting. Error: " + e.Message);
                throw new ApplicationException("AppConfig file information is invalid. Parts may be missing or the wrong type.");
            }

            log.WriteLog("Upload Server set at: " + UploadServer);
            log.WriteLog("Upload Port set at:" + UploadPort);
        }
示例#4
0
 public Connection(ref System.Net.Sockets.TcpClient TCPClient, System.Threading.ManualResetEvent eventChannelConnectionComplete, ref CarverLab.Utility.Logger logger)
 {
     log = logger;
     log.Context = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;
     m_TCPClient = TCPClient;
     m_bConnected = false;
     m_iBufferMaxLength = 2048;
     m_iBufferLength = 0;
     m_bytesIncomingBuffer = new byte[m_iBufferMaxLength];
     m_bDone = false;
     m_ThreadReceiveDataAndEnqueue = new System.Threading.Thread(new System.Threading.ThreadStart(this.ReceiveDataAndEnqueue));
     m_ThreadAutomaticDequeue = new System.Threading.Thread(new System.Threading.ThreadStart(this.DequeCommands));
     m_ThreadIsConnectionAlive = new System.Threading.Thread(new System.Threading.ThreadStart(this.IsConnectionAlive));
     m_qCommands = System.Collections.Queue.Synchronized(new System.Collections.Queue());
     m_EventChannelConnectionComplete = eventChannelConnectionComplete;
     m_EventChannelConnectionComplete.Reset();
     m_EventMessageAvailable = new System.Threading.AutoResetEvent(false);
     m_EventThreadComplete = new System.Threading.ManualResetEvent(false);
     m_bIsRunning = false;
     m_bAutomaticDequeueingSuspended = false;
     m_EventAutomaticQueueing = new System.Threading.ManualResetEvent(true);
 }
示例#5
0
文件: Info.cs 项目: CarverLab/Oyster
        public string Add(CarverLab.Utility.Encoding encoding)
        {
            int EncodingCount = 1;

            if (m_esi.CurrentEncodings != null)
            {
                EncodingCount = m_esi.CurrentEncodings.GetLength(0) + 1;
            }
            CarverLab.Utility.Encoding[] encodings = new CarverLab.Utility.Encoding[EncodingCount];

            if (m_esi.CurrentEncodings != null)
            {
                m_esi.CurrentEncodings.CopyTo(encodings,0);
            }
            encodings[EncodingCount - 1] = encoding;
            m_esi.CurrentEncodings = encodings;
            m_esi.CurrentEncodingCount = EncodingCount;
            if (m_esi.MaxConcurrentEncodingCount < m_esi.CurrentEncodingCount)
            {
                m_esi.MaxConcurrentEncodingCount = m_esi.CurrentEncodingCount;
            }
            return encoding.UniqueIdentifier;
        }
示例#6
0
        bool RemoveAndNotify(CarverLab.Utility.File file)
        {
            string FailedDirectoryName;
            string XMLFileName, MPEGFileName;

            try
            {
                System.IO.FileInfo fiXML = new System.IO.FileInfo(file.Name);
                FailedDirectoryName = fiXML.DirectoryName + @"\Failed";
                if (!System.IO.Directory.Exists(FailedDirectoryName))
                {
                    System.IO.Directory.CreateDirectory(FailedDirectoryName);
                }
                XMLFileName = fiXML.Name + fiXML.Extension;
                MPEGFileName = fiXML.Name + ".mpg";
                System.IO.File.Move(fiXML.DirectoryName + @"\" + XMLFileName,
                    FailedDirectoryName + @"\" + XMLFileName);
                System.IO.File.Move(fiXML.DirectoryName + @"\" + MPEGFileName,
                    FailedDirectoryName + @"\" + MPEGFileName);
                Remove(file.UniqueIdentifier);
                Microsoft.Win32.RegistryKey reg = m_log.CarverLabRegistryKey();
                string sNotificationAddress = (string)reg.GetValue("ErrorNotificationAddress","*****@*****.**");
                if (sNotificationAddress.Length == 0)
                {
                    sNotificationAddress = "*****@*****.**";
                }
                string sSMTPServer = (string)reg.GetValue("SMTPServer","mail.carverlab.com");
                if (sSMTPServer.Length == 0)
                {
                    sSMTPServer = "mail.carverlab.com";
                }
                MailMessage message = new MailMessage();
                message.To = sNotificationAddress;
                message.From = "*****@*****.**";
                message.Subject = "Encoding failure";
                message.Body = "The file " + MPEGFileName + " failed to encode. It has been moved to " +
                    fiXML.DirectoryName + " directory on the server. Please contact the system administrator " +
                    "with this notification.";
                try
                {
                    SmtpMail.SmtpServer = sSMTPServer;
                    SmtpMail.Send(message);
                }
                catch (System.Web.HttpException ehttp)
                {
                    m_log.WriteLog("Send mail error: " + ehttp.ToString());
                    return false;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
示例#7
0
        string AddFile(CarverLab.Utility.File file)
        {
            int FileCount = 1;

            if (m_esmi.Files != null)
            {
                FileCount = m_esmi.Files.GetLength(0) + 1;
            }
            CarverLab.Utility.File[] files = new CarverLab.Utility.File[FileCount];

            if (m_esmi.Files != null)
            {
                m_esmi.Files.CopyTo(files,0);
            }
            files[FileCount - 1] = file;
            m_esmi.Files = files;
            if (m_esmi.MaxFileCount < FileCount)
            {
                m_esmi.MaxFileCount = FileCount;
            }
            return file.UniqueIdentifier;
        }
示例#8
0
        public CarverLab.Oyster.Encoder.Command SendCommandWaitForResponse(CarverLab.Oyster.Encoder.Command cmd)
        {
            //log.Context = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;
            CarverLab.Oyster.Encoder.Command retcmd = null;
            string sLastErrorMessage = "";
            try
            {
                cmd.Write(m_TCPClient.GetStream());
            }
            catch (System.IO.IOException ioex)
            {
                if (null != ioex.InnerException)
                {
                    if (ioex.InnerException is System.Net.Sockets.SocketException)
                    {
                        int iErrorCode = ((System.Net.Sockets.SocketException)ioex.InnerException).ErrorCode;
                        string sErrorMessage = ((System.Net.Sockets.SocketException)ioex.InnerException).Message;
                        sLastErrorMessage = "SendCommand: Error Code = " + iErrorCode.ToString() + " Description = " + sErrorMessage;

                    }
                    else
                    {
                        sLastErrorMessage = "SendCommand: Unknown Error detected. Description = " + ioex.Message;
                    }
                }
                m_bDone = true;
                m_bConnected = false;
            }
            catch (System.Exception ex)
            {
                sLastErrorMessage = "SendCommand: Unknown Error detected. Description = " + ex.Message;
                m_bDone = true;
                m_bConnected = false;
            }
            if(!this.Connected)
            {
                log.WriteLog(sLastErrorMessage);
                OnConnectionErrorReceived(this,sLastErrorMessage);
            }
            #if DEBUG
            if (m_EventMessageAvailable.WaitOne(25000,false))
            #else
            if (m_EventMessageAvailable.WaitOne(3000,false))
            #endif
            {
                lock (m_qCommands.SyncRoot)
                {
                    if (m_qCommands.Count > 0)
                    {
                        retcmd = (CarverLab.Oyster.Encoder.Command)m_qCommands.Dequeue();
                    }
                }
            }
            else
            {
                log.WriteLog("WaitOne timed out waiting for a return message.");
            }
            return retcmd;
        }
示例#9
0
        public void SendCommand(CarverLab.Oyster.Encoder.Command cmd)
        {
            string sLastErrorMessage = "";

            try
            {
                cmd.Write(m_TCPClient.GetStream());
            }
            catch (System.IO.IOException ioex)
            {
                if (null != ioex.InnerException)
                {
                    if (ioex.InnerException is System.Net.Sockets.SocketException)
                    {
                        int iErrorCode = ((System.Net.Sockets.SocketException)ioex.InnerException).ErrorCode;
                        string sErrorMessage = ((System.Net.Sockets.SocketException)ioex.InnerException).Message;
                        sLastErrorMessage = "SendCommand: Error Code = " + iErrorCode.ToString() + " Description = " + sErrorMessage;

                    }
                    else
                    {
                        sLastErrorMessage = "SendCommand: Unknown Error detected. Description = " + ioex.Message;
                    }
                }
                m_bDone = true;
                m_bConnected = false;
            }
            catch (System.Exception ex)
            {
                sLastErrorMessage = "SendCommand: Unknown Error detected. Description = " + ex.Message;
                m_bDone = true;
                m_bConnected = false;
            }
            if(!m_bConnected)
            {
                log.WriteLog(sLastErrorMessage);
                OnConnectionErrorReceived(this,sLastErrorMessage);
            }
        }
示例#10
0
 public virtual void OnMessageReceived(CarverLab.Oyster.Encoder.CommandEventArgs e)
 {
     if (MessageReceived != null)
         MessageReceived(this,e);
 }
示例#11
0
 public InternalCallbackParams(CarverLab.Utility.Win32Wrapper This, System.Object obj)
 {
     m_This = This;
     m_obj = obj;
 }
示例#12
0
 internal virtual void OnEnumWindowsExReceived(CarverLab.Utility.Window window, System.Object obj)
 {
     if (EnumWindowsExReceived != null)
     {
         EnumWindowsExReceived(window,obj);
     }
 }
示例#13
0
 internal void AddChild(CarverLab.Utility.Window ChildWindow)
 {
     throw new System.NotImplementedException();
 }
示例#14
0
文件: asx.cs 项目: CarverLab/Oyster
 public ASXSerializer(CarverLab.Utility.ASX asxObject)
     : base(typeof(CarverLab.Utility.ASX))
 {
     m_asx = asxObject;
 }