Exemplo 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();
            }
        }
Exemplo n.º 2
0
 public static WarnningDataSource GetInstance()
 {
     if(sInstance == null){
         sInstance = new WarnningDataSource();
       //  sInstance.RegisterObserver();
     }
     return sInstance;
 }
Exemplo n.º 3
0
 public static WarnningDataSource GetInstance()
 {
     if (sInstance == null)
     {
         sInstance = new WarnningDataSource();
         //  sInstance.RegisterObserver();
     }
     return(sInstance);
 }
Exemplo 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.mWarnningList.Count;

            PageDataExchange context = PageDataExchange.getInstance();
            context.NotifyObserverChanged(PageWarnningHeader.TAG, WarnningDataSource.TAG, info);
        }
Exemplo n.º 5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            PageDataExchange context = PageDataExchange.getInstance();

            context.addResultObserver(TAG, this);


            String description = @"进入系统";

            Log.write(Log.CATEGOTY_RUN, description);

            WarnningDataSource observer = WarnningDataSource.GetInstance();

            observer.RegisterObserver();
        }
Exemplo n.º 6
0
        public PageWarnningHeader()
        {
            InitializeComponent();
            this.Loaded   += new RoutedEventHandler(Page_Loaded);
            this.Unloaded += new RoutedEventHandler(Page_Unloaded);

            PageDataExchange context = PageDataExchange.getInstance();

            context.addResultObserver(TAG, this);

            WarnningDataSource data = WarnningDataSource.GetInstance();

            this.cb_info.ItemsSource   = data.mWarnningList;
            this.cb_info.SelectedIndex = 0;
            // this.cb_info.DisplayMemberPath = "description";
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        private void Window_Closed(object sender, EventArgs e)
        {
            PageDataExchange context = PageDataExchange.getInstance();

            context.removeResultObserver(TAG);

            WarnningDataSource observer = WarnningDataSource.GetInstance();

            observer.UnregisterObserver();

            // http://forums.adobe.com/thread/487023
            Win32Helper.CoFreeUnusedLibraries();
            //  Win32Helper.CoUninitialize();

            mAdsClient.Dispose();
            String description = @"退出系统";

            Log.write(Log.CATEGOTY_RUN, description);
        }
        //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;
            }
        }
Exemplo n.º 10
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;
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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;
        }