Example #1
0
 //----< subscribe to new message events >------------------------
 public Window1()
 {
     InitializeComponent();
       OnNewMessage += new NewMessage(OnNewMessageHandler);
       button1.IsEnabled = false;
       button3.IsEnabled = false;
       button4.IsEnabled = false;
 }
Example #2
0
 /// <summary>
 /// To call the event <see cref="Connector.NewMessage"/>.
 /// </summary>
 /// <param name="message">A new message.</param>
 private void RaiseNewMessage(Message message)
 {
     NewMessage?.Invoke(message);
 }
Example #3
0
        public Task SendToOthers(Message message)
        {
            var messageForClient = NewMessage.Create(Context.Items["Name"] as string, message);

            return(Clients.Others.Send(messageForClient));
        }
Example #4
0
        private void ClientOnOnMessageReceived(NewMessage obj)
        {
            try
            {
                _client.ConversationLookup.TryGetValue(obj.channel, out var conversation);
                _client.UserLookup.TryGetValue(obj.user, out var user);

                var chatType = BotChatType.Channel;
                var chatId   = obj.channel;
                var chatName = obj.channel;

                if (conversation is Channel cnn)
                {
                    chatType = cnn.is_group ? BotChatType.Group : BotChatType.Channel;
                    chatName = cnn.name;
                }
                else if (conversation is DirectMessageConversation dmc)
                {
                    chatType = BotChatType.Private;
                    if (_client.UserLookup.TryGetValue(dmc.user, out var privateUser))
                    {
                        chatName = privateUser.name;
                    }
                    else
                    {
                        chatName = dmc.user;
                    }
                }

                var message = new BotTextMessage
                {
                    Id   = obj.id.ToString(),
                    Date = obj.ts,
                    Text = obj.text,
                    Chat = new BotChat
                    {
                        ChatType = chatType,
                        Id       = chatId,
                        Name     = chatName
                    },
                    User = new SlackBotUser
                    {
                        Id        = user?.id ?? obj.user,
                        Name      = user?.name ?? obj.user,
                        Color     = user?.color,
                        Presence  = user?.presence,
                        Email     = user?.profile?.email,
                        FirstName = user?.profile?.first_name,
                        LastName  = user?.profile?.last_name,
                        RealName  = user?.profile?.real_name,
                        Skype     = user?.profile?.skype,
                        Phone     = user?.profile?.phone
                    }
                };
                TextMessageReceived?.Invoke(this, new EventArgs <BotTextMessage>(message));
            }
            catch (Exception ex)
            {
                Core.Log.Write(ex);
            }
        }
Example #5
0
        private int PerformBuild(NewMessage userMsg, bool isQuietMode)
        {
            int buildErrorLevel = 0;

            string buildTimeEntry = DateTime.Now + " - Starting Build.";

            buildTimes.Add(buildTimeEntry);
            Console.WriteLine(buildTimeEntry);

            // make sure build_temp exists
            string buildTempDirectory = Path.Combine(pbDataSet.GetBuildProperty("BuildPath"), "build_temp");

            if (!Directory.Exists(buildTempDirectory))
            {
                Directory.CreateDirectory(buildTempDirectory);
            }

            // run the build batch file
            string buildCommandLineArgs = pbDataSet.GetBuildProperty("BuildDefinitionFileName");

            RunBatch(pbDataSet.GetBuildProperty("BuildBatchFileName"),
                     buildCommandLineArgs,
                     pbDataSet.GetBuildProperty("BuildPath"), isQuietMode,
                     (8 * 60 * 60 * 1000), userMsg);

            string buildCompleteTimeEntry = DateTime.Now + " - Build Finished.";

            Console.WriteLine(buildCompleteTimeEntry);

            // add entries into buildTimes from build
            string buildTimesFilename = pbDataSet.GetBuildProperty("BuildTimesFileName");

            if (File.Exists(buildTimesFilename))
            {
                StringCollection tempBuildTimes = CollectionUtil.ReadValueFile(pbDataSet.GetBuildProperty("BuildTimesFileName"));
                foreach (string line in tempBuildTimes)
                {
                    buildTimes.Add(line);
                }
            }
            buildTimes.Add(buildCompleteTimeEntry);

            // get success information
            bool warning  = false;
            bool error    = false;
            bool complete = false;

            char[] colon = new char[] { ':' };
            string status;

            string[] tokens;

            string           buildStepStatusFilename = pbDataSet.GetBuildProperty("BuildStepStatusFileName");
            StringCollection buildStepStatus         = new StringCollection();

            if (File.Exists(buildStepStatusFilename))
            {
                buildStepStatus = CollectionUtil.ReadValueFile(buildStepStatusFilename);
            }

            foreach (string line in buildStepStatus)
            {
                status = null;
                tokens = line.Split(colon);
                if (tokens.Length > 1)
                {
                    status = tokens[1].ToLower().Trim();
                }
                if (status == "error")
                {
                    error = true;
                }
                if (status == "warning")
                {
                    warning = true;
                }
                if (status == "complete")
                {
                    complete = true;
                }
            }
            if (!complete)
            {
                buildErrorLevel = 3;
            }
            else if (error)
            {
                buildErrorLevel = 2;
            }
            else if (warning)
            {
                buildErrorLevel = 1;
            }
            Console.WriteLine(GetBuildErrorLevelString(buildErrorLevel));

            return(buildErrorLevel);
        }
