Пример #1
0
        public static void 自动生成全部票费用(ArchiveOperationForm masterForm)
        {
            if (!MessageForm.ShowYesNo("是否要自动生成全部票费用?", "确认"))
            {
                return;
            }

            ProgressForm progressForm = new ProgressForm();

            progressForm.Start(masterForm, "生成");

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
            {
                foreach (object obj in masterForm.DisplayManager.Items)
                {
                    费用实体 entity = obj as 费用实体;
                    if (entity == null)
                    {
                        throw new ArgumentException("费用实体 is null!");
                    }

                    生成票费用(entity);
                }
                return(null);
            }),
                new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
            {
                Feng.Grid.BoundGridExtention.ReloadData(masterForm.MasterGrid as IBoundGrid);
                progressForm.Stop();
            }));
        }
Пример #2
0
        public static void 自动生成全部费用(ArchiveOperationForm masterForm)
        {
            if (!ServiceProvider.GetService <IMessageBox>().ShowYesNo("是否要自动全部生成费用?", "确认"))
            {
                return;
            }
            ProgressForm progressForm = new ProgressForm();

            progressForm.Start(masterForm, "生成");

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
            {
                费用实体 entity = masterForm.DisplayManager.CurrentItem as 费用实体;
                if (entity == null)
                {
                    throw new ArgumentException("请选择要生成费用的产值!");
                }
                using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <车辆产值>())
                {
                    车辆产值 piao = rep.Get <车辆产值>(entity.ID);
                    rep.Initialize(piao.任务, piao);
                    process_fy_yw.批量生成费用(rep, piao, piao.任务, null, null);
                }

                return(null);
            }),
                new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
            {
                masterForm.ControlManager.OnCurrentItemChanged();
                progressForm.Stop();
            }));
        }
Пример #3
0
        /// <summary>
        /// 与“自动生成全部费用”功能一样
        /// 当2个不同window,用DetailWindow配置时,用这个函数
        /// </summary>
        /// <param name="masterForm"></param>
        public static void 自动生成全部费用DetailWindow(ArchiveOperationForm masterForm)
        {
            if (!MessageForm.ShowYesNo("是否要自动生成全部费用?", "确认"))
            {
                return;
            }
            ProgressForm progressForm = new ProgressForm();

            progressForm.Start(masterForm, "生成");

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
            {
                费用实体 entity = (masterForm.ParentForm as ArchiveOperationForm).DisplayManager.CurrentItem as 费用实体;
                if (entity == null)
                {
                    throw new ArgumentException("请选择要生成费用的票!");
                }

                生成票费用(entity);
                return(null);
            }),
                new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
            {
                Feng.Grid.BoundGridExtention.ReloadData((masterForm.ParentForm as ArchiveOperationForm).MasterGrid as IBoundGrid);
                progressForm.Stop();
            }));
        }
Пример #4
0
 /// <summary>
 /// Stop
 /// </summary>
 public virtual void Stop()
 {
     if (m_asyncHelper != null)
     {
         m_asyncHelper.AbortWorker();
         m_asyncHelper = null;
     }
 }
        private void ExecuteProcess(string processId)
        {
            if (!string.IsNullOrEmpty(processId))
            {
                ProcessInfo info;
                lock (m_processExecuting)
                {
                    if (m_processExecuting.ContainsKey(processId) && m_processExecuting[processId])
                    {
                        println("process " + processId + " is still executing!");
                        return;
                    }

                    m_processExecuting[processId] = true;
                    info = ADInfoBll.Instance.GetProcessInfo(processId);
                }

                println("process " + processId + " start to execute!");

                Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                {
                    try
                    {
                        ProcessInfoHelper.ExecuteProcess(info);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        println(ex.Message);
                    }
                    return(false);
                }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                {
                    println("process " + processId + " has executed!");
                    lock (m_processExecuting)
                    {
                        m_processExecuting[processId] = false;
                    }
                }));
            }
            else
            {
                debug("there is no process property!");
            }
        }
