예제 #1
0
        private void PrintLine(SummaryTable table, string[] line, ILogger logger, string leftDel, string rightDel)
        {
            for (int columnIndex = 0; columnIndex < table.ColumnCount; columnIndex++)
            {
                if (table.Columns[columnIndex].NeedToShow)
                {
                    logger.WriteStatistic(leftDel + line[columnIndex].HtmlEncode() + rightDel);
                }
            }

            logger.WriteLine();
        }
예제 #2
0
        private void PrintTable(SummaryTable table, ILogger logger)
        {
            if (table.FullContent.Length == 0)
            {
                logger.WriteLineError("There are no benchmarks found ");
                logger.WriteLine();
                return;
            }

            table.PrintCommonColumns(logger);
            logger.WriteLine();

            if (useCodeBlocks)
            {
                logger.Write(codeBlockEnd);
                logger.WriteLine();
            }

            if (columnsStartWithSeparator)
            {
                logger.Write(tableHeaderSeparator);
            }

            table.PrintLine(table.FullHeader, logger, string.Empty, tableHeaderSeparator);
            if (useHeaderSeparatingRow)
            {
                if (columnsStartWithSeparator)
                {
                    logger.Write(tableHeaderSeparator);
                }

                logger.WriteLineStatistic(string.Join("", table.Columns.Where(c => c.NeedToShow).Select(column => new string('-', column.Width) + getJustificationIndicator(column.Justify) + "|")));
            }
            var rowCounter   = 0;
            var highlightRow = false;

            foreach (var line in table.FullContent)
            {
                // Each time we hit the start of a new group, alternative the colour (in the console) or display bold in Markdown
                if (table.FullContentStartOfGroup[rowCounter])
                {
                    highlightRow = !highlightRow;
                }

                if (columnsStartWithSeparator)
                {
                    logger.Write(tableColumnSeparator);
                }

                table.PrintLine(line, logger, string.Empty, tableColumnSeparator, highlightRow, table.FullContentStartOfGroup[rowCounter], startOfGroupInBold, boldMarkupFormat);
                rowCounter++;
            }
        }
예제 #3
0
        [Fact] // Issue #1168
        public void ZeroValueInMetricColumnIsDashedByDefault()
        {
            // arrange
            var config  = ManualConfig.Create(DefaultConfig.Instance);
            var metrics = new[] { new Metric(new FakeMetricDescriptor("metric1", "some legend", "0.0"), 0.0) };

            // act
            var summary = MockFactory.CreateSummary(config, hugeSd: false, metrics);
            var table   = new SummaryTable(summary);
            var actual  = table.Columns.First(c => c.Header == "metric1").Content;

            // assert
            Assert.True(actual.All(value => "-" == value));
        }
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                TypeDef definingType = null;
                if (this.typesMethods != null && this.typesMethods.Count > 0)
                {
                    definingType = (TypeDef)this.typesMethods[0].Type;
                }
                if (!this.xmlComments.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(definingType));
                }

                this.Blocks.Add(new Header1(definingType.GetDisplayName(false) + " Constructors"));

                if (this.typesMethods != null && this.typesMethods.Count > 0)
                {
                    SummaryTable methods = new SummaryTable();

                    var sortedMethods = from method in this.typesMethods
                                        where method.IsConstructor &&
                                        !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(method)
                                        orderby method.Name
                                        select method;
                    foreach (MethodDef currentMethod in sortedMethods)
                    {
                        CRefPath crefPath = new CRefPath(currentMethod);
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new System.Windows.Documents.Run(currentMethod.GetDisplayName(false)));
                        link.Tag    = new EntryKey(currentMethod.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block constructorSummary = this.GetSummaryFor(
                            xmlComments,
                            currentMethod.Assembly,
                            crefPath
                            );

                        methods.AddItem(link, constructorSummary, Model.ElementIconConstants.GetIconPathFor(currentMethod));
                    }
                    this.Blocks.Add(methods);
                }

                this.IsGenerated = true;
            }
        }
        private void PrintTable(SummaryTable table, ILogger logger)
        {
            if (table.FullContent.Length == 0)
            {
                logger.WriteLineError("There are no benchmarks found ");
                logger.WriteLine();
                return;
            }

            table.PrintCommonColumns(logger);
            logger.WriteLine();

            logger.WriteLine("Time unit definitions");

            foreach (var item in TimeUnit.All)
            {
                logger.WriteLine($"{item.Name}={item.Description}");
            }

            logger.WriteLine();

            if (useCodeBlocks)
            {
                logger.Write("```");
                logger.WriteLine();
            }

            table.PrintLine(table.FullHeader, logger, string.Empty, " |");
            logger.WriteLineStatistic(string.Join("", table.Columns.Where(c => c.NeedToShow).Select(c => new string('-', c.Width) + " |")));
            var rowCounter   = 0;
            var highlightRow = false;

            foreach (var line in table.FullContent)
            {
                // Each time we hit the start of a new group, alternative the colour (in the console) or display bold in Markdown
                if (table.FullContentStartOfGroup[rowCounter])
                {
                    highlightRow = !highlightRow;
                }

                table.PrintLine(line, logger, string.Empty, " |", highlightRow, table.FullContentStartOfGroup[rowCounter], startOfGroupInBold);
                rowCounter++;
            }

            logger.WriteLine();
        }
