Inheritance: System.Web.UI.MasterPage
Exemplo n.º 1
0
        private void ShowCustomForm()
        {
            CustomForm customForm = new CustomForm(parent, food);

            customForm.ShowDialog();
        }
 // To start playing video and etc when form being maximized
 protected override void OnStart(CustomForm Sender)
 {
 }
Exemplo n.º 3
0
 public void Save(CustomForm entity)
 {
     Context.CustomForms.Add(entity);
 }
Exemplo n.º 4
0
        public CustomFormDialog(uint formId, BedrockFormManager parent, CustomForm form, InputManager inputManager) : base(formId, parent, inputManager)
        {
            Container.AddChild(new GuiTextElement()
            {
                Anchor    = Alignment.TopCenter,
                Text      = form.Title,
                FontStyle = FontStyle.Bold,
                Scale     = 2f,
                TextColor = TextColor.White
            });

            Form = form;

            GuiScrollableStackContainer stackContainer = new GuiScrollableStackContainer();

            stackContainer.Orientation = Orientation.Vertical;
            stackContainer.Anchor      = Alignment.Fill;
            stackContainer.ChildAnchor = Alignment.MiddleFill;

            var margin = new Thickness(5, 5);

            foreach (var element in form.Content)
            {
                switch (element)
                {
                case Label label:
                {
                    stackContainer.AddChild(new GuiTextElement()
                        {
                            Text   = label.Text,
                            Margin = margin
                        });
                }
                break;

                case Input input:
                {
                    GuiTextInput guiInput = new GuiTextInput()
                    {
                        Value       = input.Value,
                        PlaceHolder = input.Placeholder,
                        Margin      = margin
                    };

                    guiInput.ValueChanged += (sender, s) => { input.Value = s; };

                    stackContainer.AddChild(guiInput);
                }
                break;

                case Toggle toggle:
                {
                    GuiToggleButton guiToggle;
                    stackContainer.AddChild(guiToggle = new GuiToggleButton(toggle.Text)
                        {
                            Margin = margin,
                            Value  = !toggle.Value
                        });

                    guiToggle.DisplayFormat = new ValueFormatter <bool>((val) =>
                        {
                            return($"{toggle.Text}: {val.ToString()}");
                        });

                    guiToggle.Value = toggle.Value;

                    guiToggle.ValueChanged += (sender, b) => { toggle.Value = b; };
                }
                break;

                case Slider slider:
                {
                    GuiSlider guiSlider;
                    stackContainer.AddChild(guiSlider = new GuiSlider()
                        {
                            Label        = { Text = slider.Text },
                            Value        = slider.Value,
                            MaxValue     = slider.Max,
                            MinValue     = slider.Min,
                            StepInterval = slider.Step,
                            Margin       = margin
                        });

                    guiSlider.ValueChanged += (sender, d) => { slider.Value = (float)d; };
                }
                break;

                case StepSlider stepSlider:
                {
                    stackContainer.AddChild(new GuiTextElement()
                        {
                            Text      = "Unsupported stepslider",
                            TextColor = TextColor.Red,
                            Margin    = margin
                        });
                }
                break;

                case Dropdown dropdown:
                {
                    stackContainer.AddChild(new GuiTextElement()
                        {
                            Text      = "Unsupported dropdown",
                            TextColor = TextColor.Red,
                            Margin    = margin
                        });
                }
                break;
                }
            }

            SubmitButton = new GuiButton("Submit", SubmitPressed);

            stackContainer.AddChild(SubmitButton);

            Container.AddChild(stackContainer);
        }
 // For overriding in forms to Stop something such as playing or etc
 protected virtual void OnStop(CustomForm Sender)
 {
 }
 public CustomFormBuilder(CustomForm customForm)
     : base(customForm.FormConfig, customForm.KeyField)
 {
     _customForm = customForm;
 }
Exemplo n.º 7
0
        private async Task <IAdminResult> ExecuteCustomFormSubmitAction <TModel>(TModel entityObject, CustomForm customForm) where TModel : class
        {
            var formActionDelegate = customForm.SubmitActionExpression.Compile();
            var result             = await(dynamic) formActionDelegate.DynamicInvoke(_serviceProvider, entityObject) as IAdminResult;

            return(result);
        }
Exemplo n.º 8
0
 public void Setup()
 {
     _tenant     = new AppTenant("Treeze", "localhost:43500", null, null);
     _customForm = new CustomForm("Novo formulário", _tenant.Id);
 }
