Ejemplo n.º 1
0
        //override
        public void onRecieveResult(Dictionary <String, Object> bundle)
        {
            Object senderName;
            Object resultValue;
            Object senderValue;

            bundle.TryGetValue(PageDataExchange.KEY_SENDER_NAME, out senderName);
            bundle.TryGetValue(PageDataExchange.KEY_RESULT_VALUE, out resultValue);
            bundle.TryGetValue(PageDataExchange.KEY_SENDER_VALUE, out senderValue);

            //beckhoff changed
            // if (WarnningDataSource.TAG.Equals(senderName) )
            {
                WarnningDataSource.ErrorInfo infoChanged = (WarnningDataSource.ErrorInfo)senderValue;
                WarnningDataSource.ErrorInfo infoCurrent = (WarnningDataSource.ErrorInfo) this.cb_info.SelectedItem;
                WarnningDataSource           data        = WarnningDataSource.GetInstance();


                if (data.IsWarnningAdded(infoChanged))
                {
                    this.cb_info.SelectedItem = infoChanged;
                }
                else if (infoChanged.level == infoCurrent.level)// item was removed
                {
                    if (this.cb_info.SelectedIndex > 0)
                    {
                        this.cb_info.SelectedIndex = 0;
                    }
                }

                this.cb_info.ItemsSource = data.mWarnningList;
                this.cb_info.Items.Refresh();
            }
        }
Ejemplo n.º 2
0
        //public class Record
        //{
        //    public int index{get;set;}
        //    public String  category{get;set;}
        //    public string description { get; set; }
        //    public string code { get; set; }
        //    public DateTime whenhappened { get; set; }
        //    public DateTime whenresolved { get; set; }
        //}

        //record infomation runtime
        public static int write(WarnningDataSource.ErrorInfo info)
        {
            ContentProvider provider = ContentProvider.getInstance();
            string          sql      = String.Format(@"INSERT INTO [warnning] ([level],[category_id],[code],[description],[whenhappened] ) 
                                                    VALUES({0},{1},'{2}','{3}','{4}')", info.level, info.category_id, info.code, info.description, DateTime.Now.ToString());

            int rowAffected = provider.insert(sql);

            return(rowAffected);
        }
Ejemplo n.º 3
0
        private void btn_delete_Click(object sender, RoutedEventArgs e)
        {
            mWarnningDataSource = WarnningDataSource.GetInstance();
            mStatusMap = mWarnningDataSource.mStatusMap;
            WarnningDataSource.ErrorInfo info = new WarnningDataSource.ErrorInfo() { level = 202, description  = "add test" };
            //test delete to list
            mWarnningDataSource.RemoveWarningItem(info);
            int count = mWarnningDataSource.mWarnningList.Count;

            PageDataExchange context = PageDataExchange.getInstance();
            context.NotifyObserverChanged(PageWarnningHeader.TAG, WarnningDataSource.TAG, info);
        }
Ejemplo n.º 4
0
        private void btn_delete_Click(object sender, RoutedEventArgs e)
        {
            mWarnningDataSource = WarnningDataSource.GetInstance();
            mStatusMap          = mWarnningDataSource.mStatusMap;
            WarnningDataSource.ErrorInfo info = new WarnningDataSource.ErrorInfo()
            {
                level = 202, description = "add test"
            };
            //test delete to list
            mWarnningDataSource.RemoveWarningItem(info);
            int count = mWarnningDataSource.GetWarnningCount();

            PageDataExchange context = PageDataExchange.getInstance();

            context.NotifyObserverChanged(PageWarnningHeader.TAG, WarnningDataSource.TAG, info);
        }
Ejemplo n.º 5
0
        //override beckhoff changed
        public void onRecieveResult(Dictionary <String, Object> bundle)
        {
            Object senderName;
            Object senderValue;

            bundle.TryGetValue(PageDataExchange.KEY_SENDER_NAME, out senderName);
            bundle.TryGetValue(PageDataExchange.KEY_SENDER_VALUE, out senderValue);

            WarnningDataSource.ErrorInfo info = (WarnningDataSource.ErrorInfo)senderValue;
            this.tb_code.Text     = info.code;
            this.tb_solution.Text = info.solution;

            PageDataExchange context = PageDataExchange.getInstance();

            context.NotifyObserverChanged(PageStatus.TAG, PageStatus.CODE, info.code);
        }
Ejemplo n.º 6
0
        //override
        public void onRecieveResult(Dictionary <String, Object> bundle)
        {
            Object senderName;
            Object resultValue;
            Object senderValue;

            bundle.TryGetValue(PageDataExchange.KEY_SENDER_NAME, out senderName);
            bundle.TryGetValue(PageDataExchange.KEY_RESULT_VALUE, out resultValue);
            bundle.TryGetValue(PageDataExchange.KEY_SENDER_VALUE, out senderValue);

            //beckhoff changed
            if (WarnningDataSource.TAG.Equals(senderName))
            {
                WarnningDataSource.ErrorInfo infoChanged = (WarnningDataSource.ErrorInfo)senderValue;
                WarnningDataSource.ErrorInfo infoCurrent = (WarnningDataSource.ErrorInfo) this.cb_info.SelectedItem;
                WarnningDataSource           data        = WarnningDataSource.GetInstance();


                //if (data.IsWarnningAdded(infoChanged))
                //{
                //    //this.cb_info.SelectedItem = infoChanged;

                //}
                //else if (infoCurrent != null && infoChanged.level == infoCurrent.level)// item was removed
                //{
                //    if (this.cb_info.SelectedIndex > 0)
                //    {
                //        this.cb_info.SelectedIndex = 0;
                //    }
                //}

                PageDataExchange   context    = PageDataExchange.getInstance();
                WarnningDataSource dataSource = WarnningDataSource.GetInstance();
                if (dataSource.GetWarnningCount() == 0 && context.IsPageLoaded(PageWarningDetail.TAG))
                {
                    Utils.NavigatePageBack();
                }

                this.cb_info.ItemsSource = data.GetWarnningList();
                this.cb_info.Items.Refresh();
                this.cb_info.SelectedIndex = 0;
            }
        }
Ejemplo n.º 7
0
        private void infoPanel_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.cb_info.SelectedIndex < 0)
            {
                this.cb_info.SelectedIndex = 0;
            }
            WarnningDataSource.ErrorInfo info    = (WarnningDataSource.ErrorInfo) this.cb_info.SelectedItem;
            PageDataExchange             context = PageDataExchange.getInstance();

            if (info.level < 200)
            {
                Dictionary <String, Object> bundle = new Dictionary <string, object>();
                bundle.Add(PageDataExchange.KEY_SENDER_NAME, WarnningDataSource.TAG);
                bundle.Add(PageDataExchange.KEY_SENDER_VALUE, info);
                context.putExtra(PageWarningDetail.TAG, bundle);
                Utils.NavigateToPage(MainWindow.sFrameReportName, PageWarningDetail.TAG);
            }

            context.NotifyObserverChanged(PageWarningDetail.TAG, WarnningDataSource.TAG, info);
            context.NotifyObserverChanged(PageStatus.TAG, PageStatus.CODE, info.code);
        }
