Exemplo n.º 1
0
        public override void SaveSettingsToStorage()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            base.SaveSettingsToStorage();

            var settingsManager   = new ShellSettingsManager(ServiceProvider.GlobalProvider);
            var userSettingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);

            if (!userSettingsStore.CollectionExists(GeneralOptionsCollection))
            {
                userSettingsStore.CreateCollection(GeneralOptionsCollection);
            }

            var converter = new StringArrayConverter();

            userSettingsStore.SetString(
                GeneralOptionsCollection,
                nameof(LibraryPackFiles),
                converter.ConvertTo(this.LibraryPackFiles, typeof(string)) as string);
        }
Exemplo n.º 2
0
        new private void SaveFormEntry(FormDescription description)
        {
            FormsManager manager         = FormsManager.GetManager();
            FormEntry    userHostAddress = null;

            if (_isProgressiveForm && _priorFormEntry == null)
            {
                FieldControl keyField = this.FieldControls.Where(fc => ((IFormFieldControl)fc).MetaField.FieldName == _progressiveKeyFieldName).FirstOrDefault() as FieldControl;

                if (keyField != null && !String.IsNullOrWhiteSpace((string)keyField.Value))
                {
                    _priorFormEntry = GetPriorFormEntryByKeyField((string)keyField.Value);
                }
            }

            if (_isProgressiveForm && _priorFormEntry != null)
            {
                string entryType = String.Format("{0}.{1}", manager.Provider.FormsNamespace, this.FormData.Name);

                userHostAddress = manager.GetFormEntry(entryType, _priorFormEntry.Id);
            }
            else
            {
                userHostAddress = manager.CreateFormEntry(string.Format("{0}.{1}", manager.Provider.FormsNamespace, description.Name));
            }

            foreach (IFormFieldControl formFieldControl in this.FieldControls)
            {
                FieldControl fieldControl = formFieldControl as FieldControl;
                object       value        = fieldControl.Value;

                if (fieldControl.GetType().Name == "FormFileUpload")
                {
                    typeof(FormsControl)
                    .GetMethod("SaveFiles", BindingFlags.Static | BindingFlags.NonPublic)
                    .Invoke(null, new object[] { value as UploadedFileCollection, manager, description, userHostAddress, formFieldControl.MetaField.FieldName });
                }
                else if (!(value is List <string>))
                {
                    userHostAddress.SetValue(formFieldControl.MetaField.FieldName, value);
                }
                else
                {
                    StringArrayConverter stringArrayConverter = new StringArrayConverter();
                    object obj = stringArrayConverter.ConvertTo((value as List <string>).ToArray(), typeof(string));

                    userHostAddress.SetValue(formFieldControl.MetaField.FieldName, obj);
                }
            }
            userHostAddress.IpAddress   = this.Page.Request.UserHostAddress;
            userHostAddress.SubmittedOn = DateTime.UtcNow;

            Guid userId = ClaimsManager.GetCurrentUserId();

            userHostAddress.UserId = userId == Guid.Empty ? Guid.Parse(_sfTrackingCookie.Value) : userId;

            if (userHostAddress.UserId == userId)
            {
                userHostAddress.Owner = userId;
            }

            if (SystemManager.CurrentContext.AppSettings.Multilingual)
            {
                userHostAddress.Language = CultureInfo.CurrentUICulture.Name;
            }

            FormDescription formData = this.FormData;

            formData.FormEntriesSeed     = formData.FormEntriesSeed + (long)1;
            userHostAddress.ReferralCode = this.FormData.FormEntriesSeed.ToString();

            manager.SaveChanges();
        }
Exemplo n.º 3
0
        new private void SaveFormEntry(FormDescription description)
        {
            FormsManager manager         = FormsManager.GetManager();
            FormEntry    userHostAddress = null;

            if (_isProgressiveForm && _priorFormEntry == null)
            {
                FieldControl keyField = this.FieldControls.Where(fc => ((IFormFieldControl)fc).MetaField.FieldName == _progressiveKeyFieldName).FirstOrDefault() as FieldControl;

                if (keyField != null && !String.IsNullOrWhiteSpace((string)keyField.Value))
                {
                    _priorFormEntry = GetPriorFormEntryByKeyField((string)keyField.Value);
                }
            }

            if (_isProgressiveForm && _priorFormEntry != null)
            {
                string entryType = String.Format("{0}.{1}", manager.Provider.FormsNamespace, this.FormData.Name);

                userHostAddress = manager.GetFormEntry(entryType, _priorFormEntry.Id);
            }
            else
            {
                userHostAddress = manager.CreateFormEntry(string.Format("{0}.{1}", manager.Provider.FormsNamespace, description.Name));
            }

            foreach (IFormFieldControl formFieldControl in this.FieldControls)
            {
                FieldControl fieldControl = formFieldControl as FieldControl;
                object       value        = fieldControl.Value;

                if (fieldControl.GetType().Name == "FormFileUpload")
                {
                    if (formFieldControl.MetaField.FieldName != "")
                    {
                        var uploadValue = value as UploadedFileCollection;
                        var files       = new Dictionary <string, List <FormHttpPostedFile> >();
                        List <FormHttpPostedFile> formHttpPostedFileList = new List <FormHttpPostedFile>();
                        foreach (UploadedFile uploadedFile in uploadValue)
                        {
                            if (uploadedFile != null)
                            {
                                formHttpPostedFileList.Add(new FormHttpPostedFile()
                                {
                                    FileName      = uploadedFile.FileName,
                                    InputStream   = uploadedFile.InputStream,
                                    ContentType   = uploadedFile.ContentType,
                                    ContentLength = uploadedFile.ContentLength
                                });
                            }
                        }

                        files.Add(formFieldControl.MetaField.FieldName, formHttpPostedFileList);
                        var type       = Type.GetType("Telerik.Sitefinity.Modules.Forms.Web.FormsHelper,Telerik.Sitefinity");
                        var method     = type.GetMethod("SaveFiles", BindingFlags.Static | BindingFlags.NonPublic);
                        var updateMode = _priorFormEntry != null;
                        method.Invoke(null, new object[] { files, description, userHostAddress, updateMode });
                    }
                }
                else if (!(value is List <string>))
                {
                    userHostAddress.SetValue(formFieldControl.MetaField.FieldName, value);
                }
                else
                {
                    StringArrayConverter stringArrayConverter = new StringArrayConverter();
                    object obj = stringArrayConverter.ConvertTo((value as List <string>).ToArray(), typeof(string));

                    userHostAddress.SetValue(formFieldControl.MetaField.FieldName, obj);
                }
            }
            userHostAddress.IpAddress   = this.Page.Request.UserHostAddress;
            userHostAddress.SubmittedOn = DateTime.UtcNow;

            Guid userId = ClaimsManager.GetCurrentUserId();

            userHostAddress.UserId = userId == Guid.Empty ? Guid.Parse(_sfTrackingCookie.Value) : userId;

            if (userHostAddress.UserId == userId)
            {
                userHostAddress.Owner = userId;
            }

            if (SystemManager.CurrentContext.AppSettings.Multilingual)
            {
                userHostAddress.Language = CultureInfo.CurrentUICulture.Name;
            }

            FormDescription formData = this.FormData;

            formData.FormEntriesSeed     = formData.FormEntriesSeed + (long)1;
            userHostAddress.ReferralCode = this.FormData.FormEntriesSeed.ToString();

            manager.SaveChanges();
        }