Exemplo n.º 1
0
        private void Load排车任务(转关箱排车暂存组 暂存组)
        {
            if (暂存组.转关箱排车 == null)
                return;

            using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<转关箱排车暂存组>())
            {
                rep.Initialize(暂存组.转关箱排车, 暂存组);

                Dictionary<string, int> dict = new Dictionary<string, int>();
                Dictionary<string, Xceed.Grid.Cell> dictCell = new Dictionary<string, Xceed.Grid.Cell>();
                foreach (Xceed.Grid.DataRow row in m_待排转关箱任务区Grid.DataRows)
                {
                    System.Data.DataRowView rowView = row.Tag as System.Data.DataRowView;
                    string s = rowView["序号"].ToString();
                    string[] ss = s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    int idx = ConvertHelper.ToInt(ss[0]).Value;

                    s = rowView["任务号"].ToString();
                    ss = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var i in ss)
                    {
                        dict[i] = idx;
                        dictCell[i] = row.Cells["任务色调"];
                    }
                }

                Dictionary<车辆, Xceed.Grid.DataRow> cls = new Dictionary<车辆, Xceed.Grid.DataRow>();
                foreach (Xceed.Grid.DataRow row in m_全部监管车辆及作业现状Grid.DataRows)
                {
                    cls[row.Tag as 车辆] = row;
                }
                foreach (var i in 暂存组.转关箱排车)
                {
                    if (dict.ContainsKey(i.任务号) && cls.ContainsKey(i.车辆))
                    {
                        string fieldName = string.Format("第{0}天", i.天数序号);
                        cls[i.车辆].Cells[fieldName].Value = dict[i.任务号].ToString();
                        cls[i.车辆].Cells[fieldName].Tag = dictCell[i.任务号];

                        ModifySrcCell(dictCell[i.任务号], -1);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void Confirm(转关箱排车暂存组 暂存组, bool 是否确认)
        {
            Dictionary<int, string[]> dict = new Dictionary<int, string[]>();
            foreach (Xceed.Grid.DataRow row in m_待排转关箱任务区Grid.DataRows)
            {
                System.Data.DataRowView rowView = row.Tag as System.Data.DataRowView;
                string s = rowView["序号"].ToString();
                string[] ss = s.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                int idx = ConvertHelper.ToInt(ss[0]).Value;

                s = rowView["任务号"].ToString();
                ss = s.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                dict[idx] = ss;
            }
            Dictionary<int, int> dictIdx = new Dictionary<int, int>();
            foreach (var i in dict.Keys)
            {
                dictIdx[i] = 0;
            }

            using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<转关箱排车暂存组>())
            {
                try
                {
                    rep.BeginTransaction();

                    rep.Attach(暂存组);
                    暂存组.IsActive = 是否确认 ? true : false;
                    暂存组.预排时间 = System.DateTime.Now;
                    m_dao暂存组.Update(rep, 暂存组);

                    if (暂存组.转关箱排车 != null)
                    {
                        foreach (var i in 暂存组.转关箱排车)
                        {
                            m_dao.Delete(rep, i);
                        }
                        暂存组.转关箱排车.Clear();
                    }
                    else
                    {
                        暂存组.转关箱排车 = new List<转关箱排车计划>();
                    }

                    foreach (Xceed.Grid.DataRow row in m_全部监管车辆及作业现状Grid.DataRows)
                    {
                        for (int i = 1; i <= Days; ++i)
                        {
                            string fieldName = string.Format("第{0}天", i);
                            if (row.Cells[fieldName].Value != null)
                            {
                                int idx = ConvertHelper.ToInt(row.Cells[fieldName].Value).Value;
                                System.Diagnostics.Debug.Assert(dict.ContainsKey(idx), "必须在现有待排任务中!");
                                string rwh = dict[idx][dictIdx[idx]];
                                dictIdx[idx] = dictIdx[idx] + 1;

                                转关箱排车计划 entity = new 转关箱排车计划();
                                entity.车辆 = row.Tag as 车辆;
                                entity.任务号 = rwh;
                                entity.日期 = 是否确认 ? (DateTime?)System.DateTime.Today.AddDays(i) : null;
                                entity.天数序号 = i;
                                entity.暂存组 = 暂存组;

                                m_dao.Save(rep, entity);

                                暂存组.转关箱排车.Add(entity);
                            }
                        }
                    }
                    rep.CommitTransaction();
                }
                catch (Exception ex)
                {
                    rep.RollbackTransaction();
                    ExceptionProcess.ProcessWithNotify(ex);
                }
            }
        }