Ejemplo n.º 1
0
        public override string QueryResult()
        {
            JsonModel  jsonModel = new JsonModel();
            ParamModel param     = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);

            TF.RunSafty.Logic.MonthWorkTimeBLL bllWorkTime = new TF.RunSafty.Logic.MonthWorkTimeBLL();
            int       nTotalWorkCount = 0;
            decimal   ntotalMinutes   = 0m;
            DataTable table           = null;

            try
            {
                table = bllWorkTime.GetWorkTimeByTrainman(param.strTrainmanGUID, param.dtBeginTime, param.dtEndTime);
                if (table != null)
                {
                    nTotalWorkCount = table.Rows.Count;
                    ntotalMinutes   = Convert.ToDecimal(table.Compute("sum(fTotalTime)", ""));
                }
                jsonModel.Detail          = table;
                jsonModel.ntotalMinutes   = ntotalMinutes.ToString();
                jsonModel.nTotalWorkCount = nTotalWorkCount.ToString();
            }
            catch (Exception ex)
            {
                TF.CommonUtility.LogClass.logex(ex, "");
            }
            jsonModel.result    = "0";
            jsonModel.resultStr = "返回成功";
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string result = Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter).Replace(":null", ":\"\"");

            return(result);
        }
Ejemplo n.º 2
0
        public WorkTime_Out GetWorkTime(string data)
        {
            WorkTime_Out jsonModel = new WorkTime_Out();
            WorkTime_In  param     = Newtonsoft.Json.JsonConvert.DeserializeObject <WorkTime_In>(data);

            TF.RunSafty.Logic.MonthWorkTimeBLL bllWorkTime = new TF.RunSafty.Logic.MonthWorkTimeBLL();
            int       nTotalWorkCount = 0;
            decimal   ntotalMinutes   = 0m;
            DataTable table           = null;

            try
            {
                table = bllWorkTime.GetWorkTimeByTrainman(param.strTrainmanGUID, param.dtBeginTime, param.dtEndTime);
                if (table != null)
                {
                    nTotalWorkCount = table.Rows.Count;
                    object minutes = table.Compute("sum(fTotalTime)", "");
                    ntotalMinutes = Convert.ToDecimal((minutes == null || minutes == DBNull.Value)?"0":minutes.ToString());
                }
                jsonModel.Detail          = table;
                jsonModel.ntotalMinutes   = ntotalMinutes.ToString();
                jsonModel.nTotalWorkCount = nTotalWorkCount.ToString();
                jsonModel.result          = "0";
                jsonModel.resultStr       = "返回成功";
            }
            catch (Exception ex)
            {
                TF.CommonUtility.LogClass.logex(ex, "");
                jsonModel.result    = "1";
                jsonModel.resultStr = "提交失败:" + ex.Message;
            }
            return(jsonModel);
        }