Exemplo n.º 1
0
 public ActionResult AuthorizeIndex(string u)
 {
     MstIndexDAO indexMasterDAO = new MstIndexDAO(this.mapper);
     SysUserModels userSession = (SysUserModels)Session["UserSession"];
     string indexCode = StringUtils.base64Decode(u);
     bool result = indexMasterDAO.UpdateIndexMaster(
             indexCode// string indexCode
             , null// string indexTypeCode
             , null// string indexName
             , -1// string seqNo
             , Constants.Type.Authority// string securityType
             , null// string indexStatus
             , userSession.userCode// string userCode
             , null
         );
     return this.Json(result, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 2
0
        public Title CreateThumbColumnTitle(string indexCode, float fontSize, string term)
        {
            Title title = new Title();
            MstIndexDAO mstIndexDAO = new MstIndexDAO(this.mapper);
            MstIndexModels mstIndex = mstIndexDAO.GetIndexMaster(indexCode, null, null, term);

            title.Text = mstIndex.indexName;

            title.ShadowColor = Color.FromArgb(32, 0, 0, 0);
            title.Font = new Font("Trebuchet MS", fontSize, FontStyle.Bold);
            title.ShadowOffset = 3;
            title.ForeColor = Color.FromArgb(26, 59, 105);
            return title;
        }
Exemplo n.º 3
0
        /**
         * Create bar chart
         * **/
        public FileResult CreateColumnChart(string indexCode, int width, int height, string fontSize, string term)
        {
            indexCode = StringUtils.base64Decode(indexCode);
            SeriesChartType chartType = SeriesChartType.Column;

            Chart chart = new Chart();
            chart.Width = width;//900;
            chart.Height = height;//300;

            //chart.BackColor = Color.FromArgb(211, 223, 240);

            chart.BackColor = ColorTranslator.FromHtml("#80C0DB");

            chart.BorderlineDashStyle = ChartDashStyle.Solid;
            chart.BackSecondaryColor = Color.White;
            chart.BackGradientStyle = GradientStyle.TopBottom;
            chart.BorderlineWidth = 1;
            chart.Palette = ChartColorPalette.BrightPastel;
            chart.BorderlineColor = Color.FromArgb(26, 59, 105);
            chart.RenderType = RenderType.BinaryStreaming;
            chart.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
            chart.AntiAliasing = AntiAliasingStyles.All;
            chart.TextAntiAliasingQuality = TextAntiAliasingQuality.Normal;
            MemoryStream ms = new MemoryStream();
            // Check index
            MstIndexDAO mstIndexDAO = new MstIndexDAO(this.mapper);
            string userCode = string.Empty;
            if (Session != null) {
                SysUserModels userSession = (SysUserModels) Session["UserSession"];
                if (userSession != null && userSession.userCode != null)
                {
                    userCode = userSession.userCode;
                }
            }

            // If not right -> redirect to Rule page
            if (!mstIndexDAO.IsUserHasIndexRight(userCode, indexCode))
            {
                chart.Titles.Add(this.CreateNoAuthorizeTitle());
                chart.SaveImage(ms);
                return File(ms.GetBuffer(), @"image/png");
            }

            IdxIndexDAO indexDAO = new IdxIndexDAO(this.mapper);
            DateTime? indexTime = null;
            //if (StringUtils.IsEmpty(userCode))
            //{
            //    indexTime = DateUtils.GetLastFriday();
            //}
            IList<IndexChartModels> indexList = indexDAO.GetIndexListChart(indexCode, indexTime, term);
            IList<MoneyChartModels> moneyList = indexDAO.GetMoneyListChart(indexCode, indexTime, term);

            if (indexList.Count != 0)
            {
                chart.Titles.Add(this.CreateColumnTitle(indexCode, float.Parse(fontSize), indexList[indexList.Count - 1].strIndexTime, term));
            }
            else
            {
                chart.Titles.Add(this.CreateColumnTitle(indexCode, float.Parse(fontSize), string.Empty, term));
            }

            //chart.Legends.Add(this.CreateLegend());
            chart.Series.Add(this.CreateColumnSeries(indexList, chartType));
            if (this.isShowMoneyLine(moneyList))
            {
                chart.Series.Add(this.CreateLineSeries(moneyList, SeriesChartType.Line));
            }
             // *** The following code should not normally be modified ***

            chart.ChartAreas.Add(this.CreateColumnChartArea());

            chart.SaveImage(ms);
            return File(ms.GetBuffer(), @"image/png");
        }
Exemplo n.º 4
0
        public ActionResult SearchMaster(MstIndexSearchModels model)
        {
            MstIndexTypeDAO indexTypeDAO = new MstIndexTypeDAO(this.mapper);
            model.indexTypeList = indexTypeDAO.GetIndexTypeList(null, Constants.Status.Active);
            MstIndexTypeModels allType = new MstIndexTypeModels();
            model.indexTypeList.Insert(0, allType);

            //if (model.isPublic)
            //{
            //    model.securityType = Constants.Type.Public;
            //}
            //else
            //{
            //    model.securityType = Constants.Type.Authority;
            //}

            if (model.isActive)
            {
                model.indexStatus = Constants.Status.Active;
            }
            else
            {
                model.indexStatus = Constants.Status.Inactive;
            }
            MstIndexDAO indexDAO = new MstIndexDAO(this.mapper);
            model = indexDAO.searchIndex(model, Constants.Term.ShortTerm);
            return View("IndexMaster", model);
        }
Exemplo n.º 5
0
 public JsonResult JSONGetIndex(string q = "")
 {
     MstIndexDAO mstIndexDAO = new MstIndexDAO(this.mapper);
     IList<MstIndexModels> lsIndex = mstIndexDAO.GetIndexMasterList(q, Constants.Term.ShortTerm);
     return Json(lsIndex, JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 6
0
        public ActionResult IndexMaster()
        {
            MstIndexSearchModels model = new MstIndexSearchModels();
            MstIndexDAO indexDAO = new MstIndexDAO(this.mapper);
            model.pageIndex = 1;
            model.securityType = Constants.Type.Public;
            model.securityType = Constants.Status.Active;
            model.isPublic = true;
            model.isActive = true;
            //model = indexDAO.searchIndex(model);

            MstIndexTypeDAO indexTypeDAO = new MstIndexTypeDAO(this.mapper);
            model.indexTypeList = indexTypeDAO.GetIndexTypeList(null, Constants.Status.Active);
            MstIndexTypeModels allType = new MstIndexTypeModels();
            model.indexTypeList.Insert(0, allType);
            return View(model);
        }
Exemplo n.º 7
0
        public IList<IdxIndexModels> GetIndexFromExcel(DataTable dtIndex, ISqlMapper mapper, out string errorMsg)
        {
            string term = null;
            IList<IdxIndexModels> indexList = new List<IdxIndexModels>();
            errorMsg = "";
            // Check file type
            if (!StringUtils.IsEmpty(dtIndex.Columns[0].ColumnName) && dtIndex.Columns[0].ColumnName.Equals(Constants.FileType.ShortIndex))
            {
                term = Constants.Term.ShortTerm;
            }
            else if (!StringUtils.IsEmpty(dtIndex.Columns[0].ColumnName) && dtIndex.Columns[0].ColumnName.Equals(Constants.FileType.MiddleIndex))
            {
                term = Constants.Term.MidTerm;
            }
            else if (!StringUtils.IsEmpty(dtIndex.Columns[0].ColumnName) && dtIndex.Columns[0].ColumnName.Equals(Constants.FileType.LongIndex))
            {
                term = Constants.Term.LongTerm;
            }
            else
            {
                errorMsg = string.Format(Resource.MsgErrWrongSelection, Resource.IndexFile);
                return null;
            }

            // Get Index TypeCode
            string indexTypeCode = "";

            // Exact indexCode
            MstIndexDAO mstIndexDAO = new MstIndexDAO(mapper);
            int seqNo = 0;
            string previousItemCode = "";
            List<IdxIndexModels> indexCodeList = new List<IdxIndexModels>();
            int i = 0;
            foreach (DataRow row in dtIndex.Rows)
            {
                i++;
                IdxIndexModels index = new IdxIndexModels();
                string indexName = row[0].ToString();
                if (indexName.Equals(Resource.ExcelEndChar)
                    || StringUtils.IsEmpty(indexName)
                    ) break;

                if (StringUtils.IsEmpty(indexName))
                {
                    index.indexCode = previousItemCode;
                    seqNo++;
                    index.seqNo = seqNo;
                }
                else
                {
                    MstIndexModels indexModels = mstIndexDAO.GetIndexCode(indexName.Trim(), "", term);
                    if (indexModels == null)
                    {
                        errorMsg = string.Format(Resource.MsgErrIndexNotExist, indexName.Trim());
                        return null;
                    }
                    indexTypeCode = indexModels.indexTypeCode;
                    String indexCode = indexModels.indexCode;
                    if (indexCode == null)
                    {
                        errorMsg = string.Format(Resource.MsgErrNotExistIndexNameUploadExcelFile, new String[] { i.ToString(), "1", indexName });
                        return null;
                    }
                    previousItemCode = indexCode; // = ws.Cell(i, 1).Value;
                    index.indexCode = previousItemCode;
                    index.seqNo = 0;
                    seqNo = 0;
                }
                index.indexTypeCode = indexTypeCode;

                indexCodeList.Add(index);
            }

            // Get Index TypeCode
            MstIndexTypeDAO indexTypeDAO = new MstIndexTypeDAO(mapper);

            MstIndexTypeModels indexTypeModel = indexTypeDAO.GetIndexType(indexTypeCode);
            if (indexTypeModel == null)
            {
                errorMsg = string.Format(Resource.MsgErrIndexTypeNotExist, indexTypeCode);
                return null;
            }
            string timeFormat = indexTypeModel.typeTimeFormat;

            // Exact time
            IList<DateTime> timeList = new List<DateTime>();
            for (i=1; i<dtIndex.Columns.Count; i++)
            {
                string time = dtIndex.Columns[i].ToString();
                if (time.Equals(Resource.ExcelEndChar)
                    || StringUtils.IsEmpty(time)
                    || time.Contains("Column")
                    ) break;

                try
                {
                    timeList.Add(DateTime.ParseExact(time, timeFormat, null));
                }
                catch (Exception e)
                {
                    errorMsg = string.Format(Resource.MsgErrDateFormatUploadExcelFile, new String[] { "1", i.ToString(), time });
                    return null;
                }
            }

            // Exact index
            for (int currentRowIndex = 0; currentRowIndex < indexCodeList.Count; currentRowIndex++)
            {
                IdxIndexModels indexCode = indexCodeList[currentRowIndex];
                for (int currentColumnIndex = 0; currentColumnIndex < timeList.Count; currentColumnIndex++)
                {
                    IdxIndexModels index = new IdxIndexModels();
                    index.indexTypeCode = indexCode.indexTypeCode.Trim();
                    index.indexCode = indexCode.indexCode.Trim();
                    index.seqNo = indexCode.seqNo;
                    index.indexTime = timeList[currentColumnIndex];
                    try
                    {
                        index.indexField = double.Parse(dtIndex.Rows[currentRowIndex][currentColumnIndex+1].ToString());
                    }
                    catch (Exception e)
                    {
                        errorMsg = string.Format(Resource.MsgErrNumberFormatUploadExcelFile
                            , new String[] { (currentRowIndex+2).ToString(), (currentColumnIndex+2).ToString(), dtIndex.Rows[currentRowIndex][currentColumnIndex+1].ToString() });
                        return null;
                    }
                    index.term = term;
                    indexList.Add(index);
                }
            }

            return indexList;
        }