Beispiel #1
0
        public NetworkDispatch(StarlightClient starlightClient, FormContainer formContainer) : base(typeof(NetworkDispatch).Assembly)
        {
            this.starlightClient = starlightClient;
            this.formContainer   = formContainer;

            Task.Run(ProcessNetworkMessages);
        }
        public static void ShowSetting(object param = null)
        {
            FormContainer formContainer = new FormContainer();

            formContainer.SetControl(new UCMenuBarDesign());
            formContainer.ShowDialog();
        }
        public override void Execute(object parameter, object target)
        {
            var form = FormContainer.Create(new MineCristalDistributionControl(), "Распределение крсталов в шахте");

            form.Width = 700;
            form.Show(AppCore.FormMain);
        }
        private void menuNoteitem_Click(object sender, EventArgs e)
        {
            bool noPicture = this.NoPicture;

            if (!noPicture)
            {
                UCNote    uCNote       = new UCNote();
                Rectangle selectRegion = this._selection.ToNormalRectangle();
                selectRegion.X      = (int)((float)this._selection.X / this.Curratio);
                selectRegion.Y      = (int)((float)this._selection.Y / this.Curratio);
                selectRegion.Width  = (int)((float)this._selection.Width / this.Curratio);
                selectRegion.Height = (int)((float)this._selection.Height / this.Curratio);
                uCNote.SelectRegion = selectRegion;
                uCNote.ImgInfo      = this._curFileInfo;
                uCNote.CutImg       = this.pictureBox1.Image.ImgCut(this._selection.ToNormalRectangle());
                FormContainer formContainer = new FormContainer();
                formContainer.SetControl(uCNote);
                bool flag = formContainer.ShowDialog() == DialogResult.OK;
                if (flag)
                {
                }
                this._selected = false;
                this.pictureBox1.Refresh();
            }
        }
 public ActionResult Index(FormContainer container)
 {
     return(View(new FormContainer()
     {
         Field1 = "123"
     }));
 }
        public static void DoTest(object param)
        {
            FormContainer formContainer = new FormContainer();

            formContainer.SetControl(typeof(UCBatchTemplateEdit));
            formContainer.TopMost = true;
        }
Beispiel #7
0
        public GenericReply GetViewerDesign()
        {
            var reply  = new GenericReply();
            var design = new ViewerDesign();

            var field1 = new Field();
            var field2 = new Field();

            var formField1 = new FormField();
            var formField2 = new FormField();

            var formContainer1 = new FormContainer();

            field1.name = "ROOMS.ID";
            field1.type = "int";

            field2.name = "ROOMS.NAME";
            field2.type = "string";

            formField1.name    = "ROOMS.ID";
            formField1.xtype   = "s1textfield";
            formField1.visible = true;
            formField1.flex    = 2;

            formField2.name    = "ROOMS.NAME";
            formField2.xtype   = "s1textfield";
            formField2.visible = true;
            formField2.flex    = 5;

            formContainer1.name    = "";
            formContainer1.xtype   = "s1cont";
            formContainer1.visible = true;
            formContainer1.items   = new List <IRenderable>()
            {
                formField1,
                formField2
            };

            var model = new Model();

            model.relationship = "OneToOne";
            model.fields       = new List <Field>()
            {
                field1,
                field2
            };

            design.model = new Dictionary <string, Model>();

            design.model.Add("ROOMS", model);

            design.form = new List <IRenderable>()
            {
                formContainer1
            };

            reply.data = design;

            return(reply);
        }
Beispiel #8
0
        public async Task <Guid> Save(Guid id, TForm form, CancellationToken cancellationToken = default(CancellationToken))
        {
            var currentClaimsPrincipal = httpContextAccessor.HttpContext.User;
            var currentUser            = await userManager.GetUserAsync(currentClaimsPrincipal);

            if (currentUser == null)
            {
                throw new UnauthorizedAccessException();
            }

            var formContainer = await dbContext.Set <FormContainer>().FirstOrDefaultAsync(f => f.Id == id && f.User == currentUser, cancellationToken);

            if (formContainer == null)
            {
                formContainer = new FormContainer(currentUser);
                await dbContext.AddAsync(formContainer);
            }
            else
            {
                dbContext.Update(formContainer);
            }

            formContainer.FormType = typeof(TForm);

            var result = await dataStore.Save(formContainer.DocumentId, formContainer.SecretId, form);

            formContainer.DocumentId = result?.DocumentId ?? throw new NullReferenceException("document id is null");
            formContainer.SecretId   = result?.SecretId ?? throw new NullReferenceException("secret id is null");
            await dbContext.SaveChangesAsync();

            return(formContainer.Id);
        }
