Exemplo n.º 1
0
        public async Task DenyQuote(int quoteId)
        {
            string quote = QuoteHandler.RequestQuoteList[quoteId - 1];

            QuoteHandler.RemoveAndUpdateRequestQuotes(quoteId - 1);
            await ReplyAsync(Context.User.Mention + " has denied Quote " + quoteId + " from the request quote list.\nQuote: " + quote);
        }
Exemplo n.º 2
0
        public async Task EditQuote(int quoteId, [Remainder] string quote)
        {
            string oldQuote = QuoteHandler.QuoteList[quoteId - 1];

            QuoteHandler.UpdateQuote(quoteId - 1, quote);
            await ReplyAsync(Context.User.Mention + " updated quote id: " + quoteId + "\nOld quote: `" + oldQuote + "`\nUpdated: `" + quote + "`");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected void ExecutePreQuoteCreate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService    service = localContext.OrganizationService;
            ITracingService         trace   = localContext.TracingService;
            Entity quote = (Entity)context.InputParameters["Target"];

            string message = context.MessageName;

            try
            {
                QuoteHandler handler = new QuoteHandler(service, trace);
                handler.ReplicateOpportunityInfo(quote);
                handler.CheckifCustomerHasTax(quote);
                handler.CheckifVehicleHasTax(quote);
                handler.ConcatenateVehicleDescription(quote, message);
                handler.SetChattelFeeAmount(quote, message);
                handler.PopulateColorPrice(quote, message);
                handler.PopulateCustomerInformation(quote, message);
            }
            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(ex.Message);
                //throw new InvalidPluginExecutionException(String.Concat("(Exception)\n", ex.Message, Environment.NewLine, ex.StackTrace));
            }
        }
Exemplo n.º 4
0
        public void QuoteHandler_SingleQuoted_StartsWithSingleQuotes_Test()
        {
            // Arrange

            string prop    = "Name";
            string method  = "eq";
            string value   = "''";
            var    handler = new QuoteHandler <Entity1>();
            var    state   = new ParserState <Entity1>($"{prop} {method} '{value}'");

            state.CurrentFilter.Left   = prop;
            state.CurrentFilter.Method = method;
            state.CharIndex            = 8;

            // Act
            handler.Action(state);
            state.CharIndex++;
            handler.Action(state);
            state.CharIndex++;
            handler.Action(state);

            // Assert
            Assert.AreEqual('\'', state.QuoteGroup.WrapChar);
            Assert.IsTrue(state.QuoteGroup.IsOpen);
            Assert.AreEqual(1, state.Builder.Length, "Builder should be empty.");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected void ExecutePreValidateQuoteDelete(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService    service = localContext.OrganizationService;
            ITracingService         trace   = localContext.TracingService;
            var    entity  = (EntityReference)context.InputParameters["Target"];
            string message = context.MessageName;

            try
            {
                EntityCollection quoteCollection = CommonHandler.RetrieveRecordsByOneValue("quote", "quoteid", entity.Id, service, null, OrderType.Ascending,
                                                                                           new[] { "statecode" });

                QuoteHandler handler = new QuoteHandler(service, trace);
                handler.ValidateDelete(quoteCollection.Entities[0]);
            }

            catch (Exception ex)
            {
                throw new InvalidPluginExecutionException(ex.Message);
            }
        }
Exemplo n.º 6
0
        public async Task ListRequestQuotes()
        {
            if (QuoteHandler.RequestQuoteList.Any())
            {
                StringBuilder sb = new StringBuilder()
                                   .Append("**Request Quote List** : *Page 1*\nTo accept a quote, type **" + Guild.Load(Context.Guild.Id).Prefix + "acceptquote [id]**.\nTo reject a quote, type **" + Guild.Load(Context.Guild.Id).Prefix + "denyquote [id]**.\n```");

                QuoteHandler.SpliceRequestQuotes();
                List <string> requestQuotes = QuoteHandler.GetRequestQuotes(1);

                for (int i = 0; i < requestQuotes.Count; i++)
                {
                    sb.Append((i + 1) + ": " + requestQuotes[i] + "\n");
                }

                sb.Append("```");

                IUserMessage msg = await ReplyAsync(sb.ToString());

                QuoteHandler.RequestQuoteMessages.Add(msg.Id);
                QuoteHandler.RequestPageNumber.Add(1);

                if (QuoteHandler.RequestQuoteList.Count > 10)
                {
                    await msg.AddReactionAsync(Extensions.Extensions.ArrowRight);
                }
            }
            else
            {
                await ReplyAsync("There are currently 0 pending request quotes.");
            }
        }
Exemplo n.º 7
0
        public async Task AddQuote([Remainder] string quote)
        {
            QuoteHandler.AddAndUpdateQuotes(quote);

            EmbedBuilder eb = new EmbedBuilder()
                              .WithDescription(Context.User.Mention + " Quote Added")
                              .WithColor(33, 210, 47);

            await ReplyAsync("", false, eb.Build());
        }
Exemplo n.º 8
0
        private static async Task HandleQuoteReactions(Cacheable <IUserMessage, ulong> message, SocketReaction reaction)
        {
            // Check to see if the next page or previous page was clicked.
            if (reaction.Emote.Name == Extensions.Extensions.ArrowLeft.Name)
            {
                if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == 1)
                {
                    return;
                }

                QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]--;
            }
            else if (reaction.Emote.Name == Extensions.Extensions.ArrowRight.Name)
            {
                if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetQuotesListLength)
                {
                    return;
                }

                QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]++;
            }

            StringBuilder sb = new StringBuilder()
                               .Append("**Quote List** : *Page " + QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] + "*\n```");

            List <string> quotes = QuoteHandler.GetQuotes(QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)]);

            for (int i = 0; i < quotes.Count; i++)
            {
                sb.Append(((i + 1) + ((QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] - 1) * 10)) + ": " + quotes[i] + "\n");
            }

            sb.Append("```");

            await message.Value.ModifyAsync(msg => msg.Content = sb.ToString());

            await message.Value.RemoveAllReactionsAsync();

            if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == 1)
            {
                await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight);
            }
            else if (QuoteHandler.PageNumber[QuoteHandler.QuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetQuotesListLength)
            {
                await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft);
            }
            else
            {
                await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft);

                await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight);
            }
        }