Exemplo n.º 9
0
 // To start playing video and etc when form being maximized
 protected override void OnStart(CustomForm Sender)
 {
     axWindowsMediaPlayer1.URL = @"C:\Users\ok\Downloads\ok.mp4";
 }
Exemplo n.º 10
0
        public String saveEmployee(FormCollection formData, HttpPostedFileBase file)
        {
            bool   access                = false;
            String dataPermissions       = Session["Permissions"].ToString();
            String dataPermissionsClient = Session["PermissionsClient"].ToString();
            bool   accessClient          = false;

            access       = validatepermissions.getpermissions("employee", "u", dataPermissions);
            accessClient = validatepermissions.getpermissions("employee", "u", dataPermissionsClient);
            //if (access == true && accessClient == true)
            if (true)
            {
                if (this.Request.IsAjaxRequest())
                {
                    formData = CustomForm.unserialize(formData);                                               //use the method serialize to parse the string into an array

                    String  employeeID   = (formData["employeeID"] == "null") ? null : formData["employeeID"]; //check insert new or update existing
                    String  EmployeeName = "";
                    JObject employee     = new JObject();
                    //get employee if update
                    if (employeeID != null)
                    {
                        String employeestring = employeetable.GetRow(employeeID);
                        employee = JsonConvert.DeserializeObject <JObject>(employeestring);
                    }

                    /*check when update , employee exist or not*/
                    if (employeeID != null && (employee == null))
                    {
                        return("{\"msg\":\"El id especificado no existe\", \"status\":\"error\"}");
                    }


                    /*The selected emoloyee Id is already in use and is not the employee who has it*/
                    if (employeeExists(formData["employee"]) == "true" && (employeeID == null || employeetable.get("employee", formData["employee"])[0].GetElement("_id").Value.ToString() != employeeID))
                    {
                        return("{\"msg\":\"El empleado ya está siendo utilizado\", \"status\":\"error\"}");
                    }

                    //due that the Employee's id is unique we use it has the image's name, so we store only the extension in the db
                    string ext = null;
                    if (file != null)
                    {
                        ext = file.FileName.Split('.').Last(); //getting the extension
                    }
                    else if (employeeID != null)
                    {
                        try
                        {
                            ext = employee["imgext"].ToString();
                        }
                        catch (Exception e) { }
                    }



                    //JArray listp = new JArray();
                    /* Format validations */



                    if (!Regex.IsMatch(formData["name"], "[A-ZÁÉÍÓÚÑa-záéíóúñ]+( [A-ZÁÉÍÓÚÑa-záéíóúñ]+){0,2}"))
                    {
                        return("{\"msg\":\"Formato incorrecto para: name\", \"status\":\"error\"}");
                    }
                    else if (!Regex.IsMatch(formData["lastname"], "[A-ZÁÉÍÓÚÑa-záéíóúñ]+( [A-ZÁÉÍÓÚÑa-záéíóúñ]+){0,1}"))
                    {
                        return("{\"msg\":\"Formato incorrecto para: Apellido Paterno\", \"status\":\"error\"}");
                    }
                    else if (!Regex.IsMatch(formData["motherlastname"], "[A-ZÁÉÍÓÚÑa-záéíóúñ]+( [A-ZÁÉÍÓÚÑa-záéíóúñ]+){0,1}"))
                    {
                        return("{\"msg\":\"Formato incorrecto para: Apellido Materno\", \"status\":\"error\"}");
                    }
                    else if (!Regex.IsMatch(formData["employee"], "([a-zA-Z0-9-_.]){4,}"))
                    {
                        return("{\"msg\":\"Formato incorrecto para: ID Empleado\", \"status\":\"error\"}");
                    }
                    ///check selected profile id exist or not
                    ///
                    else if (formData["profileId"] == "null")
                    {
                        return("{\"msg\":\"Elija El perfil\", \"status\":\"error\"}");
                    }
                    else if (employeeprofileTable.getRow(formData["profileId"]) == null)
                    {
                        return("{\"msg\":\"El perfil especificado no existe\", \"status\":\"error\"}");
                    }
                    else if (formData["type"] == "null")
                    {
                        return("{\"msg\":\"Elija El Tipo de Empleado\", \"status\":\"error\"}");
                    }
                    else if (formData["area"] == "null")
                    {
                        return("{\"msg\":\"Elija El Área\", \"status\":\"error\"}");
                    }
                    else
                    {
                        EmployeeName = formData["employee"];
                    }

                    /* Format validations */
                    //Change name representation
                    formData["name"]     = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(formData["name"].ToString().ToLower().Trim());
                    formData["lastname"] = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(formData["lastname"].ToString().ToLower().Trim());

                    //there are fields that we know that exists so we set them into the json
                    String jsonData = "{'employee':'" + formData["employee"] + "','name':'" + formData["name"].Replace("+", " ") + "','imgext':'" + ext
                                      + "','lastname':'" + formData["lastname"].Replace("+", " ")
                                      + "','motherlastname':'" + formData["motherlastname"].Replace("+", " ") + "','type':'" + formData["type"]
                                      + "','profileId':'" + formData["profileId"] + "','area':'" + formData["area"];

                    try //trying to set the creator's id
                    {
                        jsonData += "','creatorId':'";
                        jsonData += this.Session["_id"];
                        jsonData += "'";
                    }
                    catch (Exception e) { /*Ignored*/ }

                    //remove the setted data in the json from the formData
                    formData.Remove("employeeID");
                    formData.Remove("employee");
                    formData.Remove("name");
                    formData.Remove("lastname");
                    formData.Remove("motherlastname");
                    formData.Remove("type");
                    formData.Remove("profileId");
                    formData.Remove("area");


                    jsonData += ", 'profileFields':{";

                    //foreach element in the formData, let's append it to the jsonData in the profileFields
                    int cont = 0;
                    foreach (String key in formData.Keys)
                    {
                        jsonData += "'" + key + "':'" + formData[key] + "'";

                        cont++;
                        if (cont < formData.Keys.Count)
                        {
                            jsonData += ", ";
                        }
                    }
                    jsonData += "}}";



                    //now that we have the json and we know the data is ok, let's save it
                    string id = employeetable.saveRow(jsonData, employeeID);
                    //Notify this action
                    if (employeeID == null)
                    {
                        Notificate.saveNotification("Employees", "Create", "El empleado '" + EmployeeName + "' ha sido creado");
                        _logTable.SaveLog(Session["_id"].ToString(), "empleados", "Insert: " + EmployeeName, "Employee", DateTime.Now.ToString());
                    }
                    else
                    {
                        Notificate.saveNotification("Employees", "Update", "El empleado '" + EmployeeName + "' ha sido modificado");
                        _logTable.SaveLog(Session["_id"].ToString(), "empleados", "Update: " + EmployeeName, "Employee", DateTime.Now.ToString());
                    }

                    //TODO:Aqui se guarda la imagen
                    if (file != null)
                    {
                        string relativepath = "\\Uploads\\Images\\";
                        string absolutepath = Server.MapPath(relativepath);
                        if (!System.IO.Directory.Exists(absolutepath))
                        {
                            System.IO.Directory.CreateDirectory(absolutepath);
                        }
                        file.SaveAs(absolutepath + "\\" + id + "." + ext);

                        Images resizeImage = new Images(absolutepath + "\\" + id + "." + ext, absolutepath, id + "." + ext);
                        // If image bigger than 1MB, resize to 1024px max
                        if (file.ContentLength > 1024 * 1024)
                        {
                            resizeImage.resizeImage(new System.Drawing.Size(1024, 1024));
                        }

                        // Create the thumbnail of the image
                        resizeImage.createThumb();
                    }


                    return("{\"msg\":\"" + id + "\", \"status\":\"success\"}"); //returns the saved user's id
                }
                return(null);
            }

            else
            {
                return(null);
            }
        }
