示例#1
0
        private ResultWorkingFolders GetWorkingFolders()
        {
            string urlParameters = "";
            string URL           = "";
            string returnMessage = "";

            HttpResponseMessage response = new HttpResponseMessage();
            HttpClient          client   = new HttpClient();

            client.Timeout     = TimeSpan.FromMinutes(15);
            URL                = BaseURL + "GeneralSettings/GetWorkingFolders";
            urlParameters      = "";
            client.BaseAddress = new Uri(URL);
            response           = client.GetAsync(urlParameters).Result;
            using (HttpContent content = response.Content)
            {
                Task <string> resultTemp = content.ReadAsStringAsync();
                returnMessage        = resultTemp.Result;
                resultWorkingFolders = JsonConvert.DeserializeObject <ResultWorkingFolders>(returnMessage);
            }
            if (!response.IsSuccessStatusCode)
            {
                MessageBox.Show("Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage,
                                "Transaction Error...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(resultWorkingFolders);
        }
示例#2
0
        public GeneralSettingsForm()
        {
            InitializeComponent();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;

            // Set Combo Boxes
            ResultWorkingFolders resultWorkingFolders = new ResultWorkingFolders();

            resultWorkingFolders = GetWorkingFolders();
            if (resultWorkingFolders.ReturnCode == 0)
            {
                ComboboxItem firstItem = new ComboboxItem();
                firstItem.Text = "";
                firstItem.ID   = 0;
                AutoImportWatchFolderComboBox.Items.Add(firstItem);
                ScanningFolderComboBox.Items.Add(firstItem);
                PostValidationComboBox.Items.Add(firstItem);
                LoadBalancerWatchFolderComboBox.Items.Add(firstItem);
                BackupFolderComboBox.Items.Add(firstItem);
                FileConversionWatchFolderComboBox.Items.Add(firstItem);
                BatchDeliveryWatchFolderComboBox.Items.Add(firstItem);
                BatchFinalLocationComboBox.Items.Add(firstItem);
                VFRRenamerWatchFolderComboBox.Items.Add(firstItem);
                VFRDuplicateRemoverWatchFolderComboBox.Items.Add(firstItem);
                VFRBatchMonitorComboBox.Items.Add(firstItem);
                VFRBatchUploaderComboBox.Items.Add(firstItem);
                QCOutputFolderComboBox.Items.Add(firstItem);

                foreach (WorkingFolder folder in resultWorkingFolders.ReturnValue)
                {
                    ComboboxItem item = new ComboboxItem();
                    item.Text = folder.Path;
                    item.ID   = folder.FolderID;
                    AutoImportWatchFolderComboBox.Items.Add(item);
                    ScanningFolderComboBox.Items.Add(item);
                    PostValidationComboBox.Items.Add(item);
                    LoadBalancerWatchFolderComboBox.Items.Add(item);
                    BackupFolderComboBox.Items.Add(item);
                    FileConversionWatchFolderComboBox.Items.Add(item);
                    BatchDeliveryWatchFolderComboBox.Items.Add(item);
                    BatchFinalLocationComboBox.Items.Add(item);
                    VFRRenamerWatchFolderComboBox.Items.Add(item);
                    VFRDuplicateRemoverWatchFolderComboBox.Items.Add(item);
                    VFRBatchMonitorComboBox.Items.Add(item);
                    VFRBatchUploaderComboBox.Items.Add(item);
                    QCOutputFolderComboBox.Items.Add(item);
                }
            }
        }
示例#3
0
        private void LoadWorkinFolderListView()
        {
            WorkingFoldersListView.Items.Clear();
            string returnMessage = "";

            Cursor.Current = Cursors.WaitCursor;
            HttpClient client = new HttpClient();

            client.Timeout = TimeSpan.FromMinutes(15);
            string urlParameters         = "";
            string URL                   = "";
            HttpResponseMessage response = new HttpResponseMessage();

            // Get Working Folders
            ResultWorkingFolders resultWorkingFolders = new ResultWorkingFolders();

            URL                = BaseURL + "GeneralSettings/GetWorkingFolders";
            urlParameters      = "";
            client.BaseAddress = new Uri(URL);
            response           = client.GetAsync(urlParameters).Result;
            using (HttpContent content = response.Content)
            {
                Task <string> resultTemp = content.ReadAsStringAsync();
                returnMessage        = resultTemp.Result;
                resultWorkingFolders = JsonConvert.DeserializeObject <ResultWorkingFolders>(returnMessage);
            }
            // Add Services stations to Stations List
            if (resultWorkingFolders.RecordsCount != 0)
            {
                foreach (var item in resultWorkingFolders.ReturnValue)
                {
                    ListViewItem newItem = new ListViewItem();
                    newItem.Text = item.Path;
                    newItem.Tag  = item.FolderID;
                    WorkingFoldersListView.Items.Add(newItem);
                }
            }
        }
示例#4
0
        static public string GetFolderPath(int folderID, ResultWorkingFolders workingFolder)
        {
            string path = "";

            try
            {
                foreach (WorkingFolder folder in workingFolder.ReturnValue)
                {
                    if (folder.FolderID == folderID)
                    {
                        path = folder.Path.Trim();
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                //MainForm.ErrorMessage(e);
                nlogger.Fatal(General.ErrorMessage(e));
                MessageBox.Show(General.ErrorMessage(e), "Error ...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(path);
        }
示例#5
0
        private void Save(string action)
        {
            try
            {
                string URL             = "";
                string bodyString      = "";
                string workingFolderJS = "";
                string returnMessage   = "";
                string urlParameters   = "";

                WorkingFolder        workingFolder        = new WorkingFolder();
                ResultWorkingFolders resultWorkingFolders = new ResultWorkingFolders();

                foreach (ListViewItem item in WorkingFoldersListView.Items)
                {
                    workingFolder.Path = item.Text;
                    if (!string.IsNullOrEmpty(item.Tag.ToString()))
                    {
                        workingFolder.FolderID = Convert.ToInt32(item.Tag);
                    }
                    else
                    {
                        workingFolder.FolderID = 0;
                    }
                    workingFolderJS = JsonConvert.SerializeObject(workingFolder, Newtonsoft.Json.Formatting.Indented);
                    workingFolderJS = workingFolderJS.Replace(@"\", "\\\\");

                    // if Item Back color DarkGreen --> Teh item correspond to a New Station
                    if (item.ForeColor == Color.DarkGreen)
                    {
                        HttpClient client = new HttpClient();
                        client.Timeout = TimeSpan.FromMinutes(15);
                        URL            = BaseURL + "GeneralSettings/NewWorkingFolder";
                        bodyString     = "'" + workingFolderJS + "'";

                        HttpContent body_for_new = new StringContent(bodyString);
                        body_for_new.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                        HttpResponseMessage response_for_new = client.PostAsync(URL, body_for_new).Result;

                        using (HttpContent content = response_for_new.Content)
                        {
                            Task <string> resultTemp = content.ReadAsStringAsync();
                            returnMessage        = resultTemp.Result;
                            resultWorkingFolders = JsonConvert.DeserializeObject <ResultWorkingFolders>(returnMessage);
                        }
                        if (response_for_new.IsSuccessStatusCode)
                        {
                            // Set the value of the new customer to a gloval variable
                            if (resultWorkingFolders.ReturnCode == -1)
                            {
                                MessageBox.Show("Warning:" + "\r\n" + resultWorkingFolders.Message.Replace(". ", "\r\n"), "New Working Folder Transaction ...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                // Do nothing
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error:" + "\r\n" + resultWorkingFolders.Message.Replace(". ", "\r\n") + resultWorkingFolders.Message, "New Working Folder Transaction ...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    // If Back color is DarkRed --> The item correspond to a Station that needs to be deleted
                    if (item.ForeColor == Color.DarkRed)
                    {
                        HttpClient          client   = new HttpClient();
                        HttpResponseMessage response = new HttpResponseMessage();
                        client.Timeout     = TimeSpan.FromMinutes(15);
                        URL                = BaseURL + "GeneralSettings/DeleteWorkingFolder";
                        urlParameters      = "?folderID=" + item.Tag.ToString();
                        client.BaseAddress = new Uri(URL);
                        response           = client.DeleteAsync(urlParameters).Result;

                        using (HttpContent content = response.Content)
                        {
                            Task <string> resultTemp = content.ReadAsStringAsync();
                            returnMessage        = resultTemp.Result;
                            resultWorkingFolders = JsonConvert.DeserializeObject <ResultWorkingFolders>(returnMessage);
                        }
                        if (response.IsSuccessStatusCode)
                        {
                            // Set the value of the new customer to a global variable
                            if (resultWorkingFolders.ReturnCode == -1)
                            {
                                MessageBox.Show("Warning:" + "\r\n" + resultWorkingFolders.Message.Replace(". ", "\r\n"), "Delete Working Folder Transaction ...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                            else
                            {
                                // Do nothing
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error:" + "\r\n" + resultWorkingFolders.Message.Replace(". ", "\r\n") + resultWorkingFolders.Message, "Delete Working Folder Transaction ...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                if (action == "SaveAndExit")
                {
                    this.Close();
                }
                else
                {
                    LoadWorkinFolderListView();
                }
            }
            catch (Exception ex)
            {
                //MainForm.ErrorMessage(ex);
                //private static NLog.Logger nlogger = LogManager.GetCurrentClassLogger();
                nlogger.Fatal(General.ErrorMessage(ex));
                MessageBox.Show(General.ErrorMessage(ex), "Error ...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void LoadData()
        {
            //StationsListView.Items.Clear();
            string returnMessage = "";

            Cursor.Current = Cursors.WaitCursor;
            HttpClient client = new HttpClient();

            client.Timeout = TimeSpan.FromMinutes(15);
            string urlParameters         = "";
            string URL                   = "";
            HttpResponseMessage response = new HttpResponseMessage();


            // Get Working Folders
            ResultWorkingFolders resultWorkingFolders = new ResultWorkingFolders();

            URL                = BaseURL + "GeneralSettings/GetWorkingFolders";
            urlParameters      = "";
            client.BaseAddress = new Uri(URL);
            response           = client.GetAsync(urlParameters).Result;
            using (HttpContent content = response.Content)
            {
                Task <string> resultTemp = content.ReadAsStringAsync();
                returnMessage        = resultTemp.Result;
                resultWorkingFolders = JsonConvert.DeserializeObject <ResultWorkingFolders>(returnMessage);
            }
            // Add Watch and target folders in Combo Boxes
            if (resultWorkingFolders.RecordsCount != 0)
            {
                foreach (var item in resultWorkingFolders.ReturnValue)
                {
                    WatchFolderComboBox.Items.Add(new ComboBoxItem(Convert.ToString(item.FolderID), item.Path));
                    TargetFolderComboBox.Items.Add(new ComboBoxItem(Convert.ToString(item.FolderID), item.Path));
                }
            }

            if (Data.GlovalVariables.transactionType == "New")
            {
                StationNameTextBox.Enabled = true;
            }
            else
            {
                StationNameTextBox.Enabled = false;
                // Get Current Service Information
                client             = new HttpClient();
                client.Timeout     = TimeSpan.FromMinutes(15);
                URL                = Data.GlovalVariables.BaseURL + "GeneralSettings/GetServiceStationByID";
                urlParameters      = "?stationID=" + Data.GlovalVariables.currentServiceStationID;
                client.BaseAddress = new Uri(URL);
                response           = client.GetAsync(urlParameters).Result;

                if (response.IsSuccessStatusCode)
                {
                    using (HttpContent content = response.Content)
                    {
                        Task <string> resultTemp = content.ReadAsStringAsync();
                        returnMessage = resultTemp.Result;

                        ResultServiceStations resultServiceStations = JsonConvert.DeserializeObject <ResultServiceStations>(returnMessage);
                        if (resultServiceStations.ReturnCode == 0)
                        {
                            ServiceStation station = new ServiceStation();
                            station = resultServiceStations.ReturnValue.First();
                            originalServiceStation  = station;
                            StationNameTextBox.Text = station.StationName;
                            if (station.PDFStationFlag)
                            {
                                PDFGroupBox.Enabled       = true;
                                EnablePDFCheckBox.Checked = true;
                            }
                            else
                            {
                                PDFGroupBox.Enabled       = false;
                                EnablePDFCheckBox.Checked = false;
                            }
                            MaxNumBatchesUpDown.Text = Convert.ToString(station.MaxNumberBatches);
                            if (station.WeekendFlag)
                            {
                                EnableWeekendCheckBox.Checked    = true;
                                WeekendStartDateTimePicker.Value = Convert.ToDateTime(station.WeekendStartTime);
                                WeekendEndDateTimePicker.Value   = Convert.ToDateTime(station.WeenkendEndTime);
                            }
                            else
                            {
                                EnableWeekendCheckBox.Checked = false;
                                WeekendStartDateTimePicker.ResetText();
                                WeekendStartDateTimePicker.Enabled = false;
                                WeekendEndDateTimePicker.ResetText();
                                WeekendEndDateTimePicker.Enabled = false;
                            }
                            if (station.WorkdayFlag)
                            {
                                EnableWorkdayCheckBox.Checked    = true;
                                WorkdayStartDateTimePicker.Value = Convert.ToDateTime(station.WorkdayStartTime);
                                WorkdayEndDateTimePicker.Value   = Convert.ToDateTime(station.WorkdayEndTime);
                            }
                            else
                            {
                                EnableWorkdayCheckBox.Checked = false;
                                WorkdayStartDateTimePicker.ResetText();
                                WorkdayStartDateTimePicker.Enabled = false;
                                WorkdayEndDateTimePicker.ResetText();
                                WorkdayEndDateTimePicker.Enabled = false;
                            }

                            foreach (ComboBoxItem item in WatchFolderComboBox.Items)
                            {
                                if (item.Tag == Convert.ToString(station.WatchFolderID))
                                {
                                    WatchFolderComboBox.Text = item.Text;
                                    break;
                                }
                            }

                            foreach (ComboBoxItem item in TargetFolderComboBox.Items)
                            {
                                if (item.Tag == Convert.ToString(station.TargetFolderID))
                                {
                                    TargetFolderComboBox.Text = item.Text;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Error:" + "\r\n" + response.ReasonPhrase + "\r\n" + response.RequestMessage,
                                    "Transaction Error...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }