Example #1
0
 public void Validate(Model.Setting setting)
 {
     if (setting.SettingTags == "BOX")
     {
         if (setting.IdNO == "")
         {
             throw new Helper.RequireValueException(Model.Setting.PRO_IdNO);
         }
         if (setting.Blong <= 0)
         {
             throw new Helper.InvalidValueException(Model.Setting.PRO_Blong);
         }
         if (setting.BWidth <= 0)
         {
             throw new Helper.InvalidValueException(Model.Setting.PRO_BWidth);
         }
         if (setting.BHeight <= 0)
         {
             throw new Helper.InvalidValueException(Model.Setting.PRO_BHeight);
         }
         IList <Model.Setting> list = accessor.SelectByIdNo(setting.IdNO);
         if (list != null && list.Count > 0 && list[0].IdNO == setting.IdNO && list[0].SettingId != setting.SettingId)
         {
             throw new Helper.InvalidValueException(Model.Setting.PRO_IdNO);
         }
     }
 }
Example #2
0
 /// <summary>
 /// Insert a Setting.
 /// </summary>
 public void Insert(Model.Setting setting)
 {
     //
     // todo:add other logic here
     //
     this.Validate(setting);
     accessor.Insert(setting);
 }
Example #3
0
 /// <summary>
 /// Update a Setting.
 /// </summary>
 public void Update(Model.Setting setting)
 {
     //
     // todo: add other logic here.
     //
     this.Validate(setting);
     accessor.Update(setting);
 }
Example #4
0
 protected override void AddNew()
 {
     this._setting        = new Book.Model.Setting();
     _setting.SettingId   = Guid.NewGuid().ToString();
     _setting.SettingTags = "BOX";
     _setting.SettingName = "Box";
     this.action          = "insert";
 }
Example #5
0
 /// <summary>
 /// Speichert die übergebene Einstellung.
 /// </summary>
 /// <param name="setting">Einstellung zum Speichern</param>
 public void StoreSetting(Model.Setting setting)
 {
     if (null == setting)
     {
         throw new ArgumentNullException("setting");
     }
     // speichern
     DaoFactory.Instance.SettingStore.SaveOrUpdate(setting);
 }
Example #6
0
 public static string Get(string settingId)
 {
     Model.Setting setting = settingsManager.Get(settingId);
     if (setting != null)
     {
         return(setting.SettingCurrentValue);
     }
     return(null);
 }
Example #7
0
        protected override void AddNew()
        {
            this._setting             = new Book.Model.Setting();
            this._setting.SettingId   = Guid.NewGuid().ToString();
            this._setting.SettingTags = "PCISO";

            this._detail.Add(this._setting);
            this.action = "insert";
        }
 public static APIClient.Models.Setting Map(Model.Setting setting)
 {
     APIClient.Models.Setting mappedSetting = new APIClient.Models.Setting();
     mappedSetting.Application   = setting.Application;
     mappedSetting.Documentation = setting.Documentation;
     mappedSetting.Environment   = setting.Environment;
     mappedSetting.Fullpath      = setting.Fullpath;
     mappedSetting.JSONValue     = setting.JSONValue;
     return(mappedSetting);
 }
Example #9
0
 public static byte[] GetImage(string settingId)
 {
     Model.Setting setting = settingsManager.selectimage(settingId);
     byte[]        image   = null;
     if (setting != null)
     {
         image = setting.PictrueLogo;
     }
     return(image);
 }