Exemplo n.º 11
0
 // To stop playing video and etc when form being minimized
 protected override void OnStop(CustomForm Sender)
 {
     axWindowsMediaPlayer1.URL = @"";
 }
Exemplo n.º 12
0
        private void ExecutePayVisa(Player player, SimpleForm form)
        {
            CustomForm customForm = new CustomForm();

            customForm.Title         = "Secure Payment Info - VISA";
            customForm.ExecuteAction = ExecuteReviewOrder;
            customForm.Content       = new List <CustomElement>()
            {
                new Label {
                    Text = "Safe money transfer using your VISA card"
                },
                new Input
                {
                    Text        = "",
                    Placeholder = "Name - as it appears on card",
                    Value       = "John Doe"
                },
                new Input
                {
                    Text        = "",
                    Placeholder = "Credit card number",
                    Value       = "4242424242424242"
                },
                new Dropdown
                {
                    Text    = "Expiration date (month)",
                    Options = new List <string>()
                    {
                        "01 - January",
                        "02 - February",
                        "03 - March"
                    },
                    Value = 0
                },
                new Dropdown
                {
                    Text    = "Expiration date (year)",
                    Options = new List <string>()
                    {
                        "2017",
                        "2018",
                        "2019"
                    },
                    Value = 2
                },
                new Input
                {
                    Text        = "",
                    Placeholder = "Security code (3 on back)",
                    Value       = "111"
                },
                new Toggle
                {
                    Text  = "Save payment info (safe)",
                    Value = true
                },
                new Label {
                    Text = "§lWhat happens now?§r\nThis is step 1 of 2. After submitting payment information you will be able to review your order.\nWe will not bill you until confirm the order on next page (step 2)."
                },
            };

            player.SendForm(customForm);
        }
 protected override void OnStop(CustomForm Sender)
 {
     ppPresentation.Close();
     //opApp.Quit();
     Process.Start("cmd", "/c taskkill /im POWERPNT.EXE");
 }