Example #6
0
        /// <returns>Returns exit code of the application.</returns>
        private int RunBatchWithInternalOutputHandling(string batchFileName, string cmdArgs, string workingDir,
                                                       bool isQuietMode, int waitTime, NewMessage userMessage)
        {
            if (userMessage.Cancelled)
            {
                return(0);
            }

            // RunBatch() pipes output of the app to LogMsg.exe (which will post it
            // to the message queue). A consequence of this approach is that the exit code
            // that the Process object returns after the process completes is always 0.
            // (Perhaps the last app that terminates is LogMsg, and its exit code is 0.)
            //
            // This method can be used when getting the exit code is important.
            // For example, when we run validation, we need to terminate the build if
            // validation fails.
            //
            // To resolve the problem, we will manually read app output, and post it
            // to the message queue.
            // When the app exits, we will append all collected output to build log file.
            // (RunBatch() also redirects output to the build log file)

            if (cmdArgs == null)
            {
                cmdArgs = "";
            }
            cmdArgs += " 2>&1";

            using (Process buildProcess = new Process()) {
                buildProcess.StartInfo.FileName         = batchFileName;
                buildProcess.StartInfo.Arguments        = cmdArgs;
                buildProcess.StartInfo.WorkingDirectory = workingDir;
                buildProcess.StartInfo.CreateNoWindow   = false;
                buildProcess.StartInfo.UseShellExecute  = false;

                buildProcess.StartInfo.RedirectStandardInput  = false;
                buildProcess.StartInfo.RedirectStandardError  = false;
                buildProcess.StartInfo.RedirectStandardOutput = true;
                buildProcess.Start();

                userMessage.MonitorCancell(buildProcess.Id);

                string processOutput = "";
                while (true)
                {
                    String outputLine = buildProcess.StandardOutput.ReadLine();
                    if (outputLine == null)
                    {
                        break;
                    }

                    processOutput += (outputLine + "\r\n");
                    userMessage.SendCopyMessage(outputLine, 0, 0);
                }

                bool exited = buildProcess.WaitForExit(waitTime);

                int exitCode;
                if (!exited)
                {
                    buildProcess.Kill();
                    exitCode = -1;
                }
                else
                {
                    exitCode = buildProcess.ExitCode;
                }

                buildProcess.Close();

                string logFilePath = GetBuildLogfile();
                Console.WriteLine("Echoing output to " + logFilePath);
                using (StreamWriter writer = new StreamWriter(logFilePath, true)) {
                    writer.WriteLine(processOutput);
                    writer.Close();
                }

                return(exitCode);
            }
        }
Example #7
0
 /// <inheritdoc />
 public async Task <int> CreateMessage(NewMessage newMessage)
 {
     throw new System.NotImplementedException();
 }
Example #8
0
 protected virtual void OnNewMessage(LogMessage e)
 {
     NewMessage?.Invoke(this, e);
 }
Example #9
0
 public abstract Task SendAnswer(BotClient client, NewMessage message);
Example #10
0
 public abstract bool CanHandleMessage(BotClient client, NewMessage message);
Example #11
0
 /// <summary>
 /// Used to synchronously call the methods supported by the delegate object.
 /// </summary>
 /// <param name="newMessageToClientEventArgs"> Type to receive a message when an event occurs. </param>
 protected void OnNewMessage(NewMessageToClientEventArgs newMessageToClientEventArgs)
 {
     NewMessage?.Invoke(this, newMessageToClientEventArgs);
 }
Example #12
0
 public CommandArgs(string commandName, List <string> parameters, User executingUser, NewMessage messageData)
 {
     CommandName   = commandName;
     Parameters    = parameters;
     ExecutingUser = executingUser;
     MessageData   = messageData;
 }
Example #13
0
        public async Task Send(NewMessage sendedMessage)
        {
            var message = await chatRepository.AddMessage(sendedMessage.Text, sendedMessage.ChatId, Context.User.Identity.Name);

            await Clients.Users(Context.User.Identity.Name, sendedMessage.UserNameTo).SendAsync("Recived", message);
        }
 public static MessageToSend UserTurnsDownInvitation(this NewMessage incoming)
 {
     return(incoming.CreateResponseMessage("That is too bad, I will try to find someone else. \n" +
                                           "If you don't want to receive any more invitations from me try typing `opt out`"));
 }
Example #15
0
 public string GetLine()
 {
     NewMessage?.Invoke("Pattern Event Test");
     return("PatternTest");
 }
Example #16
0
 private bool IsRegularMessage(NewMessage message)
 {
     return(this.IsRegularMessage(message.user, message.subtype));
 }
