예제 #1
0
        /// <summary>
        /// 删除选区组
        /// </summary>
        public ARESULT RemoveSelectionGroup(long id)
        {
            if (ARESULT.AFAILED(GroupSelectionDAO.RemoveGroupSelection(id)))
            {
                return(ARESULT.E_FAIL);
            }

            lock (mSelectionGroups) {
                foreach (SelectionGroup selectionGroup in mSelectionGroups)
                {
                    if (selectionGroup.mId == id)
                    {
                        ClearSelectionGroupAlarm(selectionGroup);
                        mSelectionGroups.Remove(selectionGroup);
                        return(ARESULT.S_OK);
                    }
                }
            }

            return(ARESULT.E_FAIL);
        }
예제 #2
0
        /// <summary>
        /// 删除选区
        /// </summary>
        /// <param name="id">选区索引</param>
        /// <returns>是否成功</returns>
        public ARESULT RemoveSelection(long id)
        {
            try {
                if (ARESULT.AFAILED(SelectionDAO.RemoveSelection(id)))
                {
                    return(ARESULT.E_FAIL);
                }

                bool continueFlag = false;
                lock (mSelectionGroups) {
                    foreach (SelectionGroup groupSelection in mSelectionGroups)
                    {
                        lock (groupSelection) {
                            for (int i = 0; i < groupSelection.mSelectionIds.Count; i++)
                            {
                                if (groupSelection.mSelectionIds[i] == id)
                                {
                                    ClearSelectionGroupAlarm(groupSelection);

                                    if (groupSelection.mSelectionIds.Count == 1)
                                    {
                                        GroupSelectionDAO.RemoveGroupSelection(groupSelection.mId);
                                        mSelectionGroups.Remove(groupSelection);
                                    }
                                    else
                                    {
                                        for (int k = i; k < groupSelection.mSelectionIds.Count - 1; k++)
                                        {
                                            groupSelection.mSelectionIds[k] = groupSelection.mSelectionIds[k + 1];
                                        }

                                        string data = groupSelection.Serialize();
                                        if (data != null)
                                        {
                                            GroupSelectionDAO.UpdateGroupSelection(groupSelection.mId, data);
                                        }
                                    }

                                    continueFlag = true;
                                    break;
                                }
                            }
                        }

                        if (continueFlag)
                        {
                            break;
                        }
                    }
                }

                lock (mSelections) {
                    foreach (Selection selection in mSelections)
                    {
                        lock (selection) {
                            if (selection.mSelectionId == id)
                            {
                                ClearSelectionAlarm(selection);
                                mSelections.Remove(selection);
                                return(ARESULT.S_OK);
                            }
                        }
                    }
                }

                return(ARESULT.E_FAIL);
            }
            catch (Exception e) {
                Tracker.LogE(e);
                return(ARESULT.E_FAIL);
            }
        }