Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Martin Lingstuyl 202 posts 379 karma points
    May 29, 2015 @ 07:29
    Martin Lingstuyl
    0

    Recordset action succeeds but results in 403 permission denied page

    Hi all,

    Umbraco 6.1.x / Contour 3.0.26

    I'm having issues with a custom record set action of mine. It concerns one with settings, so it runs from a dialog box.

    After upgrading from Contour 3.0.17 to 3.0.26 it started doing this.

     

    It results in the following error. Which appears to be a wrong redirect or something.

     

    Does anyone know whats going on here? The Record Action does achieve it's intended result. So it's not an error.

    Martin

     

  • Comment author was deleted

    May 29, 2015 @ 10:00

    Hmm no changes have been made to record set actions, did you also upgrade Umbraco to a newer version?

  • Martin Lingstuyl 202 posts 379 karma points
    May 29, 2015 @ 10:08
    Martin Lingstuyl
    0

    I just heard from my client that he's receiving that error for a few years now.

    So it's not due to upgrading or contour versions.

    I did upgrade from 4.7.2 to 6.1. Some time last year.

     

  • Comment author was deleted

    May 29, 2015 @ 10:18

    Ok :) well hard to pinpoint then, would you mind sending the code for the action then I can test it locally and see what the issue is

  • Martin Lingstuyl 202 posts 379 karma points
    Jun 05, 2015 @ 08:54
    Martin Lingstuyl
    0

    Hi Tim,

    I could send you some of it, but I've added a logging function at the end, which gets executed. So the code runs fine.

    This is the gist of it (though I removed some procedures that require dependencies on my code:

     


        public class MoveRecord : RecordActionType
        {
            #region Constructor

            public MoveRecord()
            {
                this.Description = "Verplaats de Record data naar het geselecteerde formulier. Let op: Formulier velden moeten 1 op 1 overeen komen.";
                this.Icon = "edit.png";
                this.Id = new Guid("86645608-01a9-48bc-a5c9-91dbe445d9b1");
                this.Name = "Verplaats Record";
            }

            #endregion

            #region Public Methods

            public override RecordActionStatus Execute(Record record, Form form)
            {
                using (Entities ctx = new Entities())
                {
                    if (ListForms != "")
                    {
                        #region Copy Record to Training Inschrijving
                        //Copy information to Training
                        var recordStorage = new RecordStorage();
                        var formStorage = new FormStorage();
                        var SelectedForm = formStorage.GetForm(new Guid(ListForms));
                        var recordServiceNew = new RecordService(SelectedForm);
                        recordServiceNew.Open();

                        //Create new Record in Training Form
                        var NewRecord = recordServiceNew.Record;
                        NewRecord.IP = record.IP;
                        NewRecord.MemberKey = record.MemberKey;
                        NewRecord.CurrentPage = record.CurrentPage;
                        NewRecord.UmbracoPageId = record.UmbracoPageId;
                        NewRecord.Form = SelectedForm.Id;
                        NewRecord.State = FormState.Submitted;
                        recordStorage.InsertRecord(NewRecord, SelectedForm);


                        //Create Empty RecordFields in New Form
                        Dictionary<int, string> CaptionList = new Dictionary<int, string>();
                        int CaptionCounter = 0;
                        foreach (var field in SelectedForm.AllFields)
                        {
                            Guid key = Guid.NewGuid();
                            RecordField recordField = new RecordField()
                            {
                                Field = field,
                                Key = key,
                                Record = NewRecord.Id,
                                Values = new List<object>()
                            };



                            CaptionList.Add(CaptionCounter, field.Caption);

                            var recordFieldStorage = new RecordFieldStorage();
                            recordFieldStorage.InsertRecordField(recordField);
                            NewRecord.RecordFields.Add(key, recordField);
                            recordFieldStorage.Dispose();

                            CaptionCounter++;
                        }


                        //Copy Info From Old Form           
                        foreach (KeyValuePair<Guid, RecordField> rf in record.RecordFields)
                        {
                            //Select Fieldnumber in new Form with same caption
                            string FieldName = CaptionList.Where(it => it.Value == rf.Value.Field.Caption).FirstOrDefault().Value;

                            //Only copy exisiting Fields
                            if (FieldName != null)
                            {
                                Guid key = Guid.NewGuid();
                                var recordField = NewRecord.GetRecordField(FieldName);



                                //Check if Prevalue Guid
                                try
                                {


                                    //Als veld een guid is, gaat het om een prevalue. Vul dan gewoon de string in.
                                    Guid gd = new Guid(rf.Value.Values[0].ToString());

                                    List<object> li = new List<object>();
                                    li.Add(rf.Value.ValuesAsString());
                                    recordField.Values = li;



                                }
                                catch
                                {
                                    recordField.Values = rf.Value.Values;
                                }

                                var recordFieldStorage = new RecordFieldStorage();
                                recordFieldStorage.UpdateRecordField(recordField);
                                recordFieldStorage.Dispose();
                            }
                            else
                            {
                                try
                                {
                                    customFunctions.AddLogEntry("Contour Error", "Bij Training Entry verplaatsen werd van '" + RecordUser + "' dit veld niet meeverplaatst: '" + rf.Value.Field.Caption + "'. De inhoud was '" + rf.Value.ValuesAsString() + "'", 0, 0, "", "");
                                }
                                catch { }
                            }
                        }

                        //Set To Approved or not
                        if (Convert.ToBoolean(Approved) == true)
                            NewRecord.State = FormState.Approved;
                        else
                            NewRecord.State = FormState.Submitted;

                        //Update Record
                        recordStorage.UpdateRecord(NewRecord, SelectedForm);
                        recordStorage.UpdateRecordXml(NewRecord, SelectedForm);
                        #endregion

                        //Check if relation is already stored
                        SettingsStorage ss = new SettingsStorage();
                        string RelatedGuid = ss.GetSetting(record.Id, "MoveRecordOldNewIds");
                       

                        //Save Relation between old and new record                    
                        if (string.IsNullOrEmpty(RelatedGuid))                   
                            ss.InsertSetting(record.Id, "MoveRecordOldNewIds", NewRecord.Id.ToString());
                        else
                            ss.UpdateSetting(record.Id, "MoveRecordOldNewIds", NewRecord.Id.ToString());

                        ss.Dispose();
                      


                        record.State = FormState.Approved;
                        recordStorage.UpdateRecord(record, form);
                        recordStorage.UpdateRecordXml(record, form);
                                           
                        #region LOG MOVING RECORD
                   
                        //GET FORM NAME
                        string FormString = "";
                        using (FormStorage frmStor = new FormStorage())
                        {
                            Form frm = frmStor.GetForm(record.Form);
                            if (frm != null)
                                FormString = frm.Name;
                        }

                        customFunctions.AddLogEntry("Contour Record Moved", "MOVED: " + record.Id + " TO: " + NewRecord.Id + " FORM: " + FormString, 0, 0, "", "");
                   
                        #endregion

                        recordStorage.Dispose();
                        formStorage.Dispose();
                        recordServiceNew.Dispose();

                        return RecordActionStatus.Completed;
                    }
                    else
                        return RecordActionStatus.Failed;
                }
            }

            #endregion

            #region Properties

            [Setting("Selecteer Training", description = "Selecteer de training waarnaar u dit record wilt verplaatsen", control = "Contour.Addons.FieldSettings.ListOfForms", assembly = "EFT.Contour.Addons")]
            public string ListForms { get; set; }

            [Setting("Zet op 'Approved'", description = "Selecteer dit als je het record gelijk op approved status wilt zetten", control = "Umbraco.Forms.Core.FieldSetting.Checkbox")]
            public string Approved { get; set; }

            [Setting("Omschrijving", description = "Omschrijving van betaling (Training, Webwinkel Product) LET OP: Leeglaten betekent oude Omschrijving bewaren.", control = "Umbraco.Forms.Core.FieldSetting.TextField")]
            public string Omschrijving { get; set; }

            #endregion

        }

     

Please Sign in or register to post replies

Write your reply to:

Draft