Exemplo n.º 14
0
 public CustomControlCollection(VlufiForm pOwner) : base(pOwner)
 {
     Owner = pOwner;
 }
Exemplo n.º 15
0
        private void btnCustom_Click(object sender, EventArgs e)
        {
            CustomForm form = new CustomForm(this);

            form.ShowDialog();
        }
Exemplo n.º 16
0
        private void button2_Click(object sender, EventArgs e)
        {
            CustomForm form = new CustomForm();

            form.ShowDialog();
        }
Exemplo n.º 17
0
        /// <summary>
        /// 显示自定义窗体
        /// </summary>
        /// <param name="control">显示的视图</param>
        /// <returns>返回窗口</returns>
        public static CustomForm ShowForm(UserControl control)
        {
            CustomForm newForm = new CustomForm(control, true, null);

            return(newForm);
        }
Exemplo n.º 18
0
        public CustomFormDialog(uint formId, BedrockFormManager parent, CustomForm form, InputManager inputManager) : base(formId, parent, inputManager)
        {
            Form = form;

            GuiScrollableStackContainer stackContainer = new GuiScrollableStackContainer();

            stackContainer.Orientation = Orientation.Vertical;
            stackContainer.Anchor      = Alignment.Fill;
            stackContainer.ChildAnchor = Alignment.MiddleFill;
            stackContainer.Background  = Color.Black * 0.35f;
            var margin = new Thickness(5, 5);

            foreach (var element in form.Content)
            {
                switch (element)
                {
                case Label label:
                {
                    stackContainer.AddChild(new GuiTextElement()
                        {
                            Text   = label.Text,
                            Margin = margin
                        });
                }
                break;

                case Input input:
                {
                    GuiTextInput guiInput = new GuiTextInput()
                    {
                        Value       = input.Value,
                        PlaceHolder = !string.IsNullOrWhiteSpace(input.Placeholder) ? input.Placeholder : input.Text,
                        Margin      = margin
                    };

                    guiInput.ValueChanged += (sender, s) => { input.Value = s; };

                    stackContainer.AddChild(guiInput);
                }
                break;

                case Toggle toggle:
                {
                    GuiToggleButton guiToggle;
                    stackContainer.AddChild(guiToggle = new GuiToggleButton(toggle.Text)
                        {
                            Margin = margin,
                            Value  = !toggle.Value
                        });

                    guiToggle.DisplayFormat = new ValueFormatter <bool>((val) =>
                        {
                            return($"{toggle.Text}: {val.ToString()}");
                        });

                    guiToggle.Value = toggle.Value;

                    guiToggle.ValueChanged += (sender, b) => { toggle.Value = b; };
                }
                break;

                case Slider slider:
                {
                    GuiSlider guiSlider;
                    stackContainer.AddChild(guiSlider = new GuiSlider()
                        {
                            Label        = { Text = slider.Text },
                            Value        = slider.Value,
                            MaxValue     = slider.Max,
                            MinValue     = slider.Min,
                            StepInterval = slider.Step,
                            Margin       = margin
                        });

                    guiSlider.ValueChanged += (sender, d) => { slider.Value = (float)d; };
                }
                break;

                case StepSlider stepSlider:
                {
                    stackContainer.AddChild(new GuiTextElement()
                        {
                            Text      = "Unsupported stepslider",
                            TextColor = TextColor.Red,
                            Margin    = margin
                        });
                }
                break;

                case Dropdown dropdown:
                {
                    stackContainer.AddChild(new GuiTextElement()
                        {
                            Text      = "Unsupported dropdown",
                            TextColor = TextColor.Red,
                            Margin    = margin
                        });
                }
                break;
                }
            }

            SubmitButton = new GuiButton("Submit", SubmitPressed);

            stackContainer.AddChild(SubmitButton);

            Background = Color.Transparent;

            var width  = 356;
            var height = width;

            ContentContainer.Width  = ContentContainer.MinWidth = ContentContainer.MaxWidth = width;
            ContentContainer.Height = ContentContainer.MinHeight = ContentContainer.MaxHeight = height;

            SetFixedSize(width, height);

            ContentContainer.AutoSizeMode = AutoSizeMode.None;

            Container.Anchor = Alignment.MiddleCenter;

            var bodyWrapper = new GuiContainer();

            bodyWrapper.Anchor  = Alignment.Fill;
            bodyWrapper.Padding = new Thickness(5, 0);
            bodyWrapper.AddChild(stackContainer);

            Container.AddChild(bodyWrapper);

            Container.AddChild(Header = new GuiStackContainer()
            {
                Anchor      = Alignment.TopFill,
                ChildAnchor = Alignment.BottomCenter,
                Height      = 32,
                Padding     = new Thickness(3),
                Background  = Color.Black * 0.5f
            });

            Header.AddChild(new GuiTextElement()
            {
                Text      = FixContrast(form.Title),
                TextColor = TextColor.White,
                Scale     = 2f,
                FontStyle = FontStyle.DropShadow,

                Anchor = Alignment.BottomCenter,
            });

            stackContainer.Margin = new Thickness(0, Header.Height, 0, 0);
        }