Example #17
0
        public List <MefAddIns.Extensibility.mef_IBase> BuildListOfAddins()
        {
            if (CoreUtilities.Constants.BLANK == dataPath)
            {
                throw new Exception("No path defined for AddIns");
            }
            lg.Instance.Line("AddIns.BuildListOfAddIns", ProblemType.MESSAGE, String.Format("Scanning {0} for addins", dataPath));

            var bootStrapper = new MefAddIns.Terminal.Bootstrapper();
            //An aggregate catalog that combines multiple catalogs
            var catalog = new AggregateCatalog();

            //Adds all the parts found in same directory where the application is running!
            //var currentPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(MainForm)).Location);
            catalog.Catalogs.Add(new DirectoryCatalog(dataPath));

            //Create the CompositionContainer with the parts in the catalog
            var _container = new CompositionContainer(catalog);

            //Fill the imports of this object
            try {
                _container.ComposeParts(bootStrapper);
            } catch (CompositionException compositionException) {
                //CoreUtilities.lg.Instance.Line ("AddIns->BuildListOfAddIns", ProblemType.EXCEPTION, compositionException.ToString ());
                NewMessage.Show(compositionException.ToString());
            } catch (System.Reflection.ReflectionTypeLoadException) {
                CoreUtilities.lg.Instance.Line("AddIns->BuildListOfAddIns", ProblemType.EXCEPTION, "At least one AddIn does not implement the entirety of the needed Interface Contract");
                NewMessage.Show("At least one AddIn does not implement the entirety of the needed Interface Contract");
            }

            //Prints all the languages that were found into the application directory
            var i = 0;

            AddInsList = new List <MefAddIns.Extensibility.mef_IBase> ();

            //var bootStrapper = new MefAddIns.Terminal.Bootstrapper ();
            // May 2013 _ I was able to load in transactions but was still unable to get them to work properly, in all cases
            // hence Submission and Destination will need to remain in Transactions base class

//			foreach (var transaction in bootStrapper.tbase) {
//				NewMessage.Show (transaction.ToString());
//			}

            foreach (var language in bootStrapper.Base)
            {
                // We look to see if this is a copy of another addin loaded already
                mef_IBase AddInAlreadyIn = AddInsList.Find(mef_IBase => mef_IBase.CalledFrom.GUID == language.CalledFrom.GUID);
                if (null != AddInAlreadyIn)
                {
                    lg.Instance.Line("AddIns.BuildListOfAddIns", ProblemType.MESSAGE, "This AddIn is already found. Adding as a copy");
                    language.SetGuid(language.CalledFrom.GUID + Loc.Instance.GetString(" (COPY) "));
                    language.IsCopy = true;
                }
                lg.Instance.Line("AddIns.BuildListOfAddIns", ProblemType.MESSAGE,
                                 String.Format("[{0}] {1} by {2}.\n\t{3}\n", language.Version, language.Name, language.Author, language.Description));

                i++;
                language.SetStorage(DatabaseName);
                AddInsList.Add(language);
            }

//			// added this back in, but as part of the "Consdensceing process", will remove again TO DO
//			foreach (var language in bootStrapper.Notes) {
//
//				// We look to see if this is a copy of another addin loaded already
//				mef_IBase AddInAlreadyIn = AddInsList.Find (mef_IBase => mef_IBase.CalledFrom.GUID == language.CalledFrom.GUID);
//				if (null != AddInAlreadyIn)
//				{
//					lg.Instance.Line("AddIns.BuildListOfAddIns", ProblemType.MESSAGE,"This AddIn is already found. Adding as a copy");
//					language.SetGuid(language.CalledFrom.GUID +  Loc.Instance.GetString(" (COPY) "));
//					language.IsCopy = true;
//
//				}
//				lg.Instance.Line("AddIns.BuildListOfAddIns", ProblemType.MESSAGE,
//				                 String.Format ("[{0}] {1} by {2}.\n\t{3}\n", language.Version, language.Name, language.Author, language.Description));
//
//				i++;
//				AddInsList.Add (language);
//
//
//
//			}

//			foreach (var form in bootStrapper.FormBasic) {
//
//				// We look to see if this is a copy of another addin loaded already
//				mef_IBase AddInAlreadyIn = AddInsList.Find (mef_IBase => mef_IBase.CalledFrom.GUID == form.CalledFrom.GUID);
//				if (null != AddInAlreadyIn)
//				{
//					lg.Instance.Line("AddIns.BuildListOfAddIns", ProblemType.MESSAGE,"This AddIn is already found. Adding as a copy");
//					form.SetGuid(form.CalledFrom.GUID +  Loc.Instance.GetString(" (COPY) "));
//					form.IsCopy = true;
//
//				}
//				lg.Instance.Line("AddIns.BuildListOfAddIns", ProblemType.MESSAGE,
//				                 String.Format ("[{0}] {1} by {2}.\n\t{3} {4}\n", form.Version, form.Name, form.Author, form.Description, form.IsCopy));
//
//				i++;
//				AddInsList.Add (form);
//
////				form.ShowWindow();
//			}

            /*
             * foreach (var note in bootStrapper.Notes) {
             *      Console.WriteLine ("[{0}] {1} by {2}.\n\t{3}\n", note.Version, note.Name, note.Author, note.Description);
             *      AddInsList.Add (note);
             *      //language.Boom ();
             *      //string result = language.Tester ("this is the string I passed in");
             *      //Console.WriteLine ("RESULT = " + result);
             *
             * //				note.RegisterType();
             * }
             */

            lg.Instance.Line("AddIns.BuildListOfAddIns", ProblemType.MESSAGE, String.Format("AddIns Found: {0}.", i));

            return(AddInsList);

            //
        }
Example #18
0
 private void AddNewFilm(NewMessage <FilmWrappedModel> _) => SelectedView = FilmDetailViewModel;
Example #19
0
 private void NewMessageHandler(Message message)
 {
     AddGuiAction(() => NewMessage.SafeInvoke(message));
 }
Example #20
0
 private void AddNewDirector(NewMessage <DirectorWrappedModel> _) => SelectedView = DirectorDetailViewModel;
Example #21
0
        public int Run(NewMessage userMsg, bool isQuietMode)
        {
            int buildErrorLevel = BUILDSTATUS_INCOMPLETE;

            isValidationSuccessful = true;

            try {
                startTime = DateTime.Now;
                //must not build on net path
                if (LibraryManifest.IsNetworkPath(pbDataSet.GetBuildProperty("BuildPath")))
                {
                    string errorMsg = "Builds are not allowed on VMS product directories; ";
                    errorMsg += "please select a different build path and try again.";
                    throw new Exception(errorMsg);
                }

                // register build start in BUILD_STATUS
                RegisterBuildStart();

                // allow log to be overwritten
                SetBuildLogfile(pbDataSet.GetBuildProperty("BuildLogFileName"));
                if (File.Exists(GetBuildLogfile()))
                {
                    File.SetAttributes(GetBuildLogfile(), FileAttributes.Normal);
                    File.Delete(GetBuildLogfile());
                    FileStream logFile = File.Create(GetBuildLogfile());
                    logFile.Close();
                }

                if (!pbDataSet.SourcePathEqualsBuildPath() && !userMsg.IsCancelled())
                {
                    try {
                        ValidateLibrary(userMsg, isQuietMode);
                    }
                    catch (Exception e) {
                        isValidationSuccessful = false;
                        throw e;
                    }
                }

                if (!userMsg.IsCancelled())
                {
                    buildErrorLevel = PerformBuild(userMsg, isQuietMode);
                }
            }
            catch (Exception e) {
                buildErrorLevel = BUILDSTATUS_FAILED;
                throw e;
            }
            finally {
                completeTime = DateTime.Now;

                // register build finish in BUILD_STATUS
                RegisterBuildFinish(buildErrorLevel);

                SaveReport(buildErrorLevel, userMsg, isQuietMode);

                SendEmail(buildErrorLevel);
            }

            return(buildErrorLevel);
        }
