Example #1
0
        private void buttonDelete_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid.SelectedItem == null)
            {
                return;
            }
            KeyValuePair <string, FileSchedule.ScheduleProperty> ekySchedule = (KeyValuePair <string, FileSchedule.ScheduleProperty>)dataGrid.SelectedItem;

            FileSchedule.ScheduleProperty schedule = ekySchedule.Value as FileSchedule.ScheduleProperty;
            if (schedule == null)
            {
                return;
            }
            MessageBoxResult msgResult = MessageBox.Show(this, "Do you want to delete(" + schedule.Name + ")?", "Delete", MessageBoxButton.YesNo);

            if (msgResult == MessageBoxResult.No)
            {
                return;
            }
            if (m_schedule.ContainsKey(schedule.Name) == true)
            {
                m_schedule.Remove(schedule.Name);
            }

            dataGrid.Items.Refresh();
            EnableSaveButton();
        }
Example #2
0
        private bool UiToProperty(FileSchedule.ScheduleProperty property)
        {
            if (textBoxScheduleName.Text == string.Empty)
            {
                Keyboard.Focus(textBoxScheduleName);
                return(false);
            }

            property.RepeateTime   = checkBoxTimer.IsChecked == true;
            property.PCTurnOn      = checkBoxPCTurnON.IsChecked == true;
            property.PCTurnOff     = checkBoxPCTurnOff.IsChecked == true;
            property.PCDateChanges = checkBoxDataChanges.IsChecked == true;

            property.RepeatTimeMinute = Convert.ToInt32(textBoxRepeatTime.Text);
            property.DelayTimeMinute  = Convert.ToInt32(textBoxDelayTime.Text);

            property.Name = textBoxScheduleName.Text;
            if (radioButtonFromFTP.IsChecked == true)
            {
                property.FromDiskType = DriveType.FTP;
            }
            else //radioButtonFromDrive.IsChecked == true
            {
                property.FromDiskType = DriveType.Disk;
            }

            property.FromFtpUri  = textBoxFromFtpUri.Text;
            property.FromFtpUser = textBoxFromFtpUser.Text;
            property.FromFtpPw   = passwordBoxFromFtpPw.Password;

            property.FromDrivePath = textBoxFromFolder.Text;
            if (radioButtonFromCopy.IsChecked == true)
            {
                property.FromSyncType = FileSchedule.SyncType.Copy;
            }
            else if (radioButtonFromMove.IsChecked == true)
            {
                property.FromSyncType = FileSchedule.SyncType.Move;
            }

            if (radioButtonToFTP.IsChecked == true)
            {
                property.ToDiskType = DriveType.FTP;
            }
            else if (radioButtonToDrive.IsChecked == true)
            {
                property.ToDiskType = DriveType.Disk;
            }

            property.ToFtpUri    = textBoxToFtpUri.Text;
            property.ToFtpUser   = textBoxToFtpUser.Text;
            property.ToFtpPw     = passwordBoxToFtpPw.Password;
            property.ToDrivePath = textBoxToFolder.Text;
            return(true);
        }
Example #3
0
        private void PropertyToUi(FileSchedule.ScheduleProperty property)
        {
            checkBoxTimer.IsChecked       = property.RepeateTime;
            checkBoxPCTurnON.IsChecked    = property.PCTurnOn;
            checkBoxPCTurnOff.IsChecked   = property.PCTurnOff;
            checkBoxDataChanges.IsChecked = property.PCDateChanges;

            textBoxRepeatTime.Text = property.RepeatTimeMinute.ToString();
            textBoxDelayTime.Text  = property.DelayTimeMinute.ToString();

            textBoxScheduleName.Text = property.Name;

            if (property.FromDiskType == DriveType.FTP)
            {
                radioButtonFromFTP.IsChecked = true;
            }
            else if (property.FromDiskType == DriveType.Disk)
            {
                radioButtonFromDrive.IsChecked = true;
            }

            textBoxFromFtpUri.Text        = property.FromFtpUri;
            textBoxFromFtpUser.Text       = property.FromFtpUser;
            passwordBoxFromFtpPw.Password = property.FromFtpPw;

            textBoxFromFolder.Text = property.FromDrivePath;
            if (property.FromSyncType == FileSchedule.SyncType.Copy)
            {
                radioButtonFromCopy.IsChecked = true;
            }
            else if (property.FromSyncType == FileSchedule.SyncType.Move)
            {
                radioButtonFromMove.IsChecked = true;
            }

            if (property.ToDiskType == DriveType.FTP)
            {
                radioButtonToFTP.IsChecked = true;
            }
            else if (property.ToDiskType == DriveType.Disk)
            {
                radioButtonToDrive.IsChecked = true;
            }

            textBoxToFtpUri.Text        = property.ToFtpUri;
            textBoxToFtpUser.Text       = property.ToFtpUser;
            passwordBoxToFtpPw.Password = property.ToFtpPw;
            textBoxToFolder.Text        = property.ToDrivePath;

            textBoxScheduleName.IsEnabled = m_isEditWindow == false;
        }