예제 #6
0
        //Insert Expense
        public ActionResult InsertExpense([Bind(Include = "STId,TradeType,TradeDate,UserName")] SummaryTable summaryTable, [Bind(Include = "ExCashID,UserName,ExCashType,ExAmount,ExDate,ExNote")] CashExpense cashExpense)
        {
            if (Session["User"] == null)
            {
                return(RedirectToRoute("Default", new { Controller = "Home", Action = "Index" }));
            }

            if (ModelState.IsValid)
            {
                var username = Convert.ToString(Session["User"]);
                var Esum     = (db.CashExpense.Sum(c => c.ExAmount) + Convert.ToInt32(cashExpense.ExAmount)).HasValue? db.CashExpense.Sum(c => c.ExAmount) + Convert.ToInt32(cashExpense.ExAmount):0;
                var Isum     = db.CashIncome.Sum(c => c.InAmount).HasValue? db.CashIncome.Sum(c => c.InAmount):0;
                var net      = Isum - Esum;
                //如果淨資產小於零,不給新增支出項目
                if (net - cashExpense.ExAmount < 0)
                {
                    return(Json(net - cashExpense.ExAmount, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    //更新userdata的cashvalue
                    var userdata = db.UsersData.Where(c => c.UserName == username).Select(c => c).SingleOrDefault();
                    userdata.CashValue       = (double)net;
                    db.Entry(userdata).State = EntityState.Modified;
                    //新增總表資料
                    summaryTable.TradeType = cashExpense.ExCashType;
                    summaryTable.TradeDate = cashExpense.ExDate;
                    summaryTable.UserName  = cashExpense.UserName;
                    db.SummaryTable.Add(summaryTable);
                    //新增支出表資料
                    cashExpense.OID = summaryTable.STId;
                    db.CashExpense.Add(cashExpense);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception er)
                    {
                        throw er;
                    }
                    return(RedirectToAction("Index"));
                }
            }
            return(View(cashExpense));
        }
        //Insert Income
        public ActionResult InsertIncome([Bind(Include = "STId,TradeType,TradeDate,UserName")] SummaryTable summaryTable, [Bind(Include = "InCashID,UserName,InCashType,InAmount,InDate,InNote")] CashIncome cashIncome)
        {
            summaryTable.TradeType = cashIncome.InCashType;
            summaryTable.TradeDate = cashIncome.InDate;
            summaryTable.UserName  = cashIncome.UserName;
            db.SummaryTable.Add(summaryTable);
            db.SaveChanges();

            cashIncome.OID = summaryTable.STId;
            if (ModelState.IsValid)
            {
                db.CashIncome.Add(cashIncome);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cashIncome));
        }
예제 #8
0
        /// <summary>
        /// Generates the pages contents.
        /// </summary>
        public override void Generate()
        {
            if (!IsGenerated)
            {
                TypeDef definingType = null;
                if (_properties != null && _properties.Count > 0)
                {
                    definingType = (TypeDef)_properties[0].OwningType;
                }
                if (!_xmlComments.Exists())
                {
                    Blocks.Add(new NoXmlComments(definingType));
                }

                Blocks.Add(new Header1(definingType.GetDisplayName(false) + " Properties"));

                if (_properties != null && _properties.Count > 0)
                {
                    SummaryTable methods = new SummaryTable();

                    var sortedProperties = from property in _properties
                                           orderby new DisplayNameSignitureConvertor(property, false, true).Convert()
                                           select property;

                    foreach (PropertyDef currentProperty in sortedProperties)
                    {
                        CRefPath path = new CRefPath(currentProperty);
                        System.Windows.Documents.Hyperlink link = new System.Windows.Documents.Hyperlink();
                        link.Inlines.Add(new Run(new DisplayNameSignitureConvertor(currentProperty, false, true).Convert()));
                        link.Tag    = new EntryKey(currentProperty.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block description = GetSummaryFor(_xmlComments,
                                                          currentProperty.OwningType.Assembly,
                                                          path);

                        methods.AddItem(link, description, Model.ElementIconConstants.GetIconPathFor(currentProperty));
                    }
                    this.Blocks.Add(methods);
                }

                this.IsGenerated = true;
            }
        }
        public override void Generate()
        {
            this.Blocks.Add(new Header1(this.associatedEntry.Name));

            SummaryTable classTable = new SummaryTable("Namespace", string.Empty, false, false);

            foreach (Entry currentNamespace in this.associatedEntry.Children)
            {
                CRefPath crefPath = CRefPath.Parse(string.Format("N:{0}", currentNamespace.SubKey));

                // Find the description for the type
                // Block description = this.GetSummaryFor(xmlFile, currentType.Assembly, "/doc/members/member[@name='" + crefPath + "']/summary");
                Hyperlink nameLink = new Hyperlink(new Run(currentNamespace.Name));
                nameLink.Tag    = new EntryKey(currentNamespace.Key, currentNamespace.SubKey);
                nameLink.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);
                classTable.AddItem(nameLink, string.Empty);
            }
            this.Blocks.Add(classTable);
        }
예제 #10
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create(FXtradeTable tradeTable, SummaryTable summaryTable)
        {
            if (ModelState.IsValid)
            {
                //var x = Session["User"].ToString();
                //var x = "5566";
                //summaryTable.UserName = x;
                db.SummaryTable.Add(summaryTable);
                db.SaveChanges();

                //summaryTable.UserName = "******";
                var uid = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                tradeTable.SummaryId = uid;
                db.FXtradeTable.Add(tradeTable);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(tradeTable));
        }