Example #22
0
 /// <summary>
 /// To call the event <see cref="Connector.NewMessage"/>.
 /// </summary>
 /// <param name="message">A new message.</param>
 private void RaiseNewMessage(Message message)
 {
     NewMessage.SafeInvoke(message);
 }
Example #23
0
        private void ValidateLibrary(NewMessage userMsg, bool isQuietMode)
        {
            string buildTimeEntry = DateTime.Now + " - Starting Validate.";

            buildTimes.Add(buildTimeEntry);
            Console.WriteLine(buildTimeEntry);

            string buildPath  = pbDataSet.GetBuildProperty("BuildPath");
            string sourcePath = pbDataSet.GetBuildProperty("SourcePath");

            // save build configuration file
            string buildDefinitionFile = ProductBuildDataSet.GetBuildConfigurationFilename(buildPath);
            string tempFile            = ProductBuildDataSet.GetBuildConfigurationFilename(Path.GetTempPath());

            if (File.Exists(tempFile))
            {
                File.SetAttributes(tempFile, FileAttributes.Normal);
                File.Delete(tempFile);
            }
            string tempBuildDefinitionDirectory = Path.Combine(Path.GetPathRoot(tempFile), Path.GetDirectoryName(tempFile));

            if (!Directory.Exists(tempBuildDefinitionDirectory))
            {
                Directory.CreateDirectory(tempBuildDefinitionDirectory);
            }
            File.Move(buildDefinitionFile, tempFile);


            // copy build definition file into buildpath
            string buildDefinitionDirectory = Path.Combine(Path.GetPathRoot(buildDefinitionFile), Path.GetDirectoryName(buildDefinitionFile));

            if (Directory.Exists(buildDefinitionDirectory))
            {
                Directory.Delete(buildDefinitionDirectory, true);
            }
            Directory.CreateDirectory(buildDefinitionDirectory);
            File.Move(tempFile, buildDefinitionFile);

            string errorMsg = null;

            if (false == CanBuildOnPath(sourcePath, buildPath, ref errorMsg))
            {
                throw new Exception(errorMsg);
            }

            string buildLibName;
            string createDate;

            if (LibraryManifest.IsNetworkPath(sourcePath))
            {
                buildLibName = "NETWORK_" + libraryManifest.GetBranchOrTrunkName() + "_BUILD";
                createDate   = new DateTime(DatabaseInterface.GetCurrentServerTime()).ToString();
            }
            else
            {
                buildLibName = "LOCAL_" + libraryManifest.GetBranchOrTrunkName() + "_BUILD";
                createDate   = libraryManifest.GetDate();
            }


            // Attempt to run LB three times. Try the first time in quiet mode.
            // Disable "quiet mode" on a retry, hoping to get information
            // useful to determine the source of problem.
            string quietModeArg          = "/q";
            int    lbExitCode            = 0;
            int    attemptCount          = 0;
            string validateBatchFilePath = buildPath + "\\validate.bat";

            while (true)
            {
                string validateCmd = LibraryBuilderConfig.GetLbCommandLinePath() + " /c " + quietModeArg + " /nocopy /src:" + sourcePath + " /path:" + buildPath;
                validateCmd += " /name:" + buildLibName + " /date:\"" + createDate + "\"";

                //create bat file in buildPath and save
                StreamWriter cmdWriter = new StreamWriter(validateBatchFilePath, false);
                cmdWriter.WriteLine(validateCmd);
                cmdWriter.WriteLine("@set LB__EXIT__CODE=%ERRORLEVEL%");
                cmdWriter.WriteLine("@echo Library validation: LB exited with code: %LB__EXIT__CODE%");
                cmdWriter.WriteLine("@exit %LB__EXIT__CODE%");
                cmdWriter.Close();

                lbExitCode = RunBatchWithInternalOutputHandling(validateBatchFilePath, null, buildPath, isQuietMode, (1 * 60 * 60 * 1000), userMsg);
                Console.WriteLine("LB exited with code: " + lbExitCode);

                if (lbExitCode != 0 && ++attemptCount < 3)
                {
                    Console.WriteLine("LB failed - retrying...");
                    quietModeArg = "";
                    continue;
                }

                break;
            }

            File.Delete(validateBatchFilePath);

            if (lbExitCode != 0)
            {
                Console.WriteLine("Unable to validate library, terminating build...");
                throw new Exception("Unable to validate library. Please see build log for details.");
            }

            // refresh LibraryInfo file with current datetime
            LibraryManifest lif = new LibraryManifest(
                pbDataSet.GetBuildProperty("ProductName"),
                pbDataSet.GetBuildProperty("ProductVersion"),
                pbDataSet.GetBuildProperty("ProductPlatform"),
                pbDataSet.GetBuildProperty("BranchOrTrunkName"),
                pbDataSet.GetBuildProperty("ProductDirectory"),
                pbDataSet.GetBuildProperty("LibraryDate"));

            lif.SaveToPath(pbDataSet.GetBuildProperty("BuildPath"));

            buildTimeEntry = DateTime.Now + " - Validate Complete.";
            if (pbDataSet.IsPartialBuild())
            {
                string binCopyCmd = Path.Combine(pbDataSet.GetBuildProperty("PBToolsPath"),
                                                 "CopyBinaries.bat");
                string copyArgs = " " + sourcePath + " " + buildPath;
                RunBatch(binCopyCmd, copyArgs, buildPath, isQuietMode, (1 * 60 * 60 * 1000), userMsg);
            }
            buildTimes.Add(buildTimeEntry);
            Console.WriteLine(buildTimeEntry);
        }
        /// <summary>Delegate method invoked by rcReadMessage.</summary>
        protected void ExecuteReadMessage()
        {
            byte[] abMessageBytes;
            string sErrorMessage, sMatchedKeyMessage;
            PgpFile MessageFile;
            PgpMessage NewMessage = null;
            BytesAndTextUtility BytesAndText;

            if (isExecuteReadMessage)
            {
                MessageFile = new PgpFile();
                abMessageBytes = MessageFile.GetBytes(_sInputMessageFilePath, false);

                switch (MessageFile.eStatus)
                {
                    case PgpArmor.nStatus.CrcError: sErrorMessage = string.Format(sFileCrcError, _sInputKeyFilePath); break;
                    case PgpArmor.nStatus.ParseError: sErrorMessage = string.Format(sFileParseError, _sInputKeyFilePath); break;
                    case PgpArmor.nStatus.Undefined: sErrorMessage = string.Format(sFileError, _sInputKeyFilePath); break;
                    default: sErrorMessage = string.Empty; break;
                }

                if (string.IsNullOrEmpty(sErrorMessage))
                {
                    NewMessage = new PgpMessage(abMessageBytes, _Cryptography);

                    switch (NewMessage.eStatus)
                    {
                        case PgpMessage.nStatus.ParseErrorRaw: sErrorMessage = string.Format(sFileParseError, _sInputMessageFilePath); break;
                        case PgpMessage.nStatus.ParseErrorSub: sErrorMessage = string.Format(sFileParseErrorSub, _sInputMessageFilePath); break;
                        case PgpMessage.nStatus.Undefined: sErrorMessage = string.Format(sFileError, _sInputMessageFilePath); break;
                        default: sErrorMessage = string.Empty; break;
                    }
                }

                if (string.IsNullOrEmpty(sErrorMessage))
                {
                    if (NewMessage != null)   // just to be sure, but this should always be true 
                    {
                        NewMessage.MatchPublicKeys(_ltTokens);
                        BytesAndText = new BytesAndTextUtility();

                        foreach (PgpPublicKeyEncryptedKey WrappedKey in NewMessage.ltPublicKeyEncryptedKeys)
                        {
                            if (WrappedKey.MatchedPublicKey == null)
                            {
                                BytesAndText.abBytes = WrappedKey.abPublicKeyId;
                                sMatchedKeyMessage = string.Format(sPublicKeyNotMatched, BytesAndText.sHexadecimalBytes);
                            }
                            else
                                sMatchedKeyMessage = string.Format(sPublicKeyMatched, WrappedKey.sUserId);

                            _blMessages.Add(new Property(DateTime.Now, sMatchedKeyMessage));
                        }
                    }
                }
                else
                {
                    _blMessages.Add(new Property(DateTime.Now, sErrorMessage));
                    eMenuTab = nMenuTab.Progress;
                }
            }
        }
