private static CompositeKey KeyFromParams(EcasAction a, int iPassword,
                                                  int iKeyFile, int iUserAccount)
        {
            string strPassword  = EcasUtil.GetParamString(a.Parameters, iPassword, true);
            string strKeyFile   = EcasUtil.GetParamString(a.Parameters, iKeyFile, true);
            bool   bUserAccount = EcasUtil.GetParamBool(a.Parameters, iUserAccount);

            CompositeKey cmpKey = null;

            if (!string.IsNullOrEmpty(strPassword) || !string.IsNullOrEmpty(strKeyFile) ||
                bUserAccount)
            {
                List <string> vArgs = new List <string>();
                if (!string.IsNullOrEmpty(strPassword))
                {
                    vArgs.Add("-" + AppDefs.CommandLineOptions.Password + ":" + strPassword);
                }
                if (!string.IsNullOrEmpty(strKeyFile))
                {
                    vArgs.Add("-" + AppDefs.CommandLineOptions.KeyFile + ":" + strKeyFile);
                }
                if (bUserAccount)
                {
                    vArgs.Add("-" + AppDefs.CommandLineOptions.UserAccount);
                }

                CommandLineArgs cmdArgs = new CommandLineArgs(vArgs.ToArray());
                cmpKey = KeyUtil.KeyFromCommandLine(cmdArgs);
            }

            return(cmpKey);
        }
Example #2
0
        private static CompositeKey KeyFromParams(EcasAction a, int iPassword,
                                                  int iKeyFile, int iUserAccount, IOConnectionInfo ioc)
        {
            string strPassword  = EcasUtil.GetParamString(a.Parameters, iPassword, true);
            string strKeyFile   = EcasUtil.GetParamString(a.Parameters, iKeyFile, true);
            bool   bUserAccount = EcasUtil.GetParamBool(a.Parameters, iUserAccount);

            byte[] pbPasswordUtf8 = null;
            if (!string.IsNullOrEmpty(strPassword))
            {
                pbPasswordUtf8 = StrUtil.Utf8.GetBytes(strPassword);
            }

            return(KeyUtil.CreateKey(pbPasswordUtf8, strKeyFile, bUserAccount,
                                     ioc, false, false));
        }
        internal void NotifyUserActivity()
        {
            // if(!m_bEnabled) return;

            foreach (EcasTrigger t in m_vTriggers)
            {
                foreach (EcasEvent e in t.EventCollection)
                {
                    if (!e.Type.Equals(EcasEventIDs.TimePeriodic))
                    {
                        continue;
                    }

                    if (EcasUtil.GetParamBool(e.Parameters, 1))
                    {
                        e.RestartTimer();
                    }
                }
            }
        }
        private static void ExecuteShellCmd(EcasAction a, EcasContext ctx)
        {
            string strCmd       = EcasUtil.GetParamString(a.Parameters, 0);
            string strArgs      = EcasUtil.GetParamString(a.Parameters, 1, true, true);
            bool   bWait        = EcasUtil.GetParamBool(a.Parameters, 2);
            uint   uWindowStyle = EcasUtil.GetParamUInt(a.Parameters, 3);
            string strVerb      = EcasUtil.GetParamString(a.Parameters, 4, true);

            if (string.IsNullOrEmpty(strCmd))
            {
                return;
            }

            Process p = null;

            try
            {
                PwEntry pe = null;
                try { pe = Program.MainForm.GetSelectedEntry(false); }
                catch (Exception) { Debug.Assert(false); }

                strCmd = WinUtil.CompileUrl(strCmd, pe, true, null, false);

                ProcessStartInfo psi = new ProcessStartInfo();
                psi.FileName = strCmd;
                if (!string.IsNullOrEmpty(strArgs))
                {
                    psi.Arguments = strArgs;
                }

                bool bShEx = true;
                if (!string.IsNullOrEmpty(strVerb))
                {
                }                                                      // Need ShellExecute
                else if ((uWindowStyle == IdWindowMin) ||
                         (uWindowStyle == IdWindowMax))
                {
                }                                                          // Need ShellExecute
                else
                {
                    string strCmdFlt = strCmd.TrimEnd(new char[] { '\"', '\'',
                                                                   ' ', '\t', '\r', '\n' });
                    if (strCmdFlt.EndsWith(".exe", StrUtil.CaseIgnoreCmp) ||
                        strCmdFlt.EndsWith(".com", StrUtil.CaseIgnoreCmp))
                    {
                        bShEx = false;
                    }
                }
                psi.UseShellExecute = bShEx;

                if (uWindowStyle == IdWindowHidden)
                {
                    psi.CreateNoWindow = true;
                    psi.WindowStyle    = ProcessWindowStyle.Hidden;
                }
                else if (uWindowStyle == IdWindowMin)
                {
                    psi.WindowStyle = ProcessWindowStyle.Minimized;
                }
                else if (uWindowStyle == IdWindowMax)
                {
                    psi.WindowStyle = ProcessWindowStyle.Maximized;
                }

                if (!string.IsNullOrEmpty(strVerb))
                {
                    psi.Verb = strVerb;
                }

                p = NativeLib.StartProcessEx(psi);

                if ((p != null) && bWait)
                {
                    Program.MainForm.UIBlockInteraction(true);
                    MessageService.ExternalIncrementMessageCount();

                    try { p.WaitForExit(); }
                    catch (Exception) { Debug.Assert(false); }

                    MessageService.ExternalDecrementMessageCount();
                    Program.MainForm.UIBlockInteraction(false);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(strCmd + MessageService.NewParagraph + ex.Message);
            }
            finally
            {
                try { if (p != null)
                      {
                          p.Dispose();
                      }
                }
                catch (Exception) { Debug.Assert(false); }
            }
        }