Beispiel #1
0
        private List <ConsolePrintNetParameter> GetParameters()
        {
            ActionAsked formerAction = ActionAsked.None;

            if (cbActions.SelectedItem != null && cbActions.SelectedItem is ActionAsked)
            {
                formerAction = (ActionAsked)cbActions.SelectedItem;
            }
            Helper.SetSafeComboBox(cbActions, ActionAsked.ParametersFields);
            string resultJson = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ConsoleExeName, $"{ConsoleExeName}Result.json");

            Helper.SetSafeText(cbOutputFormat, OutputFormatEnum.JsonFile.ToString() + "=" + resultJson);
            try
            {
                RunCommand();
            }
            catch (Exception ex)
            {
                Logger.Log(ex.Message);
            }
            finally
            {
                if (formerAction != ActionAsked.None)
                {
                    Helper.SetSafeComboBox(this.cbActions, formerAction);
                }
            }

            List <ConsolePrintNetParameter> list = new List <ConsolePrintNetParameter>();

            if (File.Exists(resultJson))
            {
                object  rawObject     = JsonConvert.DeserializeObject(File.ReadAllText(resultJson));
                JObject resultJObject = rawObject as JObject;
                JArray  array         = resultJObject["parameters"]?.Value <JArray>();
                if (array != null)
                {
                    foreach (JToken item in array)
                    {
                        bool?hasDefaultValue           = item["hasDefaultValue"]?.Value <bool>();
                        ConsolePrintNetParameter param = new ConsolePrintNetParameter(item["name"]?.Value <string>(), item["promptText"]?.Value <string>());
                        if (!hasDefaultValue.HasValue || (hasDefaultValue.HasValue && !hasDefaultValue.Value))
                        {
                            list.Add(param);
                        }
                    }
                }
            }
            else
            {
                Logger.Log($"File result {resultJson} doesn't exist");
            }

            return(list);
        }
Beispiel #2
0
        private void AddItemInGrid(ConsolePrintNetParameter[] parameters, ConsolePrintNetParameter newParam, DataGridView dataGridView)
        {
            ArrayList paramList = new ArrayList();

            if (parameters != null)
            {
                paramList.AddRange(parameters);
            }
            if (newParam != null)
            {
                paramList.Add(newParam);
            }
            parameters = new ConsolePrintNetParameter[paramList.Count];
            paramList.CopyTo(parameters);

            Helper.SetSafeDatasource(dataGridView, parameters);
        }
Beispiel #3
0
        private void RemoveSelectedItems(DataGridView dataGridView)
        {
            var       fileList  = dataGridView.DataSource as ConsolePrintNetParameter[];
            ArrayList paramList = new ArrayList();

            paramList.AddRange(fileList);

            ConsolePrintNetParameter[] parameters = new ConsolePrintNetParameter[fileList.Length];
            foreach (DataGridViewRow row in dataGridView.SelectedRows)
            {
                var file = row.DataBoundItem as ConsolePrintNetParameter;
                paramList.Remove(file);
            }
            parameters = new ConsolePrintNetParameter[paramList.Count];
            paramList.CopyTo(parameters);

            Helper.SetSafeDatasource(dataGridView, parameters);
        }
Beispiel #4
0
        private void AddItemsInGrid(ConsolePrintNetParameter[] parameters, List <ConsolePrintNetParameter> newParams, DataGridView dataGridView)
        {
            ArrayList paramList = new ArrayList();

            if (parameters != null)
            {
                paramList.AddRange(parameters);
            }
            if (newParams != null)
            {
                paramList.AddRange(newParams);
            }
            parameters = new ConsolePrintNetParameter[paramList.Count];
            paramList.CopyTo(parameters);

            if (newParams?.Count > 0)
            {
                Helper.SetSafeText(labelParametersMessage, "Please fill in parameter(s) value(s)");
            }
            Helper.SetSafeDatasource(reportParametersGridView, parameters);
        }
Beispiel #5
0
 private void RemoveAllItems(DataGridView dataGridView)
 {
     ConsolePrintNetParameter[] parameters = new ConsolePrintNetParameter[0];
     Helper.SetSafeDatasource(dataGridView, parameters);
 }