Ejemplo n.º 8
0
        public static int resolve(WarnningDataSource.ErrorInfo info)
        {
            ContentProvider provider    = ContentProvider.getInstance();
            String          sqlQuery    = String.Format(@"SELECT [_id],[whenresolved]FROM [warnning] where level={0} ORDER BY [whenhappened] desc", info.level);
            DataTable       dt          = provider.query(sqlQuery);
            int             rowAffected = 0;

            foreach (DataRow row in dt.Rows)
            {
                string whenresolved = row["whenresolved"].ToString();
                if (String.IsNullOrEmpty(whenresolved))
                {
                    string id  = row["_id"].ToString();
                    string sql = String.Format(@"UPDATE [warnning] SET [whenresolved]='{0}' where [_id]={1} ", DateTime.Now.ToString(), id);
                    rowAffected = provider.update(sql);
                    break;
                }
            }

            return(rowAffected);
        }
Ejemplo n.º 9
0
        public static List <WarnningDataSource.ErrorInfo> getAllRecords(String filter)
        {
            String where = "";
            if (!String.IsNullOrEmpty(filter))
            {
                where = " where " + filter;
            }

            string sql = @"SELECT [level] ,
                                                [code] ,
                                                [category.description] as category,
                                                [warnning.description] as description,
                                                [whenhappened] ,
                                                [whenresolved] 
                                    FROM [warnning] INNER JOIN [category] ON warnning.category_id=category.id"
                         + where + " ORDER BY [whenhappened] desc ";

            ContentProvider provider = ContentProvider.getInstance();
            DataTable       dt       = provider.query(sql);

            List <WarnningDataSource.ErrorInfo> records = new List <WarnningDataSource.ErrorInfo>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row = dt.Rows[i];
                WarnningDataSource.ErrorInfo record = new WarnningDataSource.ErrorInfo();
                record.level        = int.Parse(row["level"].ToString());
                record.category     = row["category"].ToString();
                record.description  = row["description"].ToString();
                record.whenhappened = row["whenhappened"].ToString();
                record.whenresolved = row["whenresolved"].ToString();


                record.code = row["code"].ToString();

                records.Add(record);
            }

            return(records);
        }
Ejemplo n.º 10
0
        private void btn_add_Click(object sender, RoutedEventArgs e)
        {
            mWarnningDataSource = WarnningDataSource.GetInstance();
            mStatusMap          = mWarnningDataSource.mStatusMap;


            WarnningDataSource.ErrorInfo info = new WarnningDataSource.ErrorInfo()
            {
                level = 202, description = "add test"
            };

            int count = mWarnningDataSource.mWarnningList.Count;

            //test add to list
            mListError.Add(null);
            mWarnningDataSource.AddWarningItem(info);
            count = mWarnningDataSource.mWarnningList.Count;

            PageDataExchange context = PageDataExchange.getInstance();

            context.NotifyObserverChanged(PageWarnningHeader.TAG, WarnningDataSource.TAG, info);
        }
Ejemplo n.º 11
0
        public static List<WarnningDataSource.ErrorInfo> getAllRecords(String filter)
        {
            String where = "";
            if (!String.IsNullOrEmpty(filter))
            {
                where = " where " + filter;
            }

            string sql = @"SELECT [level] ,
                                                [code] ,
                                                [category.description] as category,
                                                [warnning.description] as description,
                                                [whenhappened] ,
                                                [whenresolved]
                                    FROM [warnning] INNER JOIN [category] ON warnning.category_id=category.id"
                                    + where + " ORDER BY [whenhappened] desc ";

            ContentProvider provider = ContentProvider.getInstance();
            DataTable dt = provider.query(sql);

            List<WarnningDataSource.ErrorInfo> records = new List<WarnningDataSource.ErrorInfo>();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow row = dt.Rows[i];
                WarnningDataSource.ErrorInfo record = new WarnningDataSource.ErrorInfo();
                record.level = int.Parse(row["level"].ToString());
                record.category = row["category"].ToString();
                record.description = row["description"].ToString();
                record.whenhappened = row["whenhappened"].ToString();
                record.whenresolved = row["whenresolved"].ToString();

                 record.code = row["code"].ToString();

                records.Add(record);
            }

            return records;
        }