Exemplo n.º 9
0
        private static async Task HandleRequestQuoteReactions(Cacheable <IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction)
        {
            // Check to see if the next page or previous page was clicked.
            if (reaction.Emote.Name == Extensions.Extensions.ArrowLeft.Name)
            {
                if (QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] == 1)
                {
                    return;
                }

                QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)]--;
            }
            else if (reaction.Emote.Name == Extensions.Extensions.ArrowRight.Name)
            {
                if (QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetRequestQuotesListLength)
                {
                    return;
                }

                QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)]++;
            }

            StringBuilder sb = new StringBuilder()
                               .Append("**Request Quote List** : *Page " + QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] + "*\nTo accept a quote, type **" + Guild.Load(channel.GetGuild().Id).Prefix + "acceptquote[id]**.\nTo reject a quote, type **" + Guild.Load(channel.GetGuild().Id).Prefix + "denyquote[id]**.\n```");

            List <string> requestQuotes = QuoteHandler.GetRequestQuotes(QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)]);

            for (int i = 0; i < requestQuotes.Count; i++)
            {
                sb.Append(((i + 1) + ((QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] - 1) * 10)) + ": " + requestQuotes[i] + "\n");
            }

            sb.Append("```");

            await message.Value.ModifyAsync(msg => msg.Content = sb.ToString());

            await message.Value.RemoveAllReactionsAsync();

            if (QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] == 1)
            {
                await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight);
            }
            else if (QuoteHandler.RequestPageNumber[QuoteHandler.RequestQuoteMessages.IndexOf(message.Id)] == QuoteHandler.GetRequestQuotesListLength)
            {
                await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft);
            }
            else
            {
                await message.Value.AddReactionAsync(Extensions.Extensions.ArrowLeft);

                await message.Value.AddReactionAsync(Extensions.Extensions.ArrowRight);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected void ExecutePostQuoteCreate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService    service = localContext.OrganizationService;
            ITracingService         trace   = localContext.TracingService;
            Entity quote = (Entity)context.InputParameters["Target"];

            string message = context.MessageName;
            string error   = "";

            if (context.Depth > 1)
            {
                return;
            }

            try
            {
                QuoteHandler handler = new QuoteHandler(service, trace);

                #region Calling RetrieveAndCreateVehicleFreebies method
                EntityCollection quoteRecords = CommonHandler.RetrieveRecordsByOneValue("quote", "quoteid", quote.Id, service, null, OrderType.Ascending,
                                                                                        new[] { "gsc_productid", "gsc_financingschemeid", "gsc_vehicleunitprice", "gsc_vehiclecolorid1", "gsc_amountfinanced", "gsc_bankid", "gsc_branchid" });

                if (quoteRecords != null && quoteRecords.Entities.Count > 0)
                {
                    Entity quoteToUpdate = quoteRecords.Entities[0];
                    handler.RetrieveAndCreateVehicleFreebies(quoteToUpdate, message);
                    handler.CheckMonthlyAmortizationRecord(quoteToUpdate);
                }
                #endregion
            }
            catch (Exception ex)
            {
                //throw new InvalidPluginExecutionException(String.Concat("(Exception)\n", ex.Message, Environment.NewLine, ex.StackTrace, Environment.NewLine, error));
                throw new InvalidPluginExecutionException(ex.Message);
            }
        }
Exemplo n.º 11
0
        public async Task RemoveQuote(int quoteId)
        {
            if (quoteId <= QuoteHandler.QuoteList.Count)
            {
                string quote = QuoteHandler.QuoteList[quoteId - 1];
                QuoteHandler.RemoveAndUpdateQuotes(quoteId - 1);

                EmbedBuilder eb = new EmbedBuilder()
                                  .WithDescription(Context.User.Mention + " Quote Removed\nQuote: " + quote)
                                  .WithColor(210, 47, 33);

                await ReplyAsync("", false, eb.Build());
            }
            else
            {
                EmbedBuilder eb = new EmbedBuilder()
                                  .WithDescription(Context.User.Mention + " There is no quote with that Id")
                                  .WithColor(47, 33, 210);

                await ReplyAsync("", false, eb.Build());
            }
        }
