Exemplo n.º 1
0
        //保存的信息
        private void SaveInfo()
        {
//			System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf =
//				new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
//
//			bf.FilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

//			FileStream fs = null;
            try
            {
                //fs = File.OpenWrite(savedFilePath);

                UpdaerConfigInfo uci = new UpdaerConfigInfo();

                uci.SourcePath    = txtSourceDIR.Text.Trim();
                uci.TargetVIRPath = txtTargetDIR.Text.Trim();
                uci.TargetPath    = txtPhysicalPath.Text.Trim();

                if (this.chkAutoUpdater.Checked == true)
                {
                    uci.NeedAutoUpdate = true;
                    //Laws Lu,2006/08/15 修改
                    if (radDay.Checked)
                    {
                        uci.UpdateTime = this.dateTimePicker1.Value;
                    }
                    if (radWeek.Checked)
                    {
                        uci.Week       = (DayOfWeek)cmbWeek.SelectedIndex;
                        uci.UpdateTime = this.dateTimePicker2.Value;
                    }
                    if (radMonth.Checked)
                    {
                        uci.Day        = Convert.ToInt32(cmdDay.SelectedValue);
                        uci.UpdateTime = this.dateTimePicker3.Value;
                    }
                }

                uci.SaveToFile(savedFilePath);
//				bf.Serialize(fs,uci);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }
            finally
            {
//				if(fs != null)
//				{
//					fs.Close();
//				}
            }
        }
Exemplo n.º 2
0
        //获取保存的信息
        private void GetSavedInfo()
        {
//
//			System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf =
//				new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
//
//			FileStream fs = null;
            try
            {
//				fs = File.OpenRead(savedFilePath);
//				bf.FilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
//
//				UpdaerConfigInfo uci =
//					bf.Deserialize(fs) as UpdaerConfigInfo;
                UpdaerConfigInfo uci = new  UpdaerConfigInfo();
                uci.LoadFromFile(savedFilePath);
                if (uci != null)
                {
                    txtSourceDIR.Text    = uci.SourcePath;
                    txtTargetDIR.Text    = uci.TargetVIRPath;
                    txtPhysicalPath.Text = uci.TargetPath;

                    if (uci.NeedAutoUpdate == true)
                    {
                        this.chkAutoUpdater.Checked = true;
                        if (uci.Day != 0)
                        {
                            radMonth.Checked = true;
                        }
                        if (uci.Week != 0)
                        {
                            radWeek.Checked = true;
                        }
                        if (radDay.Checked)
                        {
                            this.dateTimePicker1.Value = uci.UpdateTime;
                        }
                        if (radWeek.Checked)
                        {
                            this.dateTimePicker2.Value = uci.UpdateTime;
                            cmbWeek.SelectedIndex      = (int)uci.Week;
                        }
                        if (radMonth.Checked)
                        {
                            this.dateTimePicker3.Value = uci.UpdateTime;
                            cmdDay.SelectedValue       = uci.Day;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message);
            }
            finally
            {
//				if(fs != null)
//				{
//					fs.Close();
//				}
            }
        }