Пример #6
0
        private void RepalceParameterizedText(int groupIdx, int childIdx)
        {
            TaskInfo info = this.Items[groupIdx].Items[childIdx].Tag as TaskInfo;

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
            {
                lock (this)
                {
                    string result = GetVariableText(info);
                    return(result);
                }
            }),
                new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
            {
                if (result != null)
                {
                    this.Items[groupIdx].Items[childIdx].Text = (string)result;
                }
            }));
        }
Пример #7
0
 /// <summary>
 /// Start
 /// </summary>
 public virtual void Start()
 {
     if (m_asyncHelper == null)
     {
         m_asyncHelper = new Feng.Async.AsyncHelper(
             new Feng.Async.AsyncHelper.DoWork(delegate()
         {
             DoWork();
             return(null);
         }),
             new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
         {
         }),
             new Feng.Async.AsyncHelper.WorkProgress(delegate(object result)
         {
             string[] s = result as string[];
             if (s != null && s.Length == 2)
             {
                 Notify(s[0], s[1]);
             }
         }));
     }
 }
Пример #8
0
        private void RepalceParameterizedText(int groupIdx, int childIdx)
        {
            TaskInfo info = this.Items[groupIdx].Items[childIdx].Tag as TaskInfo;

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
                {
                    lock (this)
                    {
                        string result = GetVariableText(info);
                        return result;
                    }
                }),
                new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                {
                    if (result != null)
                    {
                        this.Items[groupIdx].Items[childIdx].Text = (string)result;
                    }
                }));
        }
Пример #9
0
        /// <summary>
        /// 与“自动生成全部费用”功能一样
        /// 当2个不同window,用DetailWindow配置时,用这个函数
        /// </summary>
        /// <param name="masterForm"></param>
        public static void 自动生成全部费用DetailWindow(ArchiveOperationForm masterForm)
        {
            if (!MessageForm.ShowYesNo("是否要自动生成全部费用?", "确认"))
            {
                return;
            }
            ProgressForm progressForm = new ProgressForm();
            progressForm.Start(masterForm, "生成");

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
                {
                    费用实体 entity = (masterForm.ParentForm as ArchiveOperationForm).DisplayManager.CurrentItem as 费用实体;
                    if (entity == null)
                    {
                        throw new ArgumentException("请选择要生成费用的票!");
                    }

                    生成票费用(entity);
                    return null;
                }),
                new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                {
                    Feng.Grid.BoundGridExtention.ReloadData((masterForm.ParentForm as ArchiveOperationForm).MasterGrid as IBoundGrid);
                    progressForm.Stop();
                }));
        }