Example #25
0
        private void SaveReport(int buildErrorLevel, NewMessage userMsg, bool isQuietMode)
        {
            string saveBuildReport = pbDataSet.GetBuildProperty("SaveBuildReport");

            if (saveBuildReport == null || saveBuildReport.ToUpper() != "TRUE")
            {
                return;
            }

            string buildName          = GetBuildName();
            string buildNameDirectory = Path.Combine(LBEnvironment.BuildReportRootDirectory, buildName);
            string buildDateDirectory = Path.Combine(buildNameDirectory, startTime.ToString("yyyyMMdd_HHmmss"));

            StringBuilder  buildReportStringBuilder = new StringBuilder();
            HtmlTextWriter reportWriter             = new HtmlTextWriter(new StringWriter(buildReportStringBuilder));

            reportWriter.WriteLine("<HTML><BODY><PRE>");

            reportWriter.WriteLine("Build Name:               " + buildName);
            reportWriter.WriteLine("Build Machine:            " + Environment.MachineName);
            reportWriter.WriteLine("Build User:               "******"\\" + Environment.UserName);
            reportWriter.WriteLine("Build Start Time:         " + startTime);
            reportWriter.WriteLine("Build Completion Time:    " + completeTime);
            reportWriter.WriteLine("Build Status:             " + GetBuildErrorLevelString(buildErrorLevel));
            reportWriter.WriteLine("Library Date:             " + pbDataSet.GetBuildProperty("LibraryDate"));
            reportWriter.WriteLine("-------------------------------------------------------------------------");
            reportWriter.WriteLine();

            if (isValidationSuccessful)
            {
                reportWriter.WriteLine("Build Times:");
                reportWriter.WriteLine();
                string           buildTimesFilename = pbDataSet.GetBuildProperty("BuildTimesFileName");
                StringCollection buildTimes         = new StringCollection();
                if (File.Exists(buildTimesFilename))
                {
                    buildTimes = CollectionUtil.ReadValueFile(buildTimesFilename);
                }
                else
                {
                    buildTimes.Add("-- The Build Times Output File, " + buildTimesFilename + ", is Missing --");
                }
                foreach (string line in buildTimes)
                {
                    reportWriter.WriteLine(line);
                }
                reportWriter.WriteLine("-------------------------------------------------------------------------");

                reportWriter.WriteLine();
                reportWriter.WriteLine("Build Step Results:");
                reportWriter.WriteLine();
                string           buildStepStatusFilename = pbDataSet.GetBuildProperty("BuildStepStatusFileName");
                StringCollection buildStepStatus         = new StringCollection();
                if (File.Exists(buildStepStatusFilename))
                {
                    buildStepStatus = CollectionUtil.ReadValueFile(buildStepStatusFilename);
                    buildStepStatus = ChangeToReportFormat(buildStepStatus, buildDateDirectory);
                }
                else
                {
                    buildStepStatus.Add("-- The Build Step Status Output File, " + buildStepStatusFilename + ", is Missing --");
                }
                foreach (string line in buildStepStatus)
                {
                    reportWriter.WriteLine(line);
                }
                reportWriter.WriteLine("-------------------------------------------------------------------------");

                reportWriter.WriteLine();
                reportWriter.WriteLine("CheckBuild Results:");
                reportWriter.WriteLine();
                string           checkBuildResultsFilename = pbDataSet.GetBuildProperty("CheckBuildResultsFileName");
                StringCollection checkBuildResults         = new StringCollection();
                if (File.Exists(checkBuildResultsFilename))
                {
                    checkBuildResults = CollectionUtil.ReadValueFile(checkBuildResultsFilename);
                }
                else
                {
                    checkBuildResults.Add("-- The CheckBuild Output File, " + checkBuildResultsFilename + ", is Missing --");
                }
                foreach (string line in checkBuildResults)
                {
                    reportWriter.WriteLine(line);
                }
                reportWriter.WriteLine("-------------------------------------------------------------------------");

                reportWriter.WriteLine();
                reportWriter.WriteLine("Build Properties:");
                reportWriter.WriteLine();
                SortedList buildProperties = pbDataSet.GetBuildProperties();
                foreach (object key in buildProperties.Keys)
                {
                    if (((string)key).ToUpper() != "UNIXPASSWORD")
                    {
                        string keyString   = (string)key;
                        string valueString = buildProperties[key].ToString();
                        reportWriter.WriteLine(keyString + "=" + valueString);
                    }
                }
            }
            else
            {
                // unsuccessful validation
                reportWriter.WriteLine("LibraryBuilder was unable to create the local library on the build machine.");
                reportWriter.WriteLine("The build could not start.");
                reportWriter.WriteLine("If you get this error consistently, please contact VMS Administrator.");
                reportWriter.WriteLine();

                string           msg  = "Validation output file: Error: file://" + GetBuildLogfile();
                StringCollection coll = new StringCollection();
                coll.Add(msg);
                coll = ChangeToReportFormat(coll, buildDateDirectory);
                if (coll.Count > 0)
                {
                    msg = coll[0];
                }

                reportWriter.WriteLine(msg);
                reportWriter.WriteLine();
            }

            reportWriter.WriteLine("-------------------------------------------------------------------------");

            reportWriter.WriteLine("</PRE></HTML></BODY>");
            reportWriter.Close();

            Directory.CreateDirectory(buildDateDirectory);
            string       buildReportFile = Path.Combine(buildDateDirectory, "BuildReport.htm");
            StreamWriter sw = File.CreateText(buildReportFile);

            sw.Write(buildReportStringBuilder.ToString());
            sw.Close();

            // copy logs
            // If validation failed, copy only the single log with LB's output.
            string copylogsScript = (isValidationSuccessful ? "CopyLogs.bat" : "CopyMainLog.bat");
            string buildPath      = pbDataSet.GetBuildProperty("BuildPath");

            RunBatch(Path.Combine(pbDataSet.GetBuildProperty("PBToolsPath"), copylogsScript),
                     buildPath + " \"" + buildDateDirectory + "\"",
                     buildPath, isQuietMode, (1 * 60 * 60 * 1000), userMsg);
        }
