Пример #1
0
        public static FormationTree GetAtomObjectFromTreeByName(string Name)
        {
            string        sql  = "select * from TreeObject where Identification='" + Name + "'";
            FormationTree atom = GetAtomObjectFromTreeBySql(sql);

            return(atom);
        }
Пример #2
0
        private async void cmdExit_Click(object sender, RoutedEventArgs e)
        {
            bool isCheckOk = await CheckOk();

            if (isCheckOk == false)
            {
                return;
            }
            if (isNew)
            {
                refAtomDTO = new FormationTree();
                refAtomDTO.Identification     = txtName.Text;
                refAtomDTO.PlatformCategoryId = enumPlatformId.GeneralHumans;
                refAtomDTO.PlatformType       = string.Empty;

                AtomObjectsEditEventArgs args = new AtomObjectsEditEventArgs();
                args.isNew = isNew;


                args.atomDTO = refAtomDTO;
                if (EndAtomObjectsEditEvent != null)
                {
                    EndAtomObjectsEditEvent(this, args);
                }
            }

            Close();
        }
Пример #3
0
        protected async override void OnDrop(System.Windows.DragEventArgs e)
        {
            double currMapX = 0;
            double currMapY = 0;

            System.Windows.DataObject d = (System.Windows.DataObject)e.Data;

            string[] dataFormats = d.GetFormats();
            string   dataText    = d.GetText();

            Point position = e.GetPosition(this);

            GMap.NET.PointLatLng curPosition = FromLocalToLatLng((int)position.X, (int)position.Y);
            currMapX = curPosition.Lng;
            currMapY = curPosition.Lat;

            for (int i = 0; i < dataFormats.Length; i++)
            {
                string dragFormat = dataFormats[i];

                if (dragFormat.Contains("FormationTree") && dataText == "Actor")
                {
                    object dragObject = d.GetData(dragFormat);

                    FormationTree formation = dragObject as FormationTree;
                    if (formation == null)
                    {
                        continue;
                    }

                    enOSMhighwayFilter highwayFilter = enOSMhighwayFilter.Undefined;
                    SetHighwayFilter(highwayFilter);
                    shPointId PointId = await clsRoadRoutingWebApi.GetNearestPointIdOnRoad("0", highwayFilter, currMapX, currMapY);

                    if (PointId != null)
                    {
                        shPoint           pnt             = PointId.point;
                        DeployedFormation deployFormation = new DeployedFormation();
                        deployFormation.x         = pnt.x;
                        deployFormation.y         = pnt.y;
                        deployFormation.formation = formation;

                        AtomData atom = await TDSClient.SAGInterface.SAGSignalR.DeployFormationFromTree(VMMainViewModel.Instance.SimulationHubProxy, deployFormation);

                        if (atom != null)
                        {
                            AtomDeployedEventArgs args = new AtomDeployedEventArgs();
                            args.atom = atom;
                            if (AtomDeployedEvent != null)
                            {
                                AtomDeployedEvent(this, args);
                            }
                        }
                    }

                    return;
                }
            }
        }
Пример #4
0
 public frmActorEdit(FormationTree atomDTO)
 {
     InitializeComponent();
     this.Background = new LinearGradientBrush(Colors.AliceBlue, Colors.LightGray, 90);
     refAtomDTO      = atomDTO;
     if (refAtomDTO == null)
     {
         isNew = true;
     }
 }
Пример #5
0
        public async void  frm_EndAtomObjectsEditEvent(object sender, AtomObjectsEditEventArgs args)
        {
            FormationTree atomDTO = await SAGSignalR.SaveTreeObject(VMMainViewModel.Instance.SimulationHubProxy, args.atomDTO);

            if (args.isNew)
            {
                AtomDTOData Rdata = new AtomDTOData();
                Rdata.atom = atomDTO;

                ((List <AtomDTOData>)(dtGridActors.ItemsSource)).Add(Rdata);

                dtGridActors.Items.Refresh();
                dtGridActors.SelectedItem = Rdata;
                dtGridActors.CurrentItem  = Rdata;
                DataGridWPFUtility.DataGridGotoLast(dtGridActors);
            }
        }
Пример #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);
        }
Пример #7
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);
        }
Пример #8
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);
        }