public ActionResult InstanceList(GridCommand command, MachineInstanceSearchModel searchModel)
 {
     SearchCacheModel searchCacheModel = this.ProcessSearchModel(command, searchModel);
     ViewBag.PageSize = base.ProcessPageSize(command.PageSize);
     ViewBag.DateType = searchModel.DateType == null ? null : searchModel.DateType.ToString();
     return View();
 }
 public void ExportXLS(MachineInstanceSearchModel searchModel)
 {
     int value = Convert.ToInt32(base.systemMgr.GetEntityPreferenceValue(com.Sconit.Entity.SYS.EntityPreference.CodeEnum.MaxRowSizeOnPage));
     GridCommand command = new GridCommand();
     command.Page = 1;
     command.PageSize = value;
     SearchStatementModel searchStatementModel = this.PrepareInstanceSearchStatement(command, searchModel);
     var fileName = string.Format("FICalendar.xls");
     ExportToXLS<SnapMachine>(fileName, GetAjaxPageData<SnapMachine>(searchStatementModel, command).Data.ToList());
 }
 public ActionResult _AjaxInstanceList(GridCommand command, MachineInstanceSearchModel searchModel)
 {
     SearchStatementModel searchStatementModel = this.PrepareInstanceSearchStatement(command, searchModel);
     return PartialView(GetAjaxPageData<SnapMachine>(searchStatementModel, command));
 }
        private SearchStatementModel PrepareInstanceSearchStatement(GridCommand command, MachineInstanceSearchModel searchModel)
        {
            string whereStatement = string.Empty;

            IList<object> param = new List<object>();
            if (searchModel.DateType != null)
            {
                if (searchModel.DateType.Value == 4)
                {
                    if (searchModel.DateIndexDate != null & searchModel.DateIndexToDate != null)
                    {
                        HqlStatementHelper.AddBetweenStatement("DateIndex", searchModel.DateIndexDate.Value.ToString("yyyy-MM-dd"), searchModel.DateIndexToDate.Value.ToString("yyyy-MM-dd"), "m", ref whereStatement, param);
                    }
                    else if (searchModel.DateIndexDate != null & searchModel.DateIndexToDate == null)
                    {
                        HqlStatementHelper.AddGeStatement("DateIndex", searchModel.DateIndexDate.Value.ToString("yyyy-MM-dd"), "m", ref whereStatement, param);
                    }
                    else if (searchModel.DateIndexDate == null & searchModel.DateIndexToDate != null)
                    {
                        HqlStatementHelper.AddLeStatement("DateIndex", searchModel.DateIndexToDate.Value.ToString("yyyy-MM-dd"), "m", ref whereStatement, param);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(searchModel.DateIndex) & !string.IsNullOrEmpty(searchModel.DateIndexTo))
                    {
                        HqlStatementHelper.AddBetweenStatement("DateIndex", searchModel.DateIndex, searchModel.DateIndexTo, "m", ref whereStatement, param);
                    }
                    else if (!string.IsNullOrEmpty(searchModel.DateIndex) & string.IsNullOrEmpty(searchModel.DateIndexTo))
                    {
                        HqlStatementHelper.AddGeStatement("DateIndex", searchModel.DateIndex, "m", ref whereStatement, param);
                    }
                    else if (string.IsNullOrEmpty(searchModel.DateIndex) & !string.IsNullOrEmpty(searchModel.DateIndexTo))
                    {
                        HqlStatementHelper.AddLeStatement("DateIndex", searchModel.DateIndexTo, "m", ref whereStatement, param);
                    }
                }
            }

            HqlStatementHelper.AddEqStatement("Code", searchModel.Code, "m", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("MachineType", searchModel.MachineType, "m", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("SnapTime", searchModel.SnapTime, "m", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("Region", searchModel.Region, "m", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("ShiftType", searchModel.ShiftType, "m", ref whereStatement, param);
            HqlStatementHelper.AddEqStatement("DateType", searchModel.DateType, "m", ref whereStatement, param);

            string sortingStatement = HqlStatementHelper.GetSortingStatement(command.SortDescriptors);
            if (command.SortDescriptors.Count == 0)
            {
                sortingStatement = " order by m.Code desc";
            }

            SearchStatementModel searchStatementModel = new SearchStatementModel();
            searchStatementModel.SelectCountStatement = selectCountInstanceStatement;
            searchStatementModel.SelectStatement = selectInstanceStatement;
            searchStatementModel.WhereStatement = whereStatement;
            searchStatementModel.SortingStatement = sortingStatement;
            searchStatementModel.Parameters = param.ToArray<object>();

            return searchStatementModel;
        }