Esempio n. 1
0
        public bool isAtomNameFromTreeExist(string AtomName)
        {
            FormationTree atom = TDS.DAL.AtomsDB.GetAtomObjectFromTreeByName(AtomName);

            if (atom != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 public FormationTree SaveTreeObject(FormationTree atomDTO)
 {
     FormationTree result = TDS.DAL.AtomsDB.SaveTreeObject(atomDTO);
     return result;
 }
Esempio n. 3
0
        public FormationTree SaveTreeObject(FormationTree atomDTO)
        {
            FormationTree result = TDS.DAL.AtomsDB.SaveTreeObject(atomDTO);

            return(result);
        }
Esempio n. 4
0
        public static IEnumerable<FormationTree> GetAllAtomsFromTree()
        {
            try
            {
                List<FormationTree> atoms = new List<FormationTree>();
                string sql = "select * from TreeObject order by Identification";
                using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection))
                using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection))
                {
                    DataSet ds = new DataSet();
                    DataTable dt = new DataTable();
                    ds.Reset();
                    da.Fill(ds);
                    dt = ds.Tables[0];

                    if (dt == null || dt.Rows == null || dt.Rows.Count == 0)
                    {
                        return null;
                    }
                    foreach (DataRow row in dt.Rows)
                    {
                        FormationTree atom = new FormationTree();
                        atom.Identification = row["Identification"].ToString();
                        atom.GUID = row["GUID"].ToString();
                        atom.ParentGUID = row["ParentGUID"].ToString();
                        atom.PlatformCategoryId = (enumPlatformId)System.Convert.ToInt32(row["PlatformCategoryId"]);
                        atom.PlatformType = row["PlatformType"].ToString();
                        atoms.Add(atom);
                    }
                }
                return atoms;
            }
            catch (Exception ex)
            {

            }
            return null;
        }
Esempio n. 5
0
        public static FormationTree SaveTreeObject(FormationTree atomDTO)
        {
            try
            {
                //int Actid = ActivityDTO.ActivityId;
                //object ob = null;
                string sql;

                using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection))
                {
                    connection.Open();
                    NpgsqlTransaction sqlTran = connection.BeginTransaction();
                    try
                    {

                        //  ******  Atom  *******
                        if (string.IsNullOrEmpty(atomDTO.GUID)) //new Atom
                        {
                            atomDTO.GUID = Util.CretaeGuid().ToString();

                            sql = "insert into TreeObject (Identification,GUID,ParentGUID,PlatformCategoryId,PlatformType)" +
                                  "values ('" + atomDTO.Identification+ "','" +
                                    atomDTO.GUID + "','" +
                                    atomDTO.ParentGUID + "'," +
                                    (int)atomDTO.PlatformCategoryId+ ",'" +
                                    atomDTO.PlatformType+ "'" +                                   
                                    " )  ";
                            using (NpgsqlCommand command = new NpgsqlCommand(sql, connection))
                            {
                                command.Transaction = sqlTran;
                                command.ExecuteNonQuery();
                            }
                        }
                        else
                        {
                            sql = "update TreeObject set Identification='" + atomDTO.Identification + "'" +
                                    " ,GUID='" + atomDTO.GUID + "'" +
                                    " ,ParentGUID='" + atomDTO.GUID + "'" +
                                    " ,PlatformCategoryId=" + (int)atomDTO.PlatformCategoryId + 
                                    " ,PlatformType='" + atomDTO.PlatformType+ "'" +
                                    " where GUID='" + atomDTO.GUID + "'";
                            using (NpgsqlCommand command = new NpgsqlCommand(sql, connection))
                            {
                                command.Transaction = sqlTran;
                                command.ExecuteNonQuery();
                            }
                        }                   

                        sqlTran.Commit();

                        return atomDTO;
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            sqlTran.Rollback();
                        }
                        catch (Exception exRollback)
                        {

                        }

                    }

                }

              
            }
            catch (Exception ex)
            {

            }
            return null;
        }
Esempio n. 6
0
        private static FormationTree GetAtomObjectFromTreeBySql(string sql)
        {
            try
            {
                FormationTree atom = new FormationTree();

                using (NpgsqlConnection connection = new NpgsqlConnection(strPostGISConnection))
                using (NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, connection))
                {
                    DataSet dsPol = new DataSet();
                    DataTable dtPol = new DataTable();
                    dsPol.Reset();
                    da.Fill(dsPol);
                    dtPol = dsPol.Tables[0];

                    if (dtPol == null || dtPol.Rows == null || dtPol.Rows.Count == 0)
                    {
                        return null;
                    }

                    foreach (DataRow row in dtPol.Rows)
                    {

                        atom.Identification = row["Identification"].ToString();
                        atom.GUID = row["GUID"].ToString();
                        atom.ParentGUID = row["ParentGUID"].ToString();
                        atom.PlatformCategoryId = (enumPlatformId)System.Convert.ToInt32(row["PlatformCategoryId"]);
                        atom.PlatformType = row["PlatformType"].ToString();

                    }
                }


                return atom;
            }
            catch (Exception ex)
            {

            }
            return null;
        }