Example #26
0
        /// <summary>
        /// Starts the and stop plug ins.
        /// </summary>
        void StartAndStopPlugIns()
        {
            if (null != addIns)
            {
                List <MefAddIns.Extensibility.mef_IBase> FullListOfAddins = addIns.BuildListOfAddins();
                List <string> myList = addIns.GetListOfInstalledPlugs();

                // TO DO: Need to set up an IsActive system. For now assume active=true;
                for (int i = 0; i < FullListOfAddins.Count; i++)
                {
                    MefAddIns.Extensibility.mef_IBase AddIn          = FullListOfAddins [i];
                    MefAddIns.Extensibility.mef_IBase AddInAlreadyIn = null;
                    if (AddInsLoaded != null)
                    {
                        AddInAlreadyIn = AddInsLoaded.Find(mef_IBase => mef_IBase.CalledFrom.GUID == AddIn.CalledFrom.GUID);
                    }
                    else
                    {
                        AddInsLoaded = new List <MefAddIns.Extensibility.mef_IBase> ();
                    }
                    if (AddInAlreadyIn == null)
                    {
                        if (myList.Contains(AddIn.CalledFrom.GUID) == true)
                        {
                            // If Plug not already Loaded then Load it
                            //NewMessage.Show ("Adding " + AddIn.Name);
                            AddInsLoaded.Add(AddIn);
                            AddIn.RegisterType();
                            AddIn.AssignHotkeys(ref Hotkeys, ref AddIn, RunAddInAction);
                            if (AddIn.CalledFrom.IsNoteAction == true)
                            {
                                // allow addins to override the noteaction menu name here if they are deploying with both a menu and note action
                                string menuNameToUse = AddIn.CalledFrom.MyMenuName;
                                if (AddIn.CalledFrom.NoteActionMenuOverride != Constants.BLANK)
                                {
                                    menuNameToUse = AddIn.CalledFrom.NoteActionMenuOverride;
                                }
                                NoteTextAction tmp = new NoteTextAction(AddIn.ActionWithParamForNoteTextActions, AddIn.BuildFileNameForActionWithParam, menuNameToUse, AddIn.CalledFrom.ToolTip);
                                tmp.Parent = NoteTextActions;
                                NoteTextActions.Add(tmp);
                                AddIn.Hookups.Add(tmp);
                            }
                            // February 2013 - removed the else. NoteActions and things with menus do not need exclusivity

                            if (AddIn.CalledFrom.IsOnAMenu == true)
                            {
                                string myMenuName = AddIn.CalledFrom.MyMenuName;
                                if (Constants.BLANK != myMenuName)
                                {
                                    string parentName = AddIn.CalledFrom.ParentMenuName;
                                    if (Constants.BLANK != parentName)
                                    {
                                        if (AddIn.CalledFrom.IsOnContextStrip == true)
                                        {
                                            // search for a context strip
                                            ContextMenuStrip strip = ContextMenus.Find(ContextMenuStrip => ContextMenuStrip.Name == parentName);
                                            if (strip != null)
                                            {
                                                ToolStripButton but = new ToolStripButton(AddIn.CalledFrom.MyMenuName);
                                                BuildAddinToolStrip(AddIn, but);
                                                strip.Items.Add(but);
                                            }
                                        }
                                        else                                                // search The MainMenuInstead
                                        {
                                            // add this menu option
                                            ToolStripItem[] items = MainMenu.Items.Find(parentName, true);
                                            if (items.Length > 0)
                                            {
                                                if (items [0].GetType() == typeof(ToolStripMenuItem))
                                                {
                                                    if (((ToolStripMenuItem)items [0]).DropDown != null)
                                                    {
                                                        ToolStripButton but = new ToolStripButton(AddIn.CalledFrom.MyMenuName);
                                                        BuildAddinToolStrip(AddIn, but);
                                                        //but.Tag = AddIn;
                                                        //but.AutoSize = true;
                                                        //but.Click += HandleAddInClick;
                                                        ((ToolStripMenuItem)items [0]).DropDownItems.Add(but);
                                                        // hack to make sure menu is 'wide enough' tried associating contextmenustrip but that did not help
                                                        ((ToolStripMenuItem)items [0]).DropDownItems.Remove(((ToolStripMenuItem)items [0]).DropDownItems.Add("removeme"));
                                                        //((ContextMenuStrip)((ToolStripMenuItem)items[0]).DropDown).Items.Add (but);
                                                        //		but.ToolTipText = AddIn.CalledFrom.ToolTip;
                                                        //	AdvancedStrip.Items.Add (but);
                                                        //((ContextMenuStrip)((ToolStripMenuItem)items[0]).Tag).Items.Add (but);
                                                        //												if (AddIn.CalledFrom.Image != null)
                                                        //												{
                                                        //													but.Image = AddIn.CalledFrom.Image;
                                                        //												}
                                                        //												AddIn.Hookups.Add (but);
                                                    }
                                                    else
                                                    {
                                                        NewMessage.Show(Loc.Instance.GetString("A dropdown contextmenustrip needs to be defined for parent menu item"));
                                                    }
                                                }
                                            }
                                        }
                                        // searching thru main mnenu
                                    }
                                    else
                                    {
                                        // create us as a parent
                                        ToolStripMenuItem parent = new ToolStripMenuItem(AddIn.CalledFrom.MyMenuName);
                                        //										parent.Click += HandleAddInClick;
                                        //										parent.Tag= AddIn;
                                        //										parent.ToolTipText = AddIn.CalledFrom.ToolTip;
                                        //										if (AddIn.CalledFrom.Image != null)
                                        //										{
                                        //											parent.Image = AddIn.CalledFrom.Image;
                                        //										}
                                        BuildAddinToolStrip(AddIn, parent);
                                        MainMenu.Items.Add(parent);
                                        //AddIn.Hookups.Add (parent);
                                    }
                                }
                            }
                            // OnAMenu
                        }
                        // Is allowed to be loaded (i.e., set in Options)
                        // We call this method. If this is a notetype we get registered, others ignore it
                    }
                    //Not Added Yet
                }


                // Remove installed plugins
                if (addIns.Count > 0)
                {
                    bool MustExit = false;
                    // We exist but we are not on the AddMe list.
                    // This means we need to be removed
                    for (int i = AddInsLoaded.Count - 1; i >= 0; i--)
                    {
                        MefAddIns.Extensibility.mef_IBase addin = AddInsLoaded [i];
                        // look at each plug and decide if it should be removed (i.e., it is no longer in the list to add
                        if (myList.Contains(addin.CalledFrom.GUID) == false)
                        {
                            // we are NOT in the list but we exist in the active list
                            // this means we must be destroyed!!
                            //	NewMessage.Show ("Destroy : " + addin.CalledFrom.GUID);

                            foreach (IDisposable connection in addin.Hookups)
                            {
                                //	NewMessage.Show ("Removing " + connection.ToString());
                                connection.Dispose();
                            }
                            if (addin.DeregisterType() == true)
                            {
                                NewMessage.Show(Loc.Instance.GetString("Because a NoteType (or other advanced AddIn) was removed, we must shut down now, because any Layout open will not be able to be edited until this NoteType is added again."));
                                MustExit = true;
                            }


                            AddInsLoaded.Remove(addin);
                        }
                    }
                    if (true == MustExit)
                    {
                        Application.Exit();
                    }
                }                 // count > 0
            }
        }