Пример #10
0
        public static void 自动生成全部票费用(ArchiveOperationForm masterForm)
        {
            if (!MessageForm.ShowYesNo("是否要自动生成全部票费用?", "确认"))
            {
                return;
            }

            ProgressForm progressForm = new ProgressForm();
            progressForm.Start(masterForm, "生成");

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
                {
                    foreach (object obj in masterForm.DisplayManager.Items)
                    {
                        费用实体 entity = obj as 费用实体;
                        if (entity == null)
                        {
                            throw new ArgumentException("费用实体 is null!");
                        }

                        生成票费用(entity);
                    }
                    return null;
                }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                        Feng.Grid.BoundGridExtention.ReloadData(masterForm.MasterGrid as IBoundGrid);
                        progressForm.Stop();
                    }));
        }
        private void btn网上导入_Click(object sender, EventArgs e)
        {
            string tdh = (string)(pnl提单号.Controls[0] as IWindowDataControl).SelectedDataValue;
            string hc = (string)(pnl船名.Controls[0] as IWindowDataControl).SelectedDataValue;

            if (string.IsNullOrEmpty(tdh))
            {
                MessageForm.ShowWarning("请填写提单号!");
                return;
            }

            if (!string.IsNullOrEmpty(hc) && hc.Contains('/'))
            {
                hc = hc.Substring(hc.LastIndexOf('/') + 1).Trim();
            }

            IList<Hd.NetRead.集装箱数据> boxList = null;
            int piao_successCount = 0;//成功导入的票数量
            int rw_successCount = 0;//成功导入的任务数量

            ProgressForm progressForm = new ProgressForm();
            progressForm.Start(this, "网上导入");

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
                {
                    nbeportRead m_nbeportGrab = new nbeportRead();
                    m_nbeportGrab.SetLoginInfo(Feng.DBDef.Instance.TryGetValue("NetReadUserName"),
                        Feng.DBDef.Instance.TryGetValue("NetReadPassword"));

                    if (string.IsNullOrEmpty(hc))
                    {
                        boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh);
                    }
                    else
                    {
                        boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh, hc);
                    }

                    if (boxList != null && boxList.Count > 0)
                    {
                        AskToReplace(m_cm, "任务性质", 任务性质.进口拆箱);
                        AskToReplace(m_cm, "提单号", boxList[0].提单号);
                        AskToReplace(m_cm, "船名航次", boxList[0].船名 + "/" + boxList[0].航次);
                        piao_successCount++;

                        foreach (集装箱数据 jzx in boxList)
                        {
                            bool have = false;
                            foreach (Xceed.Grid.DataRow row in m_显示区Grid.DataRows)
                            {
                                if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == jzx.集装箱号.Trim())
                                {
                                    have = true;
                                    break;
                                }
                            }
                            if (!have)
                            {
                                任务 rw = new 任务();
                                rw.任务来源 = 任务来源.网上;
                                rw.任务性质 = 任务性质.进口拆箱;
                                rw.提箱点编号 = NameValueMappingCollection.Instance.FindIdFromName("人员单位_全部", jzx.堆场区).ToString();
                                rw.箱号 = jzx.集装箱号;
                                rw.船名 = jzx.船名;
                                rw.航次 =  jzx.航次;
                                m_cm2.AddNew();
                                m_cm2.DisplayManager.Items[m_cm2.DisplayManager.Position] = rw;
                                m_cm2.EndEdit();
                                rw_successCount++;
                            }
                        }
                    }
                    return null;
                }),
               new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
               {
                   MessageForm.ShowInfo("成功导入 " + piao_successCount + " 票," + rw_successCount + " 条任务。");
                   progressForm.Stop();
               }));
        }
Пример #12
0
 /// <summary>
 /// Stop
 /// </summary>
 public virtual void Stop()
 {
     if (m_asyncHelper != null)
     {
         m_asyncHelper.AbortWorker();
         m_asyncHelper = null;
     }
 }
Пример #13
0
        /// <summary>
        /// Start
        /// </summary>
        public virtual void Start()
        {
            if (m_asyncHelper == null)
            {
                m_asyncHelper = new Feng.Async.AsyncHelper(
                               new Feng.Async.AsyncHelper.DoWork(delegate()
                               {
                                   DoWork();
                                   return null;
                               }),
                               new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                               {

                               }),
                               new Feng.Async.AsyncHelper.WorkProgress(delegate(object result)
                               {
                                   string[] s = result as string[];
                                   if (s != null && s.Length == 2)
                                   {
                                       Notify(s[0], s[1]);
                                   }
                               }));
            }
        }