예제 #11
0
        public ActionResult CreateEXD([Bind(Include = "TradeType,TradeDate,UserName")] SummaryTable summaryTable, [Bind(Include = "stockID,stockPrice,stockAmount,stockFee,stockTax,stockNetincome,stockNote")] StockHistory stockHistory)
        {
            if (Session["User"] == null)
            {
                return(RedirectToRoute("Default", new { Controller = "Home", Action = "Index" }));
            }

            //([Bind(Include = "TradeType,date,userID")]
            //[Bind(Include = "stockID,stockPrice,stockAmount,stockFee,stockTax,stockNetincome,stockNote"])
            if (ModelState.IsValid)
            {
                db.SummaryTable.Add(summaryTable);
                db.SaveChanges();

                var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                //存入現金帳戶
                CashIncome cashincome = new CashIncome();
                cashincome.OID        = id;
                cashincome.UserName   = summaryTable.UserName;
                cashincome.InCashType = summaryTable.TradeType;
                cashincome.InAmount   = (stockHistory.stockNetincome);
                cashincome.InDate     = summaryTable.TradeDate;
                cashincome.InNote     = "除息收入";
                db.CashIncome.Add(cashincome);
                db.SaveChanges();

                //存入股票交易紀錄表
                stockHistory.STId = id;
                AVGCalculator calculator = new AVGCalculator();
                string        _username  = Session["User"].ToString();
                string        _searchid  = stockHistory.stockID.ToString();
                int           _invchange = (int)stockHistory.stockAmount;
                int           _cashflow  = (int)stockHistory.stockNetincome;
                stockHistory.stockLastAVG = calculator.GetAvg(_username, _searchid, _invchange, _cashflow);
                db.StockHistory.Add(stockHistory);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }


            return(RedirectToAction("Index"));
        }
예제 #12
0
        /// <summary>
        /// Generates the pages contents
        /// </summary>
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                TypeRef definingType = null;
                if (_fields.Count > 0)
                {
                    definingType = _fields[0].Type;
                }
                if (!_xmlComments.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(definingType));
                }

                this.Blocks.Add(new Header1(definingType.GetDisplayName(false) + " Fields"));

                if (_fields != null && _fields.Count > 0)
                {
                    SummaryTable displayedFields = new SummaryTable();

                    var sortedFields = from field in _fields
                                       orderby field.Name
                                       where !LiveDocumentorFile.Singleton.LiveDocument.IsMemberFiltered(field)
                                       select field;
                    foreach (FieldDef currentField in sortedFields)
                    {
                        CRefPath  crefPath = new CRefPath(currentField);
                        Hyperlink link     = new Hyperlink();
                        link.Inlines.Add(new Run(currentField.Name));
                        link.Tag    = new EntryKey(currentField.GetGloballyUniqueId());
                        link.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);

                        Block summary = GetXmlComments(currentField, crefPath);

                        displayedFields.AddItem(link, summary, Model.ElementIconConstants.GetIconPathFor(currentField));
                    }
                    this.Blocks.Add(displayedFields);
                }

                this.IsGenerated = true;
            }
        }
