Esempio n. 1
0
        public static bool GetMegaLogin(string name, out string email, out string password)
        {
            email = password = null;
            XmlConfig config = new XmlConfig(@"c:\pib\drive\google\dev_data\exe\runsource\mega\config\mega.config.local.xml");
            XElement  xe     = config.GetElement($"Login[@name = '{name}']");

            if (xe != null)
            {
                email    = xe.Attribute("email").Value;
                password = xe.Attribute("password").Value;
                return(true);
            }
            else
            {
                Trace.WriteLine($"mega login not found \"{name}\"");
                return(false);
            }
        }
Esempio n. 2
0
File: pt.cs Progetto: 24/source_04
        public static void RenameFile()
        {
            //Trace.WriteLine("current directory \"{0}\"", Directory.GetCurrentDirectory());
            bool   recurseDir = false;
            bool   simulate   = true;
            bool   moveFile   = false;
            string printFile  = null;

            foreach (string opt in _options)
            {
                if (opt == "-r")
                {
                    simulate = false;
                }
                if (opt == "-s")
                {
                    simulate = true;
                }
                if (opt == "-m")
                {
                    moveFile = true;
                }
                if (opt == "-nm")
                {
                    moveFile = false;
                }
                if (opt.StartsWith("-n:"))
                {
                    printFile = opt.Substring(3);
                }
            }
            Trace.Write("rename file (");
            if (simulate)
            {
                Trace.Write("simulate");
            }
            else
            {
                Trace.Write("real");
            }
            if (moveFile)
            {
                Trace.Write(" rename and move file");
            }
            else
            {
                Trace.Write(" rename file");
            }
            Trace.Write(") ");
            foreach (string arg in _args)
            {
                Trace.Write(" {0}", arg);
            }
            if (printFile != null)
            {
                Trace.Write(" name:\"{0}\"", printFile);
            }
            Trace.WriteLine();

            //Trace.WriteLine("init PrintManager start");
            //PrintManager_v2 pm = new PrintManager_v2(_printConfig.GetElement("Print"));
            PrintManager pm = new PrintManager(_printConfig.GetElement("Print"));
            //Trace.WriteLine("init PrintManager end");

            SearchOption option = SearchOption.TopDirectoryOnly;

            if (recurseDir)
            {
                option = SearchOption.AllDirectories;
            }
            string dir         = ".";
            string filePattern = "*.pdf";

            if (_args.Length > 0)
            {
                filePattern = _args[0];
                string dir2 = zPath.GetDirectoryName(filePattern);
                if (dir2 != "")
                {
                    dir = dir2;
                }
                filePattern = zPath.GetFileName(filePattern);
            }
            //Trace.WriteLine("read directory start");
            string[] files = zDirectory.GetFiles(dir, filePattern, option);
            //Trace.WriteLine("read directory end");
            if (printFile != null && files.Length > 1)
            {
                throw new PBException("can't use option name with more than one file");
            }
            if (files.Length == 0)
            {
                Trace.WriteLine("file not found");
            }
            foreach (string file in files)
            {
                try
                {
                    //Trace.WriteLine("RenameFile start");
                    zprint.RenameFile(pm, file, simulate, moveFile, printFile);
                    //Trace.WriteLine("RenameFile end");
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex.Message);
                    Trace.WriteLine(ex.StackTrace);
                }
            }
        }