Example #10
0
 public ZXParameterSet(string invoiceId)
     : this()
 {
     this._setting = this._settingManager.Get(invoiceId);
     if (this._setting == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this.action = "view";
 }
Example #11
0
 public ZXParameterSet(Model.Setting setting)
     : this()
 {
     if (setting == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this._setting = setting;
     this.action   = "view";
 }
Example #12
0
        /// <summary>
        /// 保存配置文件到指定目录
        /// </summary>
        /// <param name="objSetting">配置对象</param>
        /// <param name="strIniFilePath">Ini配置文件路径</param>
        /// <param name="strErrInfo">操作提示</param>
        /// <returns></returns>
        public static bool SaveSetting(Model.Setting objSetting, string strIniFilePath, out string strErrInfo)
        {
            bool bIfSucc = false;

            strErrInfo = "";
            try
            {
                if (!IOHelper.Exists(strIniFilePath))
                {
                    IOHelper.CreateFile(strIniFilePath);
                }
                if (IOHelper.Exists(strIniFilePath))
                {
                    IniFile ini = new IniFile(strIniFilePath);
                    ini.IniWriteValue(null, null, null);//删除ini文件下所有段落
                    //数据库
                    ini.IniWriteValue(KeySet.SectionName_DB, KeySet.DB_IP, objSetting.DBSetting.DB_IP);
                    ini.IniWriteValue(KeySet.SectionName_DB, KeySet.DB_Name, objSetting.DBSetting.DB_Name);
                    ini.IniWriteValue(KeySet.SectionName_DB, KeySet.DB_User, objSetting.DBSetting.DB_User);
                    ini.IniWriteValue(KeySet.SectionName_DB, KeySet.DB_Password, objSetting.DBSetting.DB_Password);

                    //Com1
                    ini.IniWriteValue(KeySet.SectionName_COM1, KeySet.PortName, objSetting.WriteComProperty.PortName);
                    ini.IniWriteValue(KeySet.SectionName_COM1, KeySet.BaudRate, objSetting.WriteComProperty.BaudRate.ToString());
                    ini.IniWriteValue(KeySet.SectionName_COM1, KeySet.DataBits, objSetting.WriteComProperty.DataBits.ToString());
                    ini.IniWriteValue(KeySet.SectionName_COM1, KeySet.StopBits, (objSetting.WriteComProperty.StopBits.Equals(StopBits.One) ? "1" : "2"));
                    ini.IniWriteValue(KeySet.SectionName_COM1, KeySet.Parity, (objSetting.WriteComProperty.Parity.Equals(Parity.None) ? "0" : (objSetting.WriteComProperty.Parity.Equals(Parity.Odd) ? "1" : "2")));

                    //Com2
                    ini.IniWriteValue(KeySet.SectionName_COM2, KeySet.PortName, objSetting.MonitorComProperty.PortName);
                    ini.IniWriteValue(KeySet.SectionName_COM2, KeySet.BaudRate, objSetting.MonitorComProperty.BaudRate.ToString());
                    ini.IniWriteValue(KeySet.SectionName_COM2, KeySet.DataBits, objSetting.MonitorComProperty.DataBits.ToString());
                    ini.IniWriteValue(KeySet.SectionName_COM2, KeySet.StopBits, (objSetting.MonitorComProperty.StopBits.Equals(StopBits.One) ? "1" : "2"));
                    ini.IniWriteValue(KeySet.SectionName_COM2, KeySet.Parity, (objSetting.MonitorComProperty.Parity.Equals(Parity.None) ? "0" : (objSetting.MonitorComProperty.Parity.Equals(Parity.Odd) ? "1" : "2")));

                    //其它配置
                    ini.IniWriteValue(KeySet.SectionName_OTHER, KeySet.SyncTimePL, objSetting.OtherSetting.SyncTimePL.ToString());
                    ini.IniWriteValue(KeySet.SectionName_OTHER, KeySet.SyncAuto, objSetting.OtherSetting.SyncAuto.ToString());
                    ini.IniWriteValue(KeySet.SectionName_OTHER, KeySet.Chs, objSetting.OtherSetting.Chs.ToString());
                    ini = null;

                    bIfSucc = true;
                }
                else
                {
                    strErrInfo = string.Format("{0}文件不存在,也无法自动创建", strIniFilePath);
                }
            }
            catch (Exception err)
            {
                strErrInfo = err.Message.ToString();
            }
            return(bIfSucc);
        }
Example #13
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (this.setting == null)
     {
         this.setting = new Book.Model.Setting();
     }
     setting.SettingId           = Guid.NewGuid().ToString();
     setting.SettingCurrentValue = this.textBox1.Text;
     setting.SettingTags         = "FP";
     setting.PictrueLogo         = new Byte[] { };
     settingManager.Insert(setting);
     this.Refresh();
 }
Example #14
0
 public ZXParameterSet(Model.Setting setting, string action)
     : this()
 {
     //this._PCOtherCheck = mPCOtherCheck;
     //this.action = action;
     //if (this.action == "view")
     //    LastFlag = 1;
     if (setting == null)
     {
         throw new ArithmeticException("invoiceid");
     }
     this._setting = setting;
     this.action   = action;
 }
Example #15
0
 private void txtPCFinishCheckDesc_DoubleClick(object sender, EventArgs e)
 {
     PCParameterSet.ChooseParameter cp = new Book.UI.produceManager.PCParameterSet.ChooseParameter("BeiZhuShuoMing");
     if (cp.ShowDialog(this) != DialogResult.OK)
     {
         return;
     }
     if (cp.SelectedItem != null)
     {
         Model.Setting setParam = cp.SelectedItem as Model.Setting;
     }
     cp.Dispose();
     GC.Collect();
 }
Example #16
0
 private void textEditProduceOtherMaterialDesc_DoubleClick(object sender, EventArgs e)
 {
     PCParameterSet.ChooseParameter cp = new Book.UI.produceManager.PCParameterSet.ChooseParameter("BeiZhuShuoMing");
     if (cp.ShowDialog(this) != DialogResult.OK)
     {
         return;
     }
     if (cp.SelectedItem != null)
     {
         Model.Setting setParam = cp.SelectedItem as Model.Setting;
         this.textEditProduceOtherMaterialDesc.Text += setParam.SettingCurrentValue;
     }
     cp.Dispose();
     GC.Collect();
 }
Example #17
0
 private void bindingSource1_CurrentChanged(object sender, EventArgs e)
 {
     if (this.bindingSource1.Count != 0)
     {
         this._setting         = this.bindingSource1.Current as Model.Setting;
         this.txt_Id.Text      = this._setting.IdNO;
         this.spe_BLong.Text   = this._setting.Blong.ToString();
         this.spe_BWide.Text   = this._setting.BWidth.ToString();
         this.spe_BHigh.Text   = this._setting.BHeight.ToString();
         this.spe_JWeight.Text = this._setting.BJWeight.ToString();
         this.spe_MWeight.Text = this._setting.BMWeight.ToString();
         this.spe_Caiji.Text   = this._setting.BCaiJi.ToString();
     }
     if (this.action == "update" || this.action == "insert")
     {
         this.action = "view";
         Refresh();
     }
 }
Example #18
0
        private void SetDefMoney_Load(object sender, EventArgs e)
        {
            Model.Setting setting = this.settingManager.Get("PaymanDayily");// 男 日薪
            this.txtManDefDayPay.Text = setting.SettingCurrentValue;
            setting = this.settingManager.Get("manMonthPay");
            this.txtManDefMonthPay.Text = setting.SettingCurrentValue;
            setting = this.settingManager.Get("womanDayilyPay");
            this.txtWomanDefDaypay.Text = setting.SettingCurrentValue;
            setting = this.settingManager.Get("womanMonthPay");
            this.txtWomanDefMonthPay.Text = setting.SettingCurrentValue;;

            //XmlDocument document = new XmlDocument();
            //document.Load(ConfigFile);
            //XmlNode xn = document.SelectSingleNode("/configuration/userSettings/Book.UI.Properties.Settings/setting[@name='Pay']");
            //this.txtManDefDayPay.Text = xn.SelectSingleNode("add[@key='manDayilyPay']").Attributes["value"].Value;
            //this.txtManDefMonthPay.Text = xn.SelectSingleNode("add[@key='manMonthPay']").Attributes["value"].Value;
            //this.txtWomanDefDaypay.Text = xn.SelectSingleNode("add[@key='womanDayilyPay']").Attributes["value"].Value;
            //this.txtWomanDefMonthPay.Text = xn.SelectSingleNode("add[@key='womanMonthPay']").Attributes["value"].Value;
        }
Example #19
0
        public ZXParameterSet()
        {
            InitializeComponent();

            _detail = _settingManager.SelectTagOrderDefault("BOX");

            if (this._detail == null || this._detail.Count == 0)
            {
                this._setting = null;
            }
            else
            {
                this._setting = this._detail[0];
            }

            this.bindingSource1.DataSource = this._detail;

            this.requireValueExceptions.Add(Model.Setting.PRO_IdNO, new AA(Properties.Resources.NewNumbers, this.txt_Id));
            this.invalidValueExceptions.Add(Model.Setting.PRO_IdNO, new AA(Properties.Resources.EntityExists, this.txt_Id));
            this.invalidValueExceptions.Add(Model.Setting.PRO_Blong, new AA(Properties.Resources.BLongIsNotLessThanZero, this.spe_BLong));
            this.invalidValueExceptions.Add(Model.Setting.PRO_BWidth, new AA(Properties.Resources.BWidthIsNotLessThanZero, this.spe_BWide));
            this.invalidValueExceptions.Add(Model.Setting.PRO_BHeight, new AA(Properties.Resources.BHeigthIsNotLessThanZero, this.spe_BHigh));
            this.action = "view";
        }
Example #20
0
        protected override void Save()
        {
            this._setting = bindingSource1.Current as Model.Setting;

            try
            {
                if (!this.gridView1.PostEditor() || !this.gridView1.UpdateCurrentRow())
                {
                    return;
                }
                BL.V.BeginTransaction();

                if (_setting.SettingName == null)
                {
                    throw new Helper.RequireValueException(Model.Setting.PRO_SettingName);
                }
                _setting.PictrueLogo = new Byte[] { };
                if (this.action == "insert")
                {
                    this.settingManager.Insert(_setting);
                }
                if (this.action == "update")
                {
                    this.settingManager.Update(_setting);
                }
                this._detail = this.settingManager.SelectTagOrderDefault("PCISO");
                this.bindingSource1.Position = this.bindingSource1.IndexOf(_setting);

                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
Example #21
0
        /// <summary>
        /// 载入配置
        /// </summary>
        /// <param name="strIniFilePath">Ini配置文件路径</param>
        /// <param name="strErrInfo">操作提示</param>
        /// <returns>返回配置对象,失败返回Null</returns>
        public static Model.Setting LoadSetting(string strIniFilePath, out string strErrInfo)
        {
            Model.Setting objSetting = null;
            strErrInfo = "";
            if (IOHelper.Exists(strIniFilePath))
            {
                IniFile ini = new IniFile(strIniFilePath);
                try
                {
                    objSetting = new Model.Setting();
                    //数据库
                    objSetting.DBSetting             = new Model.DBSetting();
                    objSetting.DBSetting.DB_IP       = Functions.FormatString(ini.IniReadValue(KeySet.SectionName_DB, KeySet.DB_IP));
                    objSetting.DBSetting.DB_Name     = Functions.FormatString(ini.IniReadValue(KeySet.SectionName_DB, KeySet.DB_Name));
                    objSetting.DBSetting.DB_User     = Functions.FormatString(ini.IniReadValue(KeySet.SectionName_DB, KeySet.DB_User));
                    objSetting.DBSetting.DB_Password = Functions.FormatString(ini.IniReadValue(KeySet.SectionName_DB, KeySet.DB_Password));

                    int iParity = 0;
                    //Com1
                    objSetting.WriteComProperty          = new Classes.ComProperty();
                    objSetting.WriteComProperty.PortName = Functions.FormatString(ini.IniReadValue(KeySet.SectionName_COM1, KeySet.PortName));
                    objSetting.WriteComProperty.BaudRate = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_COM1, KeySet.BaudRate));
                    objSetting.WriteComProperty.DataBits = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_COM1, KeySet.DataBits));
                    objSetting.WriteComProperty.StopBits = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_COM1, KeySet.StopBits)).Equals(1) ? StopBits.One : StopBits.Two;
                    iParity = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_COM1, KeySet.Parity));
                    objSetting.WriteComProperty.Parity = iParity.Equals(0) ? Parity.None : (iParity.Equals(1) ? Parity.Odd : Parity.Even);

                    //Com2
                    objSetting.MonitorComProperty          = new Classes.ComProperty();
                    objSetting.MonitorComProperty.PortName = Functions.FormatString(ini.IniReadValue(KeySet.SectionName_COM2, KeySet.PortName));
                    objSetting.MonitorComProperty.BaudRate = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_COM2, KeySet.BaudRate));
                    objSetting.MonitorComProperty.DataBits = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_COM2, KeySet.DataBits));
                    objSetting.MonitorComProperty.StopBits = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_COM2, KeySet.StopBits)).Equals(1) ? System.IO.Ports.StopBits.One : System.IO.Ports.StopBits.Two;
                    iParity = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_COM2, KeySet.Parity));
                    objSetting.MonitorComProperty.Parity = iParity.Equals(0) ? Parity.None : (iParity.Equals(1) ? Parity.Odd : Parity.Even);

                    //其它配置

                    objSetting.OtherSetting            = new Model.OtherSetting();
                    objSetting.OtherSetting.SyncAuto   = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_OTHER, KeySet.SyncAuto));
                    objSetting.OtherSetting.SyncTimePL = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_OTHER, KeySet.SyncTimePL));
                    if (objSetting.OtherSetting.SyncTimePL < 1 || objSetting.OtherSetting.SyncTimePL > 9999)
                    {
                        objSetting.OtherSetting.SyncTimePL = 10;
                    }

                    objSetting.OtherSetting.Chs = Functions.FormatInt(ini.IniReadValue(KeySet.SectionName_OTHER, KeySet.Chs));
                    if (objSetting.OtherSetting.Chs < 1 || objSetting.OtherSetting.Chs > 15)
                    {
                        objSetting.OtherSetting.Chs = 1;
                    }
                }
                catch (Exception err)
                {
                    objSetting = null;
                    strErrInfo = err.Message.ToString();
                }
                finally
                {
                    ini = null;
                }
            }
            else
            {
                strErrInfo = string.Format("{0}文件不存在,所以加载失败", strIniFilePath);
            }
            return(objSetting);
        }
