public static DataBaseDAO CreateDataBaseDAO(DataTypeName dataTypeName)
        {
            DataBaseDAO dataBaseDAO = null;

            switch (dataTypeName)
            {
            case DataTypeName.ShouldPadDataTable:
                dataBaseDAO = new ShouldPadDAO();
                break;

            case DataTypeName.InOutDataTable:
                dataBaseDAO = new InOutDataDAO();
                break;

            case DataTypeName.BaseDataTable:
                dataBaseDAO = new MachineBaseDataDAO();
                break;

            case DataTypeName.FlowDataTable:
                dataBaseDAO = new FlowDataDAO();
                break;

            default:
                break;
            }
            return(dataBaseDAO);
        }
示例#2
0
        private String GetShowData()
        {
            int    count      = System.Environment.TickCount;
            String showString = String.Empty;
            int    showData   = 0;
            string showSData  = null;

            showString = this.Text;

            if (DataTypeName != DataTypeName.Null)
            {
                String      elementName = GetButtonElement();
                DataBaseDAO dataBaseDAO = MouldDataFactory.CreateDataBaseDAO(DataTypeName);
                if (elementName == "ID")
                {
                    if (elementName != String.Empty && elementName != "Null" && System.Environment.OSVersion.Platform == PlatformID.WinCE)
                    {
                        showSData  = dataBaseDAO.GetDataBaseValue(elementName);
                        showString = showSData;
                    }
                }
                else
                {
                    if (elementName != String.Empty && elementName != "Null" && System.Environment.OSVersion.Platform == PlatformID.WinCE)
                    {
                        showData = Convert.ToInt32(dataBaseDAO.GetDataBaseValue(elementName));
                        dataButtonInfo.DataInfo = ButtonDataInfo;
                        showString = DataChange.ChangeXmlDataToShowData(dataButtonInfo.DataInfo, showData).ToString();
                    }
                }
            }
            return(showString);
        }
        //开机时候的数据初始化
        public void InitSystemData()
        {
            SystemTimeManager.SystemTimerEx.GetStartTime();

            //读入机器参数XML
            MachineBaseDataDAO baseDataDAO = new MachineBaseDataDAO();

            baseDataDAO.LoadAllData();


            //读入花形参数XML
            ShouldPadDAO mouldDataDAO = new ShouldPadDAO();

            mouldDataDAO.FileIndex = baseDataDAO.GetSDataBaseValue(MachineBaseDataEnum.ID);
            mouldDataDAO.LoadAllData();

            DataTypeName[] dataTableNames = new DataTypeName[] { DataTypeName.InOutDataTable };
            DataBaseDAO    dataBaseDAO    = null;

            for (int i = 0; i < dataTableNames.Length; i++)
            {
                dataBaseDAO = MouldDataFactory.CreateDataBaseDAO(dataTableNames[i]);
                dataBaseDAO.LoadAllData();
            }
            FlowDataDAO setDataDAO = new FlowDataDAO();

            setDataDAO.LoadAllData();
            serialDataManager = new SerialDataManager();
            serialDataManager.OpenSerialPort();
        }
示例#4
0
 protected override void OnTextChanged(EventArgs e)
 {
     base.OnTextChanged(e);
     if (dataButtonInfo.HasClick)
     {
         dataButtonInfo.HasClick = false;
         int    sqliteData = 0;
         double showData;
         string showDataId = null;
         if (DataTypeName != DataTypeName.Null && dataButtonInfo.SaveDataEnable)
         {
             String elementName = GetButtonElement();
             if (elementName == "ID")
             {
                 DataBaseDAO dataBaseDAO = MouldDataFactory.CreateDataBaseDAO(DataTypeName);
                 showDataId = base.Text;
                 if (System.Environment.OSVersion.Platform == PlatformID.WinCE)
                 {
                     dataBaseDAO.SetDataBaseValue(elementName, showDataId.ToString());
                 }
             }
             else
             {
                 DataBaseDAO dataBaseDAO = MouldDataFactory.CreateDataBaseDAO(DataTypeName);
                 showData = Convert.ToDouble(base.Text);
                 if (elementName != String.Empty && elementName != "Null")
                 {
                     dataButtonInfo.DataInfo = ButtonDataInfo;
                     sqliteData = DataChange.ChangeShowDataToXmlData(dataButtonInfo.DataInfo, showData);
                     if (elementName != String.Empty && elementName != "Null" && System.Environment.OSVersion.Platform == PlatformID.WinCE)
                     {
                         dataBaseDAO.SetDataBaseValue(elementName, sqliteData.ToString());
                     }
                 }
             }
         }
     }
 }
示例#5
0
        /// <summary>
        /// 获得发生错误的文件名,将该文件删除,并且将程序中的属于该文件的数据进行保存
        /// </summary>
        /// <param name="fileName"></param>
        public void RepairSaveMachineDatas(String fileName)
        {
            String[]       pathNames     = new string[] { "InOutData", "ShouldPadData", "BaseData" };
            DataTypeName[] dataTypeNames = new DataTypeName[] { DataTypeName.InOutDataTable
                                                                , DataTypeName.ShouldPadDataTable, DataTypeName.BaseDataTable };
            DataTypeName dataTypeName = DataTypeName.Null;

            fileName = DefaultPath.DefaultPathEx.DataBasePath + fileName;
            FileOperManager.DeleteFile(fileName);
            for (int i = 0; i < pathNames.Length; i++)
            {
                if (fileName.IndexOf(pathNames[i]) != -1)
                {
                    dataTypeName = dataTypeNames[i];
                    break;
                }
            }
            DataBaseDAO dataBaseDAO = MouldDataFactory.CreateDataBaseDAO(dataTypeName);

            if (dataBaseDAO != null)
            {
                dataBaseDAO.SaveAllDataBase();
            }
        }