Example #4
0
        public WindowProperty(FileSchedule.ScheduleProperty property, bool isEdit = false)
        {
            InitializeComponent();
            m_property           = property;
            m_isEditWindow       = isEdit;
            m_isChageProperty    = false;
            buttonSave.IsEnabled = false;

            buttonSave.IsEnabled = false;

            checkBoxTimer.Click       += checkBoxWork_Checked;
            checkBoxPCTurnON.Click    += checkBoxWork_Checked;
            checkBoxPCTurnOff.Click   += checkBoxWork_Checked;
            checkBoxDataChanges.Click += checkBoxWork_Checked;

            textBoxRepeatTime.TextChanged += TextBox_TextChanged;
            textBoxDelayTime.TextChanged  += TextBox_TextChanged;

            textBoxScheduleName.TextChanged += TextBox_TextChanged;

            radioButtonFromFTP.Checked   += RadioButtonFromConnect_Checked;
            radioButtonFromDrive.Checked += RadioButtonFromConnect_Checked;

            textBoxFromFtpUri.TextChanged        += TextBox_TextChanged;
            textBoxFromFtpUser.TextChanged       += TextBox_TextChanged;
            passwordBoxFromFtpPw.PasswordChanged += PasswordBoxFtpPw_PasswordChanged;
            textBoxFromFolder.TextChanged        += TextBox_TextChanged;

            radioButtonFromCopy.Checked += RadioButtonFromCopy_Checked;
            radioButtonFromMove.Checked += RadioButtonFromCopy_Checked;

            radioButtonToFTP.Checked   += RadioButtonToConnect_Checked;
            radioButtonToDrive.Checked += RadioButtonToConnect_Checked;

            textBoxToFtpUri.TextChanged        += TextBox_TextChanged;
            textBoxToFtpUser.TextChanged       += TextBox_TextChanged;
            passwordBoxToFtpPw.PasswordChanged += PasswordBoxFtpPw_PasswordChanged;
            textBoxToFolder.TextChanged        += TextBox_TextChanged;
        }
Example #5
0
        private void buttonAdd_Click(object sender, RoutedEventArgs e)
        {
            WindowProperty winSetting = new WindowProperty(new FileSchedule.ScheduleProperty());

            winSetting.Owner = this;
            winSetting.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            winSetting.ShowDialog();

            if (winSetting.IsChanged == true)
            {
                FileSchedule.ScheduleProperty property = winSetting.Property;
                if (m_schedule.ContainsKey(property.Name) == true)
                {
                    MessageBox.Show(this, "Same Name");
                }
                else
                {
                    m_schedule.Add(property.Name, property);
                }
                dataGrid.Items.Refresh();
                EnableSaveButton();
            }
        }
