void LoadDatabase(LSDatabase database)
        {
            _database = database;
            bool isValid = false;

            if (_database != null)
            {
                if (database.GetType() != DatabaseType)
                {
                    //Note: A hacky fix for changing the type of a previously saved database is to turn on Debug mode
                    //and change the script type of the database asset in the inspector. Back it up before attempting!
                    Debug.Log("Loaded database type does not match DatabaseType.");
                }
                DatabaseEditor = new EditorLSDatabase();
                DatabaseEditor.Initialize(this, Database, out isValid);
            }
            if (!isValid)
            {
                Debug.Log("Load unsuccesful");
                this.DatabaseEditor = null;
                this._database      = null;
                IsLoaded            = false;
                return;
            }
            LSFSettingsManager.GetSettings().Database = database;
            LSFSettingsModifier.Save();
            IsLoaded = true;
        }
Example #2
0
        public static void Setup()
        {
            //LSFSettingsManagers.GetSettings().Database is the most recent database loaded/created.
            //You can also set this manually by dragging the desired database onto the saved LSFSettings in...
            //'Assets/Resources/LockstepFrameworkSettings'
            LSDatabase database = LSFSettingsManager.GetSettings().Database;

            _currentDatabase = database;
        }
Example #3
0
        private void FillDGV(DateTime DTStart, DateTime DTEnd)
        {
            string sSQL = "SELECT Name as 名称,DT_Start as 开始时间,DT_End as 结束时间 ,UserName as 操作员,Status,StepNumber as 总层数,rowguid as 唯一标示 FROM p_processinfo ";

            sSQL                    += "where DT_Start between '" + DTStart.ToString("yyyy-MM-dd hh:mm:ss");
            sSQL                    += "' and '" + DTEnd.ToString("yyyy-MM-dd HH:mm:ss") + "'order by DT_Start desc;";
            DTValue                  = LSDatabase.GetSOEData(sSQL);
            dGV1.DataSource          = DTValue;
            dGV1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
        }
Example #4
0
        public void UpdateReal(DateTime DT_S, DateTime DT_N, int iSec)//按时间长度增加曲线
        {
            if (iSec > 0)
            {
                DT_S = DT_N.AddSeconds(-1 * iSec);
            }

            UpdateListTable();
            foreach (var nTable in ListTable)
            {
                DataTable DTValue = LSDatabase.GetFastHisData(DT_S, DT_N, nTable.Key, nTable.Value);
                DateTime  DT_ss;
                if (DTValue.Rows.Count > 0)
                {
                    DT_ss = DateTime.Parse(DTValue.Rows[DTValue.Rows.Count - 1]["Date_Time"].ToString());
                }
                else
                {
                    DT_ss = DT_S;
                }
                double[] x = new double[DTValue.Rows.Count];
                double[] y = new double[DTValue.Rows.Count];
                for (int i = 0; i < DTValue.Rows.Count; i++)
                {
                    x[i] = new XDate(DateTime.Parse(DTValue.Rows[i]["Date_Time"].ToString()));
                    //Debug.WriteLine(DTValue.Rows[i]["Date_Time"].ToString() + ":" + x[i].ToString());
                }
                for (int j = 1; j < DTValue.Columns.Count; j++)
                {
                    foreach (CLSYAxisGroup nGroup in ListYAxisGroup)
                    {
                        foreach (CLSCurve nCurve in nGroup.ListCur)
                        {
                            if (nCurve.StaName == nTable.Key && nCurve.VarName == DTValue.Columns[j].ColumnName)
                            {
                                for (int i = 0; i < DTValue.Rows.Count; i++)
                                {
                                    y[i] = CABC.CABCDGV.GetValFromDT(DTValue, nCurve.VarName, i, 0);
                                }
                                nCurve.ListPT.Clear();
                                nCurve.ListPT.Add(x, y);
                                if (iSec > 0)
                                {
                                    nCurve.iSec = iSec;
                                    nCurve.UpdateReal(DT_ss, DT_N);
                                }
                            }
                        }
                    }
                }
            }
        }
        bool LoadDatabaseFromPath(string absolutePath)
        {
            string     relativePath = absolutePath.GetRelativeUnityAssetPath();
            LSDatabase database     = AssetDatabase.LoadAssetAtPath <LSDatabase>(relativePath);

            if (database != null)
            {
                LoadDatabase(database);
                return(true);
            }
            DatabaseEditor = null;

            return(false);
        }
