Ejemplo n.º 1
0
        public ActionResult List(string project, string severity, string datediscovered,
                                 string timediscovered, int projectedmanhours, string shortdescription,
                                 string location, string description)
        {
            List <string> newArgs = new List <string>();

            MySqlTableModel issueTable = SqlTables.Issues;

            //projectedmanhours
            string pmh = projectedmanhours.ToString();
            //projectedcost
            float  tempPc = projectedmanhours * 20;
            string pc     = tempPc.ToString();

            newArgs = new List <string>()
            {
                "DEFAULT",
                project,
                severity,
                datediscovered,
                timediscovered,
                pmh,
                pc,
                shortdescription,
                location,
                "DEFAULT",
                description
            };



            MySqlCrud.InsertRow(SqlConnections.IssueWebsite, issueTable.Table,
                                issueTable.Collumns, newArgs);

            return(RedirectToAction("List"));
        }
Ejemplo n.º 2
0
        public ActionResult List()
        {
            List <Issue> issues = new List <Issue>();

            List <string>[] values;
            MySqlTableModel issueTable = SqlTables.Issues;

            values = MySqlCrud.SelectAllRows(SqlConnections.IssueWebsite, issueTable.Table, issueTable.Collumns);

            /*
             * idIssues DEFAULT(int)
             * project name
             * severity string
             * datediscovered string  XX/XX/XXXX
             * time discovered string  XX:XX:XX
             * projectedmanhours float
             * projectedcost float
             * shortdescription string
             * location string
             * popularity int
             * description string
             */

            int r = 0;

            foreach (var i in values[0])
            {
                int issueId;
                Int32.TryParse(values[0][r], out issueId);

                string project        = values[1][r]; //100 MaxChars
                string severity       = values[2][r]; //45 MaxChars
                string datediscovered = values[3][r]; //45 MaxChars
                string timediscovered = values[4][r]; //45 MaxChars

                int pmhTemp;
                Int32.TryParse(values[5][r], out pmhTemp);
                float projectedmanhours = (float)pmhTemp;

                int pcTemp;
                Int32.TryParse(values[6][r], out pcTemp);
                float projectedcost = (float)pcTemp;

                string shortdescription = values[7][r]; //100 MaxChars
                string location         = values[8][r]; //45 MaxChars

                int popularity;
                Int32.TryParse(values[9][r], out popularity);

                string description = values[10][r]; //300 MaxChars


                Issue ish = new Issue()
                {
                    Project           = project,
                    Severity          = severity,
                    DateDiscovered    = datediscovered,
                    TimeDiscovered    = timediscovered,
                    ProjectedManHours = projectedmanhours,
                    ProjectedCost     = projectedcost,
                    ShortDescription  = shortdescription,
                    Location          = location,
                    Popularity        = popularity,
                    Description       = description
                };

                issues.Add(ish);
                r++;
            }


            IssueListModel IssueListModel = new IssueListModel()
            {
                Issues = issues
            };

            return(View(IssueListModel));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获得模型代码字符串
        /// </summary>
        /// <param name="tableModel">表模型</param>
        /// <returns>模型代码字符串</returns>
        public string GetModelCodeStrByCSharp(MySqlTableModel tableModel)
        {
            string code = string.Empty;

            code += "using System;\r\n";
            code += "using System.ComponentModel;\r\n";
            code += "using System.ComponentModel.DataAnnotations;\r\n";
            code += "using System.ComponentModel.DataAnnotations.Schema;\r\n";
            code += "using MateralTools.MEntityFramework;\r\n";
            code += String.Format("namespace {0}.Model\r\n", ProjectName);
            code += "{\r\n";
            if (!tableModel.Remark.MIsNullOrEmpty())
            {
                code += "    /// <summary>\r\n";
                code += String.Format("    /// {0}\r\n", tableModel.Remark);
                code += "    /// </summary>\r\n";
            }
            code += String.Format("    [Table(\"{0}\")]\r\n", tableModel.Name);
            code += String.Format("    public class {0}\r\n", tableModel.Name);
            code += "    {\r\n";
            if (tableModel.Columns != null && tableModel.Columns.Count > 0)
            {
                List <MySqlColumnModel> PKitems = tableModel.Columns.Where(m => m.ColumKey == "PRI").ToList();
                if (PKitems == null || PKitems.Count == 0)
                {
                    tableModel.Columns[0].ColumKey = "PRI";
                }
                foreach (MySqlColumnModel item in tableModel.Columns)
                {
                    if (!item.Remark.MIsNullOrEmpty())
                    {
                        code += "        /// <summary>\r\n";
                        code += String.Format("        /// {0}\r\n", item.Remark);
                        code += "        /// </summary>\r\n";
                        code += String.Format("        [Description(\"{0}\")]\r\n", item.Remark);
                    }
                    code += String.Format("        [Column(\"{0}\")]\r\n", item.Name);
                    if (item.ColumKey == "PRI")
                    {
                        code += "        [Key]\r\n";
                    }
                    if (item.DataType == "timestamp")
                    {
                        code += "        [Timestamp]\r\n";
                    }
                    else if (item.IsNull == "NO" && item.ColumKey != "PRI")
                    {
                        code += "        [Required]\r\n";
                    }
                    if (item.Name == "IsDelete")
                    {
                        code += "        [LogicDelete]\r\n";
                    }
                    //if (item.TypeByCSharp == "string")
                    //{
                    //    code += string.Format("        [MaxLength({0})]\r\n", item.Length);
                    //}
                    code += String.Format("        public {0} {1} ", item.TypeByCSharp, item.Name) + "{ get; set; }\r\n";
                }
            }
            code += "    }\r\n";
            code += "}\r\n";
            return(code);
        }