示例#1
0
        public ErrorObj DB2DefaultsAccess(DestinationDatabase destinationDatabase, DEDB2Defaults deDB2Defaults)
        {
            string   ModuleName = GetModuleNameByDestinationDB(destinationDatabase);
            ErrorObj err        = new ErrorObj();

            this.GetConnectionDetails(Settings.BusinessUnit, "", ModuleName);
            Settings.ModuleName = ModuleName;
            DB2Defaults dbDB2Access = new DB2Defaults();

            dbDB2Access.Settings      = Settings;
            dbDB2Access.DEDB2Defaults = deDB2Defaults;
            err = dbDB2Access.AccessDatabase();
            if (!err.HasError && !(dbDB2Access.ResultDataSet == null))
            {
                ResultDataSet = dbDB2Access.ResultDataSet;
            }
            return(err);
        }
示例#2
0
        public int Execute(DESettings settings)
        {
            int affectedRows = 0;

            System.Collections.Generic.List <TalentDB2Access> removeList = new System.Collections.Generic.List <TalentDB2Access>();
            foreach (TalentDB2Access db2Access in this)
            {
                bool hasQuote = false;
                foreach (DEDB2Parameter param in db2Access.CommandElements.CommandParameter)
                {
                    if (param.ParamValue != null && System.Convert.ToString(param.ParamValue).Contains("'"))
                    {
                        hasQuote = true;
                        break;
                    }
                }
                if (hasQuote)
                {
                    ErrorObj err = default(ErrorObj);
                    affectedRows += System.Convert.ToInt32(Execute(db2Access, ref err));
                    if (err.HasError)
                    {
                        throw new Exception(err.ErrorMessage);
                    }
                    removeList.Add(db2Access);
                }
            }
            foreach (TalentDB2Access item in removeList)
            {
                this.Remove(item);
            }
            if (Count > 0)
            {
                if (Count == 1)
                {
                    ErrorObj err = default(ErrorObj);
                    affectedRows += Execute(this[0], ref err);
                    if (err.HasError)
                    {
                        throw new Exception(err.ErrorMessage);
                    }
                }
                else
                {
                    ErrorObj err = default(ErrorObj);
                    settings.FunctionName = "UpdateDB2Data";
                    string        xmlString     = GetXML();
                    DEDB2Defaults deDB2Defaults = new DEDB2Defaults();
                    deDB2Defaults.XMLString = xmlString;
                    TalentDB2Access talentDB2AccessDetail = new TalentDB2Access();
                    DataTable       outputDataTable       = default(DataTable);
                    try
                    {
                        talentDB2AccessDetail.Settings = settings;
                        //Execute
                        err = talentDB2AccessDetail.DB2DefaultsAccess(DestinationDatabase.TALENTTKT, deDB2Defaults);
                        if ((!(err.HasError)) && (!(talentDB2AccessDetail.ResultDataSet == null)))
                        {
                            outputDataTable = talentDB2AccessDetail.ResultDataSet.Tables[1];
                            affectedRows    = System.Convert.ToInt32(outputDataTable.Rows[0]["AffectedRows"]);
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                    finally
                    {
                        talentDB2AccessDetail = null;
                    }
                }
            }
            Clear();
            return(affectedRows);
        }