private bool NapraviProc(TipProceduri tip) { bool uspeh = true; SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout = _defSQlTimeout; SqlDataAdapter da = new SqlDataAdapter(); DataSet ds = new DataSet(); try { DataRow[] redDS = null; uspeh = ZemiProeceduri(ref redDS,tip); if (uspeh) { _status.addInfo(TipServisi.DBAlatService, "Zemam telo na objektite od baza."); TextWriter output = File.AppendText(Pateka); foreach (DataRow red in redDS) { string ImeProc = ""; ImeProc = (Convert.ToString(red["PROCEDURE_NAME"]).Substring(0, Convert.ToString(red["PROCEDURE_NAME"]).Length - 2)).ToLower(); string strProc = ""; if (PripremiTextSqlObj(ImeProc, ref strProc, tip)) { output.WriteLine(strProc); } else { break; } } output.Close(); _status.addInfo(TipServisi.DBAlatService, "Zavrsiv so zapisuvanje objekti od TIP:" + tip.ToString().ToUpper()); } UnvFunc.ZatvoriKonekcija(ref cn); } catch (Exception ex) { uspeh = false; _status.addGreska(TipServisi.DBAlatService, "Greska(NapraviProc):" + ex.Message); } return uspeh; }
private bool ZemiProeceduri(ref DataRow []red, TipProceduri tipProc) { bool uspeh = true; SqlCommand cmd = new SqlCommand(); cmd.CommandTimeout = _defSQlTimeout; SqlDataAdapter da = new SqlDataAdapter(); DataSet dsTek = new DataSet(); try { if (UnvFunc.OtvoriKonekcija(ref cn) == false) { _status.addGreska(TipServisi.DBAlatService, "Ne mozam da vospostavam konekcija so bazata! =>" + cn.ConnectionString); return false; } _status.addInfo(TipServisi.DBAlatService, "Zemam lista objekti od bazata - TIP:" + tipProc.ToString().ToUpper()); cmd.Connection = cn; cmd.CommandText = "sp_stored_procedures"; cmd.CommandType = CommandType.StoredProcedure; da.SelectCommand = cmd; da.Fill(dsTek, "Proceduri"); } catch (Exception ex) { uspeh = false; _status.addGreska(TipServisi.DBAlatService, "Greska(ZemiProceduri):" + ex.Message); } if (uspeh) { red = dsTek.Tables["Proceduri"].Select(this.PripremiSlect(tipProc)); } _status.addInfo(TipServisi.DBAlatService, "Vkupno " + red.Length.ToString() + " objekti!"); return uspeh ; }