示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Track  track  = new Monaco();
            Engine engine = new Engine();

            engine.Begin(track);
        }
        public void Process(Monaco.Classroom.Ordering.ProductProcessor processor)
        {
            bool inserted = false;

            try
            {
                inserted = ClassroomController.InsertEnrollment(processor.Order.CustomerID, processor.Order.Sku);
            }
            catch (SqlException ex)
            {
                WebExceptionEvent evnt = new WebExceptionEvent("Critical SQL Error", this, WebEventCodes.WebExtendedBase + 1230235, ex);
                evnt.Raise();
            }
            catch (Exception ex)
            {
                WebExceptionEvent evnt = new WebExceptionEvent("Critical Unknown Error", this, WebEventCodes.WebExtendedBase + 1230236, ex);
                evnt.Raise();
            }

            if (inserted)
            {
                //processor.Order.OnOrderSucceeded(EventArgs.Empty);
                processor.Order.UpdateStatus(processor.Order.Status + 1);
                processor.ContinueNow = true;
            }
            else
            {
                processor.OnOrderFailure(new OrderFailureEventArgs("Unable to create enrollment"));
                processor.ContinueNow = false;
            }
        }
        public void Process(Monaco.Classroom.Ordering.ProductProcessor processor)
        {
            try
            {
                //Cathexis.Entities.OrderItem orderItem = processor.Order;
                Monaco.Billing.Entities.OrderItem orderItem = processor.Order;  
              //  Product product = ProductController.GetProduct(orderItem.Sku);
                Product product = new Product();
                SubscriptionInfo sub = new SubscriptionInfo();
                sub.Id = Guid.NewGuid();
                sub.UserId = orderItem.CustomerID;
                sub.CreateDate = DateTime.Now;
                sub.StartDate = DateTime.Now.AddDays(product.TrialPeriodDays) ;
                sub.Status = BillingStatus.Active;
                sub.GatewayId = product.GatewayId;
                sub.CreditCardId = orderItem.CreditCardId;
                sub.RefId = orderItem.ID;


                sub.IntervalType = IntervalType.Month;
                sub.IntervalLength = 1;
                if (product.AvailableDuration.HasValue)
                    sub.TotalOccurrences = (int)product.AvailableDuration;
                else
                    sub.TotalOccurrences = int.MaxValue;

                sub.TrialOccurrences = 0;
                sub.TotalOccurrencesDone = 0;
                sub.TrialOccurrencesDone = 0;
                sub.TrialAmount = 0;
                sub.Amount = (decimal)product.RecurringPrice;

                if (product.RecurringPrice > 0)
                {
                    BillingController.CreateSubscription(ref sub);
                }
               
                processor.Order.UpdateStatus(processor.Order.Status + 1);
               
            }
            catch (Exception)
            {
                // exception was caught, but at this point card was charged initially, 
                // so we can recreate this later

                processor.OnOrderFailure(new OrderFailureEventArgs("Unable to create subscription"));
               
            }
            processor.ContinueNow = false;

             
        }