예제 #13
0
        public ActionResult CreateStockBuy([Bind(Include = "TradeType,TradeDate,UserName")] SummaryTable summaryTable, [Bind(Include = "stockID,stockPrice,stockAmount,stockFee,stockTax,stockNetincome,stockNote,CashAccount")] StockHistory stockHistory)
        {
            if (Session["User"] == null)
            {
                return(RedirectToRoute("Default", new { Controller = "Home", Action = "Index" }));
            }

            if (ModelState.IsValid)
            {
                //存入總表獲得交易序號
                db.SummaryTable.Add(summaryTable);
                db.SaveChanges();
                var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                if (stockHistory.CashAccount)
                {
                    CashExpense expense = new CashExpense();
                    expense.OID        = id;
                    expense.UserName   = summaryTable.UserName;
                    expense.ExCashType = summaryTable.TradeType;
                    expense.ExAmount   = (stockHistory.stockNetincome) * (-1);
                    expense.ExDate     = summaryTable.TradeDate;
                    expense.ExNote     = "買進股票";
                    db.CashExpense.Add(expense);
                    db.SaveChanges();
                }
                //存入股票交易紀錄表
                stockHistory.STId        = id;
                stockHistory.stockAmount = stockHistory.stockAmount * 1000;
                AVGCalculator calculator = new AVGCalculator();
                string        _username  = Session["User"].ToString();
                string        _searchid  = stockHistory.stockID.ToString();
                int           _invchange = (int)stockHistory.stockAmount;
                int           _cashflow  = (int)stockHistory.stockNetincome;
                stockHistory.stockLastAVG = calculator.GetAvg(_username, _searchid, _invchange, _cashflow);
                db.StockHistory.Add(stockHistory);
                db.SaveChanges();
                ViewBag.Alert = "alert('新增成功')";
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
예제 #14
0
        //[Ignore]
        public void VsSummaryTableTest()
        {
            EidssUserContext.Init();
            var session = VsSessionTest.GetTestSession();

            var frm = new Form
            {
                Size          = new Size(500, 300),
                StartPosition = FormStartPosition.CenterScreen,
            };

            var navBarControl = new NavBarControl();

            frm.Controls.Add(navBarControl);
            navBarControl.Dock = DockStyle.Fill;
            navBarControl.FillTestSummary(SummaryTable.GetSummaryTables(session.FieldTests));

            frm.ShowDialog();
            EidssUserContext.Clear();
        }
예제 #15
0
        public ActionResult CreateEXS([Bind(Include = "TradeType,TradeDate,UserName")] SummaryTable summaryTable, [Bind(Include = "stockID,stockPrice,stockAmount,stockFee,stockTax,stockNetincome,stockNote")] StockHistory stockHistory)
        {
            //([Bind(Include = "TradeType,date,userID")]
            //[Bind(Include = "stockID,stockPrice,stockAmount,stockFee,stockTax,stockNetincome,stockNote")
            if (ModelState.IsValid)
            {
                db.SummaryTable.Add(summaryTable);
                db.SaveChanges();

                var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                stockHistory.STId = id;
                db.StockHistory.Add(stockHistory);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }


            return(RedirectToAction("Index"));
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "SerialNumber,UserID,InsuranceName,PurchaseDate,WithdrawDate,PaymentPerYear,PayYear,PurchaseOrWithdraw,CashFlow,Withdrawal,RelateCash")] Insurances insurances)
        {
            if (insurances.RelateCash == true)
            {
                insurances.CashFlow = -insurances.PaymentPerYear * insurances.PayYear;
            }
            else
            {
                insurances.CashFlow = 0;
            }
            insurances.PurchaseOrWithdraw = true;
            insurances.Withdrawed         = false;

            //insurances.UserID = Session["User"].ToString();
            if (ModelState.IsValid)
            {
                insurances.UserID = Session["User"].ToString();
                SummaryTable ST = new SummaryTable {
                    TradeType = "保險", TradeDate = insurances.PurchaseDate, UserName = insurances.UserID
                };
                db.SummaryTable.Add(ST);
                db.SaveChanges();
                var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                insurances.STID = id;
                db.Insurances.Add(insurances);
                db.SaveChanges();

                CashExpense CE = new CashExpense();
                CE.ExAmount   = -insurances.CashFlow;
                CE.UserName   = insurances.UserID;
                CE.ExDate     = ST.TradeDate;
                CE.ExCashType = ST.TradeType;
                CE.OID        = id;

                db.CashExpense.Add(CE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(insurances));
        }
예제 #17
0
        public ActionResult Create([Bind(Include = "TradeType,date,userID")] SummaryTable summaryTable, [Bind(Include = "stockID,stockPrice,stockAmount,stockTP,stockFee,stockTax,stockNetincome,stockNote")] StockHistory stockHistory)
        // public ActionResult Create([Bind(Include = "TradeType,userID,date")]SummaryTable summaryTable)
        {
            MyInvestEntities db = new MyInvestEntities();

            if (ModelState.IsValid)
            {
                summaryTable.UserName = Session["User"].ToString();

                db.SummaryTable.Add(summaryTable);
                db.SaveChanges();

                var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                stockHistory.STId = id;
                db.StockHistory.Add(stockHistory);
                db.SaveChanges();
                ViewBag.state = "ok";
                return(RedirectToAction("Index"));
            }
            return(RedirectToAction("Index"));
        }
예제 #18
0
        public GetData()
        {
            Dictionary <string, HtmlNode> TableData = DataFormatter.SplitToCategories(InnerBodyHtml.TargetNodes());
            InterchangeTable Interchange            = new InterchangeTable
            {
                InterchangeDataRaw = TableData["InterchangeTable"]
            };
            SummaryTable Summary = new SummaryTable
            {
                SummaryDataRaw = TableData["Summary"]
            };
            FuelTable Hydro = new FuelTable
            {
                FuelDataRaw = TableData["Hydro"]
            };
            FuelTable Coal = new FuelTable
            {
                FuelDataRaw = TableData["Coal"]
            };
            FuelTable Wind = new FuelTable
            {
                FuelDataRaw = TableData["Wind"]
            };
            FuelTable Biomass = new FuelTable
            {
                FuelDataRaw = TableData["Biomass"]
            };
            GasTable Gas = new GasTable
            {
                GasDataRaw = TableData["Gas"]
            };

            InterchangeData = Interchange.GetInterchangeDataRaw();
            SummaryData     = Summary.GetSummaryDataRaw();
            CoalData        = Coal.GetFuelDataRaw();
            HydroData       = Hydro.GetFuelDataRaw();
            WindData        = Wind.GetFuelDataRaw();
            BiomassData     = Biomass.GetFuelDataRaw();
            GasData         = Gas.GetRawGasData();
        }
예제 #19
0
        private DataTable ToDataTable(SummaryTable summaryTable)
        {
            DataTable result = new DataTable();

            var summaryColumns = summaryTable.Columns.ToArray();

            foreach (var summaryColumn in summaryColumns)
            {
                var column = new DataColumn();
                column.ColumnName = summaryColumn.Header;
                column.DataType   = summaryColumn.OriginalColumn.IsNumeric ? typeof(decimal) : typeof(string);
                result.Columns.Add(column);
            }

            for (int i = 0; i < summaryTable.FullContent.Length; i++)
            {
                var dataRow = result.NewRow();
                var row     = summaryTable.FullContent[i];
                for (int j = 0; j < summaryColumns.Length; j++)
                {
                    var summaryColumn = summaryColumns[j];
                    var value         = row[j];
                    if (summaryColumn.OriginalColumn.IsNumeric)
                    {
                        //var b = summaryTable.Summary.BenchmarksCases[0];
                        //var x = summaryColumn.OriginalColumn.GetValue(summaryTable.Summary, b);
                        dataRow[summaryColumn.Header] = ToDecimal(value);
                    }
                    else
                    {
                        dataRow[summaryColumn.Header] = value.ToString();
                    }
                }
                result.Rows.Add(dataRow);
            }

            return(result);
        }
예제 #20
0
        //Insert Income
        public ActionResult InsertIncome([Bind(Include = "STId,TradeType,TradeDate,UserName")] SummaryTable summaryTable, [Bind(Include = "InCashID,UserName,InCashType,InAmount,InDate,InNote")] CashIncome cashIncome)
        {
            if (Session["User"] == null)
            {
                return(RedirectToRoute("Default", new { Controller = "Home", Action = "Index" }));
            }

            summaryTable.TradeType = cashIncome.InCashType;
            summaryTable.TradeDate = cashIncome.InDate;
            summaryTable.UserName  = cashIncome.UserName;
            db.SummaryTable.Add(summaryTable);
            db.SaveChanges();

            cashIncome.OID = summaryTable.STId;
            if (ModelState.IsValid)
            {
                db.CashIncome.Add(cashIncome);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cashIncome));
        }
