Exemple #1
0
        public static DeleteEntryController DeleteEntryController(EntryPage entryPage)
        {
            IDeleteEntryOutput deleteEntryOutput = new DeleteEntryPresenter(entryPage);
            ICaseCRUD          caseCRUD          = new CaseCRUD();
            IPropertyCRUD      propertyCRUD      = new PropertyCRUD();
            IAddressCRUD       addressCRUD       = new AddressCRUD();
            IDeleteEntryInput  deleteEntryInput  = new DeleteEntry(deleteEntryOutput, caseCRUD, propertyCRUD, addressCRUD);

            return(new DeleteEntryController(deleteEntryInput));
        }
Exemple #2
0
        /// <summary>
        /// Delete entity.
        /// </summary>
        /// <param name="client">SugarRestClient object.</param>
        /// <param name="request">The request object.</param>
        /// <param name="modelInfo">The entity model info.</param>
        /// <returns>SugarRestResponse object.</returns>
        public static SugarRestResponse ExecuteDelete(this SugarRestClient client, SugarRestRequest request, ModelInfo modelInfo)
        {
            var sugarRestResponse = new SugarRestResponse();
            var loginResponse     = new LoginResponse();

            try
            {
                var loginRequest = new LoginRequest
                {
                    Url      = request.Url,
                    Username = request.Username,
                    Password = request.Password
                };

                loginResponse = Authentication.Login(loginRequest);

                var deleteEntryResponse = DeleteEntry.Run(loginResponse.SessionId, loginRequest.Url, request.ModuleName, request.Parameter.ToString());

                if (deleteEntryResponse != null)
                {
                    sugarRestResponse.JsonRawRequest  = deleteEntryResponse.JsonRawRequest;
                    sugarRestResponse.JsonRawResponse = deleteEntryResponse.JsonRawResponse;

                    if (!string.IsNullOrEmpty(deleteEntryResponse.Id))
                    {
                        sugarRestResponse.Data       = deleteEntryResponse.Id;
                        sugarRestResponse.JData      = (deleteEntryResponse.Id == null) ? null : JToken.FromObject(deleteEntryResponse.Id).ToString();
                        sugarRestResponse.StatusCode = deleteEntryResponse.StatusCode;
                    }
                    else
                    {
                        sugarRestResponse.Error      = deleteEntryResponse.Error;
                        sugarRestResponse.StatusCode = deleteEntryResponse.StatusCode;
                    }
                }

                return(sugarRestResponse);
            }
            catch (Exception exception)
            {
                sugarRestResponse.StatusCode = HttpStatusCode.InternalServerError;
                sugarRestResponse.Error      = ErrorResponse.Format(exception, string.Empty);
            }
            finally
            {
                Authentication.Logout(request.Url, loginResponse.SessionId);
            }

            return(sugarRestResponse);
        }
Exemple #3
0
 protected override void DoDeleteOldData(DateTime deletePoint)
 {
     m_Database.Collections.ForEach((collection, i) =>
     {
         if (!Running)
         {
             return;
         }
         var deleteAt    = RoundDatePerDetalization(deletePoint, DetalizationLevel);
         var query       = new Query();
         var betweenDate = new BSONDocument();
         betweenDate.Set(new BSONDateTimeElement("$lte", deleteAt));
         query.Set(new BSONDocumentElement("dt", betweenDate));
         var deleteEntry = new DeleteEntry(query, DeleteLimit.None);
         var result      = collection.Delete(deleteEntry);
         //Log(MessageType.Debug, this.GetType().Name +".DoDeleteOldDate", deleteAt.ToLongDateString() + "\n" +result.ToJSON(JSONWritingOptions.PrettyPrint));
     });
 }
Exemple #4
0
 public virtual async Task <ResponseApi> Delete([/*Bind("ids"),*/ FromForm, FromBody] DeleteEntry deleteEntry)
 {
     if (Request.ContentType.Contains("application/json"))
     {
         using (System.IO.StreamReader reader = new System.IO.StreamReader(Request.Body))
         {
             // Ref(ref deleteEntry, reader.ReadToEnd());
             Ref(ref deleteEntry, reader.ReadToEndAsync().Result);//类库影响
         }
     }
     else if (Request.ContentType.Contains("text/xml"))
     {
         using System.IO.StreamReader reader = new System.IO.StreamReader(Request.Body);
         Type          t          = typeof(DeleteEntry);
         XmlSerializer serializer = new XmlSerializer(t);
         deleteEntry = serializer.Deserialize(reader) as DeleteEntry;
     }
     //this.ActionParam(HttpContext.Request,ref deleteEntry);//无效 作用域可能 绑定模型失败
     if (!deleteEntry.Ids.Any())
     {
         ResponseApi response = ResponseApi.Create(GetLanguage(), Code.ParamNotNull, false);
         response.Message = $"id {response.Message}";
         return(await Task.FromResult(response));
     }
     else
     {
         this.DeleteBefore(deleteEntry.Ids);
         foreach (var item in deleteEntry.Ids)
         {
             T obj = new T();
             obj.Id = item;
             this.UnitWork.Delete <T>(obj);
             // UnitWork.Delete<T>(item);
         }
         this.DeleteAfter(deleteEntry.Ids);
         ResponseApi response = ResponseApi.Create(GetLanguage(), Code.DeleteSuccess);
         return(await Task.FromResult(response));
     }
 }
Exemple #5
0
        public override bool OnContextItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {

                case MenuOpen:
                    LaunchEntry();
                    return true;
                case MenuDelete:
                    Handler handler = new Handler();
                    DeleteEntry task = new DeleteEntry(Context, App.Kp2a, _entry, new GroupBaseActivity.RefreshTask(handler, _groupActivity));
                    task.Start();
                    return true;
                case MenuMove:
                    NavigateToFolderAndLaunchMoveElementTask navMove =
                        new NavigateToFolderAndLaunchMoveElementTask(_entry.ParentGroup, _entry.Uuid, _isSearchResult);
                    _groupActivity.StartTask (navMove);
                    return true;
                case MenuNavigate:
                    NavigateToFolder navNavigate = new NavigateToFolder(_entry.ParentGroup, true);
                    _groupActivity.StartTask (navNavigate);
                    return true;

                default:
                    return false;
            }
        }
Exemple #6
0
 public override async Task <ResponseApi> Delete([/*Bind(new[] { "ids" }),*/ FromForm, FromBody] DeleteEntry deleteEntry)
 {
     return(await base.Delete(deleteEntry));
 }