public IDictionary<string, object> GetIndexList( string indexTypeCode , string indexCode , DateTime fromTime , DateTime toTime , string limit , string term ) { IDictionary<string, object> param = new Dictionary<string, object>(); string timeFormat = Resource.DateFormat; Int32 precision = Int32.Parse(Resource.Precision); if (!StringUtils.IsEmpty(indexTypeCode)) { param.Add("indexTypeCode", indexTypeCode); MstIndexTypeDAO indexTypeDAO = new MstIndexTypeDAO(this.mapper); MstIndexTypeModels indexTypeModel = indexTypeDAO.GetIndexType(indexTypeCode); if (indexTypeModel != null) { timeFormat = indexTypeModel.displayTimeFormat; precision = indexTypeModel.precisionField; } } if (!StringUtils.IsEmpty(indexCode)) { param.Add("indexCode", indexCode); } if (!StringUtils.IsEmpty(term)) { param.Add("term", term); } if (fromTime != null) { param.Add("fromTime", fromTime); } if (toTime != null) { param.Add("toTime", toTime); } if (!StringUtils.IsEmpty(limit)) { param.Add("limit", limit); } IList<string> timeList = this.GetTimeList( indexTypeCode , indexCode , fromTime , toTime , limit , timeFormat , Constants.Term.ShortTerm ); log.Debug("Application loaded successfully."); param.Add("timeFormat", Int32.Parse(timeFormat)); param.Add("precision", precision); param.Add("timeList", timeList.ToArray<string>()); // param.Add("limit", 2); IList<ArrayList> indexList = mapper.QueryForList<ArrayList>("Idx.getIndex", param); IList<IDictionary<string, string>> result = new List<IDictionary<string, string>>(); foreach (ArrayList list in indexList) { IDictionary<string, string> obj = new Dictionary<string, string>(); for (int i = 0; i < list.Count; i++) { string value = list[i].ToString(); if (i == 0) { obj.Add(Resource.IndexName, value); } else { if (!obj.ContainsKey(timeList[i - 1])) { obj.Add(timeList[i - 1], value); } } } result.Add(obj); } IDictionary<string, object> data = new Dictionary<string, object>(); timeList.Insert(0, Resource.IndexName); data.Add("header", timeList); data.Add("body", result); return data; }
public SysUserViewModels getUserView(string userCode, SysUserViewModels model) { SysUserViewModels temp = model; temp.userInfo = this.GetUserByUserCode(userCode); MstIndexTypeDAO mstIndexTypeDAO = new MstIndexTypeDAO(this.mapper); temp.indexTypeList = mstIndexTypeDAO.GetIndexTypeList(null, Constants.Status.Active); MstIndexTypeUserDAO mstIndexTypeUserDAO = new MstIndexTypeUserDAO(this.mapper); temp.indexTypeUserList = mstIndexTypeUserDAO.GetIndexTypeUserList(null, userCode, Constants.Flag.HasRight); MstAccessPackageDAO accessPackageDAO = new MstAccessPackageDAO(this.mapper); temp.packageList = accessPackageDAO.GetAccessPackageList(null, null, -1, Constants.Status.Active); temp.userCode = userCode; return temp; }
public IList<MoneyChartModels> GetMoneyListChart(string indexCode, DateTime? indexTime,string term) { IList<MoneyChartModels> results = null; // Get Index Type Code // Check exist index string indexTypeCode = (string)mapper.QueryForObject("Idx.getIndexTypeCode", indexCode); IDictionary<string, object> param = new Dictionary<string, object>(); string timeFormat = Resource.DateFormat; Int32 precision = Int32.Parse(Resource.Precision); if (!StringUtils.IsEmpty(indexTypeCode)) { param.Add("indexTypeCode", indexTypeCode); MstIndexTypeDAO indexTypeDAO = new MstIndexTypeDAO(this.mapper); MstIndexTypeModels indexTypeModel = indexTypeDAO.GetIndexType(indexTypeCode); if (indexTypeModel != null) { timeFormat = indexTypeModel.typeTimeFormat; precision = indexTypeModel.precisionField; } } param.Clear(); param.Add("indexCode", indexCode); param.Add("seqNo", 0); //param.Add("timeFormat", Int32.Parse(timeFormat)); param.Add("precision", precision); param.Add("max", ConfigUtils.GetInt(Constants.MaxIndexValueDisplay)); if (indexTime != null) { param.Add("indexTime", indexTime); } if (!StringUtils.IsEmpty(term)) { param.Add("term", term); } results = mapper.QueryForList<MoneyChartModels>("Idx.getMoneyByCode", param); if (results != null) { for (int i = 0; i < results.Count; i++) { MoneyChartModels obj = results[i]; obj.strIndexTime = obj.indexTime.ToString(timeFormat); } } return results; }
private void SaveMoney(IdxIndexModels index, SysUserModels userSession) { // Check exist index IDictionary<string, object> param = new Dictionary<string, object>(); string timeFormat = Resource.DateFormat; string displayTimeFormat = Resource.DateFormat; Int32 precision = Int32.Parse(Resource.Precision); MstIndexTypeDAO indexTypeDAO = new MstIndexTypeDAO(this.mapper); MstIndexTypeModels indexTypeModel = indexTypeDAO.GetIndexType(index.indexTypeCode); if (indexTypeModel != null) { displayTimeFormat = indexTypeModel.displayTimeFormat; timeFormat = indexTypeModel.typeTimeFormat; precision = indexTypeModel.precisionField; // Check exist index param.Add("indexCode", index.indexCode); param.Add("term", index.term); param.Add("indexTypeCode", index.indexTypeCode); param.Add("seqNo", index.seqNo); param.Add("indexTime", index.indexTime); param.Add("displayTimeFormat", Int32.Parse(displayTimeFormat)); Hashtable obj = (Hashtable)mapper.QueryForObject("Idx.selectIndex", param); index.updatedBy = userSession.userCode; index.createdBy = userSession.userCode; index.indexStatus = Constants.Status.Active; // If not exist -> Insert if (obj == null) { mapper.Insert("Idx.insertIndex", index); } else // If exist -> Update { param.Add("indexMoney", index.indexMoney); param.Add("updatedBy", index.updatedBy); mapper.Update("Idx.updateIndex", param); } } else { mapper.Insert("Idx.insertIndex", index); } }
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); }
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); }
public ActionResult IndexManagement(IndexManagementModels model) { MstIndexTypeDAO indexTypeDAO = new MstIndexTypeDAO(this.mapper); model.indexTypeList = indexTypeDAO.GetIndexTypeList(null, Constants.Status.Active); MstIndexTypeModels allType = new MstIndexTypeModels(); model.indexTypeList.Insert(0, allType); IdxIndexDAO indexDAO = new IdxIndexDAO(this.mapper); indexDAO.DeleteIndex(model.indexTypeCode, model.indexCode, model.fromTime, model.toTime, model.term); model.infoMessage = PsMModel.Resource.MsgSuccess; return View(model); }
public ActionResult IndexManagement() { IndexManagementModels model = new IndexManagementModels(); 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); }
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; }