Exemplo n.º 19
0
        private static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                // may throw exception if its doesn' find a database
                voteAppEntities entities = DbUtils.AppEntities;
            }
            catch (Exception ex)
            {
                MessageBox.Show("NOT CONNECTED TO A DATABASE!", "MISSING DATA", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Trace.WriteLine(ex.Message);
                return;
            }

            bool isLicensed = RegistryUtils.IsLicensed();

            if (!isLicensed)
            {
                // check if app is already activated through windows registry
                using (LicenseForm enterLicense = new LicenseForm())
                {
                    //enterLicense.ShowDialog();
                    Application.Run(enterLicense);
                    isLicensed = enterLicense.DialogResult == DialogResult.OK;
                }
            }

            // invalid license
            if (!isLicensed)
            {
                return;
            }

            // if there is at least one user (superadmin) show the login form
            if (DbUtils.AppEntities.Users.Any(user => user.Type == TypeUser.SuperAdmin) == false)
            {
                CreateAdminConfigurations configs = new CreateAdminConfigurations
                {
                    Title    = "Create super admin!",
                    TypeUser = TypeUser.SuperAdmin
                };
                bool showLoginForm = false;
                //User loginUser = null;
                using (CreateAdminForm formCreateSuperAdmin = new CreateAdminForm(configs))
                {
                    if (formCreateSuperAdmin.ShowDialog() == DialogResult.OK)
                    {
                        showLoginForm = formCreateSuperAdmin.User != null;
                    }
                }
                if (showLoginForm)
                {
                    using (CustomForm customForm = new CustomForm())
                    {
                        customForm.ShowDialog();
                    }
                }
            }

            Application.Run(new LoginForm());
        }