예제 #21
0
        private static void PrintTable(SummaryTable table, ILogger logger)
        {
            if (table.FullContent.Length == 0)
            {
                logger.WriteLine("[WARNING]");
                logger.WriteLine("====");
                logger.WriteLineError("There are no benchmarks found ");
                logger.WriteLine("====");
                logger.WriteLine();
                return;
            }

            table.PrintCommonColumns(logger);
            logger.WriteLine("....");

            logger.WriteLine("[options=\"header\"]");
            logger.WriteLine("|===");
            table.PrintLine(table.FullHeader, logger, "|", string.Empty);
            foreach (var line in table.FullContent)
            {
                table.PrintLine(line, logger, "|", string.Empty);
            }
            logger.WriteLine("|===");
        }
        /// <summary>
        /// Generates the contents of the page.
        /// </summary>
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                this.Blocks.Add(new Header1(System.IO.Path.GetFileName(assembly.FileName)));
                Paragraph versionDetails = new Paragraph();
                versionDetails.Inlines.Add(new Bold(new Run("Version: ")));
                versionDetails.Inlines.Add(new Run(assembly.Version.ToString()));
                this.Blocks.Add(versionDetails);

                // Output a list of namespaces in this assembly as links
                this.Blocks.Add(new Header2("Namespaces"));
                SummaryTable  namespaces    = new SummaryTable("Name", string.Empty, false, false);
                List <string> allNamespaces = this.assembly.GetNamespaces();

                // Sort the namespaces
                allNamespaces.Sort();

                int count = allNamespaces.Count;
                for (int i = 0; i < count; i++)
                {
                    string current = allNamespaces[i];
                    if (string.IsNullOrEmpty(current))
                    {
                        continue;                               // Skip the empty namespace defined in all assemblies
                    }
                    Hyperlink link = new Hyperlink(new Run(current));
                    link.Tag    = new CrefEntryKey(assembly, "N:" + current);
                    link.Click += new RoutedEventHandler(LinkHelper.Resolve);
                    namespaces.AddItem(link, string.Empty);
                }
                this.Blocks.Add(namespaces);

                this.IsGenerated = true;
            }
        }
예제 #23
0
        /// <summary>
        /// Adds a table of the <paramref name="types"/> to the document with a header <paramref name="name"/>.
        /// </summary>
        /// <param name="name">The header text.</param>
        /// <param name="types">The types to add to the table.</param>
        /// <param name="xmlFile">The XML file to read comments from.</param>
        private void OutputTypes(string name, IOrderedEnumerable <TypeDef> types, ICommentSource xmlFile)
        {
            if (types.Count() != 0)
            {
                SummaryTable classTable = new SummaryTable();
                foreach (TypeDef currentType in types)
                {
                    CRefPath crefPath = new CRefPath(currentType);

                    // Find the description for the type
                    Block description = this.GetSummaryFor(
                        xmlFile,
                        currentType.Assembly,
                        crefPath
                        );
                    Hyperlink nameLink = new Hyperlink(new Run(currentType.GetDisplayName(false)));
                    nameLink.Tag    = new EntryKey(currentType.GetGloballyUniqueId());
                    nameLink.Click += new System.Windows.RoutedEventHandler(LinkHelper.Resolve);
                    classTable.AddItem(nameLink, description, Model.ElementIconConstants.GetIconPathFor(currentType));
                }
                this.Blocks.Add(new Header2(name));
                this.Blocks.Add(classTable);
            }
        }
