Example #1
0
        private Task <OperationResult> InternalDeleteRegionVehicleRelation(int RelationID, TerminalOperationClient client)
        {
            return(Task <OperationResult> .Run(() =>
            {
                var RegionInfo = TerminalSettingsBLL.GetRegionInformation(base.CurrentUserID, RelationID);
                if (RegionInfo.Item1)
                {
                    string PlateNum = RegionInfo.Item2;
                    string TerminalCode = RegionInfo.Item3;
                    int RegionType = RegionInfo.Item4;
                    long RegionID = RegionInfo.Item5;
                    OperationResultGeneralRep response;
                    switch (RegionType)
                    {
                    case 1:
                        response = client.DeleteCircularRegion(TerminalCode, new RegionLineDeletionData()
                        {
                            IDs = new uint[] { (uint)RegionID }
                        });
                        break;

                    case 2:
                        response = client.DeleteRectangularRegion(TerminalCode, new RegionLineDeletionData()
                        {
                            IDs = new uint[] { (uint)RegionID }
                        });
                        break;

                    case 3:
                        response = client.DeletePolygonRegion(TerminalCode, new RegionLineDeletionData()
                        {
                            IDs = new uint[] { (uint)RegionID }
                        });
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }

                    OperationResult resultElement = null;
                    if (!response.State)
                    {
                        resultElement = new OperationResult()
                        {
                            Success = false,
                            Message = response.Message
                        };
                    }
                    else
                    {
                        bool success = TerminalSettingsBLL.DeleteRegionVehicleRelation(base.CurrentUserID, RelationID);
                        resultElement = new OperationResult()
                        {
                            Success = success,
                            Message = success ? DisplayText.OperationSucceeded : "车机端删除操作成功完成,删除数据库记录出错。"
                        };
                    }
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID, TerminalSettingType.RegionSettings_Delete, PlateNum, TerminalCode, false,
                        RelationID.ToString(), resultElement.Message, GetRemoteAddress()
                        );
                    return resultElement;
                }
                else
                {
                    string RecordNotExists = "数据库中找不到对应的设置记录。";
                    TerminalSettingsBLL.InsertTerminalOperationsLog(
                        base.CurrentUserID, TerminalSettingType.RegionSettings_Delete,
                        null, null, false, RelationID.ToString(), RecordNotExists, GetRemoteAddress()
                        );
                    return new OperationResult()
                    {
                        Success = false,
                        Message = RecordNotExists
                    };
                }
            }));
        }