Beispiel #1
0
        public void Execute()
        {
            Console.Clear();
            Console.WriteLine("Removing Orders");
            Console.WriteLine(UserIO.Separator);
            order.dateTime = io.RemoveEditGetDate();
            List <Orders> orders = manager.DisplayOrder(order.dateTime).Orders;

            order = io.DeleteGettingOrderNumer(orders);
            if (order != null)
            {
                UserIO.DisplayForCustomer(order);
                order = io.DeletingOrder(order);
                if (order != null)
                {
                    RemoveResponse response = manager.DeletOrder(order);
                    if (response.Success)
                    {
                        Console.WriteLine("Order have been deleted.");
                        Console.ReadKey();
                    }
                    else
                    {
                        Console.WriteLine("Failure");
                        Console.WriteLine(response.Message);
                        Console.ReadKey();
                    }
                }
            }
        }
        /// <summary>
        /// 移除下载任务
        /// </summary>
        /// <param name="gid"></param>
        /// <returns></returns>
        public async Task <string> Remove(string gid)
        {
            var res = new RemoveResponse(await _client.SendRequestAsync(new RemoveRequest
            {
                GID = gid
            }));

            return(res?.GID);
        }
Beispiel #3
0
        JsonResult IDriver.Remove(IEnumerable <string> targets)
        {
            RemoveResponse answer = new RemoveResponse();

            foreach (string item in targets)
            {
                string decodedItem = this.DecodeTarget(this.GetCorectTarget(item));
                client.Delete(decodedItem);
                answer.Removed.Add(item);
            }
            return(Json(answer));
        }
        public override Task <RemoveResponse> RemoveOperate(RemoveRequest request, ServerCallContext context)
        {
            var response = new RemoveResponse();

            try
            {
                _operate.Delete(request.Id);
                response.IsComplete = true;
                return(Task.FromResult(response));
            }
            catch
            {
                response.IsComplete = false;
                return(Task.FromResult(response));
            }
        }
Beispiel #5
0
        public RemoveResponse DeletOrder(Orders order)
        {
            RemoveResponse response = new RemoveResponse();

            if (_orderRepository.DeleteOrder(order))
            {
                response.Success = true;
                response.Order   = order;
            }
            else
            {
                response.Success = false;
                response.Message = "Not valid";
            }
            return(response);
        }
        JsonResult IDriver.Remove(IEnumerable <string> targets)
        {
            var answer = new RemoveResponse();

            foreach (var item in targets)
            {
                var fullPath = ParsePath(item);
                if (fullPath.Directory != null)
                {
                    ResourceManager.Instance.Delete(fullPath.Directory.ResourceId);
                }
                else
                {
                    ResourceManager.Instance.Delete(fullPath.File.ResourceId);
                }
                answer.Removed.Add(item);
            }
            return(Json(answer));
        }
        JsonResult IDriver.Remove(IEnumerable <string> targets)
        {
            RemoveResponse answer = new RemoveResponse();

            foreach (var item in targets)
            {
                FullPath fullPath = ParsePath(item);
                if (fullPath.Directory != null)
                {
                    fullPath.Directory.Delete(true);
                }
                else
                {
                    fullPath.File.Delete();
                }
                answer.Removed.Add(item);
            }
            return(Json(answer));
        }
Beispiel #8
0
        public override Task <RemoveResponse> RemoveRole(RemoveRequest request, ServerCallContext context)
        {
            var response = new RemoveResponse();

            if (request.Id == 1)
            {
                throw new RpcException(new Status(StatusCode.InvalidArgument, "管理员角色不能被删除"));
            }
            try
            {
                _role.Delete(request.Id);
                response.IsComplete = true;
                return(Task.FromResult(response));
            }
            catch
            {
                response.IsComplete = false;
                return(Task.FromResult(response));
            }
        }
        JsonResult IDriver.Remove(IEnumerable <string> targets)
        {
            RemoveResponse answer = new RemoveResponse();

            foreach (string item in targets)
            {
                FullPath fullPath = ParsePath(item);
                RemoveThumbs(fullPath);
                if (fullPath.Directory != null)
                {
                    System.IO.Directory.Delete(fullPath.Directory.FullName, true);
                }
                else
                {
                    File.Delete(fullPath.File.FullName);
                }
                answer.Removed.Add(item);
            }
            return(Json(answer));
        }