Example #22
0
        /// <summary>
        /// 测试配置是否正确
        /// </summary>
        /// <param name="objSetting">配置对象</param>
        /// <param name="strErrInfo">错误信息</param>
        /// <returns></returns>
        public static bool CheckSettings(Model.Setting objSetting, out string strErrInfo)
        {
            bool bIfOk = false;

            strErrInfo = "";

            //1.数据库验证
            //地址
            if (string.IsNullOrEmpty(objSetting.DBSetting.DB_IP) || objSetting.DBSetting.DB_IP.Equals(""))
            {
                strErrInfo += "数据库地址为空!\r\n";
            }
            //名称
            if (string.IsNullOrEmpty(objSetting.DBSetting.DB_Name) || objSetting.DBSetting.DB_Name.Equals(""))
            {
                strErrInfo += "数据库名为空!\r\n";
            }
            //用户名
            if (string.IsNullOrEmpty(objSetting.DBSetting.DB_User) || objSetting.DBSetting.DB_User.Equals(""))
            {
                strErrInfo += "数据库用户名为空!\r\n";
            }

            double[] arrBaudRate = { 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 43000, 56000, 57600, 115200 };
            double[] arrDataBits = { 5, 6, 7, 8 };
            //2.写卡COM验证
            //串口名
            //if (string.IsNullOrEmpty(objSetting.WriteComProperty.PortName) || objSetting.WriteComProperty.PortName.Equals(""))
            //{
            //    strErrInfo += "制卡COM的串口名为空!\r\n";
            //}
            //串口波特率
            if (Functions.IsInArr(arrBaudRate, objSetting.WriteComProperty.BaudRate))
            {
                strErrInfo += "制卡COM的波特率不在范围内,取值范围为:300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 43000, 56000, 57600, 115200!\r\n";
            }
            //串口数据位
            if (Functions.IsInArr(arrDataBits, objSetting.WriteComProperty.DataBits))
            {
                strErrInfo += "制卡COM的数据位不在范围内,取值范围为:5, 6, 7, 8!\r\n";
            }

            //3.监控COM验证
            //串口名
            //if (string.IsNullOrEmpty(objSetting.MonitorComProperty.PortName) || objSetting.MonitorComProperty.PortName.Equals(""))
            //{
            //    strErrInfo += "监控COM的串口名为空!\r\n";
            //}
            //串口波特率
            if (Functions.IsInArr(arrBaudRate, objSetting.MonitorComProperty.BaudRate))
            {
                strErrInfo += "监控COM的波特率不在范围内,取值范围为:300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 43000, 56000, 57600, 115200!\r\n";
            }
            //串口数据位
            if (Functions.IsInArr(arrDataBits, objSetting.MonitorComProperty.DataBits))
            {
                strErrInfo += "监控COM的数据位不在范围内,取值范围为:5, 6, 7, 8!\r\n";
            }

            if (strErrInfo.Equals(""))
            {
                if (!string.IsNullOrEmpty(objSetting.WriteComProperty.PortName) && objSetting.WriteComProperty.PortName.Equals(objSetting.MonitorComProperty.PortName))
                {
                    strErrInfo += "制卡COM和监控COM不能用同一个串口!\r\n";
                }
            }

            //4.同步时间频率验证
            if (!(objSetting.OtherSetting.SyncTimePL >= 1 && objSetting.OtherSetting.SyncTimePL <= 9999))
            {
                strErrInfo += "时间同步频率值不在1~9999范围内!\r\n";
            }

            //5.扇区验证
            if (!(objSetting.OtherSetting.Chs >= 1 && objSetting.OtherSetting.Chs <= 15))
            {
                strErrInfo += "扇区不在1~15范围内!\r\n";
            }

            if (strErrInfo.Equals(""))
            {
                bIfOk = true;
            }
            return(bIfOk);
        }
Example #23
0
 public void Insert(Model.Setting e)
 {
     this.Insert <Model.Setting>(e);
 }
Example #24
0
 public void Update(Model.Setting e)
 {
     this.Update <Model.Setting>(e);
 }
 public bool TryLocateByKey(string key, out Model.Setting value)
 {
     return(settings.TryGetValue(key, out value));
 }