Example #27
0
 public void OnNewMessage(NewMessage newMessage, bool windowVisible)
 {
 }
Example #28
0
        static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                errorLevel = 3;
                Usage();
                return(errorLevel);
            }

            try {
                string    path = null;
                Hashtable commandLineProperties = new Hashtable();

                ProcessCommandLineArguments(args, ref path, commandLineProperties);

                LibraryManifest libraryInfo = new LibraryManifest(path);

                // default to Development profile
                string profileName            = "Development (Public)";
                string commandLineProfileName = (string)commandLineProperties["BuildProfileName"];
                profileName = (commandLineProfileName != null) ? commandLineProfileName : profileName;

                ProductBuildDataSet pbDataSet = ProductBuildDataSet.GetProductBuildDataSetWithoutComplist(
                    profileName,
                    libraryInfo.GetName(),
                    libraryInfo.GetVersion(),
                    libraryInfo.GetPlatform(),
                    libraryInfo.GetBranchOrTrunkName(),
                    libraryInfo.GetDirectory(),
                    path,
                    libraryInfo.GetDate());

                pbDataSet.ApplyCommandLineProperties(commandLineProperties);
                pbDataSet.LoadComplist();
                pbDataSet.FinalizeProperties();
                pbDataSet.WriteBuildConfigurationFile(pbDataSet.GetBuildConfigurationFilename());

                string           buildPath        = pbDataSet.GetBuildProperty("BuildPath");
                VmsProduct       currProduct      = new VmsProduct(libraryInfo.GetName(), libraryInfo.GetVersion(), libraryInfo.GetPlatform());
                VmsLibrary       currLibrary      = new VmsLibrary(currProduct, libraryInfo.GetBranchOrTrunkName());
                ControllerObject controllerObject = new ControllerObject();
                string           currentKey       = Util.GetServiceKey();
                bool             actionSucceeded  = false;
                string           errorMessage     = null;
                if (controllerObject.BuildLibrary(currLibrary, currentKey, buildPath, out errorMessage, false))
                {
                    NewMessage.ProcessMessages(currentKey, ref errorMessage, ref actionSucceeded, false, ref errorLevel);
                    if (actionSucceeded)
                    {
                        Console.WriteLine("    Successfully built " + currLibrary.ShortLibraryName);
                    }
                    else
                    {
                        Console.WriteLine("    Error building " + currLibrary.ShortLibraryName + ":" + errorMessage);
                    }
                }
                else
                {
                    Console.WriteLine("    Error building " + currLibrary.ShortLibraryName + ":" + errorMessage);
                }
            }
            catch (Exception e) {
                errorLevel = 3;
                Console.Error.WriteLine("An error occurred in ProductBuilder:");
                Console.Error.WriteLine(e.ToString());
                Usage();
            }
            return(errorLevel);
        }
