Ejemplo n.º 1
0
        private void RunSP(object jobName)
        {
            try
            {
                DataRow rowOfJob = this.FindRow(jobName.ToString());
                rowOfJob["RunStatus"] = "运行中";

                ProcedureParameter pp1 = new ProcedureParameter("v_jobList", typeof(string), 40, DirectionType.Input, jobName.ToString());
                ProcedureParameter pp2 = new ProcedureParameter("v_date", typeof(int), 8, DirectionType.Input, m_InputDate);

                ProcedureCondition pc = new ProcedureCondition("PKG_DBTRANSFER.Transfer", new ProcedureParameter[] { pp1, pp2 });

                // 多线程Run每一个任务,每一个任务自己创建自己的数据库链接
                IDomainDataProvider newProvider = DomainDataProviderManager.DomainDataProvider();
                newProvider.CustomProcedure(ref pc);

                Thread.Sleep(10000);

                rowOfJob["RunStatus"] = "完成";

                TransferJob job = TransferFacade.GetTransferJob(Convert.ToInt32(rowOfJob["Serial"])) as TransferJob;
                rowOfJob["LastRunDate"]     = job.LastRunDate == 0 ? "0" : FormatHelper.TODateTimeString(job.LastRunDate, job.LastRunTime);
                rowOfJob["LastSuccessDate"] = job.LastSuccessDate == 0 ? "0" : FormatHelper.TODateTimeString(job.LastSuccessDate, job.LastSuccessTime);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.Invoke(new Action <int>(this.SetFlag), 1);
            }
        }