示例#4
0
        //private bool ValidateImport(string path) => ResolveImport(path) != null;
        //private string ResolveImport(string path)
        //{
        //    // only allow the things that we actively find under "protoc" on the web root,
        //    // remembering to normalize our slashes; this means that c:\... or ../../ etc will
        //    // all fail, as they are not in "legalImports"
        //    if (legalImports == null)
        //    {
        //        var tmp = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
        //        var root = Path.Combine(_host.WebRootPath, "protoc");
        //        foreach (var found in Directory.EnumerateFiles(root, "*.proto", SearchOption.AllDirectories))
        //        {
        //            if (found.StartsWith(root))
        //            {
        //                tmp.Add(found.Substring(root.Length).TrimStart(DirSeparators)
        //                    .Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), found);
        //            }
        //        }
        //        legalImports = tmp;
        //    }
        //    return legalImports.TryGetValue(path.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar),
        //        out string actual) ? actual : null;
        //}

        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            if (firstRender)
            {
                await Monaco.InitializeAsync();

                Monaco.CreateEditor("protocontainer", "", "proto3lang");
                Monaco.CreateEditor("csharpcontainer", "", "csharp", true);

                var index = UriHelper.Uri.IndexOf("#g");
                if (index > -1)
                {
                    string gisttId = UriHelper.Uri.Substring(index + 2);
                    var    result  = await Http.GetJsonAsync <Gist>("https://api.github.com/gists/" + gisttId);

                    Monaco.SetCode("protocontainer", result?.Files?.Values?.FirstOrDefault()?.Content ?? "");
                }
            }
        }
        public void Process(Monaco.Classroom.Ordering.ProductProcessor processor)
        {
            processor.ContinueNow = false;
            Cathexis.Entities.OrderItem orderItem = new Cathexis.Entities.OrderItem();//= processor.Order;
          //  Product product = ProductController.GetProduct(orderItem.Sku);
            Product product = new Product ();
            double amountToAuthorize = product.InitialPrice;
            GatewayInfo gateway = BillingController.GetGateway(product.GatewayId);
         
            Guid g = new Guid ("FEF56DBF-86D3-428C-926C-00145AF288C5");
            CreditCardInfo card = BillingController.GetCreditCard(g);
            GatewayTypeInfo gatewayType = BillingController.GetGatewayType(gateway.GatewayTypeId);
            Customer customer = BillingController.GetCustomer(orderItem.CustomerID);

            if (amountToAuthorize > 0)
            {
                TransactionInfo transaction = BillingController.ProcessPayment(gateway, gatewayType, orderItem.ID, customer, card, (decimal)amountToAuthorize, orderItem.TestMode);

                if (transaction.Status != TransactionStatus.Approved)
                {
                    // delete the enrollment...
                    // todo: implement logic to delete enrollment
                    

                    processor.OnOrderFailure(new OrderFailureEventArgs("Credit Card Was Declined"));
                    processor.ContinueNow = false;
                }
                else
                {
                    processor.Order.UpdateStatus(processor.Order.Status + 1);
                    processor.ContinueNow = true;
                }
            }
            else
            {
                processor.Order.UpdateStatus(processor.Order.Status + 1);
                processor.ContinueNow = true;
            }
        }
        public void Process(Monaco.Classroom.Ordering.ProductProcessor processor)
        {
            processor.ContinueNow = false;
            OrderItem orderItem = processor.Order;
            Product product = ProductController.GetProduct(orderItem.Sku);
            double amountToAuthorize = product.InitialPrice + product.RecurringPrice;
            GatewayInfo gateway = BillingController.GetGateway(product.GatewayId);
            CreditCardInfo card = BillingController.GetCreditCard(orderItem.CreditCardId);
            GatewayTypeInfo gatewayType = BillingController.GetGatewayType(gateway.GatewayTypeId);
            Monaco.Billing.Provider.Customer customer = BillingController.GetCustomer(orderItem.CustomerID);

            // dont need to run on a $0 price
            if (amountToAuthorize > 0)
            {
                // see if the transaction approves
                TransactionInfo transaction = BillingController.PreAuthorize(gateway, gatewayType, orderItem.ID, customer, card, (decimal)amountToAuthorize, orderItem.TestMode);

                if (transaction.Status != TransactionStatus.Approved)
                {
                    processor.OnOrderFailure(new OrderFailureEventArgs("Credit Card Declined"));
                    processor.ContinueNow = false;
                }
                else
                {
                    processor.Order.UpdateStatus(processor.Order.Status + 1);
                    /* Updating generated order id in transaction table for current transaction */
                    transaction.OrderId = processor.Order.ID;
                    BillingController.UpdateTransaction(ref transaction);

                    processor.ContinueNow = true;
                }
            }
            else
            {
                processor.Order.UpdateStatus(processor.Order.Status + 1);
                processor.ContinueNow = true;
            }
        }
示例#7
0
 void processor_OrderFailure(object o, Monaco.Classroom.Ordering.OrderFailureEventArgs args)
 {
     ErrorMessage.Text = args.ErrorMessage;
 }
示例#8
0
 void processor_OrderSuccess(object o, Monaco.Classroom.Ordering.OrderSuccessEventArgs args)
 {
     if (args.OrderItem != null)
     {
         Response.Redirect("~/Catalog/Thanks.aspx?orderid=" + args.OrderItem.ID.ToString());
     }
     else
     {
         Response.Redirect("~/Catalog/Thanks.aspx");
     }
 }
示例#9
0
 public CustomerCreatedEventArgs(Monaco.Billing.Provider.Customer customer)
 {
     this._customer = customer;
 }