Exemplo n.º 20
0
            public void Start()
            {
                Console.WriteLine("Checking for update.");

                if (_client == null)
                {
                    _client = new WebClient();
                }

                _client.Proxy = null;
                Checking      = true;

                try
                {
#if BETA
                    CustomForm form = new CustomForm()
                    {
                        Text          = "Check for updates",
                        StartPosition = FormStartPosition.CenterScreen,
                        ControlBox    = false,
                        Sizable       = false,
                        Icon          = Icon.ExtractAssociatedIcon(Application.ExecutablePath),
                        Size          = new Size(350, 150),
                        TopMost       = true
                    };

                    Label label = new Label()
                    {
                        Font      = new Font("Segoe UI", 20, FontStyle.Regular),
                        ForeColor = Color.White,
                        Text      = "Checking...",
                        AutoSize  = true,
                    };
                    label.Location = new Point(form.Width / 2 - label.Width / 2 - 25, form.Height / 2 - label.Height / 2);
                    label.Parent   = form;
                    form.Show();

                    Version checkedVersion = new Version(_client.DownloadString(new Uri("http://razorenhanced.org/download/Version-EM-Beta.txt")));

                    if (checkedVersion > MainCore.MapVersion)
                    {
                        form.Close();

                        form = new CustomForm()
                        {
                            Text          = "New updates available!",
                            StartPosition = FormStartPosition.CenterScreen,
                            ControlBox    = false,
                            Sizable       = false,
                            Icon          = Icon.ExtractAssociatedIcon(Application.ExecutablePath),
                            Size          = new Size(350, 150),
                            TopMost       = true
                        };

                        label = new Label()
                        {
                            Font      = new Font("Segoe UI", 20, FontStyle.Regular),
                            ForeColor = Color.White,
                            Text      = "Updating...",
                            AutoSize  = true,
                        };
                        label.Location = new Point(form.Width / 2 - label.Width / 2 - 25, form.Height / 2 - label.Height / 2);
                        label.Parent   = form;

                        Task.Run(() =>
                        {
                            string path = Path.Combine(Path.GetTempPath(), "Enhanced-Map-Beta.zip");

                            if (File.Exists(path))
                            {
                                File.Delete(path);
                            }

                            _client.DownloadFile("http://razorenhanced.org/download/Enhanced-Map-Beta.zip", path);

                            string pathtoextract = Path.Combine(Path.GetTempPath(), "map-beta");
                            if (Directory.Exists(pathtoextract))
                            {
                                Directory.Delete(pathtoextract, true);
                            }

                            ZipFile.ExtractToDirectory(path, pathtoextract);

                            Process p = new Process
                            {
                                StartInfo =
                                {
                                    FileName        = Path.Combine(pathtoextract, "EnhancedMap.exe"),
                                    UseShellExecute = false,
                                    Arguments       =
                                        $"--source \"{Application.ExecutablePath}\" --pid {Process.GetCurrentProcess().Id} --action update"
                                }
                            };
                            p.Start();
                            Process.GetCurrentProcess().Kill();
                        });

                        form.ShowDialog();
                    }
                    if (form != null && !form.Disposing)
                    {
                        form.Close();
                    }
#else
                    _client.DownloadStringCompleted += m_Client_DownloadStringCompleted;
                    _client.DownloadStringAsync(new Uri("http://razorenhanced.org/download/Version-EM.txt"));
#endif
                }
                catch (WebException webEx)
                {
                    Checking = false;
                    MessageBox.Show("Failed to comunicate with server", "Error");
                }
                catch (Exception ex)
                {
                    Checking = false;
                    MessageBox.Show("Failed to download new version.", "Error");
                }
            }
 // To stop playing video and etc when form being minimized
 protected override void OnStop(CustomForm Sender)
 {
     axWindowsMediaPlayer1.Ctlcontrols.pause();
 }
Exemplo n.º 22
0
        public ICommandResult Handle(CreateCustomFormRequest command)
        {
            if (!command.IsValid())
            {
                return(new CommandResult(false, "Request inválida", command));
            }

            var customForm = new CustomForm(command.Name, _tenant.Id);

            AddNotifications(customForm.Notifications);

            if (command.Fields != null)
            {
                foreach (var fieldCommand in command.Fields)
                {
                    var customField = new CustomField(fieldCommand.Name, fieldCommand?.Description, fieldCommand.Type, customForm.Id, fieldCommand.Mandatory, _tenant.Id);

                    AddNotifications(customField.Notifications);

                    if (customField.HasOptions())
                    {
                        if (fieldCommand.Options == null || fieldCommand.Options.Count == 0)
                        {
                            AddNotification("Type", $"Campo {fieldCommand.Name} deve conter opções.");
                        }
                    }

                    if (fieldCommand.Options != null)
                    {
                        foreach (var optionCommand in fieldCommand.Options)
                        {
                            var customFieldOption =
                                new CustomFieldOption(optionCommand.Name, customField.Id, _tenant.Id);

                            AddNotifications(customFieldOption.Notifications);

                            customField.AddOption(customFieldOption);
                        }
                    }

                    customForm.AddField(customField);
                }
            }
            else
            {
                AddNotification("Fields", "Os campos do formulário não foram inseridos.");
            }

            if (Valid)
            {
                _customFormRepository.Save(customForm);

                if (command.PageComponentId.HasValue)
                {
                    var formPageComponent = new FormPageComponent(command.PageComponentId.Value, customForm.Id, _tenant.Id);

                    AddNotifications(formPageComponent.Notifications);

                    _formPageComponentRepository.Save(formPageComponent);
                }
            }

            if (Valid)
            {
                return(new CommandResult(true, "Formulário cadastrado com sucesso", new { Id = customForm.Id, Name = customForm.Name }));
            }
            else
            {
                return(new CommandResult(false, "Erro ao cadastrar formulário", Notifications));
            }
        }