예제 #24
0
        //[ValidateAntiForgeryToken]
        public ActionResult Create(FXtradeTable tradeTable, SummaryTable summaryTable, UsersData usersData)
        {
            if (ModelState.IsValid)
            {
                //存總表
                db.SummaryTable.Add(summaryTable);
                db.SaveChanges();

                //存外匯交易表
                var uid = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                tradeTable.SummaryId = uid;
                db.FXtradeTable.Add(tradeTable);
                db.SaveChanges();
                if (tradeTable.TradeClass == "賣出")
                {
                    CashIncome cashincome = new CashIncome();
                    cashincome.UserName   = Session["User"].ToString();
                    cashincome.OID        = uid;
                    cashincome.InCashType = summaryTable.TradeType;
                    cashincome.InDate     = summaryTable.TradeDate;
                    cashincome.InNote     = tradeTable.TradeClass;
                    var change = tradeTable.NTD * -1;
                    cashincome.InAmount = Convert.ToInt32(change);
                    db.CashIncome.Add(cashincome);
                    db.SaveChanges();
                    //更新個人資產表
                    TestHomeController th = new TestHomeController();
                    var name = summaryTable.UserName;
                    var ud   = th.GetUsersData(name);

                    usersData.FXValue  = th.SaveUserdata(name);
                    usersData.UserName = ud[0].UserName;
                    var cv = Math.Abs(tradeTable.NTD.Value);
                    usersData.CashValue       = ud[0].CashValue + tradeTable.NTD;
                    usersData.InsuranceValue  = ud[0].InsuranceValue;
                    usersData.StockValue      = ud[0].StockValue;
                    usersData.FundValue       = ud[0].FundValue;
                    usersData.Email           = ud[0].Email;
                    usersData.Password        = ud[0].Password;
                    db.Entry(usersData).State = EntityState.Modified;
                    db.SaveChanges();
                }
                else
                {
                    CashExpense cashexpense = new CashExpense();
                    cashexpense.UserName   = Session["User"].ToString();
                    cashexpense.OID        = uid;
                    cashexpense.ExCashType = summaryTable.TradeType;
                    cashexpense.ExDate     = summaryTable.TradeDate;
                    cashexpense.ExNote     = tradeTable.TradeClass;
                    if (tradeTable.TradeClass == "買入(不要連動新臺幣帳戶)")
                    {
                        cashexpense.ExAmount = 0;
                    }
                    else
                    {
                        cashexpense.ExAmount = Convert.ToInt32(tradeTable.NTD);
                    }
                    db.CashExpense.Add(cashexpense);
                    db.SaveChanges();
                    //更新個人資產表
                    TestHomeController th = new TestHomeController();
                    var name = summaryTable.UserName;
                    var ud   = th.GetUsersData(name);

                    usersData.FXValue  = th.SaveUserdata(name);
                    usersData.UserName = ud[0].UserName;
                    var cv = Math.Abs(tradeTable.NTD.Value);
                    if (tradeTable.TradeClass == "買入(不要連動新臺幣帳戶)")
                    {
                        usersData.CashValue = ud[0].CashValue;
                    }
                    else
                    {
                        usersData.CashValue = ud[0].CashValue - tradeTable.NTD;
                    }
                    usersData.InsuranceValue  = ud[0].InsuranceValue;
                    usersData.StockValue      = ud[0].StockValue;
                    usersData.FundValue       = ud[0].FundValue;
                    usersData.Email           = ud[0].Email;
                    usersData.Password        = ud[0].Password;
                    db.Entry(usersData).State = EntityState.Modified;
                    db.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            return(View(tradeTable));
        }
예제 #25
0
        /// <summary>
        /// Generates the contents of the page, utilising details of the
        /// type and its associated xml comments.
        /// </summary>
        public override void Generate()
        {
            if (!this.IsGenerated)
            {
                CRefPath     crefPath     = new CRefPath(this._representedType);
                List <Block> parsedBlocks = Elements.Parser.Parse(this._representedType.Assembly, _commentsXml, crefPath);

                if (!_commentsXml.Exists())
                {
                    this.Blocks.Add(new NoXmlComments(this._representedType));
                }

                this.Blocks.Add(new Header1(this._representedType.Name + " Enumeration"));

                // Add the summary if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Summary);
                    if (summary != null)
                    {
                        this.Blocks.Add(summary);
                    }
                }

                this.AddSyntaxBlock(this._representedType);

                // Add the table of classes to the page
                List <FieldDef> fields       = this._representedType.GetFields();
                SummaryTable    classTable   = new SummaryTable("Member Name", "Description", false);
                var             sortedFields = from field in fields
                                               orderby field.Name
                                               select field;
                foreach (FieldDef currentField in sortedFields)
                {
                    if (currentField.IsSystemGenerated)
                    {
                        continue;
                    }
                    Block description = this.GetSummaryFor(
                        _commentsXml,
                        currentField.Assembly,
                        new CRefPath(currentField)
                        );
                    classTable.AddItem(currentField.Name, description);
                }
                this.Blocks.Add(new Header2("Members"));
                this.Blocks.Add(classTable);

                if (parsedBlocks != null)
                {
                    Block permissions = parsedBlocks.Find(current => current is PermissionList);
                    if (permissions != null)
                    {
                        this.Blocks.Add(permissions);
                    }
                }

                // Add the remarks if it exists
                if (parsedBlocks != null)
                {
                    Block remarks = parsedBlocks.Find(currentBlock => currentBlock is Remarks);
                    if (remarks != null)
                    {
                        this.Blocks.Add(remarks);
                    }
                }

                // Add the example if it exists
                if (parsedBlocks != null)
                {
                    Block summary = parsedBlocks.Find(currentBlock => currentBlock is Example);
                    if (summary != null)
                    {
                        this.Blocks.Add(new Header2("Examples"));
                        this.Blocks.Add(summary);
                    }
                }

                // Add the seealso list if it exists
                this.AddSeeAlso(parsedBlocks);

                this.IsGenerated = true;
            }
        }
예제 #26
0
 public void RefreshFilter(object sender, RoutedEventArgs e)
 {
     SummaryTable.RefreshFilter();
 }
예제 #27
0
        public void UpdateSummary(string portfolio)
        {
            string[] list = new string[]
            {
                "Portfolio Investment",
                "Portfolio Return If Unchange",
                "Portfolio Current Return",
                "Portfolio Theta [day]"
            };

            foreach (string item in list)
            {
                bool    is_new = false;
                DataRow row    = SummaryTable.FindByCriteria(item);

                if (row == null)
                {
                    row    = SummaryTable.NewRow();
                    is_new = true;
                }

                row["Criteria"] = item;
                row["Total"]    = DBNull.Value;
                row["TotalPrc"] = DBNull.Value;

                if (is_new)
                {
                    SummaryTable.Rows.Add(row);
                }
                SummaryTable.AcceptChanges();
            }

            try
            {
                // get portfolio rows
                DataRow[] portfolio_rows = PortfolioTable.Select("PortfolioMembership LIKE '*" + portfolio + ",*'");

                // update net-investment
                double net_investment = 0;
                foreach (DataRow prw in portfolio_rows)
                {
                    net_investment += (double)prw["NetInvestment"];
                }
                DataRow row = SummaryTable.FindByCriteria(list[0]);
                if (row != null)
                {
                    row["Total"] = net_investment;
                }

                // update return-if-unchange
                double return_if_unchanged = 0;
                foreach (DataRow prw in portfolio_rows)
                {
                    return_if_unchanged += (double)prw["ReturnIfUnchange"];
                }
                row = SummaryTable.FindByCriteria(list[1]);
                if (row != null)
                {
                    row["Total"] = return_if_unchanged;
                    double prc = return_if_unchanged / net_investment;
                    if (double.IsNaN(prc))
                    {
                        row["TotalPrc"] = DBNull.Value;
                    }
                    else
                    {
                        row["TotalPrc"] = prc;
                    }
                    row["IsCredit"] = true;
                }

                // update current-return
                double current_return = 0;
                foreach (DataRow prw in portfolio_rows)
                {
                    current_return += (double)prw["CurrentReturn"];
                }
                row = SummaryTable.FindByCriteria(list[2]);
                if (row != null)
                {
                    row["Total"] = current_return;
                    double prc = current_return / net_investment;
                    if (double.IsNaN(prc))
                    {
                        row["TotalPrc"] = DBNull.Value;
                    }
                    else
                    {
                        row["TotalPrc"] = prc;
                    }
                    row["IsCredit"] = true;
                }

                // update total-theta
                double total_theta = 0;
                foreach (DataRow prw in portfolio_rows)
                {
                    if (!double.IsNaN((double)prw["TotalTheta"]))
                    {
                        total_theta += (double)prw["TotalTheta"];
                    }
                }
                row = SummaryTable.FindByCriteria(list[3]);
                if (row != null)
                {
                    row["Total"] = total_theta;
                    double prc = total_theta / net_investment;
                    if (double.IsNaN(prc))
                    {
                        row["TotalPrc"] = DBNull.Value;
                    }
                    else
                    {
                        row["TotalPrc"] = prc;
                    }
                    row["IsCredit"] = true;
                }
            }
            catch { }
        }
예제 #28
0
        public ActionResult Withdraw(Insurances insurances)
        {
            if (Session["User"] == null)
            {
                return(RedirectToRoute("Default", new { Controller = "Home", Action = "Index" }));
            }

            if (ModelState.IsValid)
            {
                SummaryTable ST = new SummaryTable
                {
                    TradeType = "保險",
                    TradeDate = insurances.WithdrawDate,
                    UserName  = Session["User"].ToString()
                };



                Insurances olddata = db.Insurances.Find(insurances.SerialNumber);
                olddata.Withdrawed = true;
                db.SaveChanges();

                insurances.PurchaseOrWithdraw = false;
                insurances.Withdrawed         = true;

                insurances.UserID = Session["User"].ToString();
                if (insurances.RelateCash == true)
                {
                    insurances.CashFlow = insurances.Withdrawal;
                    db.SummaryTable.Add(ST);
                    db.SaveChanges();

                    var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                    insurances.STID = id;
                    db.Insurances.Add(insurances);
                    db.SaveChanges();

                    var User = db.UsersData.Where(U => U.UserName == insurances.UserID).Select(U => U).SingleOrDefault();
                    User.InsuranceValue -= insurances.Withdrawal;
                    User.CashValue      += insurances.Withdrawal;
                    db.SaveChanges();

                    CashIncome CI = new CashIncome
                    {
                        OID        = id,
                        UserName   = insurances.UserID,
                        InCashType = "保險",
                        InAmount   = insurances.CashFlow,
                        InDate     = insurances.WithdrawDate,
                        InNote     = insurances.InsuranceName + "解約金"
                    };

                    db.CashIncome.Add(CI);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    insurances.CashFlow = 0;
                    db.SummaryTable.Add(ST);
                    db.SaveChanges();

                    var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                    insurances.STID = id;
                    db.Insurances.Add(insurances);
                    db.SaveChanges();

                    var User = db.UsersData.Where(U => U.UserName == insurances.UserID).Select(U => U).SingleOrDefault();
                    User.InsuranceValue -= insurances.Withdrawal;
                    User.CashValue      += insurances.Withdrawal;
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }
            }
            return(View(insurances));
        }
예제 #29
0
        public ActionResult Create([Bind(Include = "SerialNumber,UserID,InsuranceName,PurchaseDate,WithdrawDate,PaymentPerYear,PayYear,PurchaseOrWithdraw,CashFlow,Withdrawal,RelateCash")] Insurances insurances)
        {
            if (ModelState.IsValid)
            {
                insurances.UserID             = Session["User"].ToString();
                insurances.PurchaseOrWithdraw = true;
                insurances.Withdrawed         = false;

                SummaryTable ST = new SummaryTable
                {
                    TradeType = "保險",
                    TradeDate = insurances.PurchaseDate,
                    UserName  = insurances.UserID
                };
                string UID   = Session["User"].ToString();
                var    ExSUM = db.CashExpense.Where(C => C.UserName == UID).Sum(C => C.ExAmount);
                var    InSUM = db.CashIncome.Where(C => C.UserName == UID).Sum(C => C.InAmount);

                if (insurances.RelateCash == true && InSUM - ExSUM > insurances.PaymentPerYear * insurances.PayYear)
                {
                    db.SummaryTable.Add(ST);
                    db.SaveChanges();

                    var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                    insurances.STID     = id;
                    insurances.CashFlow = -insurances.PaymentPerYear * insurances.PayYear;

                    db.Insurances.Add(insurances);
                    db.SaveChanges();

                    CashExpense CE = new CashExpense
                    {
                        ExAmount   = -insurances.CashFlow,
                        UserName   = insurances.UserID,
                        ExDate     = ST.TradeDate,
                        ExCashType = ST.TradeType,
                        OID        = id,
                        ExNote     = insurances.InsuranceName + "支出"
                    };
                    db.CashExpense.Add(CE);

                    var User = db.UsersData.Where(U => U.UserName == insurances.UserID).Select(U => U).SingleOrDefault();
                    User.InsuranceValue += insurances.Withdrawal;
                    User.CashValue      -= insurances.PaymentPerYear * insurances.PayYear;
                    db.SaveChanges();
                }
                else
                {
                    db.SummaryTable.Add(ST);
                    db.SaveChanges();

                    var id = db.SummaryTable.Select(c => c.STId).ToList().LastOrDefault();
                    insurances.STID     = id;
                    insurances.CashFlow = 0;
                    db.Insurances.Add(insurances);
                    db.SaveChanges();

                    var User = db.UsersData.Where(U => U.UserName == insurances.UserID).Select(U => U).SingleOrDefault();
                    User.InsuranceValue += insurances.Withdrawal;
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }
            return(View(insurances));
        }
예제 #30
0
        private void PrintTable(SummaryTable table, ILogger logger)
        {
            if (table.FullContent.Length == 0)
            {
                logger.WriteLineError("There are no benchmarks found ");
                logger.WriteLine();
                return;
            }

            table.PrintCommonColumns(logger);
            logger.WriteLine();

            if (UseCodeBlocks)
            {
                logger.Write(CodeBlockEnd);
                logger.WriteLine();
            }

            if (ColumnsStartWithSeparator)
            {
                logger.WriteStatistic(TableHeaderSeparator.TrimStart());
            }

            table.PrintLine(table.FullHeader, logger, string.Empty, TableHeaderSeparator);
            if (UseHeaderSeparatingRow)
            {
                if (ColumnsStartWithSeparator)
                {
                    logger.WriteStatistic(TableHeaderSeparator.TrimStart());
                }

                logger.WriteLineStatistic(string.Join("",
                                                      table.Columns.Where(c => c.NeedToShow).Select(column => new string('-', column.Width) + GetJustificationIndicator(column.Justify) + "|")));
            }

            int  rowCounter    = 0;
            bool highlightRow  = false;
            var  separatorLine = Enumerable.Range(0, table.ColumnCount).Select(_ => "").ToArray();

            foreach (var line in table.FullContent)
            {
                if (rowCounter > 0 && table.FullContentStartOfLogicalGroup[rowCounter] && table.SeparateLogicalGroups)
                {
                    // Print logical separator
                    if (ColumnsStartWithSeparator)
                    {
                        logger.WriteStatistic(TableColumnSeparator.TrimStart());
                    }
                    table.PrintLine(separatorLine, logger, string.Empty, TableColumnSeparator, highlightRow, false, StartOfGroupHighlightStrategy,
                                    BoldMarkupFormat, false);
                }

                // Each time we hit the start of a new group, alternative the colour (in the console) or display bold in Markdown
                if (table.FullContentStartOfHighlightGroup[rowCounter])
                {
                    highlightRow = !highlightRow;
                }

                if (ColumnsStartWithSeparator)
                {
                    logger.WriteStatistic(TableColumnSeparator.TrimStart());
                }

                table.PrintLine(line, logger, string.Empty, TableColumnSeparator, highlightRow, table.FullContentStartOfHighlightGroup[rowCounter],
                                StartOfGroupHighlightStrategy, BoldMarkupFormat, EscapeHtml);
                rowCounter++;
            }
        }