Пример #14
0
        public static void 自动生成全部费用(ArchiveOperationForm masterForm)
        {
            if (!ServiceProvider.GetService<IMessageBox>().ShowYesNo("是否要自动全部生成费用?", "确认"))
            {
                return;
            }
            ProgressForm progressForm = new ProgressForm();
            progressForm.Start(masterForm, "生成");

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
                {
                    费用实体 entity = masterForm.DisplayManager.CurrentItem as 费用实体;
                    if (entity == null)
                    {
                        throw new ArgumentException("请选择要生成费用的产值!");
                    }
                    using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<车辆产值>())
                    {
                        车辆产值 piao = rep.Get<车辆产值>(entity.ID);
                        rep.Initialize(piao.任务, piao);
                        process_fy_yw.批量生成费用(rep, piao, piao.任务, null, null);
                    }

                    return null;
                }),
                new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                {
                    masterForm.ControlManager.OnCurrentItemChanged();
                    progressForm.Stop();
                }));
        }
        private void ExecuteProcess(string processId)
        {
            if (!string.IsNullOrEmpty(processId))
            {
                ProcessInfo info;
                lock (m_processExecuting)
                {
                    if (m_processExecuting.ContainsKey(processId) && m_processExecuting[processId])
                    {
                        println("process " + processId + " is still executing!");
                        return;
                    }

                    m_processExecuting[processId] = true;
                    info = ADInfoBll.Instance.GetProcessInfo(processId);
                }

                println("process " + processId + " start to execute!");

                Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                        new Feng.Async.AsyncHelper.DoWork(delegate()
                        {
                            try
                            {
                                ProcessInfoHelper.ExecuteProcess(info);
                                return true;
                            }
                            catch (Exception ex)
                            {
                                println(ex.Message);
                            }
                            return false;
                        }),
                        new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                        {
                            println("process " + processId + " has executed!");
                            lock (m_processExecuting)
                            {
                                m_processExecuting[processId] = false;
                            }
                        }));
            }
            else
            {
                debug("there is no process property!");
            }
        }
Пример #16
0
        private void btn网上导入_Click(object sender, EventArgs e)
        {
            string tdh = (string)(pnl提单号.Controls[0] as IWindowDataControl).SelectedDataValue;
            string hc  = (string)(pnl船名.Controls[0] as IWindowDataControl).SelectedDataValue;

            if (string.IsNullOrEmpty(tdh))
            {
                MessageForm.ShowWarning("请填写提单号!");
                return;
            }

            if (!string.IsNullOrEmpty(hc) && hc.Contains('/'))
            {
                hc = hc.Substring(hc.LastIndexOf('/') + 1).Trim();
            }

            IList <Hd.NetRead.集装箱数据> boxList = null;
            int piao_successCount            = 0; //成功导入的票数量
            int rw_successCount = 0;              //成功导入的任务数量

            ProgressForm progressForm = new ProgressForm();

            progressForm.Start(this, "网上导入");

            Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                new Feng.Async.AsyncHelper.DoWork(delegate()
            {
                nbeportRead m_nbeportGrab = new nbeportRead();
                m_nbeportGrab.SetLoginInfo(Feng.DBDef.Instance.TryGetValue("NetReadUserName"),
                                           Feng.DBDef.Instance.TryGetValue("NetReadPassword"));

                if (string.IsNullOrEmpty(hc))
                {
                    boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh);
                }
                else
                {
                    boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh, hc);
                }

                if (boxList != null && boxList.Count > 0)
                {
                    AskToReplace(m_cm, "任务性质", 任务性质.进口拆箱);
                    AskToReplace(m_cm, "提单号", boxList[0].提单号);
                    AskToReplace(m_cm, "船名航次", boxList[0].船名 + "/" + boxList[0].航次);
                    piao_successCount++;

                    foreach (集装箱数据 jzx in boxList)
                    {
                        bool have = false;
                        foreach (Xceed.Grid.DataRow row in m_显示区Grid.DataRows)
                        {
                            if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == jzx.集装箱号.Trim())
                            {
                                have = true;
                                break;
                            }
                        }
                        if (!have)
                        {
                            任务 rw    = new 任务();
                            rw.任务来源  = 任务来源.网上;
                            rw.任务性质  = 任务性质.进口拆箱;
                            rw.提箱点编号 = NameValueMappingCollection.Instance.FindIdFromName("人员单位_全部", jzx.堆场区).ToString();
                            rw.箱号    = jzx.集装箱号;
                            rw.船名    = jzx.船名;
                            rw.航次    = jzx.航次;
                            m_cm2.AddNew();
                            m_cm2.DisplayManager.Items[m_cm2.DisplayManager.Position] = rw;
                            m_cm2.EndEdit();
                            rw_successCount++;
                        }
                    }
                }
                return(null);
            }),
                new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
            {
                MessageForm.ShowInfo("成功导入 " + piao_successCount + " 票," + rw_successCount + " 条任务。");
                progressForm.Stop();
            }));
        }