Exemplo n.º 23
0
        private void button5_Click(object sender, EventArgs e)
        {
            var customForm = new CustomForm();

            customForm.ShowDialog();
        }
Exemplo n.º 24
0
 public void Update(CustomForm entity)
 {
     Context.Entry(entity).State = EntityState.Modified;
 }
Exemplo n.º 25
0
        /// <summary>
        ///     This method saves a new list in the bd if not id is gived, or update an existing list if is gived
        /// </summary>
        /// <param name="formData"></param>
        /// <param name="id"></param>
        /// <author>
        ///     Luis Gonzalo Quijada Romero
        /// </author>
        /// <returns>
        ///     Returns the saved document's id
        /// </returns>
        public String saveList(FormCollection formData)
        {
            String dataPermissions       = Session["Permissions"].ToString();
            String dataPermissionsClient = Session["PermissionsClient"].ToString();
            bool   access       = false;
            bool   accessClient = false;

            //  access = getpermissions("users", "r");
            access       = validatepermissions.getpermissions("lists", "u", dataPermissions);
            accessClient = validatepermissions.getpermissions("lists", "u", dataPermissionsClient);

            if (access == true && accessClient == true)
            {
                if (this.Request.IsAjaxRequest())
                {
                    try //trying to unserialize the formcollection gived
                    {
                        formData = CustomForm.unserialize(formData);
                    }
                    catch (Exception e)
                    {
                        return(null);
                    }

                    String listID = (formData["listID"] == "null") ? null : formData["listID"]; //is this an insert or an update?, converting null in javascript to null in c#
                    if (listID != null)
                    {
                        char[]   delimiters      = { ',', '[', ']' };
                        string[] changedElements = formData["changedElements"].Split(delimiters);
                        foreach (string element in changedElements)
                        {
                            removeElement(formData["listID"], element);
                        }
                    }

                    BsonDocument list = listTable.getRow(listID);

                    //validating listName
                    if (!Regex.IsMatch(formData["listName"], "[A-Za-z_]+[A-Za-z0-9.-_]*"))
                    {
                        return("El nombre de la lista tiene un formato incorrecto");
                    }
                    //validating listDisplayName
                    else if (!Regex.IsMatch(formData["listDisplayName"], ""))
                    {
                        return("El nombre para mostrar de la lista tiene un formato incorrecto");
                    }
                    else if (listNameUsed(formData["listName"]) && (list == null || formData["listName"] != list.GetElement("name").Value.ToString()))
                    {
                        return("El nombre de la lista ya está siendo utilizado");
                    }

                    JObject jsonData = new JObject();
                    try
                    {
                        jsonData.Add("name", formData["listName"]);
                        jsonData.Add("displayName", formData["listDisplayName"]);
                    }
                    catch (Exception e)
                    {
                        return(null);
                    }

                    try //trying to set the creator's id
                    {
                        if (listID == null)
                        {
                            jsonData.Add("creatorId", this.Session["_id"].ToString());
                        }
                        else
                        {
                            try
                            {
                                jsonData.Add("creatorId", list["creatorId"].ToString());
                            }
                            catch (Exception e) { /*Ignored*/ }
                        }
                    }
                    catch (Exception e) { /*Ignored*/ }

                    /*setting dependency*/
                    try
                    {
                        String       dependency         = formData["dependency"]; //checking dependency of this list
                        BsonDocument dependencyDocument = BsonDocument.Parse(dependency);
                        if (listHasElement(dependencyDocument.GetElement("listID").Value.ToString(), dependencyDocument.GetElement("elementName").Value.ToString()))
                        {
                            jsonData.Add("dependency", formData["dependency"]);
                        }
                    }
                    catch (Exception e) { /*Ignored*/ }

                    /***  Creating elements  ***/
                    JObject listElements    = new JObject();
                    JArray  unorderElements = new JArray();
                    try //trying to create the unorder elements
                    {
                        BsonDocument uoElements = BsonDocument.Parse(formData["unorderElements"]);
                        foreach (BsonElement element in uoElements)
                        {
                            if (Regex.IsMatch(element.Name.ToString(), "[A-Za-z0-9.-_]+") && Regex.IsMatch(element.Value.ToString(), "[A-Za-z0-9._-áéíóúÁÉÍÓÚñÑ]*"))
                            {
                                JObject newElement = new JObject();
                                newElement.Add(element.Name.ToString(), element.Value.ToString());
                                unorderElements.Add(newElement);
                            }
                        }

                        if (listID != null)
                        {
                            BsonDocument oldElements = list.GetElement("elements").Value.ToBsonDocument();
                            foreach (BsonDocument document in (BsonArray)oldElements.GetElement("unorder").Value)
                            {
                                BsonElement element    = document.First();
                                JObject     newElement = new JObject();
                                newElement.Add(element.Name.ToString(), element.Value.ToString());
                                unorderElements.Add(newElement);
                            }
                        }
                    }
                    catch (Exception e) { /*Ignored*/ }
                    listElements.Add("unorder", unorderElements);

                    JArray orderElements = new JArray();
                    try //trying to create the unorder elements
                    {
                        BsonDocument uoElements = BsonDocument.Parse(formData["orderElements"]);
                        int          index      = 0;
                        foreach (BsonElement element in uoElements)
                        {
                            if (Regex.IsMatch(element.Name.ToString(), "[A-Za-z0-9.-_]+") && Regex.IsMatch(element.Value.ToString(), "[A-Za-z0-9._-áéíóúÁÉÍÓÚñÑ]*"))
                            {
                                JObject orderElement = new JObject();
                                orderElement.Add(element.Name.ToString(), element.Value.ToString());
                                orderElement.Add("position", index);
                                orderElements.Add(orderElement);
                                ++index;
                            }
                        }
                    }
                    catch (Exception e) { /*Ignored*/ }
                    listElements.Add("order", orderElements);
                    jsonData.Add("elements", listElements);

                    String jsonString = JsonConvert.SerializeObject(jsonData);

                    String savedID = listTable.saveRow(jsonString, listID);
                    _logTable.SaveLog(Session["_id"].ToString(), "Listas", "Insert: guardar lista", "List", DateTime.Now.ToString());
                    jsonData.Add("client-name", "cinepolis");
                    jsonData.Add("innerCollection", "list");
                    jsonData.Add("auxId", listID);
                    jsonData.Add("idInClient", savedID);

                    jsonString = JsonConvert.SerializeObject(jsonData);
                    jsonString = jsonString.Replace("\"", "'");
                    String jsonAgent = "{'action':'spreadToFather','collection':'ObjectReference','document':" + jsonString + ",'Source':'cinepolis'}";

                    //    initAgent();
                    //     agent.sendMessage(jsonAgent);
                    return(savedID);
                }
                return(null);
            }
            return(null);
        }
