コード例 #1
0
ファイル: Weather.cs プロジェクト: giangnamnam/intelli-room
        private void UpdateWeather(String city)
        {
            XmlDocument xml = Data.HTTPRequest.GetXML("http://www.google.com/ig/api?weather=" + city + "&hl=" + Languages.CodeRegion);

            lastCity = city;
            if (xml != null)
            {
                try
                {
                    XmlNodeList current = xml.ChildNodes.Item(1).ChildNodes.Item(0).ChildNodes.Item(1).ChildNodes;

                    this.condition     = current.Item(0).Attributes.GetNamedItem("data").Value;
                    this.temperatureF  = int.Parse(current.Item(1).Attributes.GetNamedItem("data").Value);
                    this.temperatureC  = int.Parse(current.Item(2).Attributes.GetNamedItem("data").Value);
                    this.humidity      = ParseHumidity(current.Item(3).Attributes.GetNamedItem("data").Value);
                    this.windDirection = ParseWindDirection(current.Item(5).Attributes.GetNamedItem("data").Value);
                    this.windSpeed     = ParseWindSpeed(current.Item(5).Attributes.GetNamedItem("data").Value);
                    if (temperatureC > maxTemperatureEvent && temperatureMaxEvent != null)
                    {
                        temperatureMaxEvent(temperatureC);
                    }
                    if (temperatureC < minTemperatureEvent && temperatureMinEvent != null)
                    {
                        temperatureMinEvent(temperatureC);
                    }
                }
                catch (Exception)
                {
                    InfoMessages.ErrorMessage("No existe ninguna ciudad con ese nombre");
                }
            }
        }
コード例 #2
0
        void singleStreamDownload(String fullpath, YoutubeVideoStreamedItem item)
        {
            FileStream outFile = null;

            try
            {
                outFile = new FileStream(fullpath, FileMode.Create);
                string mimeType;

                ItemProgressMax = 1;
                ItemProgress    = 0;

                ItemInfo = "Downloading: " + fullpath;
                StreamUtils.readHttpRequest(new Uri(item.Location), outFile, out mimeType, CancellationToken, downloadProgressCallback);

                ItemProgressMax = 1;
                ItemProgress    = 1;

                outFile.Close();
            }
            catch (Exception e)
            {
                InfoMessages.Add("Error downloading: " + fullpath + " " + e.Message);

                if (outFile != null)
                {
                    outFile.Close();
                    File.Delete(fullpath);
                }
                return;
            }
        }
