コード例 #1
0
 public CpPackageItemInfo(CpPackageItemInfo objEntr) : base(objEntr)
 {
 }
コード例 #2
0
        public override bool import(string db, JArray p, string mode, ref string errMsg, ref string logMsg)
        {
            bool anyError      = false,
                 isTransaction = false;

            BUS.CpPackageItemControl ctr = this;

            if (p.Count > 1)
            {
                isTransaction = true;
            }

            if (isTransaction)
            {
                ctr.BeginTransaction(ref logMsg);
                if (logMsg != "")
                {
                    errMsg   = BUS.StLanguageControl.translate(this, "There was processing errors. Transaction ROLLBACKED");
                    anyError = true;
                }
            }
            String seqcode = null, format = string.Empty;

            BUS.CsSequenceControl ctrSq = new BUS.CsSequenceControl(this);
            bool   isSeq                = ctrSq.CheckSequence(db, shortCmd, ref logMsg);
            string keyField             = "packagecodeitemid",
                   tableName            = "cppackageitem";

            foreach (JObject o in p)
            {
                if (anyError)
                {
                    break;
                }
                DTO.CpPackageItemInfo inf = null;
                if (isSeq && (o[keyField] == null || o[keyField].ToString() == ""))
                {
                    o[keyField] = ctrSq.genSeqCode(db, this.LD, ref seqcode, shortCmd, tableName, keyField, o, ref format);
                }
                anyError = ctr.validate(o, BUS.BUSControl.ValidType.Imp, ref errMsg);

                if (anyError)
                {
                    break;
                }
                try {
                    inf           = o.ToObject <DTO.CpPackageItemInfo>();
                    inf.tvcdb     = db;
                    inf.updatedby = USER_ID;
                } catch (Exception ex) {
                    anyError = true;
                    logMsg   = ex.Message;
                    errMsg   = BUS.StLanguageControl.translate(this, "There was processing errors. Transaction ROLLBACKED");
                }

                if (anyError)
                {
                    break;
                }

                if (IsExist(inf.tvcdb, inf.packagecode, inf.itemid, ref logMsg))
                {
                    logMsg = ctr.Update(inf);
                }
                else
                {
                    inf.createdby = USER_ID;
                    if (string.IsNullOrEmpty(logMsg))
                    {
                        ctr.Add(inf, ref logMsg);
                    }
                    if (!string.IsNullOrEmpty(logMsg))
                    {
                        anyError = true;
                    }
                }
            }

            if (isTransaction)
            {
                if (anyError)
                {
                    RollbackTransaction(ref logMsg);
                }
                else
                {
                    CommitTransaction(ref logMsg);
                }
            }

            return(anyError);
        }