Example #6
0
        private void butQuery_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor      = Cursors.WaitCursor;
                butQuery.Enabled = false;
                DateTime DT_S, DT_E;
                if (dTP_S.Value > dTP_E.Value)
                {
                    DT_E = dTP_S.Value;
                    DT_S = dTP_E.Value;
                }
                else
                {
                    DT_E = dTP_E.Value;
                    DT_S = dTP_S.Value;
                }
                string sSQL = "SELECT (@i:=@i+1) as 序号, AL_SOELog.Date_Time as 时间,";
                sSQL += "AL_SOELog.StationName as 子站名称,AL_SOELog.AlarmType as 类型 ,";
                sSQL += "AL_SOELog.Recorder as 报警内容,AL_SOELog.ConfirmTime as 确认时间,";
                sSQL += "AL_SOELog.ConfirmName as 确认人 FROM (select @i:=0)it,AL_SOELog ";
                sSQL += "where AL_SOELog.Date_Time between '" + DT_S.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + DT_E.ToString("yyyy-MM-dd HH:mm:ss") + "' ";

                string    sSQL1   = sSQL + " and (AL_SOELog.Priority=1 or AL_SOELog.Priority=2) and AL_SOELog.AlarmType!= '人工操作' order by AL_SOELog.Date_Time;";
                DataTable DTValue = LSDatabase.GetSOEData(sSQL1);
                HisdGV1.DataSource          = DTValue;
                HisdGV1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

                string    sSQL2    = sSQL + " and AL_SOELog.Priority=3 and AL_SOELog.AlarmType!= '人工操作' order by AL_SOELog.Date_Time;";
                DataTable DTValue2 = LSDatabase.GetSOEData(sSQL2);
                HisdGV2.DataSource          = DTValue2;
                HisdGV2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;

                string    sSQL3    = sSQL + " and AL_SOELog.AlarmType= '人工操作' order by AL_SOELog.Date_Time;";
                DataTable DTValue3 = LSDatabase.GetSOEData(sSQL3);
                HisdGV3.DataSource          = DTValue3;
                HisdGV3.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "butQuery_Click");
            }
            finally
            {
                this.Cursor      = Cursors.Default;
                butQuery.Enabled = true;
            }
        }
        private bool CreateDatabase(string absolutePath)
        {
            LSDatabase database = (LSDatabase)ScriptableObject.CreateInstance(DatabaseType);

            if (database == null)
            {
                return(false);
            }

            string relativePath = absolutePath.GetRelativeUnityAssetPath();

            AssetDatabase.CreateAsset(database, relativePath);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            LoadDatabase(database);

            return(true);
        }
Example #8
0
        public void InitTimeList()
        {
            try
            {
                listBox1.Items.Clear();

                string    sSQL      = "SELECT year(DT_Start) as Y,month(DT_Start) as M,count(*) as N FROM p_processinfo group by year(DT_Start) , month(DT_Start) order by DT_Start desc;";
                DataTable ListValue = LSDatabase.GetSOEData(sSQL);
                foreach (DataRow nRow in ListValue.Rows)
                {
                    DateTime DT = new DateTime(Convert.ToInt32(nRow["Y"]), Convert.ToInt32(nRow["M"]), 1, 0, 0, 0);
                    listBox1.Items.Add(DT.ToString("yyyy年MM月") + "(" + nRow["N"] + ")");
                }
                listBox1.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("InitTimeList:" + ex.Message);
            }
        }
        public void Initialize(EditorLSDatabaseWindow window, LSDatabase database, out bool valid)
        {
            this.MainWindow = window;
            Database        = database;
            InitializeData();
            bool isValid = true;

            for (int i = 0; i < DataItemInfos.Count; i++)
            {
                DataItemInfo info = DataItemInfos [i];
                bool         bufferValid;
                CreateDataHelper(info, out bufferValid);
                if (!bufferValid)
                {
                    Debug.LogError("Database does not match database type described by the database editor. Make sure Lockstep_Database.asset is the correct database type.");
                    isValid = false;
                    break;
                }
            }
            valid = isValid;
        }
        public DataHelper(
            Type targetType,
            EditorLSDatabase sourceEditor,
            LSDatabase sourceDatabase,
            string displayName,
            string dataFieldName,
            SortInfo[] sorts,
            out bool valid)
        {
            Sorts            = sorts;
            this.TargetType  = targetType;
            SourceEditor     = sourceEditor;
            this.DisplayName = displayName;
            SourceDatabase   = sourceDatabase;
            _dataFieldName   = dataFieldName;

            FieldInfo info = sourceDatabase.GetType().GetField(_dataFieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            if (info == null)
            {
                Debug.Log(string.Format("Field with fieldName of {0} not found.", dataFieldName));
                valid = false;
                return;
            }

            _getData = () => (DataItem[])info.GetValue(sourceDatabase);
            _setData = (value) => info.SetValue(sourceDatabase, value);
            if (Data == null)
            {
                Data = (DataItem[])Array.CreateInstance(TargetType, 0);
            }
            DataItemAttribute dataAttribute = (DataItemAttribute)Attribute.GetCustomAttribute(targetType, typeof(DataItemAttribute));

            _dataAttribute = dataAttribute ?? new DataItemAttribute();
            valid          = true;
        }
Example #11
0
 public static string ToJson(LSDatabase database)
 {
     return(JsonUtility.ToJson(database, true));
 }
Example #12
0
 public CUserDBUM(string _sApp, LSDatabase _DB)
     : base(_sApp, _DB)
 {
 }
Example #13
0
 public CUserInfo(string _sApp, LSDatabase _DB)
 {
     nDatabase = _DB;
     sXMLPath  = _sApp + "\\Project\\User.xml";
     LoadXML();
 }