示例#10
0
        /// <summary>
        /// Inserts a student enrollment into the database
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="SKU"></param>
        /// <returns></returns>
        public override bool UpdateStudentEnrollment(Monaco.ELearning.Entities.UserEnrollment userEnrollment)
        {
            DbCommand cmd = SqlHelpers.CreateCommand(DataHelpers.ConnectionString);
            cmd.CommandText = "dbo.mon_elrn_UPDATE_STUDENT_ENROLLMENT";

            cmd.AddInputParam("@UserID", DbType.Guid, userEnrollment.UserID);
            cmd.AddInputParam("@sku", DbType.AnsiString, userEnrollment.SKU);
            cmd.AddInputParam("@CourseID", DbType.Int32, userEnrollment.CourseID);
            cmd.AddInputParam("@IsFree", DbType.Boolean, userEnrollment.IsFree);
            cmd.AddInputParam("@IsTest", DbType.Boolean, userEnrollment.IsTest);
            cmd.AddInputParam("@TrialPeriodDays", DbType.Int32, userEnrollment.TrialPeriod);
            cmd.AddInputParam("@InitialPrice", DbType.Double, userEnrollment.InitialPrice);
            cmd.AddInputParam("@RecurringPrice", DbType.Double, userEnrollment.PricePerMonth);
            cmd.AddInputParam("@EnrollmentStartDate", DbType.DateTime, userEnrollment.EnrollmentStartDate);
            cmd.AddInputParam("@SubscriptionDuration", DbType.Int32, userEnrollment.SubscriptionDuration);
            cmd.AddInputParam("@AvailableDuration", DbType.Int32, userEnrollment.AvailableDuration);

            int result;

            result = int.Parse(SqlHelpers.ExecuteScalar(cmd));
            if (result > 0)
                return true;
            else
                return false;



        }
示例#11
0
 public abstract bool UpdateStudentEnrollment(Monaco.ELearning.Entities.UserEnrollment userEnrollment);
示例#12
0
        public void Generate()
        {
            CodeGenResult = null;

            string schema = Monaco.GetCode("protocontainer");

            if (string.IsNullOrWhiteSpace(schema))
            {
                return;
            }

            Dictionary <string, string> options = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            options["langver"] = LangVer;
            if (OneOfEnum)
            {
                options["oneof"] = "enum";
            }
            if (ListSet)
            {
                options["listset"] = "yes";
            }

            NameNormalizer nameNormalizer = null;

            switch (Names)
            {
            case "auto":
                nameNormalizer = NameNormalizer.Default;
                break;

            case "original":
                nameNormalizer = NameNormalizer.Null;
                break;
            }
            var result = new GenerateResult();

            try
            {
                using (var reader = new StringReader(schema))
                {
                    var set = new FileDescriptorSet
                    {
                        //ImportValidator = path => ValidateImport(path),
                    };
                    //set.AddImportPath(Path.Combine(_host.WebRootPath, "protoc"));
                    set.Add("my.proto", true, reader);

                    set.Process();
                    var errors = set.GetErrors();

                    if (errors.Length > 0)
                    {
                        result.ParserExceptions = errors;
                    }
                    CodeGenerator codegen;
                    switch (Tooling)
                    {
                    case "protogen:VB":
#pragma warning disable 0618
                        codegen = VBCodeGenerator.Default;
#pragma warning restore 0618
                        break;

                    case "protogen:C#":
                    default:
                        codegen = CSharpCodeGenerator.Default;
                        break;
                    }
                    result.Files = codegen.Generate(set, nameNormalizer, options).ToArray();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                result.Exception = ex.Message;
            }
            CodeGenResult = result;
            Monaco.SetCode("csharpcontainer", CodeGenResult?.Files?.FirstOrDefault()?.Text ?? "");
            JSInProcess.InvokeVoid("processResults", CodeGenResult);
        }
示例#13
0
 public static bool UpdateStudentEnrollment(Monaco.ELearning.Entities.UserEnrollment userEnrollment) { return Instance.UpdateStudentEnrollment(userEnrollment); }
示例#14
0
 protected void ForumsDataSource_Selected(object sender, Monaco.Forums.Controls.ForumsDataSource.SelectedEventArgs e)
 {
     _userCount = e.Count;
 }