Exemplo n.º 26
0
        public String saveObject(FormCollection data, HttpPostedFileBase file, IEnumerable <HttpPostedFileBase> files, String parentCategory = "null", String id = null)
        {
            if (id == "null" || id == "") //differents ways to receive null from javascript
            {
                id = null;
            }

            bool access = getpermissions("objects", "u");

            if (access == true)
            {
                data = CustomForm.unserialize(data);
                JObject objectArray = new JObject();
                try //name must be gived
                {
                    if (data["txtserie"] == null || data["txtserie"] == "")
                    {
                        return("ingrese un numero de serie"); //name is wrong
                    }
                    objectArray.Add("serie", data["txtserie"].ToString());
                    data.Remove("txtserie");
                }
                catch (Exception e)
                { //what to do if name is wrong
                    return("Ha ocurrido un error");
                }
                try //name must be gived
                {
                    if (data["name"] == null || data["name"] == "")
                    {
                        return("ingrese un nombre"); //name is wrong
                    }
                    objectArray.Add("name", data["name"].ToString());
                    data.Remove("name");
                }
                catch (Exception e)
                { //what to do if name is wrong
                    return("Ha ocurrido un error");
                }
                objectArray.Add("hardware_reference", parentCategory);

                JObject profileFields = new JObject();

                //foreach element in the formData, let's append it to the jsonData in the profileFields
                foreach (String key in data.Keys)
                {
                    profileFields.Add(key, data[key]);
                }
                objectArray.Add("profileFields", profileFields);
                String jsonData = JsonConvert.SerializeObject(objectArray);

                String auxid = id;
                id = _hardwareTable.SaveRow(jsonData, id);

                return("Guardado Correctamente");
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 27
0
 public static void FormBordersColor(this CustomForm form, Color color)
 {
     form.InvokeSafe(() => form.FormBorders.Color = color);
     form.InvokeSafe(form.Invalidate);
 }