コード例 #3
0
        void export(ICollection <MediaFileItem> items)
        {
            foreach (MediaFileItem item in items)
            {
                try
                {
                    if (CancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    ItemProgress = 0;

                    if (item.Metadata == null)
                    {
                        ItemInfo = "Reading Metadata: " + item.Location;

                        item.ExitUpgradeableReadLock();
                        try
                        {
                            item.readMetadata_URLock(MetadataFactory.ReadOptions.AUTO, CancellationToken);
                            if (item.Metadata == null || item.Metadata is UnknownMetadata)
                            {
                                ItemInfo = "Could not open file and/or read it's metadata: " + item.Location;
                                InfoMessages.Add("Could not open file and/or read it's metadata: " + item.Location);
                                Logger.Log.Error("Could not open file and/or read it's metadata: " + item.Location);
                            }
                        }
                        finally
                        {
                            item.ExitUpgradeableReadLock();
                        }
                    }

                    if (item.Metadata.IsImported == false)
                    {
                        InfoMessages.Add("Skipping non-imported file: " + item.Location);
                        ItemProgress = 100;
                        TotalProgress++;
                        continue;
                    }

                    ItemInfo = "Exporting: " + item.Location;

                    MediaFileState.export(item, CancellationToken);

                    ItemProgress = 100;
                    TotalProgress++;
                    InfoMessages.Add("Exported: " + item.Location);
                }
                catch (Exception e)
                {
                    ItemInfo = "Error exporting file: " + item.Location;
                    InfoMessages.Add("Error exporting file: " + item.Location + " " + e.Message);
                    Logger.Log.Error("Error exporting file: " + item.Location, e);
                    MessageBox.Show("Error exporting file: " + item.Location + "\n\n" + e.Message,
                                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Checks that a single INFO message exists that contains all of the specified strings
        /// </summary>
        public string AssertSingleInfoMessageExists(params string[] expected)
        {
            var matches = InfoMessages.Where(m => expected.All(e => m.Contains(e)));

            matches.Should().ContainSingle("More than one INFO message contains the expected strings: {0}", string.Join(",", expected));
            return(matches.First());
        }
コード例 #5
0
        private void saveMetadata(string fullpath, YoutubeVideoItem item)
        {
            YoutubeItemMetadata metadata = item.Metadata as YoutubeItemMetadata;

            MediaFileItem fileItem = MediaFileItem.Factory.create(fullpath);

            fileItem.EnterWriteLock();
            try
            {
                YoutubeItemMetadata saveMetadata = metadata.Clone() as YoutubeItemMetadata;

                saveMetadata.Location = fullpath;
                ItemProgress          = 0;
                ItemInfo = "Saving metadata: " + item.Name;

                MetadataFactory.write(saveMetadata, MetadataFactory.WriteOptions.WRITE_TO_DISK, this);

                ItemProgress = 100;
                InfoMessages.Add("Finished saving metadata: " + fullpath);
            }
            finally
            {
                fileItem.ExitWriteLock();
            }

            /*fileItem.EnterUpgradeableReadLock();
             * fileItem.readMetadata_URLock(MetadataFactory.ReadOptions.READ_FROM_DISK, CancellationToken);
             * fileItem.ExitUpgradeableReadLock();*/
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sCmd"></param>
        public int ExecNonQuery(String sCmd)
        {
            int iErr = -20;

            ErrorMessages.Clear();
            InfoMessages.Clear();

            try
            {
                SqlCommand cmd = new SqlCommand(sCmd, con);
                con.Open();
                iErr = cmd.ExecuteNonQuery();
            }

            catch (SqlException ex)
            {
                ErrorMessages.Add(sCmd);
                ProcessException(ex);
                iErr = -19;
            }

            finally
            {
                con.Close();
            }
            return(iErr);
        }
コード例 #7
0
 public void Write(string data)
 {
     Monitor.Enter(WriteMonitor);
     if (serial == null)
     {
         InfoMessages.InformationMessage("Arduino no está conectado, escaneamos los puertos...");
         GetSerialArduino();
     }
     try
     {
         if (serial != null)
         {
             serial.WriteLine(data);
         }
         else
         {
             InfoMessages.ErrorMessage("No se ha podido enviar la orden a Arduino, por no estar este conectado");
         }
     }
     catch (Exception)
     {
         InfoMessages.ErrorMessage("Error en el envío de datos");
         GetSerialArduino();
     }
     finally
     {
         Monitor.Exit(WriteMonitor);
     }
 }
コード例 #8
0
        public String RestoreDB(String sSource)
        {
            string sCmd;

            ErrorMessages.Clear();
            InfoMessages.Clear();

            sCmd = string.Format("restore database EMON from disk='{0}' with REPLACE", sSource);
            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand("alter database EMON set offline with rollback immediate", con);
                cmd.ExecuteNonQuery();
                cmd = new SqlCommand(sCmd, con);
                cmd.ExecuteNonQuery();
                cmd = new SqlCommand("alter database EMON set online with rollback immediate", con);
                cmd.ExecuteNonQuery();
                con.Close();

                connectionString = "server=" + server +
                                   ";database=" + db + ";uid=" + user + ";pwd=" + pwd;
                con              = new SqlConnection(connectionString);
                con.InfoMessage += new SqlInfoMessageEventHandler(OnInfoMessage);

                return(ErrorMessage);
            }

            catch (SqlException ex)
            {
                MessageBox.Show("Exception during SQL RestoreDB occured,\nsee the logger window!");
                ProcessException(ex);
                con.Close();
                return("");
            }
        }
コード例 #9
0
        private void importItem(FileInfo info)
        {
            try
            {
                ItemProgress = 0;

                MediaFileItem mediaFile = MediaFileItem.Factory.create(info.FullName);

                ItemInfo = "Importing: " + mediaFile.Location;

                MediaFileState.import(mediaFile, CancellationToken);

                ItemProgress = 1;
                TotalProgress++;
                InfoMessages.Add("Imported: " + mediaFile.Location);
            }
            catch (Exception e)
            {
                ItemInfo = "Error importing file: " + info.FullName;
                InfoMessages.Add("Error importing file: " + info.FullName + " " + e.Message);
                Logger.Log.Error("Error importing file: " + info.FullName, e);
                MessageBox.Show("Error importing file: " + info.FullName + "\n\n" + e.Message,
                                "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
コード例 #10
0
 public void Info(string message)
 {
     lock (InfoMessages)
     {
         InfoMessages.Add(message);
     }
 }
コード例 #11
0
        void startTranscode()
        {
            VideoLib.VideoOperations videoOperations = new VideoLib.VideoOperations();
            videoOperations.setLogCallback(logCallback, true, VideoLib.VideoOperations.LogLevel.LOG_LEVEL_INFO);
            TotalProgressMax = Items.Count;
            TotalProgress    = 0;
            ItemProgressMax  = 100;

            Dictionary <String, Object> options = getOptions();

            foreach (VideoAudioPair input in Items)
            {
                ItemProgress = 0;
                ItemInfo     = "Transcoding: " + input.Name;

                if (CancellationToken.IsCancellationRequested)
                {
                    return;
                }

                /*if (MediaFormatConvert.isImageFile(input.Location))
                 * {
                 *  InfoMessages.Add("Skipping: " + input.Name + " is not a video file.");
                 *  TotalProgress++;
                 *  continue;
                 * }*/

                String outLocation = getOutputLocation(input);

                try
                {
                    VideoLib.OpenVideoArgs openArgs =
                        new VideoLib.OpenVideoArgs(input.Location, null, input.Audio == null ? null : input.Audio.Location, null);

                    videoOperations.transcode(openArgs, outLocation, CancellationToken, options,
                                              transcodeProgressCallback);
                }
                catch (Exception e)
                {
                    InfoMessages.Add("Error transcoding: " + e.Message);

                    try
                    {
                        File.Delete(outLocation);
                    }
                    catch (Exception ex)
                    {
                        InfoMessages.Add("Error deleting: " + outLocation + " " + ex.Message);
                    }

                    return;
                }

                ItemProgress = 100;
                TotalProgress++;

                InfoMessages.Add("Finished Transcoding: " + input.Name + " -> " + outLocation);
            }
        }
コード例 #12
0
        /// <summary>
        /// Checks that a single INFO message exists that contains all of the specified strings
        /// </summary>
        public string AssertSingleInfoMessageExists(params string[] expected)
        {
            var matches = InfoMessages.Where(m => expected.All(e => m.Contains(e)));

            Assert.AreNotEqual(0, matches.Count(), "No INFO message contains the expected strings: {0}", string.Join(",", expected));
            Assert.AreEqual(1, matches.Count(), "More than one INFO message contains the expected strings: {0}", string.Join(",", expected));
            return(matches.First());
        }
コード例 #13
0
ファイル: ViewModel.cs プロジェクト: mattybabaallos/ACIS
 private void LogInfo(string message)
 {
     InfoMessages.Add(message);
     logger.Info(message);
     Application.Current.Dispatcher.Invoke(new Action(() =>
     {
         m_home.InfoMessageScrollViewer.ScrollToBottom();
     }));
 }
コード例 #14
0
ファイル: TaskLogger.cs プロジェクト: PLCnext/PLCnext_CLI_VS
        public void WriteLine(string line)
        {
            bool   logAsError = false;
            string rawLine    = line;

            InfoMessages.Add(line);

            RemoveCmakePrefix();

            FormatLinkerPrefix();

            // output format of librarybuilder does not match visual studio error format
            string libBuilder = "[EngineeringLibraryBuilder]:";

            if (line.TrimStart().StartsWith(libBuilder) && ErrorMessages.Contains(line))
            {
                logAsError = true;
            }

            if (logAsError)
            {
                _loggingHelper.LogMessageFromText("error: " + line, MessageImportance.High);
            }
            else
            {
                _loggingHelper.LogMessageFromText(line, MessageImportance.Normal);
            }

            void RemoveCmakePrefix()
            {
                string cmake = "[cmake]: ";

                if (line.Contains(cmake))
                {
                    line = line.Substring(line.IndexOf(cmake) + cmake.Length);
                }
            }

            void FormatLinkerPrefix()
            {
                string linker = "real-ld.exe";

                if (line.Contains(linker + ":"))
                {
                    string linkerPath = line.Substring(0, line.IndexOf(linker) + linker.Length);
                    if (File.Exists(linkerPath))
                    {
                        if (ErrorMessages.Contains(rawLine))
                        {
                            logAsError = true;
                        }

                        line = line.Substring(line.IndexOf(linker) + linker.Length + 1) + $"(message from {linkerPath})";
                    }
                }
            }
        }
コード例 #15
0
        public void import(String filename)
        {
            WindowTitle = "Importing Tags";

            XmlTextReader inFile = null;

            try
            {
                inFile = new XmlTextReader(filename);
                Type[] knownTypes = new Type[] { typeof(TagDTO), typeof(TagCategoryDTO) };

                DataContractSerializer tagSerializer = new DataContractSerializer(typeof(List <TagDTO>), knownTypes);

                List <Tag>    tags    = new List <Tag>();
                List <TagDTO> tagDTOs = (List <TagDTO>)tagSerializer.ReadObject(inFile);

                foreach (TagDTO tagDTO in tagDTOs)
                {
                    var tag = Mapper.Map <TagDTO, Tag>(tagDTO, new Tag());
                    tags.Add(tag);
                }

                TotalProgressMax = tags.Count;
                TotalProgress    = 0;

                using (TagDbCommands tagCommands = new TagDbCommands())
                {
                    foreach (Tag tag in tags)
                    {
                        if (CancellationToken.IsCancellationRequested == true)
                        {
                            return;
                        }

                        ItemInfo     = "Merging: " + tag.Name;
                        ItemProgress = 0;
                        tagCommands.merge(tag);
                        ItemProgress = 100;
                        TotalProgress++;
                        InfoMessages.Add("Merged: " + tag.Name);
                    }
                }
            }
            catch (Exception e)
            {
                InfoMessages.Add("Error importing tags " + e.Message);
            }
            finally
            {
                operationFinished();

                if (inFile != null)
                {
                    inFile.Dispose();
                }
            }
        }
コード例 #16
0
        public void WriteInformation(string format, params object[] args)
        {
            var formattedMsg = string.Format(format, args);
            var value        = "Info:         " + formattedMsg;

            Console.WriteLine(value);
            logBuilder.AppendLine(value);
            InfoMessages.Add(formattedMsg);
        }
コード例 #17
0
        public void startDownload(String outputPath, List <MediaItem> items)
        {
            TotalProgress    = 0;
            TotalProgressMax = items.Count;

            try
            {
                foreach (YoutubeVideoItem item in items)
                {
                    CancellationToken.ThrowIfCancellationRequested();

                    YoutubeVideoStreamedItem videoStream, audioStream;
                    item.getStreams(out videoStream, out audioStream, (int)Properties.Settings.Default.MaxDownloadResolution);

                    if (videoStream == null)
                    {
                        InfoMessages.Add("Skipping: " + item.Name + " no streams found");
                        continue;
                    }

                    YoutubeItemMetadata metadata = item.Metadata as YoutubeItemMetadata;

                    String fullpath;
                    String ext      = "." + MediaFormatConvert.mimeTypeToExtension(metadata.MimeType);
                    String filename = FileUtils.removeIllegalCharsFromFileName(item.Name, " ") + ext;

                    try
                    {
                        fullpath = FileUtils.getUniqueFileName(outputPath + "\\" + filename);
                    }
                    catch (Exception)
                    {
                        fullpath = FileUtils.getUniqueFileName(outputPath + "\\" + "stream" + ext);
                    }

                    if (audioStream == null)
                    {
                        singleStreamDownload(fullpath, videoStream);
                    }
                    else
                    {
                        downloadAndMuxStreams(fullpath, videoStream, audioStream);
                    }

                    saveMetadata(fullpath, item);

                    InfoMessages.Add("Finished: " + videoStream.Name + " -> " + fullpath);

                    TotalProgress++;
                }
            }
            catch (Exception e)
            {
                InfoMessages.Add("Error: " + e.Message);
            }
        }
コード例 #18
0
        private void GetSerialArduino()
        {
            SerialPort arduino = null;

            string[] serialPortsName = SerialPort.GetPortNames();
            foreach (var PortCom in serialPortsName)
            {
                SerialPort serialPort = new SerialPort(PortCom, 9600)
                {
                    NewLine = "\r\n"
                };
                serialPort.ReadTimeout = 500;
                bool found = false;
                if (!serialPort.IsOpen)
                {
                    //a veces detecta COM que no existen.
                    try
                    {
                        serialPort.Open();
                        found = IsArduino(serialPort);
                        serialPort.Close();
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }
                else //puerto está abierto
                {
                    found = IsArduino(serialPort);
                }
                if (found)
                {
                    arduino = serialPort;
                    break;
                }
            }

            if (arduino != null) //hemos encontrado arduino
            {
                //abrimos si es posible
                if (!arduino.IsOpen)
                {
                    arduino.Open();
                }

                serial = arduino;
                serial.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(serial_DataReceived);

                InfoMessages.InformationMessage("Arduino encontrado en puerto " + arduino.PortName);
            }
            else
            {
                InfoMessages.ErrorMessage("Arduino no encontrado");
            }
        }
コード例 #19
0
        private void RemoveMessage(InfoMessage infoMessage)
        {
            var message =
                InfoMessages.FirstOrDefault(m => m.Message == infoMessage.Message);

            if (message != null)
            {
                InfoMessages.Remove(infoMessage);
            }
        }
コード例 #20
0
        void export(ObservableCollection <ScanLocation> includeLocations, ObservableCollection <ScanLocation> excludeLocations)
        {
            List <String> items = new List <String>();

            foreach (ScanLocation location in includeLocations)
            {
                if (CancellationToken.IsCancellationRequested)
                {
                    return;
                }
                ItemInfo = "Searching files in: " + location.Location;

                Tuple <ScanLocation, ObservableCollection <ScanLocation>, List <String> > state =
                    new Tuple <ScanLocation, ObservableCollection <ScanLocation>, List <String> >(location, excludeLocations, items);

                FileUtils.iterateFilesInDirectory(new DirectoryInfo(location.Location),
                                                  getMediaFiles, state, location.IsRecursive);

                InfoMessages.Add("Completed searching files in: " + location.Location);
            }

            TotalProgressMax = items.Count;
            ItemProgressMax  = 100;

            foreach (String item in items)
            {
                try
                {
                    if (CancellationToken.IsCancellationRequested)
                    {
                        return;
                    }
                    ItemProgress = 0;

                    MediaFileItem mediaFile = MediaFileItem.Factory.create(item);

                    ItemInfo = "Exporting: " + mediaFile.Location;

                    MediaFileState.export(mediaFile, CancellationToken);

                    ItemProgress = 100;
                    TotalProgress++;
                    InfoMessages.Add("Exported: " + mediaFile.Location);
                }
                catch (Exception e)
                {
                    ItemInfo = "Error exporting file: " + item;
                    InfoMessages.Add("Error exporting file: " + item + " " + e.Message);
                    Logger.Log.Error("Error exporting file: " + item, e);
                    MessageBox.Show("Error exporting file: " + item + "\n\n" + e.Message,
                                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
        }
コード例 #21
0
        public SendInfoMessageEventArgs(InfoMessages message)
        {
            Args = new List <string>();

            var infoMessage = GameDataManager <InfoMessage> .Instance.Get((int)message);

            if (infoMessage != null)
            {
                Type      = (InfoMessageType)infoMessage.Type;
                MessageId = (short)infoMessage.Id;
            }
        }
コード例 #22
0
        public void CancelAll()
        {
            var tasks = Tasks.Keys.ToList();

            foreach (var task in tasks)
            {
                Tasks[task].Cancel();
                Tasks.Remove(task);
            }

            InfoMessages.Clear();
        }
コード例 #23
0
        public async Task generatePreviews()
        {
            await Task.Factory.StartNew(() =>
            {
                try
                {
                    TotalProgressMax = asyncState.Media.Count;

                    for (TotalProgress = 0; TotalProgress < TotalProgressMax; TotalProgress++)
                    {
                        MediaFileItem item = asyncState.Media.ElementAt(TotalProgress);

                        if (CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        if (!MediaFormatConvert.isVideoFile(item.Location))
                        {
                            InfoMessages.Add("Skipping: " + item.Location + " is not a video file.");
                            continue;
                        }
                        if (item.Metadata == null)
                        {
                            item.EnterUpgradeableReadLock();
                            try
                            {
                                item.readMetadata_URLock(MetadataFactory.ReadOptions.AUTO, CancellationToken);
                                if (item.ItemState != MediaItemState.LOADED)
                                {
                                    InfoMessages.Add("Skipping: " + item.Location + " could not read metadata.");
                                    continue;
                                }
                            }
                            finally
                            {
                                item.ExitUpgradeableReadLock();
                            }
                        }

                        generatePreview(item);
                    }
                }
                finally
                {
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        OkCommand.IsExecutable     = true;
                        CancelCommand.IsExecutable = false;
                    });
                }
            });
        }
コード例 #24
0
        public void AddInfoMessageWithoutTracking(InfoMessage infoMessage)
        {
            InfoMessages.Insert(0, infoMessage);
            var task = Task.Delay(infoMessage.Duration)
                       .ContinueWith(t =>
            {
                InfoMessages.Remove(infoMessage);
                Tasks.Remove(t);
            },
                                     TaskScheduler.FromCurrentSynchronizationContext());

            Tasks.Add(task, new CancellationTokenSource());
        }
コード例 #25
0
        public IEnumerable <ErrorInfo> GetCurrent(int count)
        {
            if (InfoCurrent < (count - 1))
            {
                InfoCurrent = count - 1;
            }

            var result = InfoMessages
                         .OrderByDescending((i) => i.LoggingId)
                         .Where((c) => c.LoggingId <= InfoCurrent)
                         .Take(count)
                         .ToList();

            return(result);
        }
コード例 #26
0
 private void HandleInAppInfoMessageReceived(Tuple <InAppInfoMessageType, Dictionary <string, string> > data)
 {
     if (data.Item1 == InAppInfoMessageType.EntrySaved)
     {
         InfoMessages.Add("Entry saved"); //ToDo
     }
     else if (data.Item1 == InAppInfoMessageType.SavingAttachment)
     {
         InfoMessages.Add("Saving attachment - " + data.Item2["AttachmentName"]); //ToDo
     }
     else if (data.Item1 == InAppInfoMessageType.AttachmentSaved)
     {
         InfoMessages.Add("Attachment saved - " + data.Item2["AttachmentName"]); //ToDo
     }
 }
コード例 #27
0
        /// <summary>
        /// This should be call before doing final storage, will reduce the size of
        /// unused fields
        /// </summary>
        public void SetEmptyValueToNull()
        {
            foreach (var err in ErrorMessages)
            {
                err.SetEmptyValueToNull();
            }


            if (String.IsNullOrEmpty(MediaItemId))
            {
                MediaItemId = null;
            }

            if (String.IsNullOrEmpty(MessageId))
            {
                MessageId = null;
            }
            if (!Log.Any())
            {
                Log = null;
            }
            if (!OutputCommands.Any())
            {
                OutputCommands = null;
            }
            if (!OutgoingMessages.Any())
            {
                OutgoingMessages = null;
            }
            if (!ErrorMessages.Any())
            {
                ErrorMessages = null;
            }
            if (!InfoMessages.Any())
            {
                InfoMessages = null;
            }
            if (!WarningMessages.Any())
            {
                WarningMessages = null;
            }
            if (Envelope.SetEmptyValueToNull())
            {
                Envelope = null;
            }
        }
コード例 #28
0
        void startConcat()
        {
            VideoLib.VideoOperations videoOperations = new VideoLib.VideoOperations();
            videoOperations.setLogCallback(logCallback, true, VideoLib.VideoOperations.LogLevel.LOG_LEVEL_INFO);
            TotalProgressMax = Items.Count;
            TotalProgress    = 0;
            ItemProgressMax  = 100;

            List <VideoLib.OpenVideoArgs> inputArgs = new List <VideoLib.OpenVideoArgs>();

            foreach (VideoAudioPair input in Items)
            {
                inputArgs.Add(new VideoLib.OpenVideoArgs(input.Location, null, input.Audio == null ? null : input.Audio.Location, null));
            }

            String outLocation = getOutputLocation(Items.ElementAt(0));
            Dictionary <String, Object> options = getOptions();

            try
            {
                videoOperations.concat(inputArgs, outLocation, CancellationToken, options,
                                       concatProgressCallback);
            }
            catch (Exception e)
            {
                InfoMessages.Add("Error concatenating: " + e.Message);

                try
                {
                    File.Delete(outLocation);
                }
                catch (Exception ex)
                {
                    InfoMessages.Add("Error deleting: " + outLocation + " " + ex.Message);
                }

                return;
            }

            ItemProgress = 100;
            TotalProgress++;

            InfoMessages.Add("Finished concatenating: " + outLocation);
        }
コード例 #29
0
        public void AddGrammar(string url)
        {
            //cargamos el documento XML
            XmlDocument xml = new XmlDocument();

            try
            {
                xml.Load(Directories.GetGrammarDirectory() + "\\" + url);

                foreach (XmlNode command in xml.ChildNodes[1].ChildNodes)
                {
                    AddGrammar(LoadCommand(command));
                }
            }
            catch (Exception)
            {
                InfoMessages.ErrorMessage("No se ha encontrado el archivo de gramática: " + Directories.GetGrammarXML() + ", no se cargará la gramática de voz");
            }
        }
コード例 #30
0
        public void clear()
        {
            List <Tag> tags;

            try
            {
                if (CancellationToken.IsCancellationRequested)
                {
                    return;
                }

                using (TagDbCommands tagCommands = new TagDbCommands())
                {
                    tags          = tagCommands.getAllUnusedTags();
                    TotalProgress = tags.Count();

                    foreach (Tag tag in tags)
                    {
                        if (CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }

                        ItemInfo     = "Deleting: " + tag.Name;
                        ItemProgress = 0;

                        tagCommands.delete(tag);

                        ItemProgress = 100;
                        InfoMessages.Add("Deleting: " + tag.Name);
                        TotalProgress++;
                    }
                }
            }
            catch (Exception e)
            {
                InfoMessages.Add("Error deleting tags: " + e.Message);
            }
            finally
            {
                operationFinished();
            }
        }