Beispiel #9
0
        public ActionResult Edit(FormViewModel vm)
        {
            var model = GetModel();

            if (ModelState.IsValid)
            {
                FormContainer formContainer = model.Region <FormContainer>("FormContainer");
                CFItem        submission    = SubmissionService.SaveSubmission(
                    vm.Form,
                    vm.FormSubmissionRef,
                    vm.ItemId,
                    formContainer.EntityTypeId,
                    formContainer.FormId,
                    formContainer.CollectionId);

                CFAuditEntry.eAction action = submission.Id == 0 ? CFAuditEntry.eAction.Create : CFAuditEntry.eAction.Update;
                string actor = User.Identity.IsAuthenticated ? User.Identity.Name : "Annonymous";
                Db.SaveChanges(User.Identity);

                string confirmLink = "confirmation";
                return(Redirect(confirmLink));
            }

            ViewBag.PageModel = model;
            return(View(model.GetView(), vm));
        }
        /// <summary>
        /// Executes this command.
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        public override void Execute(object parameter, object target)
        {
            var form = FormContainer.Create(new BalanceControl(), "Баланс игрока.");

            form.Width = 700;
            form.Show(AppCore.FormMain);
        }
Beispiel #11
0
        public FormContainer BeginForm(string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, object htmlAttributes, BootstrapFormType formType = BootstrapFormType.Horizontal)
        {
            var formAction = UrlHelper.GenerateUrl(null, actionName, controllerName, routeValues, this.helper.RouteCollection, this.helper.ViewContext.RequestContext, true);
            var textWriter = new HtmlTextWriter(helper.ViewContext.Writer);
            var fc         = new FormContainer(textWriter, formAction, method: method, htmlAttributes: htmlAttributes, formType: formType);

            return(fc);
        }
Beispiel #12
0
        public FormContainer BeginForm(BootstrapFormType formType)
        {
            var rawUrl     = this.helper.ViewContext.HttpContext.Request.RawUrl;
            var textWriter = new HtmlTextWriter(helper.ViewContext.Writer);
            var fc         = new FormContainer(textWriter, rawUrl);

            return(fc);
        }
Beispiel #13
0
        public FormContainer BeginForm(IDictionary <string, object> htmlAttributes)
        {
            var rawUrl     = this.helper.ViewContext.HttpContext.Request.RawUrl;
            var textWriter = new HtmlTextWriter(helper.ViewContext.Writer);
            var fc         = new FormContainer(textWriter, rawUrl, BootstrapFormType.Horizontal, FormMethod.Post, htmlAttributes);

            return(fc);
        }
Beispiel #14
0
        public FormContainer BeginForm(BootstrapFormType formType, object htmlAttributes)
        {
            var rawUrl     = this.helper.ViewContext.HttpContext.Request.RawUrl;
            var textWriter = new HtmlTextWriter(helper.ViewContext.Writer);
            var fc         = new FormContainer(textWriter, rawUrl, method: FormMethod.Post, htmlAttributes: htmlAttributes);

            return(fc);
        }
Beispiel #15
0
        public JsonResult Submit(FormViewModel vm, FormContainer formContainer)
        {
            if (ModelState.IsValid)
            {
                SubmissionService subSrv = new SubmissionService(Db);
                //add AttributeMappings -- Apr 10 2018
                IDictionary <string, string> attributeMappings = new Dictionary <string, string>();
                foreach (var map in formContainer.FieldMappings)
                {
                    attributeMappings.Add(map.AttributeName, map.FieldName);
                }
                CFItem submission = subSrv.SaveSubmission(
                    vm.Form,
                    vm.FormSubmissionRef,
                    vm.ItemId,
                    formContainer.EntityTypeId,
                    formContainer.FormId,
                    formContainer.CollectionId, attributeMappings);

                //Sept 16 2019 -- if formContainer.AttachItemToUser = true, throw exception if current user is not authenticate
                if (formContainer.AttachItemToUser)
                {
                    if (!User.Identity.IsAuthenticated)
                    {
                        //throw new HttpException("You have to authenticate to save this page.");
                        vm.Errors = new Dictionary <string, string[]>();
                        vm.Errors.Add("NotAuthorized", (new string[] { "You are not authorized." }));
                        return(Json(vm));
                    }
                }


                // Set's the audit log value when saving.
                // TODO: this should be more automated.
                CFAuditEntry.eAction action = submission.Id == 0 ? CFAuditEntry.eAction.Create : CFAuditEntry.eAction.Update;
                string actor = User.Identity.IsAuthenticated ? User.Identity.Name : "Annonymous";



                Db.SaveChanges(User.Identity);
            }
            else
            {
                vm.Errors = new Dictionary <string, string[]>();

                IEnumerable <KeyValuePair <string, System.Web.Mvc.ModelState> > errors = ModelState.Where(m => m.Value.Errors.Count > 0);
                List <string> errorList = new List <string>();
                foreach (var error in errors)
                {
                    vm.Errors.Add(error.Key, error.Value.Errors.Select(e => e.ErrorMessage).ToArray());
                    // errorList.AddRange(error.Value.Errors.Select(e => e.ErrorMessage));
                }

                // vm.Errors.Add("Message", errorList.ToArray());
            }

            return(Json(vm));
        }