Ejemplo n.º 2
0
        private void ucButtonOK_Click(object sender, EventArgs e)
        {
            //获取产品原始的序列号
            DataCollectFacade dataCollectFacade = new DataCollectFacade(this.DataProvider);
            string            sourceOldRCard    = dataCollectFacade.GetSourceCard(this.ucLabelEditOldRCard.Value.Trim().ToUpper(), string.Empty);
            string            sourceNewRCard    = dataCollectFacade.GetSourceCard(this.ucLabelEditNewRCard.Value.Trim().ToUpper(), string.Empty);

            //check OldRcard Is Empty
            if (string.IsNullOrEmpty(this.ucLabelEditOldRCard.Value.Trim()))
            {
                ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditOldRCard.Value + ":" + this.ucLabelEditOldRCard.Value,
                                                   new UserControl.Message(MessageType.Error, "$CS_OLDRCARD_ISNULL"), true);
                this.ucLabelEditOldRCard.TextFocus(true, true);
                return;
            }

            //Check OldRcard Is Exist in ProductInfo
            Object ObjectSimulationOld = dataCollectFacade.GetLastSimulationReport(FormatHelper.CleanString(sourceOldRCard.Trim().ToUpper()));

            if (ObjectSimulationOld == null)
            {
                ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditOldRCard.Value + ":" + this.ucLabelEditOldRCard.Value,
                                                   new UserControl.Message(MessageType.Error, "$CS_OLDRCARD_IS_NOT_EXIT"), true);
                this.ucLabelEditOldRCard.TextFocus(false, true);
                return;
            }

            //Check NewRcard Is Empty
            if (string.IsNullOrEmpty(this.ucLabelEditNewRCard.Value.Trim()))
            {
                ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditNewRCard.Value + ":" + this.ucLabelEditNewRCard.Value,
                                                   new UserControl.Message(MessageType.Error, "$CS_newIDisNull"), true);
                this.ucLabelEditNewRCard.TextFocus(false, true);
                return;
            }

            //Compare NewRcard and OldRcard Is  Same
            if (this.ucLabelEditNewRCard.Value.Trim() == this.ucLabelEditOldRCard.Value.Trim())
            {
                ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditNewRCard.Value + ":" + this.ucLabelEditNewRCard.Value,
                                                   new UserControl.Message(MessageType.Error, "$CS_SAMERCARD"), true);
                this.ucLabelEditNewRCard.TextFocus(false, true);
                return;
            }

            //Check OldRcard Is Not Exist in ProductInfo
            Object ObjectSimulationNew = dataCollectFacade.GetLastSimulationReport(FormatHelper.CleanString(sourceNewRCard.Trim().ToUpper()));

            if (ObjectSimulationNew != null)
            {
                ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditNewRCard.Value + ":" + this.ucLabelEditNewRCard.Value,
                                                   new UserControl.Message(MessageType.Error, "$CS_NEWRCARD_IS_PRODUCTINFO"), true);
                this.ucLabelEditNewRCard.TextFocus(false, true);
                return;
            }

            //Check ChangeReason is Empty
            if (string.IsNullOrEmpty(this.ucLabelEditReason.Value.Trim()))
            {
                ApplicationRun.GetInfoForm().AddEx(this._FunctionName, this.ucLabelEditReason.Value + ":" + this.ucLabelEditReason.Value,
                                                   new UserControl.Message(MessageType.Error, "$CS_INPUT_CHANGEREASON"), true);
                this.ucLabelEditReason.TextFocus(false, true);
                return;
            }

            BaseSetting.BaseModelFacade baseModelFacade = new BenQGuru.eMES.BaseSetting.BaseModelFacade(this.DataProvider);

            string OldRcard      = FormatHelper.CleanString(this.ucLabelEditOldRCard.Value.Trim().ToUpper());
            string NewRcard      = FormatHelper.CleanString(this.ucLabelEditNewRCard.Value.Trim().ToUpper());
            string OutPutResoult = string.Empty;

            ProcedureCondition procedureCondition = new ProcedureCondition("CHANGERCARD",
                                                                           new ProcedureParameter[] {
                new ProcedureParameter("i_FromRCard", typeof(string), 40, DirectionType.Input, OldRcard),
                new ProcedureParameter("i_ToRCard", typeof(string), 40, DirectionType.Input, NewRcard),
                new ProcedureParameter("o_Result", typeof(string), 40, DirectionType.Output, OutPutResoult)
            });

            this.DataProvider.BeginTransaction();
            try
            {
                baseModelFacade.DoRCardChange(ref procedureCondition);

                if (procedureCondition.Parameters[2].Value.ToString().Length == 2)
                {
                    DBDateTime  DBDateTime     = FormatHelper.GetNowDBDateTime(this.DataProvider);
                    RCardChange NewRCardChange = baseModelFacade.CreateNewRCardChange();

                    NewRCardChange.RCardFrom    = OldRcard;
                    NewRCardChange.RCardTo      = NewRcard;
                    NewRCardChange.Reason       = FormatHelper.CleanString(this.ucLabelEditReason.Value.Trim());
                    NewRCardChange.MaintainUser = ApplicationService.Current().UserCode;
                    NewRCardChange.MaintainDate = DBDateTime.DBDate;
                    NewRCardChange.MaintainTime = DBDateTime.DBTime;
                    NewRCardChange.EAttribute1  = string.Empty;

                    baseModelFacade.AddRCardChange(NewRCardChange);

                    ApplicationRun.GetInfoForm().AddEx(this._FunctionName, procedureCondition.Parameters[2].Value.ToString(),
                                                       new UserControl.Message(MessageType.Success, "$CS_RCARDCHANGE_SUCCESS"), true);
                    this.ucLabelEditNewRCard.Value = string.Empty;
                    this.ucLabelEditReason.Value   = string.Empty;
                }
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                ApplicationRun.GetInfoForm().AddEx(this._FunctionName, "", new UserControl.Message(ex), true);
            }
            finally
            {
                this.DataProvider.CommitTransaction();
            }

            if (procedureCondition.Parameters[2].Value.ToString().Length > 2)
            {
                ApplicationRun.GetInfoForm().AddEx(this._FunctionName, procedureCondition.Parameters[2].Value.ToString(),
                                                   new UserControl.Message(MessageType.Error, "$CS_RCARDCHANGE_WRONG"), true);
            }
            this.ucLabelEditOldRCard.TextFocus(false, true);
        }