Example #29
0
 // Read error message
 private void ErrorMessage(string error, int parent, int offset, int parentoffset)
 {
     NewMessage.Show("LAZY SHELL", "Error in animation #" + parent + " @ offset $" + offset.ToString("X4") + ". " +
                     "Data is corrupt: " + error + " " + "The sprites editor will continue to load anyways.\n\nAnimation Data:",
                     Do.BitArrayToString(buffer, 16, true, true, parentoffset), "Lucida Console");
 }
Example #30
0
        /// <summary>
        /// Gets the config panel for AddIns
        /// </summary>
        /// <returns>
        /// The config panel.
        /// </returns>
        public Panel GetConfigPanel()
        {
            // if panel made then leave it alone\

            //February 27 2013 -- I removed this because it would not notice addins added
            // at runtime, which was one of the main points for this (i.e., once panel was open it never refreshed)
            //	if (PanelWasMade == true)
            //		return configPanel;


            PanelWasMade = true;

            configPanel           = new Panel();
            configPanel.BackColor = Color.Blue;
            checkers        = new CheckedListBox();
            checkers.Parent = configPanel;
            checkers.Dock   = DockStyle.Fill;
            checkers.BringToFront();



            BuildListOfAddins();

            if (null == AddInsList)
            {
                lg.Instance.Line("Addins.GetConfigPanel", ProblemType.MESSAGE, "No AddIns discovered.");
            }
            //checkers.DataSource = AddInsList;
            //checkers.DisplayMember = "CalledFrom.MyMenuName";


            //#STEP #1 : Load the previous preferences (go back into GetConfigPanel)


            List <string> myList = GetListOfInstalledPlugs();

            /*List<string>Guids = new List<string>();
             *
             *
             * if (myList != null && myList.Count > 0) {
             *
             *      foreach (object[] o in myList) {
             *              string GUIDOfAPlugIn = o [0].ToString ();
             *              Guids.Add (GUIDOfAPlugIn);
             *      }
             * }*/



            foreach (MefAddIns.Extensibility.mef_IBase plug in AddInsList)
            {
                ListViewItem item = new ListViewItem(plug.CalledFrom.MyMenuName);
                item.Text = String.Format("{0} ({1}) ", plug.Name, plug.Version.ToString());
                if (plug.IsCopy)
                {
                    // a copy of this GUID was present
                    item.Text = item.Text + Loc.Instance.GetString(" (COPY) ");
                }



                item.Tag = plug.CalledFrom;
                bool IsChecked  = false;
                bool IsDisabled = false;
                if (plug.dependencyguid != Constants.BLANK)
                {
                    IsDisabled = true;
                }
                bool IsVersionDisabled = false;
                if (plug.dependencymainapplicationversion != Constants.BLANK)
                {
                    //	NewMessage.Show(String.Format ("Comparing {0} with Application {1}",plug.dependencymainapplicationversion, Application.ProductVersion));
                    Version plugNeedsVersion = new Version(plug.dependencymainapplicationversion);
                    Version appVersion       = new Version(Application.ProductVersion);
                    if (plugNeedsVersion > appVersion)
                    {
                        IsVersionDisabled = true;
                    }
                }

                foreach (string guid in myList)
                {
                    if (guid == plug.CalledFrom.GUID)
                    {
                        IsChecked = true;
                    }
                    if (IsDisabled == true)
                    {
                        // check to see if the GUID is enabled for my dependency
                        if (guid == plug.dependencyguid)
                        {
                            IsDisabled = false;
                        }
                    }
                }

                // we do not add Disabled Items
                if (true != IsDisabled)
                {
                    if (true != IsVersionDisabled)
                    {
                        if (plug.CalledFrom.IsANote)
                        {
                            item.Text = String.Format("{0} ({1})", item.Text, Loc.Instance.GetString("Deactivating requires application exit."));
                        }
                        checkers.Items.Add(item, IsChecked);
                    }
                    else
                    {
                        NewMessage.Show(Loc.Instance.GetStringFmt("The Addin '{0}' was not added because it requires version '{1}' of the main application.", plug.Name, plug.dependencymainapplicationversion));
                    }
                }
                else
                {
                    NewMessage.Show(Loc.Instance.GetStringFmt("The AddIn '{0}' was not added because it requires the AddIn '{1}' to be installed", plug.Name, plug.dependencyguid));
                }
            }


            checkers.DisplayMember = "Text";
            return(configPanel);
        }
        //----< subscribe to new message events and Intialize Window component >------------------------
        public WindowMain()
        {
            InitializeComponent();
            Title = "Client1";

            IPHostEntry host1;
            string localIP = "?";
            host1 = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host1.AddressList)
            {
                if (ip.AddressFamily.ToString() == "InterNetwork")
                {
                    localIP = ip.ToString();
                }
            }
            string address = "http://" + localIP + ":8001/MessageService";
            ServiceHost host = ProgClient.CreateServiceChannel(address);
            host.Open();

            OnNewMessage += new NewMessage(OnNewMessageHandler);

            combobox_1.Items.Add("http://localhost:9001/MessageService");
            combobox_1.Items.Add("http://localhost:9002/MessageService");

            Connect.IsEnabled = false;
            Dependency_Button.IsEnabled = false;

            result.IsEnabled = false;
            message.IsEnabled = false;
        }
Example #32
0
        public static MessageToSend ChannelUnrecogised(this NewMessage incomingMessage, string channel)
        {
            var message = incomingMessage.CreateResponseMessage($"I don't recognise that channel name: {channel}");

            return(message);
        }