Exemplo n.º 12
0
        public async Task RequestToAddQuote([Remainder] string quote = null)
        {
            if (Guild.Load(Context.Guild.Id).QuotesEnabled)
            {
                int userLevel             = User.Load(Context.User.Id).Level;
                int quoteLevelRequirement = Configuration.Load().QuoteLevelRequirement;


                if (userLevel < quoteLevelRequirement)
                {
                    await ReplyAsync(Context.User.Mention + ", you need to be level " + quoteLevelRequirement + "+ to add a quote request.");

                    return;
                }

                if (quote == null)
                {
                    await ReplyAsync("**Syntax:** " +
                                     Guild.Load(Context.Guild.Id).Prefix + "buyquote [quote]\n```" +
                                     "**Information:**\n" +
                                     "-----------------------------\n" +
                                     "• Your quote will not be added instantly to the list. A staff member must first verify that it is safe to put on the list.\n" +
                                     "```");

                    return;
                }

                QuoteHandler.AddAndUpdateRequestQuotes(quote);
                await ReplyAsync(Context.User.Mention + ", your quote has been added to the list, and should be verified by a staff member shortly.");

                await Configuration.Load().LogChannelId.GetTextChannel().SendMessageAsync("**New Quote**\nQuote requested by: **" + Context.User.Mention + "**\nQuote: " + quote);

                await Guild.Load(Context.Guild.Id).LogChannelID.GetTextChannel().SendMessageAsync("**New Quote**\n" + quote + "\n\n*Do " + Guild.Load(Context.Guild.Id).Prefix + "listrequestquotes to view the ID and other quotes.*");
            }
            else
            {
                await ReplyAsync("Quotes are currently disabled. Try again later.");
            }
        }
Exemplo n.º 13
0
        public void QuoteHandlerOpenTest()
        {
            // Arrange
            string prop    = "Name";
            string method  = "eq";
            string value   = "Jared Barneck";
            var    handler = new QuoteHandler <Entity1>();
            var    state   = new ParserState <Entity1>($"{prop} {method} '{value}'");

            state.CurrentFilter.Left   = prop;
            state.CurrentFilter.Method = method;
            state.CharIndex            = 8;

            // Act
            handler.Action(state);

            // Assert
            Assert.AreEqual('\'', state.QuoteGroup.WrapChar);
            Assert.IsTrue(state.QuoteGroup.IsOpen);
            Assert.AreEqual(0, state.Builder.Length, "Builder should be empty.");
            Assert.AreEqual(8, state.CharIndex, "CharIndex should not be updated. The loop updates it and this test bypasses the loop.");
        }
Exemplo n.º 14
0
        public async Task ListQuotes()
        {
            if (QuoteHandler.QuoteList.Count > 0)
            {
                StringBuilder sb = new StringBuilder();

                QuoteHandler.SpliceQuotes();
                List <string> quotesList = new List <string>();
                int           id         = 0;
                for (int i = 0; i < QuoteHandler.GetQuotesListLength; i++)
                {
                    List <string> quotes = QuoteHandler.GetQuotes(i + 1);

                    foreach (var quote in quotes)
                    {
                        id++;
                        sb.Append(id + ": " + quote + "\n");
                    }
                    quotesList.Add(sb.ToString());
                    sb.Clear();
                }

                PaginatedMessage message = new PaginatedMessage
                {
                    Title   = "**Quote List**",
                    Color   = new Color(User.Load(Context.User.Id).AboutR, User.Load(Context.User.Id).AboutG, User.Load(Context.User.Id).AboutB),
                    Pages   = quotesList,
                    Options = new PaginatedAppearanceOptions()
                    {
                        DisplayInformationIcon = false
                    }
                };
                await PagedReplyAsync(message);
            }
            else
            {
                await ReplyAsync("There are no quotes in the database.");
            }
        }
Exemplo n.º 15
0
        //Created By: Raphael Herrera, Created On: 9/19/2016

        /*Purpose: Set CC Add-Ons Amount in Quote Entity
         * Registration Details:
         * Event/Message:
         *      Post/Create: QuoteCabChassis
         *      Pre/Delete: QuoteCabChassis
         *      Post/Update: QuoteCabChassis
         *      Post/Update: quote gsc_paymentmode
         * Primary Entity: gsc_sls_quotecabchassis
         */
        public void SetCCAddOnAmount(Entity quoteCabChassis, String message)
        {
            _tracingService.Trace("Started SetCCAddOnAmount Method...");
            var quoteId = quoteCabChassis.Contains("gsc_quoteid") ? quoteCabChassis.GetAttributeValue <EntityReference>("gsc_quoteid").Id
                : Guid.Empty;
            Decimal ccAddOns = 0;

            EntityCollection quoteCollection = CommonHandler.RetrieveRecordsByOneValue("quote", "quoteid", quoteId, _organizationService, null, OrderType.Ascending,
                                                                                       new[] { "gsc_ccaddons", "gsc_netprice", "gsc_totaldiscount", "gsc_unitprice", "gsc_colorprice", "gsc_freightandhandling", "gsc_paymentmode", "gsc_branchid",
                                                                                               "gsc_vatablesales", "gsc_vatexemptsales", "gsc_zeroratedsales", "gsc_totalsales", "gsc_vatamount", "gsc_totalamountdue", "gsc_insurance", "gsc_othercharges", "customerid"
                                                                                               , "gsc_accessories", "gsc_productid" });

            _tracingService.Trace("Quote Records retrieved: " + quoteCollection.Entities.Count);
            if (quoteCollection.Entities.Count > 0)
            {
                Entity quoteEntity = quoteCollection.Entities[0];

                Decimal paymentMode = quoteEntity.Contains("gsc_paymentmode") ? quoteEntity.GetAttributeValue <OptionSetValue>("gsc_paymentmode").Value
                    : 0;

                //Retrieve all quote cab chassis related to quote
                EntityCollection quoteCabChassisCollection = CommonHandler.RetrieveRecordsByOneValue("gsc_sls_quotecabchassis", "gsc_quoteid", quoteId, _organizationService,
                                                                                                     null, OrderType.Ascending, new[] { "gsc_amount", "gsc_financing" });

                _tracingService.Trace("Quote Cab Chassis Records Retrieved: " + quoteCabChassisCollection.Entities.Count);
                if (quoteCabChassisCollection.Entities.Count > 0)
                {
                    //Get total cc add on price that are for financing...
                    foreach (Entity quoteCabChassisEntity in quoteCabChassisCollection.Entities)
                    {
                        if (quoteCabChassisEntity.Contains("gsc_amount"))
                        {
                            ccAddOns += quoteCabChassisEntity.GetAttributeValue <Money>("gsc_amount").Value;
                            _tracingService.Trace("CC Add Ons Amount: " + ccAddOns);
                        }
                    }

                    //Subtract sellprice of deleted.
                    if (quoteCabChassis.Contains("gsc_amount") && message.Equals("Delete"))
                    {
                        _tracingService.Trace("Message is Delete...");
                        ccAddOns = ccAddOns - (Decimal)quoteCabChassis.GetAttributeValue <Money>("gsc_amount").Value;
                    }

                    quoteEntity["gsc_ccaddons"] = new Money(ccAddOns);

                    #region Recalculate net price

                    QuoteHandler quoteHandler = new QuoteHandler(_organizationService, _tracingService);
                    quoteEntity["gsc_netprice"] = new Money(quoteHandler.ComputeNetPrice(quoteEntity));
                    quoteEntity = quoteHandler.ComputeVAT(quoteEntity);

                    var paymentmode = quoteEntity.Contains("gsc_paymentmode")
                        ? quoteEntity.GetAttributeValue <OptionSetValue>("gsc_paymentmode").Value
                        : Decimal.Zero;
                    var amountfinanced = Decimal.Zero;

                    //Financing
                    if (paymentmode == 100000001 || paymentmode == 100000001)
                    {
                        amountfinanced = quoteHandler.ComputeAmountFinanced(quoteEntity);
                        quoteEntity["gsc_amountfinanced"]      = new Money(amountfinanced);
                        quoteEntity["gsc_totalamountfinanced"] = new Money(amountfinanced);
                    }

                    #endregion

                    if (ccAddOns >= 0)
                    {
                        _organizationService.Update(quoteEntity);
                        _tracingService.Trace("CC Add Ons Amount:" + ccAddOns + ". Updated quote entity...");
                    }
                    else
                    {
                        _tracingService.Trace("CC add on is negative...");
                    }
                }
            }
            _tracingService.Trace("ending SetCCAddOnAmount Entity");
        }