Beispiel #16
0
        /// <summary>
        /// Executes the specified cow.
        /// </summary>
        /// <param name="cow">The cow.</param>
        public void Execute(Cow cow)
        {
            var control = new FightStatisticsControl();
            var form    = FormContainer.Create(control, "Ћог боев " + cow.UserName);

            form.StartPosition = FormStartPosition.CenterParent;
            form.Show(AppCore.FormMain);
            control.Show(cow.UserID);
        }
        public override void Execute(object parameter, object target)
        {
            // var form= new Form\

            var form = FormContainer.Create(new MineTotalStatistics(), "Статистика по шахте");

            form.Width = 700;
            form.Show(AppCore.FormMain);
        }
        public static void ShowSetting(SharpAcquirerFactory aptf)
        {
            FormContainer    formContainer = new FormContainer();
            UCAdapterSetting control       = new UCAdapterSetting(aptf);

            formContainer.SetControl(control);
            formContainer.TopLevel = true;
            formContainer.SetKeyEscCloseForm(true);
            formContainer.ShowDialog();
        }
Beispiel #19
0
        private void Menucategorymodiname_Click(object sender, EventArgs e)
        {
            UCCategory    ctrl      = new UCCategory();
            FormContainer container = new FormContainer();

            container.SetControl(ctrl);
            if (container.ShowDialog() == DialogResult.OK)
            {
                navigateTree.SelectedNode.Text = ctrl.CategoryName;
                (navigateTree.SelectedNode.Tag as NCategoryInfo).CategoryName = ctrl.CategoryName;
                if ((navigateTree.SelectedNode.GetBatchNode().Tag as NBatchInfo).Operation == EOperType.eFROM_SERVER_NOTCHANGE)
                {
                }
            }
        }
        private void menusignaturecheck_Click(object sender, EventArgs e)
        {
            bool noPicture = this.NoPicture;

            if (!noPicture)
            {
                Image toCheckBitmap = this.pictureBox1.Image.ImgCut(this._selection);
                UCSignatureInfoCheck uCSignatureInfoCheck = new UCSignatureInfoCheck();
                FormContainer        formContainer        = new FormContainer();
                uCSignatureInfoCheck.ToCheckBitmap = toCheckBitmap;
                formContainer.SetControl(uCSignatureInfoCheck);
                formContainer.ShowDialog();
                this._selected = false;
                this.pictureBox1.Refresh();
            }
        }
        private void menusignature_Click(object sender, EventArgs e)
        {
            bool noPicture = this.NoPicture;

            if (!noPicture)
            {
                Image clipBitmap = this.pictureBox1.Image.ImgCut(this._selection);
                UCSignatureInfoRecord uCSignatureInfoRecord = new UCSignatureInfoRecord();
                FormContainer         formContainer         = new FormContainer();
                uCSignatureInfoRecord.ClipBitmap = clipBitmap;
                formContainer.SetControl(uCSignatureInfoRecord);
                formContainer.ShowDialog();
                this._selected = false;
                this.pictureBox1.Refresh();
            }
        }