Beispiel #10
0
        public RemoveResponse RemoveProductFromBasket(Basket basket)
        {
            RemoveResponse response = new RemoveResponse();

            using (MyDb db = new MyDb())
            {
                try
                {
                    basket = db.Baskets.FirstOrDefault(x => x.Product_ID == basket.Product_ID && x.User_ID == basket.User_ID);
                    db.Entry(basket).State = System.Data.Entity.EntityState.Deleted;
                    db.SaveChanges();
                    response.SetError(Common.SystemConstant.SystemConstants.ERRORS.SUCCESSFUL);
                }
                catch (Exception ex)
                {
                    response.SetError(Common.SystemConstant.SystemConstants.ERRORS.SYSTEMERROR);
                }
                return(response);
            }
        }
        public JsonResult Remove(IEnumerable <string> targets)
        {
            var answer = new RemoveResponse();

            foreach (var item in targets)
            {
                var path = Helper.DecodePath(item);

                if (mediaService.FileExists(path))
                {
                    mediaService.DeleteFile(path);
                }
                else if (mediaService.FolderExists(path))
                {
                    mediaService.DeleteFolder(path);
                }

                answer.Removed.Add(item);
            }
            return(Json(answer));
        }
Beispiel #12
0
        public void ResponseDelete(int orderNumber, bool expectedResult)
        {
            Orders order = new Orders()
            {
                dateTime               = new DateTime(2020, 06, 06),
                OrderNumber            = orderNumber,
                CustomerName           = "Wise",
                State                  = "OH",
                TaxRate                = 6.25m,
                ProductType            = "Wood",
                Area                   = 100.00m,
                CostPerSquareFoot      = 5.15m,
                LaborCostPerSquareFoot = 4.75m
            };

            RemoveResponse response = manager.DeletOrder(order);

            Assert.AreEqual(expectedResult, response.Success);

            if (response.Success == true)
            {
                repo.CreateOrder(new DateTime(2020, 06, 06), order);
            }
        }
Beispiel #13
0
        JsonResult IDriver.Remove(IEnumerable <string> targets)//done*
        {
            var            pathlist = new List <string>();
            RemoveResponse answer   = new RemoveResponse();

            foreach (string item in targets)
            {
                FullPath fullPath = ParsePath(item);

                RemoveThumbs(fullPath);

                if (fullPath.Directory != null)
                {
                    var filesinfolder = Directory.GetFiles(fullPath.Directory.FullName, "*", SearchOption.AllDirectories);

                    System.IO.Directory.Delete(fullPath.Directory.FullName, true);
                    foreach (var files in filesinfolder)
                    {
                        //LuceneIndexController.StopBackgroundJob(files, "UpdateLuceneIndexContent"); //stop before delete if textextraction continue

                        //LuceneIndexController.OnDelete(files);
                        pathlist.Add(files);
                    }
                }
                else
                {
                    //LuceneIndexController.StopBackgroundJob(fullPath.File.FullName, "UpdateLuceneIndexContent"); //stop before delete if textextraction continue
                    File.Delete(fullPath.File.FullName);
                    //LuceneIndexController.OnDelete(fullPath.File.FullName);
                    pathlist.Add(fullPath.File.FullName);
                }
                answer.Removed.Add(item);
            }
            BackgroundJob.Enqueue(() => IndexCRUD.OnDeleteResponse(pathlist));
            return(Json(answer));
        }
