Beispiel #1
0
        /// <summary>
        /// Saves the specified type.
        /// </summary>
        /// <param name="type">
        /// The OutputName type.
        /// </param>
        public static void Save(OutputName type)
        {
            switch (type)
            {
            case OutputName.MovieDb:
                SaveMovieDB();
                break;

            case OutputName.MediaPathDb:
                SaveMediaPathDb();
                break;

            case OutputName.MovieSets:
                SaveMovieSets();
                break;

            case OutputName.TvDb:
                SaveTvDB();
                break;

            case OutputName.ScanSeriesPick:
                SaveScanSeriesPick();
                break;

            case OutputName.All:
                StartSaveDialog();
                SaveMovieDB();
                SaveMediaPathDb();
                SaveMovieSets();
                SaveTvDB();
                SaveScanSeriesPick();
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loads the specified output name.
        /// </summary>
        /// <param name="outputName">
        /// Name of the output.
        /// </param>
        public static void Load(OutputName outputName)
        {
            switch (outputName)
            {
            case OutputName.MovieDb:
                LoadMovieDB();
                break;

            case OutputName.MediaPathDb:
                LoadMediaPathDb();
                break;

            case OutputName.MovieSets:
                LoadMovieSets();
                break;

            case OutputName.TvDb:
                LoadTvDB();
                break;

            case OutputName.ScanSeriesPick:
                LoadScanSeriesPick();
                break;

            case OutputName.All:
                LoadMovieDB();
                LoadMovieSets();
                LoadMediaPathDb();
                MasterMediaDBFactory.PopulateMasterMovieMediaDatabase();
                LoadTvDB();
                LoadScanSeriesPick();
                MasterMediaDBFactory.PopulateMasterTvMediaDatabase();
                break;
            }
        }
        /// <summary>
        /// Indexer looks up the first IOutput with the specified name or path.<br/>
        /// If several IOutput objects in the list are using the same name, only the first matching IOutput will be returned.<br/>
        /// Instead of a name and path consisting of {OutputControllerName}\\{OutputName} can be supplied. If no item matches the path, null will be returned.
        /// </summary>
        /// <param name="Name">Name of the IOutput to look up.</param>
        /// <returns>IOutput object if a match is found, null otherwise.</returns>
        public IOutput this[string Name]
        {
            get
            {
                string OutputName = "";

                string[] N = Name.Replace("/", "\\").Split('\\');
                if (N.Length == 2)
                {
                    //it is a path
                    if (OutputControllers.Contains(N[0]))
                    {
                        OutputName = N[1];
                    }
                }
                else
                {
                    //just a simple name
                    OutputName = Name;
                }


                string[] NameParts = OutputName.Split('.');
                if (NameParts.Length == 2)
                {
                    int Nr = 0;
                    if (this.OutputControllers.Contains(NameParts[0]) && int.TryParse(NameParts[1], out Nr))
                    {
                        IOutputController OC = this.OutputControllers[NameParts[0]];

                        IOutput O = OC.Outputs.FirstOrDefault(OP => OP.Number == Nr);
                        if (O != null)
                        {
                            return(O);
                        }
                    }
                }


                foreach (IOutputController OC in this.OutputControllers)
                {
                    if (OC.Outputs.Contains(OutputName))
                    {
                        return((IOutput)OC.Outputs[OutputName]);
                    }
                }
                return(null);
            }
        }
        private void CheckForStringShortcuts()
        {
            if (OutputName.Contains("{D}"))
            {
                OutputName = OutputName.Replace("{D}", SelectedDate.ToString("M-d-yy"));
            }

            if (OutputName.Contains("{C}"))
            {
                OutputName = OutputName.Replace("{C}", SelectedContract.ContractNumber.ToString());
            }

            if (OutputName.Contains("{N}"))
            {
                OutputName = OutputName.Replace("{N}", SelectedContract.ContractName);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Saves the specified type.
        /// </summary>
        /// <param name="type">
        /// The OutputName type.
        /// </param>
        public static void Save(OutputName type)
        {
            if (SavingCount > 0)
            {
                return;
            }

            switch (type)
            {
            case OutputName.MovieDb:
                SaveMovieDB();
                break;

            case OutputName.MediaPathDb:
                SaveMediaPathDb();
                break;

            case OutputName.MovieSets:
                SaveMovieSets();
                break;

            case OutputName.TvDb:
                SaveTvDB();
                break;

            case OutputName.ScanSeriesPick:
                SaveScanSeriesPick();
                break;

            case OutputName.All:
                StartSaveDialog();
                SaveMovieDB();
                SaveMediaPathDb();
                SaveMovieSets();
                SaveTvDB();
                SaveScanSeriesPick();
                DatabaseDirty = false;
                break;
            }
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (OutputName.Length != 0)
            {
                hash ^= OutputName.GetHashCode();
            }
            if (topicDestinationCase_ == TopicDestinationOneofCase.Topic)
            {
                hash ^= Topic.GetHashCode();
            }
            if (topicDestinationCase_ == TopicDestinationOneofCase.TopicDemux)
            {
                hash ^= TopicDemux.GetHashCode();
            }
            hash ^= (int)topicDestinationCase_;
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
 /// <summary>
 /// Saves the specified type.
 /// </summary>
 /// <param name="type">
 /// The OutputName type.
 /// </param>
 public static void Save(OutputName type)
 {
     switch (type)
     {
         case OutputName.MovieDb:
             SaveMovieDB();
             break;
         case OutputName.MediaPathDb:
             SaveMediaPathDb();
             break;
         case OutputName.MovieSets:
             SaveMovieSets();
             break;
         case OutputName.TvDb:
             SaveTvDB();
             break;
         case OutputName.ScanSeriesPick:
             SaveScanSeriesPick();
             break;
         case OutputName.All:
             StartSaveDialog();
             SaveMovieDB();
             SaveMediaPathDb();
             SaveMovieSets();
             SaveTvDB();
             SaveScanSeriesPick();
             break;
     }
 }
 /// <summary>
 /// Loads the specified output name.
 /// </summary>
 /// <param name="outputName">
 /// Name of the output.
 /// </param>
 public static void Load(OutputName outputName)
 {
     switch (outputName)
     {
         case OutputName.MovieDb:
             LoadMovieDB();
             break;
         case OutputName.MediaPathDb:
             LoadMediaPathDb();
             break;
         case OutputName.MovieSets:
             LoadMovieSets();
             break;
         case OutputName.TvDb:
             LoadTvDB();
             break;
         case OutputName.ScanSeriesPick:
             LoadScanSeriesPick();
             break;
         case OutputName.All:
             LoadMovieDB();
             LoadMovieSets();
             LoadMediaPathDb();
             MasterMediaDBFactory.PopulateMasterMovieMediaDatabase();
             LoadTvDB();
             LoadScanSeriesPick();
             MasterMediaDBFactory.PopulateMasterTvMediaDatabase();
             break;
     }
 }
Beispiel #9
0
        static bool ParseArgs(string[] args)
        {
            for (int a = 0; a < args.Length; a++)
            {
                string curr = args[a];
                if (curr == "-c" && ++a < args.Length)
                {
                    CharSets.Set whichSet = CharSets.Set.None;
                    if (!Enum.TryParse <CharSets.Set>(args[a], true, out whichSet))
                    {
                        Log.Error("Unknown characer set");
                        return(false);
                    }
                    WhichSet = whichSet;
                }
                else if (curr == "-f" && ++a < args.Length)
                {
                    FontFile = args[a];
                }
                else if (curr == "-fs" && ++a < args.Length)
                {
                    string s = args[a]?.ToLowerInvariant();
                    if (!Enum.TryParse <FontStyle>(s, out StyleOfFont))
                    {
                        char first = s[0];
                        if (first == 'r')
                        {
                            StyleOfFont = FontStyle.Regular;
                        }
                        else if (first == 'i')
                        {
                            StyleOfFont = FontStyle.Italic;
                        }
                        else if (first == 'b')
                        {
                            StyleOfFont = FontStyle.Bold;
                        }
                        else if (s.StartsWith("bi"))
                        {
                            StyleOfFont = FontStyle.BoldItalic;
                        }
                        else
                        {
                            Log.Error("unrecognized font style '" + s + "'");
                            return(false);
                        }
                    }
                }
                else if (curr == "-tw" && ++a < args.Length)
                {
                    if (!int.TryParse(args[a], out CharWidth))
                    {
                        Log.Error("Invalid width");
                        return(false);
                    }
                }
                else if (curr == "-th" && ++a < args.Length)
                {
                    if (!int.TryParse(args[a], out CharHeight))
                    {
                        Log.Error("Invalid height");
                        return(false);
                    }
                }
                else if (curr == "-it" && ++a < args.Length)
                {
                    CharFile = args[a];
                }
                else if (curr == "-lf")
                {
                    ListFonts = true;
                }
                else if (curr == "-sf" && ++a < args.Length)
                {
                    SystemFont = args[a];
                }
                else if (curr == "-ot")
                {
                    OutputText = true;
                }
                else if (curr == "-pt" && ++a < args.Length)
                {
                    if (!float.TryParse(args[a], out FontSize))
                    {
                        Log.Error("Invalid font size");
                        return(false);
                    }
                }
                else if (null == InputName)
                {
                    InputName = curr;
                }
                else if (null == OutputName)
                {
                    OutputName = curr;
                }
            }

            //Set any dynamic defaults here
            if (String.IsNullOrWhiteSpace(OutputName))
            {
                OutputName = nameof(ArtAscii).ToLowerInvariant()
                             + "-" + DateTime.Now.ToString("yyyyMMdd-HHmmss");
            }
            string suffix = OutputText ? ".txt" : ".png";

            if (!OutputName.EndsWith(suffix))
            {
                OutputName += suffix;
            }

            //Do sanity checks / warnings here
            if (null != CharFile && WhichSet != CharSets.Set.None)
            {
                Log.Warn("Option '-c' takes precedence over '-it'");
            }
            if (null != SystemFont && null != FontFile)
            {
                Log.Warn("Option '-sf' takes precedence over '-f'");
            }
            if (FontSize < 1.0f)
            {
                Log.Error("Font size must be at least 1.0");
                return(false);
            }

            return(true);
        }
Beispiel #10
0
        /// <summary>
        /// Saves the specified type.
        /// </summary>
        /// <param name="type">
        /// The OutputName type.
        /// </param>
        public static void Save(OutputName type)
        {
            if (SavingCount > 0)
            {
                return;
            }

            switch (type)
            {
                case OutputName.MovieDb:
                    SaveMovieDB();
                    break;
                case OutputName.MediaPathDb:
                    SaveMediaPathDb();
                    break;
                case OutputName.MovieSets:
                    SaveMovieSets();
                    break;
                case OutputName.TvDb:
                    SaveTvDB();
                    break;
                case OutputName.ScanSeriesPick:
                    SaveScanSeriesPick();
                    break;
                case OutputName.All:
                    StartSaveDialog();
                    SaveMovieDB();
                    SaveMediaPathDb();
                    SaveMovieSets();
                    SaveTvDB();
                    SaveScanSeriesPick();
                    DatabaseDirty = false;
                    break;
            }
        }
        /// <summary>
        /// Set new NETIO state.
        /// </summary>
        /// <param name="output">selected output</param>
        /// <param name="action">selected action</param>
        /// <returns></returns>
        public bool SetState(OutputName output, Action action)
        {
            try
            {
                // format set data
                NetIoSet netIoSet = new()
                {
                    Outputs = new List <NetIo.Output>()
                };

                if (OutputName.Output_All == output)
                {
                    netIoSet.Outputs.Add(new NetIo.Output()
                    {
                        ID = OutputName.Output_1, Action = action,
                    });
                    netIoSet.Outputs.Add(new NetIo.Output()
                    {
                        ID = OutputName.Output_2, Action = action,
                    });
                    netIoSet.Outputs.Add(new NetIo.Output()
                    {
                        ID = OutputName.Output_3, Action = action,
                    });
                    netIoSet.Outputs.Add(new NetIo.Output()
                    {
                        ID = OutputName.Output_4, Action = action,
                    });
                }
                else
                {
                    netIoSet.Outputs.Add(new NetIo.Output()
                    {
                        ID = output, Action = action,
                    });
                }

                // convert to json
                var jsonData = System.Text.Json.JsonSerializer.Serialize <NetIoSet>(netIoSet);

                // convert to bytes
                ASCIIEncoding encoding     = new();
                Byte[]        jsonByteData = encoding.GetBytes(jsonData);

                // setup
                var request = (HttpWebRequest)WebRequest.Create(url);
                request.Credentials   = new System.Net.NetworkCredential(user, password);
                request.ContentType   = "application/json";
                request.Method        = "POST";
                request.ContentLength = jsonByteData.Length;
                request.Timeout       = 2000;

                // post data
                using (Stream requestStream = request.GetRequestStream())
                    requestStream.Write(jsonByteData);

                // read response
                using HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                return(HttpStatusCode.OK == response.StatusCode);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
        protected override void Execute(CodeActivityContext context)
        {
            // Get some file names
            var files = Directory.EnumerateFiles(FileDirectory.Get(context), "*.*", SearchOption.AllDirectories)
                        .Where(s => s.ToLower().EndsWith(".pdf"));

            // Open the output document
            PdfDocument outputDocument = new PdfDocument();

            // Iterate files
            foreach (string file in files)
            {
                // Open the document to import pages from it.
                PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import);

                // Iterate pages
                int count = inputDocument.PageCount;
                for (int idx = 0; idx < count; idx++)
                {
                    // Get the page from the external document...
                    PdfPage page = inputDocument.Pages[idx];
                    // ...and add it to the output document.
                    outputDocument.AddPage(page);
                }
            }

            // Save the document...
            string filename = string.Format("{0}", FileDirectory.Get(context)) + "\\" + string.Format("{0}", OutputName.Get(context));

            outputDocument.Save(filename);

            // Set full output path
            OutputFullPath.Set(context, filename);

            // Based on input from the selecter, open or do not open when merged
            if (string.Format("{0}", this.Option) == "Yes")
            {
                // ...and start a viewer.
                Process.Start(filename);
            }
        }