Ejemplo n.º 1
0
        public Get_Out GetGroupOrder(string data)
        {
            Get_Out json = new Get_Out();

            try
            {
                Get_In input = Newtonsoft.Json.JsonConvert.DeserializeObject <Get_In>(data);
                string strTrainmanJiaoLuGUID = input.TrainmanJiaoluGUID;
                string strWorkShopGUID       = input.WorkShopGUID;
                TF.Api.BLL.BanXuBLL bllBanXu = new TF.Api.BLL.BanXuBLL();
                json.Content = new List <GroupItem>();
                DataTable      table = bllBanXu.GetBanXuByJiaoLuGUID(strWorkShopGUID, strTrainmanJiaoLuGUID);
                SimpleTrainman man   = null;
                if (table != null)
                {
                    for (int i = 0; i < table.Rows.Count; i++)
                    {
                        DataRow   row    = table.Rows[i];
                        GroupItem record = new GroupItem();
                        DateTime  endWorkTime;
                        string    strEndWorkTime = row["dtLastEndWorkTime1"] == null ? "" : row["dtLastEndWorkTime1"].ToString();
                        if (DateTime.TryParse(strEndWorkTime, out endWorkTime))
                        {
                            record.EndWorkTime = endWorkTime.ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        else
                        {
                            record.EndWorkTime = "";
                        }
                        record.Index        = (i + 1).ToString();
                        record.TrainmanList = new SimpleTrainmanList();
                        json.Content.Add(record);
                        for (int j = 1; j < 5; j++)
                        {
                            man = new SimpleTrainman();
                            man.TrainmanName = row["strTrainmanName" + j.ToString()].ToString();
                            man.TrainmanNo   = row["strTrainmanNumber" + j.ToString()].ToString();
                            man.trianmanGUID = row["strTrainmanGUID" + j.ToString()].ToString();
                            record.TrainmanList.Add(man);
                        }
                    }
                }
                json.result    = "0";
                json.resultStr = "返回成功";
            }
            catch (Exception ex)
            {
                json.result    = "1";
                json.resultStr = "提交失败:" + ex.Message;
            }
            return(json);
        }
Ejemplo n.º 2
0
        public override string QueryResult()
        {
            DataModel dataModel             = Newtonsoft.Json.JsonConvert.DeserializeObject <DataModel>(this.Data);
            string    strTrainmanJiaoLuGUID = dataModel.TrainmanJiaoluGUID;
            string    strWorkShopGUID       = dataModel.WorkShopGUID;

            TF.Api.BLL.BanXuBLL bllBanXu  = new TF.Api.BLL.BanXuBLL();
            JsonModel           jsonModel = new JsonModel();

            jsonModel.Content = new List <Record>();
            TrainMan  man   = null;
            DataTable table = bllBanXu.GetBanXuByJiaoLuGUID(strWorkShopGUID, strTrainmanJiaoLuGUID);

            if (table != null)
            {
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    DataRow  row    = table.Rows[i];
                    Record   record = new Record();
                    DateTime endWorkTime;
                    string   strEndWorkTime = row["dtLastEndWorkTime1"] == null ? "" : row["dtLastEndWorkTime1"].ToString();
                    if (DateTime.TryParse(strEndWorkTime, out endWorkTime))
                    {
                        record.EndWorkTime = endWorkTime.ToString("yyyy-MM-dd HH:mm:ss");
                    }
                    else
                    {
                        record.EndWorkTime = "";
                    }
                    record.Index        = (i + 1).ToString();
                    record.TrainmanList = new List <TrainMan>();
                    jsonModel.Content.Add(record);
                    for (int j = 1; j < 5; j++)
                    {
                        man = new TrainMan();
                        man.TrainmanName = row["strTrainmanName" + j.ToString()].ToString();
                        man.TrainmanNo   = row["strTrainmanNumber" + j.ToString()].ToString();
                        man.trianmanGUID = row["strTrainmanGUID" + j.ToString()].ToString();
                        record.TrainmanList.Add(man);
                    }
                }
            }
            jsonModel.result    = "0";
            jsonModel.resultStr = "返回成功";
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter));
        }