Example #6
0
        private void buttonEdit_Click(object sender, RoutedEventArgs e)
        {
            if (dataGrid.SelectedItem == null)
            {
                return;
            }
            KeyValuePair <string, FileSchedule.ScheduleProperty> ekySchedule = (KeyValuePair <string, FileSchedule.ScheduleProperty>)dataGrid.SelectedItem;

            FileSchedule.ScheduleProperty schedule = ekySchedule.Value as FileSchedule.ScheduleProperty;
            if (schedule == null)
            {
                return;
            }
            WindowProperty winSetting = new WindowProperty(schedule, true);

            winSetting.Owner = this;
            winSetting.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            winSetting.ShowDialog();
            if (winSetting.IsChanged == true)
            {
                dataGrid.Items.Refresh();
                EnableSaveButton();
            }
        }
        private Dictionary <string, FileSchedule.ScheduleProperty> XmlToScheduleProperty(string filePath)
        {
            Dictionary <string, FileSchedule.ScheduleProperty> maptree = new Dictionary <string, FileSchedule.ScheduleProperty>();

            try
            {
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.Load(filePath);
                XmlElement  element = xmldoc.DocumentElement;
                XmlNodeList nodes   = element.ChildNodes;
                foreach (XmlNode node in nodes)
                {
                    try
                    {
                        if (node.Name != "FileTransmit")
                        {
                            continue;
                        }
                        FileSchedule.ScheduleProperty property = new FileSchedule.ScheduleProperty();
                        property.Name          = node["Name"].InnerText;
                        property.RepeateTime   = false;
                        property.PCTurnOn      = false;
                        property.PCTurnOff     = false;
                        property.PCDateChanges = false;
                        XmlNode repeateNode = node["RepeatType"];
                        if (repeateNode != null)
                        {// 구버젼 호환용
                            if (repeateNode.InnerText == "Time")
                            {
                                property.RepeateTime = true;
                            }
                            else if (repeateNode.InnerText == "WinEnd")
                            {
                                property.PCTurnOff = true;
                            }
                            else if (repeateNode.InnerText == "WinEndDate")
                            {
                                property.PCTurnOff     = true;
                                property.PCDateChanges = true;
                            }
                            else if (repeateNode.InnerText == "WinStart")
                            {
                                property.PCTurnOn = true;
                            }
                            else if (repeateNode.InnerText == "WinStartDate")
                            {
                                property.PCTurnOn      = true;
                                property.PCDateChanges = true;
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else
                        {
                            repeateNode = node["WorkRepeateTime"];
                            if (repeateNode != null)
                            {
                                property.RepeateTime = repeateNode.InnerText == "true";
                            }

                            repeateNode = node["WorkPCTurnOn"];
                            if (repeateNode != null)
                            {
                                property.PCTurnOn = repeateNode.InnerText == "true";
                            }

                            repeateNode = node["WorkPCTurnOff"];
                            if (repeateNode != null)
                            {
                                property.PCTurnOff = repeateNode.InnerText == "true";
                            }

                            repeateNode = node["WorkPCDateChanges"];
                            if (repeateNode != null)
                            {
                                property.PCDateChanges = repeateNode.InnerText == "true";
                            }
                        }

                        property.RepeatTimeMinute = Convert.ToInt32(node["RepeatTimeMinute"].InnerText);
                        property.DelayTimeMinute  = Convert.ToInt32(node["DelayTimeMinute"].InnerText);
                        if (node["FromDiskType"].InnerText == DriveType.FTP.ToString())
                        {
                            property.FromDiskType = DriveType.FTP;
                        }
                        else if (node["FromDiskType"].InnerText == DriveType.Disk.ToString())
                        {
                            property.FromDiskType = DriveType.Disk;
                        }
                        else
                        {
                            continue;
                        }

                        property.FromFtpUri    = node["FromFtpUri"].InnerText;
                        property.FromFtpUser   = node["FromFtpUser"].InnerText;
                        property.FromFtpPw     = node["FromFtpPw"].InnerText;
                        property.FromDrivePath = node["FromDrivePath"].InnerText;

                        if (node["FromSyncType"].InnerText == FileSchedule.SyncType.Copy.ToString())
                        {
                            property.FromSyncType = FileSchedule.SyncType.Copy;
                        }
                        else if (node["FromSyncType"].InnerText == FileSchedule.SyncType.Move.ToString())
                        {
                            property.FromSyncType = FileSchedule.SyncType.Move;
                        }
                        else
                        {
                            continue;
                        }

                        if (node["ToDiskType"].InnerText == DriveType.FTP.ToString())
                        {
                            property.ToDiskType = DriveType.FTP;
                        }
                        else if (node["ToDiskType"].InnerText == DriveType.Disk.ToString())
                        {
                            property.ToDiskType = DriveType.Disk;
                        }
                        else
                        {
                            continue;
                        }

                        property.ToFtpUri    = node["ToFtpUri"].InnerText;
                        property.ToFtpUser   = node["ToFtpUser"].InnerText;
                        property.ToFtpPw     = node["ToFtpPw"].InnerText;
                        property.ToDrivePath = node["ToDrivePath"].InnerText;
                        maptree.Add(property.Name, property);
                    }
                    catch (Exception ex)
                    {
                        SystemLog.Output(SystemLog.MSG_TYPE.Err, "Property Setting", "Load: {0}", ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "Property Setting", "Load: {0}", ex.Message);
            }
            return(maptree);
        }