Beispiel #14
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (System.Exception exc)
            {
                _removeResult = OperationResult.Failure;
                if (!base.immatureId.Equals("-2"))
                {
                    //PROTOBUF:RESPONSE
                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                return;
            }

            CompressedValueEntry flagValueEntry = null;
            NCache nCache = clientManager.CmdExecuter as NCache;

            if (!cmdInfo.DoAsync)
            {
                OperationContext operationContext = null;

                try
                {
                    Notifications notification = null;
                    if (cmdInfo.DsItemRemovedId != -1)
                    {
                        notification = new Notifications(clientManager.ClientID, -1, -1, -1, -1, cmdInfo.DsItemRemovedId
                                                         , Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None); //DataFilter not required
                    }

                    operationContext = _operationContext;
                    operationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                    operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID);
                    operationContext.Add(OperationContextFieldName.MethodOverload, overload);
                    operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);
                    CommandsUtil.PopulateClientIdInContext(ref operationContext, clientManager.ClientAddress);
                    flagValueEntry = nCache.Cache.Remove(cmdInfo.Key, cmdInfo.FlagMap, notification, cmdInfo.LockId, cmdInfo.Version, cmdInfo.LockAccessType, cmdInfo.ProviderName, operationContext);
                    stopWatch.Stop();
                    UserBinaryObject ubObject = null;
                    if (flagValueEntry != null)
                    {
                        if (flagValueEntry.Value is UserBinaryObject)
                        {
                            ubObject = (UserBinaryObject)flagValueEntry.Value;
                        }
                        else
                        {
                            var flag = flagValueEntry.Flag;
                            ubObject = (flagValueEntry == null) ? null : (UserBinaryObject)nCache.Cache.SocketServerDataService.GetClientData(flagValueEntry.Value, ref flag, LanguageContext.DOTNET);
                        }
                    }


                    //PROTOBUF:RESPONSE
                    RemoveResponse removeResponse = _removeResponse;

                    if (ubObject != null)
                    {
                        removeResponse.value.AddRange(ubObject.DataList);
                        removeResponse.flag     = flagValueEntry.Flag.Data;
                        removeResponse.itemType = MiscUtil.EntryTypeToProtoItemType(flagValueEntry.Type);
                    }

                    if (clientManager.ClientVersion >= 5000)
                    {
                        ResponseHelper.SetResponse(removeResponse, command.requestID, command.commandID);
                        _serializedResponsePackets.Add(ResponseHelper.SerializeResponse(removeResponse, Response.Type.REMOVE));
                    }
                    else
                    {
                        Response response = Stash.ProtobufResponse;
                        {
                            response.remove = removeResponse;
                        };

                        ResponseHelper.SetResponse(response, command.requestID, command.commandID, Response.Type.REMOVE);
                        _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                    }
                }
                catch (System.Exception exc)
                {
                    _removeResult = OperationResult.Failure;
                    exception     = exc.ToString();

                    _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponseWithType(exc, command.requestID, command.commandID, clientManager.ClientVersion));
                }
                finally
                {
                    operationContext?.MarkFree(NCModulesConstants.SocketServer);

                    cmdInfo.FlagMap?.MarkFree(NCModulesConstants.SocketServer);
                    TimeSpan executionTime = stopWatch.Elapsed;

                    if (flagValueEntry != null)
                    {
                        MiscUtil.ReturnEntryToPool(flagValueEntry.Entry, clientManager.CacheTransactionalPool);
                        MiscUtil.ReturnCompressedEntryToPool(flagValueEntry, clientManager.CacheTransactionalPool);
                    }

                    try
                    {
                        if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                        {
                            APILogItemBuilder log = new APILogItemBuilder(MethodsName.REMOVE.ToLower());
                            log.GenerateRemoveAPILogItem(cmdInfo.Key, cmdInfo.FlagMap, cmdInfo.LockId, (long)cmdInfo.Version, cmdInfo.LockAccessType, cmdInfo.ProviderName, cmdInfo.DsItemRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                        }
                    }
                    catch
                    {
                    }
                }
            }

            else
            {
                OperationContext operationContext = null;

                try
                {
                    cmdInfo.FlagMap = new BitSet {
                        Data = cmdInfo.FlagMap.Data
                    };

                    object[] package = null;
                    if (cmdInfo.RequestId != -1 || cmdInfo.DsItemRemovedId != -1)
                    {
                        package = new object[] { cmdInfo.Key, cmdInfo.FlagMap, new Notifications(clientManager.ClientID,
                                                                                                 Convert.ToInt32(cmdInfo.RequestId),
                                                                                                 -1,
                                                                                                 -1,
                                                                                                 (short)(cmdInfo.RequestId == -1 ? -1 : 0),
                                                                                                 cmdInfo.DsItemRemovedId
                                                                                                 , Runtime.Events.EventDataFilter.None, Runtime.Events.EventDataFilter.None), cmdInfo.ProviderName }; //DataFilter not required
                    }
                    else
                    {
                        package = new object[] { cmdInfo.Key, cmdInfo.FlagMap, null, cmdInfo.ProviderName };
                    }

                    operationContext = OperationContext.CreateAndMarkInUse(clientManager.CacheFakePool, NCModulesConstants.SocketServer);
                    operationContext.Add(OperationContextFieldName.OperationType, OperationContextOperationType.CacheOperation);
                    operationContext.Add(OperationContextFieldName.RaiseCQNotification, true);
                    operationContext.Add(OperationContextFieldName.MethodOverload, overload);
                    nCache.Cache.RemoveAsync(package, operationContext);
                    stopWatch.Stop();
                }
                finally
                {
                    operationContext?.MarkFree(NCModulesConstants.SocketServer);

                    TimeSpan executionTime = stopWatch.Elapsed;
                    try
                    {
                        if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                        {
                            APILogItemBuilder log = new APILogItemBuilder(MethodsName.RemoveAsync.ToLower());
                            log.GenerateRemoveAPILogItem(cmdInfo.Key, cmdInfo.FlagMap, cmdInfo.LockId, (long)cmdInfo.Version, cmdInfo.LockAccessType, cmdInfo.ProviderName, cmdInfo.DsItemRemovedId, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString());
                        }
                    }
                    catch { }
                }
            }
        }
Beispiel #15
0
 public RemoveCommand()
 {
     _bitSet           = new BitSet();
     _removeResponse   = new RemoveResponse();
     _operationContext = new OperationContext();
 }
Beispiel #16
0
        // Method invoked in a separate thread, sets up a UDP listener
        // that listens for anything on a management port, then detemines
        // what kind of message it is (with what information) and handles
        // the response.
        void ReceiveManagementMsg()
        {
            UdpClient  listener = new UdpClient(mgmtLocalPort);
            IPEndPoint groupEP  = new IPEndPoint(IPAddress.Parse("127.0.0.1"), mgmtLocalPort);

            try
            {
                while (true)
                {
                    byte[] bytes = listener.Receive(ref groupEP);

                    Communications.Message msg = Communications.Serialization.Deserialize(bytes);

                    switch (msg.messageType)
                    {
                    case "NHLF.AddUpdateRequest":
                        Log.WriteLine("[MGMT CCI] {1}, port {2}: {0})", msg.messageType, msg.senderID, msg.senderPort);
                        AddUpdateRequest addUpdateReq = (AddUpdateRequest)msg;
                        transportFunction.UpdateRoutingTable(addUpdateReq.entry, true);
                        // !!! IT CAN GO TERRIBLY WRONG HERE !!!
                        SendManagementMsg(
                            (ushort)addUpdateReq.senderPort,
                            new AddUpdateResponse(id, mgmtLocalPort, addUpdateReq.seq, true)
                            );
                        Log.WriteLine("[MGMT CCI] Add/update forward: conn {2}, iface {0}, label {1}", addUpdateReq.entry.interface_in, addUpdateReq.entry.label_in, addUpdateReq.entry.connectionID);
                        break;

                    case "NHLF.RemoveRequest":
                        Log.WriteLine("[MGMT CCI] {1}, port {2}: {0})", msg.messageType, msg.senderID, msg.senderPort);
                        RemoveRequest removeReq = (RemoveRequest)msg;
                        bool          status    = transportFunction.RemoveFromRoutingTable(removeReq.connectionID);
                        SendManagementMsg(
                            (ushort)removeReq.senderPort,
                            new RemoveResponse(id, mgmtLocalPort, removeReq.seq, status)
                            );
                        Log.WriteLine("[MGMT CCI] {0} entries for connection {1}", status ? "Removed" : "Could not remove", removeReq.connectionID);
                        break;

                    case "AllocateRequest":
                        Log.WriteLine("[MGMT LRM] {1}, port {2}: {0})", msg.messageType, msg.senderID, msg.senderPort);
                        AllocateRequest allocateReq = (AllocateRequest)msg;
                        uint            label       = LRM.AssignBandwidthOnInterface(allocateReq.interfaceID, (uint)allocateReq.bitrate, allocateReq.connectionID);
                        SendManagementMsg(
                            (ushort)allocateReq.senderPort,
                            new AllocateResponse(
                                id,
                                mgmtLocalPort,
                                (int)label,
                                allocateReq.seq
                                )
                            );
                        if (label != 0)
                        {
                            Log.WriteLine("[MGMT LRM] Allocate {0} Mb/s on iface {1} for connection {2})", allocateReq.bitrate, allocateReq.interfaceID, allocateReq.connectionID);
                        }
                        else
                        {
                            Log.WriteLine("[MGMT LRM] Could not allocate {0} Mb/s on iface {1} for connection {2})", allocateReq.bitrate, allocateReq.interfaceID, allocateReq.connectionID);
                        }
                        break;

                    case "DeallocateRequest":
                        Log.WriteLine("[MGMT LRM] {1}, port {2}: {0})", msg.messageType, msg.senderID, msg.senderPort);
                        DeallocateRequest deallocateReq = (DeallocateRequest)msg;
                        LRM.ReleaseAsignedBandwidth(deallocateReq.connectionID);
                        SendManagementMsg(
                            (ushort)deallocateReq.senderPort,
                            new DeallocateResponse(
                                id,
                                mgmtLocalPort,
                                deallocateReq.seq
                                )
                            );
                        Log.WriteLine("[MGMT LRM] Deallocate resources for connection {0})", deallocateReq.connectionID);
                        break;

#if DEBUG
                    case "NHLF.AddUpdateResponse":
                        AddUpdateResponse addUpdateResponse = (AddUpdateResponse)msg;
                        Log.WriteLine("[CCI] AddUpdateRequest for {0} {1}.", addUpdateResponse.senderID, addUpdateResponse.status ? "successful" : "failed");
                        break;

                    case "NHLF.RemoveResponse":
                        RemoveResponse removeResp = (RemoveResponse)msg;
                        Log.WriteLine("[CCI] Remove {0}", removeResp.status ? "some" : "none");
                        break;

                    case "LRMRC.LinkStateUpdate":
                        LinkStateUpdate linkStateUpdate = (LinkStateUpdate)msg;
                        Log.WriteLine("[RC] {0} --{2}-> {1}", linkStateUpdate.beginNode.id, linkStateUpdate.endNode.id, linkStateUpdate.capacity);
                        break;
#endif
                    default:
                        break;
                    }

                    // NHLFMgmtMessage mgmtMessage = NHLFSerialization.Deserialize(bytes);

                    //NHLFEntry newEntry = mgmtMessage.entry;

                    //string result = transportFunction.UpdateRoutingTable(newEntry, mgmtMessage.addOrSwap);
                }
            }
            catch (Exception e)
            {
                Log.WriteLine(e.ToString());
            }
            finally
            {
                listener.Close();
            }
        }