Exemplo n.º 16
0
        public static void StartBot()
        {
            Console.Write(@"DiscordBot: [");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.Write(@"Version " + ProgramVersion.Major + @"." + ProgramVersion.Minor + @"." + ProgramVersion.Build + @"." + ProgramVersion.Revision);
            Console.ResetColor();
            Console.WriteLine(@"]    ");

            Console.Write(@"Developed by Melissa Brennan (");
            Console.ForegroundColor = ConsoleColor.Magenta;
            Console.Write(@"@MythicalCuddles");
            Console.ResetColor();
            Console.WriteLine(@")");

            Console.WriteLine(@"Web: www.mythicalcuddles.xyz");

            Console.WriteLine(@"Copyright 2017 - 2019 Melissa Brennan | Licensed under the MIT License.");
            Console.WriteLine(@"-----------------------------------------------------------------");

            MelissaNet.MelissaNet.Initialize();

            /*    Update Checker via MythicalCore    */
            try
            {
                var updateCheck = Updater.CheckForUpdate("DiscordBot", ProgramVersion);
                if (updateCheck.Item1)
                {
                    Console.WriteLine(@"-----------------------------------------------------------------");
                    LogMessage lm = new LogMessage(LogSeverity.Info, "MythicalCore",
                                                   "A new update has been found. Would you like to download?");
                    lm.PrintToConsole();
                    Console.WriteLine(@"-----------------------------------------------------------------");

                    DialogResult result = MessageBox.Show("A new update is available. Would you like to update?",
                                                          "DiscordBot Update Available", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                    if (result == DialogResult.Yes)
                    {
                        System.Diagnostics.Process.Start(updateCheck.Item2);
                        Environment.Exit(0);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(@"-----------------------------------------------------------------");
                LogMessage lm = new LogMessage(LogSeverity.Error, "MythicalCore",
                                               "Unable to check for new updates.");
                lm.PrintToConsole();
                Console.WriteLine(@"-----------------------------------------------------------------");
            }
            /*    Update End    */

            Configuration.EnsureExists();
            StringConfiguration.EnsureExists();
            QuoteHandler.EnsureExists();
            VoteLinkHandler.EnsureExists();

            try
            {
                DatabaseActivity.CheckForDatabase();
            }
            catch (Exception e)
            {
                LogMessage lm = new LogMessage(LogSeverity.Critical, "MySQL Database", "Unable to connect to database. Is it currently running?", e);
                lm.PrintToConsole();
                Environment.Exit(0);
            }


            Console.WriteLine(@"-----------------------------------------------------------------");

            new DiscordBot().RunBotAsync().GetAwaiter().GetResult();
        }
Exemplo n.º 17
0
        //Created By : Jerome Anthony Gerero, Created On: 3/11/2016

        /*Modified By: Raphael Herrera, Modified On: 9/19/2016
         * Modification Purpose: Compute for Freight & Handling Charges
         */
        public Entity SetQuoteTotalChargesAmount(Entity quoteChargeEntity, String message)
        {
            _tracingService.Trace("Started SetQuoteTotalChargesAmount method..");

            var quoteId = quoteChargeEntity.GetAttributeValue <EntityReference>("gsc_quoteid") != null
                ? quoteChargeEntity.GetAttributeValue <EntityReference>("gsc_quoteid").Id
                : Guid.Empty;

            var actualcost = quoteChargeEntity.Contains("gsc_actualcost")
                ? quoteChargeEntity.GetAttributeValue <Money>("gsc_actualcost")
                : new Money(0);

            if (actualcost.Value == 0)
            {
                Entity quoteChargeToUpdate = _organizationService.Retrieve(quoteChargeEntity.LogicalName, quoteChargeEntity.Id,
                                                                           new ColumnSet("gsc_actualcost"));

                quoteChargeToUpdate["gsc_actualcost"] = new Money(0);

                _organizationService.Update(quoteChargeToUpdate);
            }

            Decimal totalChargesAmount = 0;
            Decimal totalFreightAmount = 0;

            //Retrieve Applied Charges records with the same Quote
            EntityCollection quoteChargeRecords = CommonHandler.RetrieveRecordsByOneValue("gsc_cmn_quotecharge", "gsc_quoteid", quoteId, _organizationService, null, OrderType.Ascending,
                                                                                          new[] { "gsc_free", "gsc_actualcost", "gsc_chargetype" });

            //Retrieve Quote record from Quote field value
            EntityCollection quoteRecords = CommonHandler.RetrieveRecordsByOneValue("quote", "quoteid", quoteId, _organizationService, null, OrderType.Ascending,
                                                                                    new[] { "gsc_totalchargesamount", "gsc_othercharges", "statecode", "gsc_totalcashoutlay", "gsc_downpayment", "gsc_chattelfee", "gsc_productid",
                                                                                            "gsc_insurance", "gsc_freightandhandling", "gsc_ccaddons", "gsc_totaldiscount", "gsc_unitprice", "gsc_colorprice", "customerid", "gsc_paymentmode",
                                                                                            "gsc_netprice", "gsc_accessories", "gsc_vatablesales", "gsc_vatexemptsales", "gsc_zeroratedsales", "gsc_totalsales", "gsc_vatamount", "gsc_totalamountdue",
                                                                                            "gsc_amountfinanced", "gsc_totalamountfinanced", "gsc_downpaymentamount", "gsc_lessdiscountaf" });

            _tracingService.Trace("Quote Charge records retrieved: " + quoteChargeRecords.Entities.Count);

            if (quoteChargeRecords != null && quoteChargeRecords.Entities.Count > 0)
            {
                foreach (var quoteCharge in quoteChargeRecords.Entities)
                {
                    if (quoteCharge.Contains("gsc_actualcost"))
                    {
                        // charge type is freight charges
                        if (quoteCharge.GetAttributeValue <OptionSetValue>("gsc_chargetype").Value == 100000000)
                        {
                            totalFreightAmount += quoteCharge.GetAttributeValue <Boolean>("gsc_free")
                            ? Decimal.Zero
                            : quoteCharge.GetAttributeValue <Money>("gsc_actualcost").Value;
                        }
                        //Other charge type
                        else
                        {
                            totalChargesAmount += quoteCharge.GetAttributeValue <Boolean>("gsc_free")
                            ? Decimal.Zero
                            : quoteCharge.GetAttributeValue <Money>("gsc_actualcost").Value;
                        }

                        _tracingService.Trace("Toal Freight: " + totalFreightAmount + " Total Charges:" + totalChargesAmount);
                    }
                }

                if (quoteChargeEntity.Contains("gsc_actualcost") && message.Equals("Delete"))
                {
                    _tracingService.Trace("Message is Delete...");
                    // charge type is freight charges
                    if (quoteChargeEntity.GetAttributeValue <OptionSetValue>("gsc_chargetype").Value == 100000000)
                    {
                        totalFreightAmount = totalFreightAmount - quoteChargeEntity.GetAttributeValue <Money>("gsc_actualcost").Value;
                    }
                    //Other charge type
                    else
                    {
                        totalChargesAmount = totalChargesAmount - quoteChargeEntity.GetAttributeValue <Money>("gsc_actualcost").Value;
                    }
                }
            }

            if (quoteRecords != null && quoteRecords.Entities.Count > 0 && quoteRecords.Entities[0].GetAttributeValue <OptionSetValue>("statecode").Value == 0)
            {
                QuoteHandler quoteHandler = new QuoteHandler(_organizationService, _tracingService);

                Entity quote = quoteRecords.Entities[0];

                quote["gsc_totalchargesamount"] = new Money(totalChargesAmount + totalFreightAmount);
                quote["gsc_othercharges"]       = new Money(totalChargesAmount);
                quote["gsc_freightandhandling"] = new Money(totalFreightAmount);

                var paymentmode = quote.Contains("gsc_paymentmode")
                  ? quote.GetAttributeValue <OptionSetValue>("gsc_paymentmode").Value
                  : Decimal.Zero;

                //Compute Net Price
                quote["gsc_netprice"] = new Money(quoteHandler.ComputeNetPrice(quote));

                //Compute VAT
                quote = quoteHandler.ComputeVAT(quote);

                quote["gsc_totalcashoutlay"] = new Money(quoteHandler.ComputeCashLayout(quote));

                var amountfinanced = Decimal.Zero;

                //Financing
                if (paymentmode == 100000001 || (paymentmode == 100000002 && quoteHandler.CheckifQuoteHasDownPayment(quote) == true))
                {
                    amountfinanced = quoteHandler.ComputeAmountFinanced(quote);
                    quote["gsc_amountfinanced"]      = new Money(amountfinanced);
                    quote["gsc_totalamountfinanced"] = new Money(amountfinanced);
                }
                else
                {
                    quote["gsc_amountfinanced"]      = null;
                    quote["gsc_totalamountfinanced"] = new Money(amountfinanced);
                }

                _organizationService.Update(quote);
                _tracingService.Trace("Updated quote entity...");

                return(quote);
            }
            _tracingService.Trace("Ended SetQuoteTotalChargesAmount method..");
            return(quoteChargeEntity);
        }
Exemplo n.º 18
0
        //Created By: Leslie Baliguat, Created On: 9/27/2016

        /*Purpose: Set Accessories in Quote
         * Registration Details:
         * Event/Message:
         *      Post/Create:
         *      Pre/Delete:
         *      Post/Update: gsc_free, gsc_productid
         * Primary Entity: gsc_sls_quoteaccessorry
         */
        public void SetTotalAccessories(Entity quoteAccessory, string message)
        {
            _tracingService.Trace("Started SetTotalAccessories Method...");

            var quoteId = quoteAccessory.Contains("gsc_quoteid") ? quoteAccessory.GetAttributeValue <EntityReference>("gsc_quoteid").Id
                : Guid.Empty;

            Decimal totalAccessories = 0;

            EntityCollection quoteCollection = CommonHandler.RetrieveRecordsByOneValue("quote", "quoteid", quoteId, _organizationService, null, OrderType.Ascending,
                                                                                       new[] { "gsc_downpayment", "gsc_chattelfee", "gsc_insurance", "gsc_othercharges", "gsc_accessories", "gsc_netprice", "gsc_paymentmode",
                                                                                               "gsc_branchid", "gsc_vatablesales", "gsc_vatexemptsales", "gsc_zeroratedsales", "gsc_totalsales", "gsc_vatamount", "gsc_totalamountdue",
                                                                                               "customerid", "gsc_productid", "gsc_totalcashoutlay" });

            if (quoteCollection != null && quoteCollection.Entities.Count > 0)
            {
                _tracingService.Trace("Retrieve Quote");

                var quoteEntity = quoteCollection.Entities[0];

                //Retrieve all quote cab chassis related to quote
                EntityCollection quoteAccessoryCollection = CommonHandler.RetrieveRecordsByOneValue("gsc_sls_quoteaccessory", "gsc_quoteid", quoteEntity.Id, _organizationService,
                                                                                                    null, OrderType.Ascending, new[] { "gsc_actualcost" });

                if (quoteAccessoryCollection.Entities.Count > 0)
                {
                    _tracingService.Trace("Retrieve Quote Accessories");

                    //Get total cc add on price that are for financing...
                    foreach (Entity quoteAccessoryEntity in quoteAccessoryCollection.Entities)
                    {
                        if (quoteAccessoryEntity.Contains("gsc_actualcost"))
                        {
                            totalAccessories += quoteAccessoryEntity.GetAttributeValue <Money>("gsc_actualcost").Value;
                            _tracingService.Trace("Accessories:" + totalAccessories);
                        }
                    }

                    _tracingService.Trace("total Accessories: " + totalAccessories);
                }

                //Add Current record to total Accessories
                if (message == "Create")
                {
                    totalAccessories += quoteAccessory.Contains("gsc_actualcost") ? quoteAccessory.GetAttributeValue <Money>("gsc_actualcost").Value : 0;
                }

                //Subtract sellprice of deleted.
                if (quoteAccessory.Contains("gsc_actualcost") && message.Equals("Delete"))
                {
                    _tracingService.Trace("Message is Delete...");
                    _tracingService.Trace("To be subtract: " + (Decimal)quoteAccessory.GetAttributeValue <Money>("gsc_actualcost").Value);
                    totalAccessories = totalAccessories - (Decimal)quoteAccessory.GetAttributeValue <Money>("gsc_actualcost").Value;
                    totalAccessories = totalAccessories < 0 ? 0 : totalAccessories;
                }

                _tracingService.Trace("total Accessories: " + totalAccessories);
                quoteEntity["gsc_accessories"] = new Money(totalAccessories);

                #region Recalculate total cash outlay

                QuoteHandler quoteHandler = new QuoteHandler(_organizationService, _tracingService);
                var          paymentmode  = quoteEntity.Contains("gsc_paymentmode")
                  ? quoteEntity.GetAttributeValue <OptionSetValue>("gsc_paymentmode").Value
                  : Decimal.Zero;

                quoteEntity = quoteHandler.ComputeVAT(quoteEntity);

                quoteEntity["gsc_totalcashoutlay"] = new Money(quoteHandler.ComputeCashLayout(quoteEntity));

                _organizationService.Update(quoteEntity);

                _tracingService.Trace("Quote Computation Updated");
                #endregion
            }

            _tracingService.Trace("Ended SetTotalAccessories Method...");
        }
Exemplo n.º 19
0
        /// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected void ExecutePostQuoteUpdate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService    service = localContext.OrganizationService;
            ITracingService         trace   = localContext.TracingService;

            Entity preImageEntity  = (context.PreEntityImages != null && context.PreEntityImages.Contains(this.preImageAlias)) ? context.PreEntityImages[this.preImageAlias] : null;
            Entity postImageEntity = (context.PostEntityImages != null && context.PostEntityImages.Contains(this.postImageAlias)) ? context.PostEntityImages[this.postImageAlias] : null;

            if (!(context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity))
            {
                return;
            }

            if (postImageEntity.LogicalName != "quote")
            {
                return;
            }

            string message = context.MessageName;

            if (context.Mode == 0) //synchronous plugin
            {
                try
                {
                    QuoteHandler quotehandler = new QuoteHandler(service, trace);

                    var status = postImageEntity.Contains("statecode")
                        ? postImageEntity.GetAttributeValue <OptionSetValue>("statecode").Value.ToString()
                        : "";

                    if (status == "0")
                    {
                        #region Call functions that will run when Vehicle Model (gsc_productid) was changed.

                        var preImageProductId = preImageEntity.Contains("gsc_productid")
                                ? preImageEntity.GetAttributeValue <EntityReference>("gsc_productid").Id
                                : Guid.Empty;

                        var postImageProductId = postImageEntity.Contains("gsc_productid")
                                    ? postImageEntity.GetAttributeValue <EntityReference>("gsc_productid").Id
                                    : Guid.Empty;

                        if (preImageProductId != postImageProductId)
                        {
                            quotehandler.CheckifVehicleHasTax(postImageEntity);
                            quotehandler.ConcatenateVehicleDescription(postImageEntity, message);
                            quotehandler.DeleteExistingVehicleFreebies(postImageEntity, message);
                            quotehandler.DeleteExistingCabChassis(postImageEntity);

                            /*  if (quotehandler.CheckIfHasUnitPrice(postImageEntity) == true)
                             * {
                             *    throw new InvalidPluginExecutionException("Cannot update quote. The selected vehicle model does not have a unit price. Please contact the administrator.");
                             * }*/
                        }

                        #endregion

                        #region Call functions that will run when Preferred Color 1 was changed.

                        var preImageColorId = preImageEntity.Contains("gsc_vehiclecolorid1")
                                ? preImageEntity.GetAttributeValue <EntityReference>("gsc_vehiclecolorid1").Id
                                : Guid.Empty;

                        var postImageColroId = postImageEntity.Contains("gsc_vehiclecolorid1")
                                    ? postImageEntity.GetAttributeValue <EntityReference>("gsc_vehiclecolorid1").Id
                                    : Guid.Empty;

                        if (preImageColorId != postImageColroId)
                        {
                            quotehandler.PopulateColorPrice(postImageEntity, message);
                        }

                        #endregion

                        #region Call functions that will run when Financing Scheme was changed.

                        var preImageFinancingSchemeId = preImageEntity.Contains("gsc_financingschemeid")
                                ? preImageEntity.GetAttributeValue <EntityReference>("gsc_financingschemeid").Id
                                : Guid.Empty;

                        var postImageFinancingSchemeId = postImageEntity.Contains("gsc_financingschemeid")
                                    ? postImageEntity.GetAttributeValue <EntityReference>("gsc_financingschemeid").Id
                                    : Guid.Empty;

                        if (preImageFinancingSchemeId != postImageFinancingSchemeId)
                        {
                            quotehandler.CheckMonthlyAmortizationRecord(postImageEntity);
                        }

                        #endregion

                        #region Call functions that will run when Total Insurance Charges was changed.

                        var preImageTotalInsurance = preImageEntity.Contains("gsc_totalinsurancecharges")
                               ? preImageEntity.GetAttributeValue <Money>("gsc_totalinsurancecharges").Value
                               : new Decimal(0);

                        var postImageTotalInsurance = postImageEntity.Contains("gsc_totalinsurancecharges")
                                    ? postImageEntity.GetAttributeValue <Money>("gsc_totalinsurancecharges").Value
                                    : new Decimal(0);

                        if (preImageTotalInsurance != postImageTotalInsurance)
                        {
                            quotehandler.UpdateInsurance(postImageEntity, message);
                        }

                        #endregion

                        #region Call functions that will run when Amount in AF, UP and AP were updated.

                        var preImageDpAmount = preImageEntity.Contains("gsc_applytodpamount")
                               ? preImageEntity.GetAttributeValue <Money>("gsc_applytodpamount").Value
                               : new Decimal(0);

                        var postImageDpAmount = postImageEntity.Contains("gsc_applytodpamount")
                                    ? postImageEntity.GetAttributeValue <Money>("gsc_applytodpamount").Value
                                    : new Decimal(0);

                        var preImageAfAmount = preImageEntity.Contains("gsc_applytoafamount")
                               ? preImageEntity.GetAttributeValue <Money>("gsc_applytoafamount").Value
                               : new Decimal(0);
                        var preImageAmountFinanced = preImageEntity.Contains("gsc_amountfinanced")
                                ? preImageEntity.GetAttributeValue <Money>("gsc_amountfinanced").Value
                                : new Decimal(0);

                        var postImageAfAmount = postImageEntity.Contains("gsc_applytoafamount")
                                    ? postImageEntity.GetAttributeValue <Money>("gsc_applytoafamount").Value
                                    : new Decimal(0);

                        var preImageUpAmount = preImageEntity.Contains("gsc_applytoupamount")
                               ? preImageEntity.GetAttributeValue <Money>("gsc_applytoupamount").Value
                               : new Decimal(0);

                        var postImageUpAmount = postImageEntity.Contains("gsc_applytoupamount")
                                    ? postImageEntity.GetAttributeValue <Money>("gsc_applytoupamount").Value
                                    : new Decimal(0);
                        var postImageAmountFinanced = postImageEntity.Contains("gsc_amountfinanced")
                                ? postImageEntity.GetAttributeValue <Money>("gsc_amountfinanced").Value
                                : new Decimal(0);

                        if (preImageAfAmount != postImageAfAmount || preImageUpAmount != postImageUpAmount || preImageDpAmount != postImageDpAmount || preImageAmountFinanced != postImageAmountFinanced)
                        {
                            quotehandler.SetLessDiscountValues(postImageEntity);
                        }

                        #endregion

                        #region Call functions that will run when Net Downpayment was updated.

                        var preImageNetDownpayment = preImageEntity.Contains("gsc_netdownpayment")
                               ? preImageEntity.GetAttributeValue <Money>("gsc_netdownpayment").Value
                               : new Decimal(0);

                        var postImageNetDownpayment = postImageEntity.Contains("gsc_netdownpayment")
                                    ? postImageEntity.GetAttributeValue <Money>("gsc_netdownpayment").Value
                                    : new Decimal(0);


                        if (preImageNetDownpayment != postImageNetDownpayment)
                        {
                            quotehandler.SetLessDiscountValues(postImageEntity);
                        }

                        #endregion

                        #region Call functions that will run when Product, Bank and Free Chattel Feewere updated.

                        var preImageFreeChattel = preImageEntity.Contains("gsc_freechattelfee")
                               ? preImageEntity.GetAttributeValue <Boolean>("gsc_freechattelfee")
                               : false;

                        var postImageFreeChattel = postImageEntity.Contains("gsc_freechattelfee")
                               ? postImageEntity.GetAttributeValue <Boolean>("gsc_freechattelfee")
                               : false;

                        var preImageBankId = preImageEntity.Contains("gsc_bankid")
                               ? preImageEntity.GetAttributeValue <EntityReference>("gsc_bankid").Id
                               : Guid.Empty;

                        var postImageBankId = postImageEntity.Contains("gsc_bankid")
                                    ? postImageEntity.GetAttributeValue <EntityReference>("gsc_bankid").Id
                                    : Guid.Empty;

                        if (preImageProductId != postImageProductId || preImageBankId != postImageBankId || preImageFreeChattel != postImageFreeChattel)
                        {
                            quotehandler.SetChattelFeeAmount(postImageEntity, message);
                        }

                        #endregion

                        //Created By : Jerome Anthony Gerero, Created On : 9/15/2016
                        #region Call function on Chattle Fee (gsc_chattelfeeeditable) change

                        Decimal preImageChattelFeeEditable = preImageEntity.Contains("gsc_chattelfeeeditable")
                            ? preImageEntity.GetAttributeValue <Money>("gsc_chattelfeeeditable").Value
                            : Decimal.Zero;

                        Decimal postImageChattelFeeEditable = postImageEntity.Contains("gsc_chattelfeeeditable")
                            ? postImageEntity.GetAttributeValue <Money>("gsc_chattelfeeeditable").Value
                            : Decimal.Zero;

                        if (preImageChattelFeeEditable != postImageChattelFeeEditable)
                        {
                            quotehandler.ReplicateEditableChattelFee(postImageEntity);
                        }

                        #endregion

                        #region Call functions on Close Quote change

                        Boolean preImageCloseQuote = preImageEntity.GetAttributeValue <Boolean>("gsc_closequote");

                        Boolean postImageCloseQuote = postImageEntity.GetAttributeValue <Boolean>("gsc_closequote");

                        if (preImageCloseQuote != postImageCloseQuote)
                        {
                            quotehandler.CloseRelatedOpportunity(postImageEntity);
                        }

                        #endregion

                        #region Call functions of Create Order change

                        Boolean preImageCreateOrder = preImageEntity.GetAttributeValue <Boolean>("gsc_createorder");

                        Boolean postImageCreateOrder = postImageEntity.GetAttributeValue <Boolean>("gsc_createorder");

                        if (preImageCreateOrder != postImageCreateOrder)
                        {
                            quotehandler.CreateOrder(postImageEntity);
                            quotehandler.ConvertPotentialtoCustomer(postImageEntity);
                        }

                        #endregion

                        #region Call functions that will run when Customer Id was updated.

                        var preCustomerId = preImageEntity.Contains("customerid")
                               ? preImageEntity.GetAttributeValue <EntityReference>("customerid").Id
                               : Guid.Empty;

                        var postCustomerId = postImageEntity.Contains("customerid")
                               ? postImageEntity.GetAttributeValue <EntityReference>("customerid").Id
                               : Guid.Empty;

                        if (preCustomerId != postCustomerId)
                        {
                            quotehandler.PopulateCustomerInformation(postImageEntity, message);
                        }

                        #endregion

                        //Added by: Raphael Herrera, Added On: 4/27/2016
                        #region Call functions that will run if Payment Mode was changed
                        var prePaymentMode = preImageEntity.Contains("gsc_paymentmode")
                               ? preImageEntity.GetAttributeValue <OptionSetValue>("gsc_paymentmode").Value
                               : 0;
                        var postPaymentMode = postImageEntity.Contains("gsc_paymentmode")
                               ? postImageEntity.GetAttributeValue <OptionSetValue>("gsc_paymentmode").Value
                               : 0;

                        /* if (prePaymentMode != postPaymentMode)
                         * {
                         *   quotehandler.SetCabChassisFinancing(postImageEntity);
                         *
                         *   //Not Financed
                         *   if (postPaymentMode != 100000001)
                         *       quotehandler.ClearFinancingFields(postImageEntity);
                         * }*/
                        #endregion

                        //Recompute Unit Price when Markup % Changed - Leslie Baliguat 05/08/17
                        var preMarkup = preImageEntity.Contains("gsc_markup")
                               ? preImageEntity.GetAttributeValue <Decimal>("gsc_markup")
                               : 0;
                        var postMarkup = postImageEntity.Contains("gsc_markup")
                               ? postImageEntity.GetAttributeValue <Decimal>("gsc_markup")
                               : 0;

                        if (preMarkup != postMarkup)
                        {
                            quotehandler.UpdateGovernmentTax(postImageEntity, message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("Cannot update opportunity status to lost since there's at least one quote record which is not closed."))
                    {
                        throw new InvalidPluginExecutionException("Cannot update opportunity status to lost since there's at least one quote record which is not closed.");
                    }
                    else
                    {
                        //throw new InvalidPluginExecutionException(String.Concat("(Exception)\n", ex.Message, Environment.NewLine, ex.StackTrace, Environment.NewLine, error));
                        throw new InvalidPluginExecutionException(ex.Message);
                    }
                }
            }
        }