Beispiel #22
0
 public static DialogResult LoadChildForm(string formName, string title = "", Object[] args = null)
 {
     try
     {
         if (FormsFactory.Forms.ContainsKey(formName))
         {
             var          form = (UserControl)Activator.CreateInstance(FormsFactory.Forms[formName], args);
             var          frm  = new FormContainer(form, title);
             DialogResult dr   = frm.ShowDialog();
             return(dr);
         }
     }
     catch (Exception ex)
     {
         KryptonMessageBox.Show(ex.Message, "Error Loading", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     return(DialogResult.Abort);
 }
Beispiel #23
0
        // GET: Forms
        public ActionResult Index()
        {
            var model = GetModel();

            ViewBag.PageModel = model;

            FormContainer formContainer = model.Region <FormContainer>("FormContainer");

            Form form = SubmissionService.CreateSubmissionForm(formContainer.FormId);

            FormViewModel vm = new FormViewModel()
            {
                Form   = form,
                ItemId = 0
            };

            return(View(model.GetView(), vm));
        }
        public bool Acquire()
        {
            bool result;

            try
            {
                FormContainer formContainer = new FormContainer();
                UCPreviewer   uCPreviewer   = new UCPreviewer(this);
                uCPreviewer.Start();
                formContainer.SetControl(uCPreviewer);
                formContainer.SetKeyEscCloseForm(true);
                formContainer.Parent = this.Parent;
                bool flag = formContainer.ShowDialog() == DialogResult.OK;
                if (flag)
                {
                    List <string> images = uCPreviewer.GetImages();
                    bool          flag2  = this.OnAcquired != null;
                    if (flag2)
                    {
                        foreach (string current in images)
                        {
                            this.OnAcquired(this, new TEventArg <string>(current));
                        }
                    }
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            catch (Exception ex)
            {
                bool flag3 = this.OnError != null;
                if (flag3)
                {
                    this.OnError(this, new TEventArg <string>(ex.ToString()));
                }
                result = false;
            }
            return(result);
        }
Beispiel #25
0
        private void BatchAddCategory_Click(object sender, EventArgs e)
        {
            RadTreeNode   parentNode = sender as RadTreeNode;
            UCCategory    ctrl       = new UCCategory();
            FormContainer container  = new FormContainer();

            container.SetControl(ctrl);
            if ((container.ShowDialog() == DialogResult.OK) && !(navigateTree.SelectedNode.Tag is NFileInfo))
            {
                NCategoryInfo categoryInfo = new NCategoryInfo(ctrl.CategoryName);
                RadTreeNode   categoryNode = CreateCategoryNode(parentNode, categoryInfo);
                categoryNode.ContextMenu = this.categoryContextMenu;
                navigateTree.Refresh();
                navigateTree.SelectedNode.ExpandAll();
                Application.DoEvents();
                categoryNode.Selected = true;
                //categoryNode.ExpandAll();
                Application.DoEvents();
            }
        }
Beispiel #26
0
        public JsonResult Submit(FormViewModel vm, FormContainer formContainer)
        {
            if (ModelState.IsValid)
            {
                SubmissionService subSrv = new SubmissionService(Db);
                //add AttributeMappings -- Apr 10 2018
                IDictionary <string, string> attributeMappings = new Dictionary <string, string>();
                foreach (var map in formContainer.FieldMappings)
                {
                    attributeMappings.Add(map.AttributeName, map.FieldName);
                }
                CFItem submission = subSrv.SaveSubmission(
                    vm.Form,
                    vm.FormSubmissionRef,
                    vm.ItemId,
                    formContainer.EntityTypeId,
                    formContainer.FormId,
                    formContainer.CollectionId, attributeMappings);

                // Set's the audit log value when saving.
                // TODO: this should be more automated.
                CFAuditEntry.eAction action = submission.Id == 0 ? CFAuditEntry.eAction.Create : CFAuditEntry.eAction.Update;
                string actor = User.Identity.IsAuthenticated ? User.Identity.Name : "Annonymous";
                Db.SaveChanges(User.Identity);
            }
            else
            {
                vm.Errors = new Dictionary <string, string[]>();

                IEnumerable <KeyValuePair <string, System.Web.Mvc.ModelState> > errors = ModelState.Where(m => m.Value.Errors.Count > 0);
                foreach (var error in errors)
                {
                    vm.Errors.Add(error.Key, error.Value.Errors.Select(e => e.ErrorMessage).ToArray());
                }
            }

            return(Json(vm));
        }
        // GET: Forms
        public ActionResult Index()
        {
            var model = GetModel();

            ViewBag.PageModel = model;

            FormContainer formContainer = model.Region <FormContainer>("FormContainer");

            Form form = SubmissionService.CreateSubmissionForm(
                formContainer.FormId,
                formContainer.EnforceLists,
                formContainer.ShuffleBlocks,
                formContainer.ShuffleQuestions,
                formContainer.QuestionStepOption,
                formContainer.QuestionPartsStepOption);

            FormViewModel vm = new FormViewModel()
            {
                Form   = form,
                ItemId = 0
            };

            return(View(model.GetView(), vm));
        }
Beispiel #28
0
        private static void Download(string exchange, DateTime startDate, DateTime endDate, bool initialRun)
        {
            var regexKey = new Regex("&k=([a-z0-9]*)&");

            const string templateUrl = "http://eoddata.com/data/filedownload.aspx?e={0}&sd={1}&ed={2}&d=1&k={3}&o=d&ea=1&p=0";

            var session   = new AgentSession();
            var action    = new AgentAction("http://eoddata.com/", false);
            var document  = AgentHandler.Instance.PerformAction(session, action);
            var forms     = FormContainer.ParseAll(document.ResponseString, document.Uri);
            var loginForm = forms.FirstOrDefault(x => x.Elements.Any(y => y.Name.EndsWith("txtEmail")) &&
                                                 x.Elements.Any(y => y.Name.EndsWith("txtPassword")) &&
                                                 x.Elements.Any(y => y.Name.EndsWith("btnLogin")));

            if (loginForm == null)
            {
                Console.WriteLine("Can't log in");
                return;
            }

            loginForm.Elements.First(x => x.Name.EndsWith("txtEmail")).Value    = "*****@*****.**";
            loginForm.Elements.First(x => x.Name.EndsWith("txtPassword")).Value = "3b4f5w8i";

            action        = loginForm.CreateLocalAction();
            action.WebURL = "http://eoddata.com/";

            var loggedIn = AgentHandler.Instance.PerformAction(session, action);

            if (!loggedIn.ResponseString.Contains("chris stafford"))
            {
                throw new Exception("Can't log in");
            }

            var downloadAction = new AgentAction("http://eoddata.com/download.aspx", false);
            var downloadResult = AgentHandler.Instance.PerformAction(session, downloadAction);
            var key            = regexKey.Match(downloadResult.ResponseString).Result("$1");

            var downloadUrl = string.Format(
                templateUrl,
                exchange,
                startDate.ToString("yyyyMMdd"),
                endDate.ToString("yyyyMMdd"),
                key);

            Console.WriteLine($"Downloading {exchange}");

            var downloadDataAction = new AgentAction(downloadUrl, false);
            var data = AgentHandler.Instance.PerformAction(session, downloadDataAction);

            Console.WriteLine("Done. Saving.");

            var parseDate = new Func <string, DateTime>(datetimestr => new DateTime(
                                                            int.Parse(datetimestr.Substring(0, 4)),
                                                            int.Parse(datetimestr.Substring(4, 2)),
                                                            int.Parse(datetimestr.Substring(6, 2))));

            var lastTicker = string.Empty;

            using (var db = new MarketContext())
            {
                using (var connection = db.GetConnection())
                {
                    connection.Open();

                    using (var transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            data.ResponseString.Split('\n').ToList().ForEach(line =>
                            {
                                var items = line.Split(',');

                                if (items.Length < 8)
                                {
                                    return;
                                }

                                var eoddata = new EodEntry
                                {
                                    Ticker = exchange + ":" + items[0],
                                    Per    = items[1],
                                    Date   = parseDate(items[2]),
                                    Open   = decimal.Parse(items[3]),
                                    High   = decimal.Parse(items[4]),
                                    Low    = decimal.Parse(items[5]),
                                    Close  = decimal.Parse(items[6]),
                                    Vol    = double.Parse(items[7]),
                                };

                                if (lastTicker != eoddata.Ticker)
                                {
                                    lastTicker = eoddata.Ticker;
                                    Console.WriteLine(eoddata.Ticker);
                                }

                                db.Insert(eoddata, connection, initialRun);
                            });
                        }
                        finally
                        {
                            transaction.Commit();
                        }
                    }
                }
            }

            Console.WriteLine("Done");
        }
Beispiel #29
0
        public override Task Render(RequestContext ctx, StringWriter stream, IDummy authObj)
        {
                        #if MONO
            AddResource(new JsResource(Constants.kWebRoot, "/js/mainPageCompiled.js", true));
                        #endif

            IEnumerable <string> markets = ctx.Request.GetWildcardParameters(2);

            // get any referral partner out of the query args
            int refid = 0;
            if (ctx.Request.QueryArgs.Args.ContainsKey(WebForms.kReferralId))
            {
                int.TryParse((string)ctx.Request.QueryArgs.Args[WebForms.kReferralId], out refid);
            }

            string @base = "", quote = "";
            if (markets.Count() == 2)
            {
                @base = markets.First();
                quote = markets.Last();
            }

            string market = @base + "_" + quote;

            if (authObj.m_database.GetMarket(market) == null)
            {
                ctx.Respond(System.Net.HttpStatusCode.NotFound);
            }

            ImgResource logo = CreateLogo();
            AddResource(logo);

            // render head
            base.Render(ctx, stream, authObj);

            using (new DivContainer(stream, "ng-app", "myApp", "ng-controller", "StatsController", HtmlAttributes.id, "rootId"))
            {
                using (new DivContainer(stream, HtmlAttributes.@class, "jumbotron clearfix no-padding-bottom-top"))
                {
                    using (new DivContainer(stream, HtmlAttributes.@class, "container"))
                    {
                        using (new DivContainer(stream, HtmlAttributes.@class, "row"))
                        {
                            using (new DivContainer(stream, HtmlAttributes.@class, "col-xs-12"))
                            {
                                RenderJumbo(stream, logo);

                                using (new DivContainer(stream, HtmlAttributes.id, "serviceStatusId"))
                                {
                                    SPAN("Market status: ");
                                    SPAN("{{status}}", "", "label label-{{label}}");
                                }

                                /*using (new DivContainer(stream, HtmlAttributes.id, "serviceStatusId"))
                                 * {
                                 *      SPAN("Market status: ");
                                 *      SPAN("{{status}}", "", "label label-{{label}}");
                                 *      HR();
                                 *
                                 *      SPAN("Symbol: ");
                                 *      SPAN("", "assetSymbolId", "label label-success");
                                 *      BR();
                                 *
                                 *      SPAN("Name: ");
                                 *      SPAN("", "assetNameId", "label label-success");
                                 *      BR();
                                 *
                                 *      SPAN("Description: ");
                                 *      SPAN("", "assetDescriptionId", "label label-success");
                                 *      BR();
                                 *
                                 *      SPAN("Supply: ");
                                 *      SPAN("", "assetSupplyId", "label label-success");
                                 *      BR();
                                 *
                                 *      using (new Script(stream, HtmlAttributes.src, "https://api.bitsharesblocks.com/v2/assets/" + @base + "?callback=UpdateAssetDetails"))
                                 *      {
                                 *
                                 *      }
                                 * }*/
                            }
                        }
                    }
                }

                //
                // buy and sell section
                //
                //
                using (new DivContainer(stream, HtmlAttributes.@class, "container"))
                {
                    using (new DivContainer(stream, HtmlAttributes.@class, "row"))
                    {
                        using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-6"))
                        {
                            Button("Buy {{market.base_symbol}}<br/><span class='badge'>1.00 {{market.quote_symbol}}</span><span class='glyphicon glyphicon-arrow-right arrow'></span><span class='badge'>{{market.buy_quantity | number:3}} {{market.base_symbol}}</span>",
                                   HtmlAttributes.@class, "btn btn-success btn-lg btn-block",
                                   "data-toggle", "collapse",
                                   "aria-expanded", "false",
                                   "aria-controls", "buyId",
                                   "data-target", "#buyId");

                            using (new Panel(stream, "Buy {{market.base_symbol}}", "panel panel-success collapse in", false, "buyId"))
                            {
                                P("Once you enter your BitShares account name, we will generate your deposit address and send your {{market.base_symbol}} to you after 1 confirmation.");

                                using (var fm = new FormContainer(stream, HtmlAttributes.method, "post",
                                                                  HtmlAttributes.ajax, true,
                                                                  HtmlAttributes.handler, "OnSubmitAddressBts",
                                                                  HtmlAttributes.action, Routes.kSubmitAddress))
                                {
                                    using (new DivContainer(stream, HtmlAttributes.@class, "form-group"))
                                    {
                                        fm.Label(stream, "Where shall we send your {{market.base_symbol}}?");

                                        fm.Input(stream, HtmlAttributes.type, InputTypes.hidden,
                                                 HtmlAttributes.name, WebForms.kOrderType,
                                                 HtmlAttributes.value, MetaOrderType.buy.ToString());

                                        fm.Input(stream, HtmlAttributes.type, InputTypes.hidden,
                                                 HtmlAttributes.name, WebForms.kReferralId,
                                                 HtmlAttributes.value, refid);

                                        fm.Input(stream, HtmlAttributes.type, InputTypes.hidden,
                                                 HtmlAttributes.name, WebForms.kSymbolPair,
                                                 HtmlAttributes.value, market);

                                        using (new DivContainer(stream, HtmlAttributes.@class, "input-group"))
                                        {
                                            fm.Input(stream, HtmlAttributes.type, InputTypes.text,
                                                     HtmlAttributes.name, WebForms.kReceivingAddress,
                                                     HtmlAttributes.minlength, 1,
                                                     HtmlAttributes.maxlength, 63,
                                                     HtmlAttributes.required, true,
                                                     HtmlAttributes.id, "bitsharesBlurId",
                                                     HtmlAttributes.@class, "form-control submitOnBlur",
                                                     HtmlAttributes.placeholder, "BitShares account name");

                                            using (new Span(stream, HtmlAttributes.@class, "input-group-btn"))
                                            {
                                                Button("Submit", HtmlAttributes.@class, "btn btn-info");
                                            }
                                        }
                                    }

                                    Alert("", "alert alert-danger", "bitsharesErrorId", true);
                                }

                                using (var fm = new FormContainer(stream))
                                {
                                    using (new DivContainer(stream, HtmlAttributes.@class, "form-group has-success unhideBtsId"))
                                    {
                                        fm.Label(stream, "Your bitcoin deposit address");
                                        fm.Input(stream, HtmlAttributes.type, InputTypes.text,
                                                 HtmlAttributes.id, "bitcoinDespositId",
                                                 HtmlAttributes.@class, "form-control",
                                                 HtmlAttributes.@readonly, "readonly",
                                                 HtmlAttributes.style, "cursor:text;");
                                    }

                                    Button("Click to generate QR code", HtmlAttributes.@class, "btn btn-warning btn-xs pull-right unhideBtsId",
                                           HtmlAttributes.onclick, "GenerateQrModal()");
                                    SPAN("Maximum {{market.ask_max | number:8}} {{market.quote_symbol}} per transaction", "maxBtcId", "label label-info");
                                }
                            }
                        }
                        using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-6"))
                        {
                            Button("Sell {{market.base_symbol}}<br/><span class='badge'>{{market.sell_quantity | number:3}} {{market.base_symbol}}</span><span class='glyphicon glyphicon-arrow-right arrow'></span><span class='badge'>1.00 {{market.quote_symbol}}</span>", HtmlAttributes.@class, "btn btn-danger btn-lg btn-block",
                                   "data-toggle", "collapse",
                                   "aria-expanded", "false",
                                   "aria-controls", "sellId",
                                   "data-target", "#sellId");

                            using (new Panel(stream, "Sell {{market.base_symbol}}", "panel panel-danger collapse in", false, "sellId"))
                            {
                                P("Once you enter your bitcoin receiving address, we will generate your deposit address and send your bitcoins to you the instant we receive your {{market.base_symbol}}.");

                                using (var fm = new FormContainer(stream, HtmlAttributes.method, "post",
                                                                  HtmlAttributes.ajax, true,
                                                                  HtmlAttributes.action, Routes.kSubmitAddress,
                                                                  HtmlAttributes.handler, "OnSubmitAddressBtc"))
                                {
                                    fm.Input(stream, HtmlAttributes.type, InputTypes.hidden,
                                             HtmlAttributes.name, WebForms.kOrderType,
                                             HtmlAttributes.value, MetaOrderType.sell.ToString());

                                    fm.Input(stream, HtmlAttributes.type, InputTypes.hidden,
                                             HtmlAttributes.name, WebForms.kReferralId,
                                             HtmlAttributes.value, refid);

                                    fm.Input(stream, HtmlAttributes.type, InputTypes.hidden,
                                             HtmlAttributes.id, "symbolPairId",
                                             HtmlAttributes.name, WebForms.kSymbolPair,
                                             HtmlAttributes.value, market);

                                    using (new DivContainer(stream, HtmlAttributes.@class, "form-group"))
                                    {
                                        fm.Label(stream, "Where shall we send your bitcoins?");
                                        using (new DivContainer(stream, HtmlAttributes.@class, "input-group"))
                                        {
                                            fm.Input(stream, HtmlAttributes.type, InputTypes.text,
                                                     HtmlAttributes.name, WebForms.kReceivingAddress,
                                                     HtmlAttributes.minlength, 25,
                                                     HtmlAttributes.maxlength, 34,
                                                     HtmlAttributes.required, true,
                                                     HtmlAttributes.id, "bitcoinBlurId",
                                                     HtmlAttributes.@class, "form-control submitOnBlur",
                                                     HtmlAttributes.placeholder, "Bitcoin address from your wallet");

                                            using (new Span(stream, HtmlAttributes.@class, "input-group-btn"))
                                            {
                                                Button("Submit", HtmlAttributes.@class, "btn btn-info");
                                            }
                                        }
                                    }

                                    Alert("", "alert alert-danger", "bitcoinErrorId", true);
                                }

                                using (var fm = new FormContainer(stream))
                                {
                                    using (new DivContainer(stream, HtmlAttributes.@class, "unhideBtcId"))
                                    {
                                        using (new DivContainer(stream, HtmlAttributes.@class, "form-group has-success"))
                                        {
                                            fm.Label(stream, "Your BitShares deposit account");
                                            fm.Input(stream, HtmlAttributes.type, InputTypes.text,
                                                     HtmlAttributes.id, "bitsharesDespositAccountId",
                                                     "ng-model", "sell.sendToAccount",
                                                     HtmlAttributes.@class, "form-control",
                                                     HtmlAttributes.@readonly, "readonly",
                                                     HtmlAttributes.style, "cursor:text;");
                                        }

                                        using (new DivContainer(stream, HtmlAttributes.@class, "form-group has-success"))
                                        {
                                            fm.Label(stream, "Your BitShares deposit memo");
                                            fm.Input(stream, HtmlAttributes.type, InputTypes.text,
                                                     HtmlAttributes.id, "bitsharesMemoId",
                                                     "ng-model", "sell.memo",
                                                     HtmlAttributes.@class, "form-control",
                                                     HtmlAttributes.@readonly, "readonly",
                                                     HtmlAttributes.style, "cursor:text;");
                                        }
                                    }

                                    Button("Click to generate transaction", HtmlAttributes.@class, "btn btn-warning btn-xs pull-right unhideBtcId",
                                           HtmlAttributes.onclick, "GenerateTransactionModal()");
                                    SPAN("Maximum {{market.bid_max | number:8}} {{market.base_symbol}} per transaction", "maxbitBtcId", "label label-info pull-left");
                                }
                            }
                        }
                    }
                }

                //
                // bullet points
                //

                using (new DivContainer(stream, HtmlAttributes.@class, "container",
                                        HtmlAttributes.style, "margin-top:20px"))
                {
                    using (new DivContainer(stream, HtmlAttributes.@class, "row"))
                    {
                        using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4"))
                        {
                            H4("<i class=\"glyphicon glyphicon-ok text-info\"></i>  No registration required");
                            P("There is no need to register an account, just tell us where you'd like to receive the coins that you buy or sell.");
                        }

                        using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4"))
                        {
                            H4("<i class=\"glyphicon glyphicon-flash text-info\"></i>  Fast transactions");
                            P("Only one confirmation is neccessary for buying or selling, which is around 7 minutes for a buy and around 3 seconds for a sell.");
                        }

                        using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-4"))
                        {
                            H4("<i class=\"glyphicon glyphicon-lock text-info\"></i>  Safe");
                            P("We don't hold any of our customer's funds, so there is nothing to get lost or stolen.");
                        }
                    }
                }

                using (new DivContainer(stream, HtmlAttributes.@class, "bg-primary hidden-xs",
                                        HtmlAttributes.style, "margin-top:20px"))
                {
                    using (new DivContainer(stream, HtmlAttributes.@class, "container"))
                    {
                        using (new DivContainer(stream, HtmlAttributes.style, "margin:30px 0px 30px 0px"))
                        {
                            using (new DivContainer(stream, HtmlAttributes.@class, "row unhideBtsId unhideBtcId",
                                                    HtmlAttributes.id, "myTransactionsId"))
                            {
                                using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-12"))
                                {
                                    H3("Your transactions");

                                    using (new Table(stream, "", 4, 4, "table noMargin", "Market", "Type", "Price", "Amount", "Fee", "Date", "Status", "Notes", "Inbound Tx", "Outbound Tx"))
                                    {
                                        using (var tr = new TR(stream, "ng-repeat", "t in myTransactions"))
                                        {
                                            tr.TD("{{renameSymbolPair(t.symbol_pair)}}");
                                            tr.TD("{{t.order_type}}");
                                            tr.TD("{{t.price}}");
                                            tr.TD("{{t.amount}}");
                                            tr.TD("{{t.fee}}");
                                            tr.TD("{{t.date*1000 | date:'MMM d, HH:mm'}}");
                                            tr.TD("{{t.status}}");
                                            tr.TD("{{t.notes}}");
                                            tr.TD("<a ng-if=\"t.order_type=='" + MetaOrderType.buy + "'\" target=\"_blank\" ng-href=\"https://blockchain.info/tx/{{t.received_txid}}\">Look up</a>" +
                                                  "<a ng-if=\"t.order_type=='" + MetaOrderType.sell + "'\" target=\"_blank\" ng-href=\"http://bitsharesblocks.com/blocks/block?trxid={{t.received_txid}}\">Look up</a>");

                                            tr.TD("<a ng-if=\"t.order_type=='" + MetaOrderType.buy + "' && t.status == '" + MetaOrderStatus.completed + "'\" target=\"_blank\" ng-href=\"http://bitsharesblocks.com/blocks/block?trxid={{t.sent_txid}}\">Look up</a>" +
                                                  "<a ng-if=\"t.order_type=='" + MetaOrderType.buy + "' && t.status == '" + MetaOrderStatus.refunded + "'\" target=\"_blank\" ng-href=\"https://blockchain.info/tx/{{t.sent_txid}}\">Look up</a>" +
                                                  "<a ng-if=\"t.order_type=='" + MetaOrderType.sell + "' && t.status == '" + MetaOrderStatus.completed + "'\" target=\"_blank\" ng-href=\"https://blockchain.info/tx/{{t.sent_txid}}\">Look up</a>" +
                                                  "<a ng-if=\"t.order_type=='" + MetaOrderType.sell + "' && t.status == '" + MetaOrderStatus.refunded + "'\" target=\"_blank\" ng-href=\"http://bitsharesblocks.com/blocks/block?trxid={{t.sent_txid}}\">Look up</a>");
                                        }
                                    }
                                }
                            }

                            using (new DivContainer(stream, HtmlAttributes.@class, "unhideBtsId unhideBtcId"))
                            {
                                HR();
                            }

                            using (new DivContainer(stream, HtmlAttributes.@class, "row"))
                            {
                                using (new DivContainer(stream, HtmlAttributes.@class, "col-sm-12"))
                                {
                                    H3("Recent {{renameSymbolPair(market.symbol_pair)}} transactions");

                                    using (new Table(stream, "", 4, 4, "table noMargin", "Market", "Type", "Price", "Amount", "Fee", "Date"))
                                    {
                                        using (var tr = new TR(stream, "ng-repeat", "t in transactions"))
                                        {
                                            tr.TD("{{renameSymbolPair(t.symbol_pair)}}");
                                            tr.TD("{{t.order_type}}");
                                            tr.TD("{{t.price}}");
                                            tr.TD("{{t.amount}}");
                                            tr.TD("{{t.fee}}");
                                            tr.TD("{{t.date*1000 | date:'MMM d, HH:mm'}}");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                Modal("Generate BitShares transaction", "bitsharesModalId", () =>
                {
                    using (var fm = new FormContainer(stream))
                    {
                        using (new DivContainer(stream, HtmlAttributes.@class, "form-group"))
                        {
                            fm.Label(stream, "Sending amount");

                            using (new DivContainer(stream, HtmlAttributes.@class, "input-group"))
                            {
                                fm.Input(stream, HtmlAttributes.type, InputTypes.number,
                                         HtmlAttributes.name, "amount",
                                         HtmlAttributes.@class, "form-control",
                                         HtmlAttributes.required, true,
                                         HtmlAttributes.id, "gtxAmountId",
                                         "ng-model", "sell.quantity",
                                         HtmlAttributes.placeholder, "bitAsset quantity");

                                SPAN("{{market.base_symbol}}", "", "input-group-addon");
                            }
                        }

                        using (new DivContainer(stream, HtmlAttributes.@class, "form-group"))
                        {
                            fm.Label(stream, "Account name to send from");

                            fm.Input(stream, HtmlAttributes.type, InputTypes.text,
                                     HtmlAttributes.name, "account",
                                     HtmlAttributes.@class, "form-control",
                                     HtmlAttributes.required, true,
                                     HtmlAttributes.id, "gtxAccountId",
                                     "ng-model", "sell.payFrom",
                                     HtmlAttributes.placeholder, "Sending acount");
                        }

                        Href(stream, "Click to open in BitShares",
                             HtmlAttributes.id, "bitsharesLinkId",
                             HtmlAttributes.href, "bts:{{sell.sendToAccount}}/transfer/amount/{{sell.quantity}}/memo/{{sell.memo}}/from/{{sell.payFrom}}/asset/{{(market.base_symbol).TrimStart('bit')}}",
                             HtmlAttributes.style, "display:none",
                             HtmlAttributes.@class, "btn btn-success");
                    }
                }, true, "", "modal", "close", false);

                Modal("Scan for bitcoin address", "qrModalId", () =>
                {
                    using (new DivContainer(stream, "row text-center"))
                    {
                        BaseComponent.IMG(stream, "", HtmlAttributes.@class, "center-block");
                    }
                }, true, "", "modal", "close", false);
            }

            return(null);
        }
Beispiel #30
0
 public RequestContext(int connectionId, StarlightClient networkClient, FormContainer formContainer)
 {
     this.ConnectionId  = connectionId;
     this.NetworkClient = networkClient;
     this.FormContainer = formContainer;
 }