text:
import { PureComponent, createElement } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import { actions } from 'components/modal-metadata';
import Component from './context-by-country-component';

class ContextByCountryContainer extends PureComponent {
  handleInfoClick = () => {
    this.props.setModalMetadata({
      customTitle: 'Data Sources',
      category: 'Agriculture - Context by Country',
      slugs: [
        'FAOSTAT_3',
        'FAOSTAT_4',
        'FAOSTAT_5',
        'WBD',
        'OECD-FAO',
        'Aqueduct_Country_River_Basin_Rankings'
      ],
      open: true
    });
  };

  render() {
    return createElement(Component, {
      ...this.props,
      handleInfoClick: this.handleInfoClick
    });
  }
}

ContextByCountryContainer.propTypes = {
  setModalMetadata: PropTypes.func
};

export default connect(null, actions)(ContextByCountryContainer);


text:
namespace views {
class Widget;
}

namespace app_list {

class AppListItem;
class AppListModel;
class AppListViewDelegate;
class ApplicationDragAndDropHost;
class ContentsView;
class PaginationModel;
class SearchBoxView;

// AppListMainView contains the normal view of the app list, which is shown
// when the user is signed in.
class APP_LIST_EXPORT AppListMainView : public views::View,
                                        public AppsGridViewDelegate,
                                        public AppListModelObserver,
                                        public SearchBoxViewDelegate,
                                        public SearchResultListViewDelegate {
 public:
  explicit AppListMainView(AppListViewDelegate* delegate);
  ~AppListMainView() override;

  void Init(gfx::NativeView parent,
            int initial_apps_page,
            SearchBoxView* search_box_view);

  void ShowAppListWhenReady();

  void ResetForShow();

  void Close();

  void Prerender();

  void ModelChanged();

  SearchBoxView* search_box_view() const { return search_box_view_; }

  // Gets the invisible widget that sits partly over the bottom of the app list,
  // covering the collapsed-state custom page. May return nullptr, if the widget
  // has not been initialized or has already been destroyed.
  views::Widget* GetCustomPageClickzone() const;

  // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
  // operations outside the application list.
  void SetDragAndDropHostOfCurrentAppList(
      ApplicationDragAndDropHost* drag_and_drop_host);

  ContentsView* contents_view() const { return contents_view_; }
  AppListModel* model() { return model_; }
  AppListViewDelegate* view_delegate() { return delegate_; }

  // Returns true if the app list should be centered and in landscape mode.
  bool ShouldCenterWindow() const;

  // Called when the search box's visibility is changed.
  void NotifySearchBoxVisibilityChanged();

  // Initialize widgets that live inside the app list's main widget.
  void InitWidgets();

  // Overridden from AppListModelObserver:
  void OnCustomLauncherPageEnabledStateChanged(bool enabled) override;

 private:
  class IconLoader;

  // Adds the ContentsView.
  void AddContentsViews();

  // Gets the PaginationModel owned by the AppsGridView.
  PaginationModel* GetAppsPaginationModel();

  // Loads icon image for the apps in the selected page of |pagination_model_|.
  // |parent| is used to determine the image scale factor to use.
  void PreloadIcons(gfx::NativeView parent);

  // Invoked when |icon_loading_wait_timer_| fires.
  void OnIconLoadingWaitTimer();

  // Invoked from an IconLoader when icon loading is finished.
  void OnItemIconLoaded(IconLoader* loader);

  // Overridden from AppsGridViewDelegate:
  void ActivateApp(AppListItem* item, int event_flags) override;
  void GetShortcutPathForApp(
      const std::string& app_id,
      const base::Callback<void(const base::FilePath&)>& callback) override;
  void CancelDragInActiveFolder() override;

  // Overridden from SearchBoxViewDelegate:
  void QueryChanged(SearchBoxView* sender) override;
  void BackButtonPressed() override;

  // Overridden from SearchResultListViewDelegate:
  void OnResultInstalled(SearchResult* result) override;

  AppListViewDelegate* delegate_;  // Owned by parent view (AppListView).
  AppListModel* model_;  // Unowned; ownership is handled by |delegate_|.

  // Created by AppListView. Owned by views hierarchy.
  SearchBoxView* search_box_view_;
  ContentsView* contents_view_;  // Owned by views hierarchy.

  // Invisible widget that sits partly over the bottom of the app list, covering
  // the collapsed-state custom page, and intercepts click events. Always use
  // GetCustomPageClickzone() to access this (do not access it directly).
  views::Widget* custom_page_clickzone_;  // Owned by the app list widget.

  // A timer that fires when maximum allowed time to wait for icon loading has
  // passed.
  base::OneShotTimer<AppListMainView> icon_loading_wait_timer_;

  ScopedVector<IconLoader> pending_icon_loaders_;

  base::WeakPtrFactory<AppListMainView> weak_ptr_factory_;

  DISALLOW_COPY_AND_ASSIGN(AppListMainView);
};

}  // namespace app_list

#endif  // UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL.IDAL.SysMaster;
using model = Model.SysMaster;
using LinqToSQLModel;
using DAL.SqlDAL.LocalLayer;
using System.Data.Linq.SqlClient;
using Model.SysMaster;
using Model.General;
using System.Transactions;

namespace DAL.SqlDAL.SysMaster
{
    class UserPurviewDA : IUserPurviewDA
    {
        private Sys_UserPurview_usp_Info FindUser(Sys_UserPurview_usp_Info info)
        {
            Sys_FormMaster_fom_Info formInfo = new Sys_FormMaster_fom_Info();

            List<Sys_FormMaster_fom_Info> formList = new List<Sys_FormMaster_fom_Info>();
            formList = info.formMasterList;
            if (formList != null)
            {
                formInfo = info.formMasterList[0];

                string sqlString = string.Empty;
                sqlString += "SELECT DISTINCT usm_cUserLoginID,usm_cChaName " + Environment.NewLine;
                sqlString += "FROM Sys_UserMaster_usm " + Environment.NewLine;
                sqlString += "LEFT JOIN  Sys_UserPurview_usp" + Environment.NewLine;
                sqlString += "ON usm_cUserLoginID=usp_cUserLoginID" + Environment.NewLine;
                sqlString += "LEFT JOIN Sys_FormPurview_frp" + Environment.NewLine;
                sqlString += "ON usp_cPurviewCode=frp_cPurviewCode" + Environment.NewLine;
                sqlString += "LEFT JOIN Sys_FormMaster_fom" + Environment.NewLine;
                sqlString += "ON frp_cFormNumber=fom_cFormNumber WHERE fom_cFormNumber='" + formInfo.fom_cFormNumber + "'";

                IEnumerable<Sys_UserMaster_usm_Info> infos = null;
                List<Sys_UserMaster_usm_Info> infoList = null;

                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        infos = db.ExecuteQuery<Sys_UserMaster_usm_Info>(sqlString, new object[] { });

                        if (infos != null)
                        {
                            infoList = infos.ToList<Sys_UserMaster_usm_Info>();
                        }
                        foreach (Sys_UserMaster_usm_Info t in infoList)
                        {
                            info.userMasterList.Add(t);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }

                for (int i = 0; i < info.userMasterList.Count; i++)
                {
                    sqlString = string.Empty;
                    sqlString += "SELECT DISTINCT fum_cFunctionNumber,fum_cFunctionDesc" + Environment.NewLine;
                    sqlString += "FROM Sys_FunctionMaster_fum" + Environment.NewLine;
                    sqlString += "LEFT JOIN Sys_FormPurview_frp" + Environment.NewLine;
                    sqlString += "ON fum_cFunctionNumber=frp_cFunctionNumber" + Environment.NewLine;

                    sqlString += "LEFT JOIN Sys_FormMaster_fom" + Environment.NewLine;
                    sqlString += "ON fom_cFormNumber=frp_cFormNumber" + Environment.NewLine;

                    sqlString += "LEFT JOIN Sys_UserPurview_usp" + Environment.NewLine;
                    sqlString += "ON frp_cPurviewCode=usp_cPurviewCode" + Environment.NewLine;
                    sqlString += "LEFT JOIN Sys_UserMaster_usm" + Environment.NewLine;
                    sqlString += "ON usp_cUserLoginID=usm_cUserLoginID WHERE usm_cUserLoginID='" + info.userMasterList[i].usm_cUserLoginID + "' AND fom_cFormNumber='" + formInfo.fom_cFormNumber + "'";
                    IEnumerable<Sys_FunctionMaster_fum_Info> fums = null;
                    List<Sys_FunctionMaster_fum_Info> fumList = null;
                    try
                    {
                        using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                        {
                            fums = db.ExecuteQuery<Sys_FunctionMaster_fum_Info>(sqlString, new object[] { });

                            if (fums != null)
                            {
                                fumList = fums.ToList<Sys_FunctionMaster_fum_Info>();
                            }
                            List<Sys_FunctionMaster_fum_Info> fumList1 = new List<Sys_FunctionMaster_fum_Info>();
                            foreach (Sys_FunctionMaster_fum_Info t in fumList)
                            {
                                fumList1.Add(t);
                                //info.userMasterList[i].functionMasterList.Add(t);
                                //info.userMasterList.Add(t);
                            }
                            info.userMasterList[i].functionMasterList = fumList1;
                        }
                    }
                    catch (Exception Ex)
                    {
                        throw Ex;
                    }

                }

            }
            return info;
        }

        private Sys_UserPurview_usp_Info FindRole(Sys_UserPurview_usp_Info info)
        {
            Sys_FormMaster_fom_Info formInfo = new Sys_FormMaster_fom_Info();
            if (info.formMasterList != null)
            {
                formInfo = info.formMasterList[0];

                string sqlString = string.Empty;
                sqlString += "SELECT DISTINCT rlm_cRoleID,rlm_cRoleDesc " + Environment.NewLine;
                sqlString += "FROM Sys_RoleMaster_rlm " + Environment.NewLine;
                sqlString += "LEFT JOIN  Sys_UserPurview_usp" + Environment.NewLine;
                sqlString += "ON rlm_cRoleID=usp_cRoleID" + Environment.NewLine;
                sqlString += "LEFT JOIN Sys_FormPurview_frp" + Environment.NewLine;
                sqlString += "ON usp_cPurviewCode=frp_cPurviewCode" + Environment.NewLine;
                sqlString += "LEFT JOIN Sys_FormMaster_fom" + Environment.NewLine;
                sqlString += "ON frp_cFormNumber=fom_cFormNumber WHERE fom_cFormNumber='" + formInfo.fom_cFormNumber + "'";

                IEnumerable<Sys_RoleMaster_rlm_Info> infos = null;
                List<Sys_RoleMaster_rlm_Info> infoList = null;

                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        infos = db.ExecuteQuery<Sys_RoleMaster_rlm_Info>(sqlString, new object[] { });

                        if (infos != null)
                        {
                            infoList = infos.ToList<Sys_RoleMaster_rlm_Info>();
                        }
                        foreach (Sys_RoleMaster_rlm_Info t in infoList)
                        {
                            info.roleMasterList.Add(t);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }

                for (int i = 0; i < info.roleMasterList.Count; i++)
                {
                    sqlString = string.Empty;
                    sqlString += "SELECT DISTINCT fum_cFunctionNumber,fum_cFunctionDesc" + Environment.NewLine;
                    sqlString += "FROM Sys_FunctionMaster_fum" + Environment.NewLine;
                    sqlString += "LEFT JOIN Sys_FormPurview_frp" + Environment.NewLine;
                    sqlString += "ON fum_cFunctionNumber=frp_cFunctionNumber" + Environment.NewLine;

                    sqlString += "LEFT JOIN Sys_FormMaster_fom" + Environment.NewLine;
                    sqlString += "ON fom_cFormNumber=frp_cFormNumber" + Environment.NewLine;

                    sqlString += "LEFT JOIN Sys_UserPurview_usp" + Environment.NewLine;
                    sqlString += "ON frp_cPurviewCode=usp_cPurviewCode" + Environment.NewLine;
                    sqlString += "LEFT JOIN Sys_RoleMaster_rlm" + Environment.NewLine;
                    sqlString += "ON usp_cRoleID=rlm_cRoleID WHERE rlm_cRoleID='" + info.roleMasterList[i].rlm_cRoleID + "' AND fom_cFormNumber='" + formInfo.fom_cFormNumber + "'";
                    IEnumerable<Sys_FunctionMaster_fum_Info> fums = null;
                    List<Sys_FunctionMaster_fum_Info> fumList = null;
                    try
                    {
                        using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                        {
                            fums = db.ExecuteQuery<Sys_FunctionMaster_fum_Info>(sqlString, new object[] { });

                            if (fums != null)
                            {
                                fumList = fums.ToList<Sys_FunctionMaster_fum_Info>();
                            }
                            List<Sys_FunctionMaster_fum_Info> fumList1 = new List<Sys_FunctionMaster_fum_Info>();
                            foreach (Sys_FunctionMaster_fum_Info t in fumList)
                            {
                                fumList1.Add(t);
                                //info.userMasterList[i].functionMasterList.Add(t);
                                //info.userMasterList.Add(t);
                            }
                            info.roleMasterList[i].functionMasterList = fumList1;
                        }
                    }
                    catch (Exception Ex)
                    {
                        throw Ex;
                    }

                }
            }
            return info;
        }

        private Sys_UserPurview_usp_Info FindFunction(Sys_UserPurview_usp_Info info)
        {
            Sys_FormMaster_fom_Info formInfo = new Sys_FormMaster_fom_Info();
            if (info.formMasterList != null)
            {
                formInfo = info.formMasterList[0];

                string sqlString = string.Empty;
                sqlString += "SELECT DISTINCT fum_cFunctionNumber,fum_cFunctionDesc " + Environment.NewLine;
                sqlString += "FROM Sys_FunctionMaster_fum " + Environment.NewLine;
                sqlString += "LEFT JOIN  Sys_FormPurview_frp" + Environment.NewLine;
                sqlString += "ON fum_cFunctionNumber=frp_cFunctionNumber" + Environment.NewLine;
                sqlString += "LEFT JOIN Sys_FormMaster_fom" + Environment.NewLine;
                sqlString += "ON frp_cFormNumber=fom_cFormNumber WHERE fom_cFormNumber='" + formInfo.fom_cFormNumber + "'";

                IEnumerable<Sys_FunctionMaster_fum_Info> infos = null;
                List<Sys_FunctionMaster_fum_Info> infoList = null;

                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        infos = db.ExecuteQuery<Sys_FunctionMaster_fum_Info>(sqlString, new object[] { });

                        if (infos != null)
                        {
                            infoList = infos.ToList<Sys_FunctionMaster_fum_Info>();
                        }
                        foreach (Sys_FunctionMaster_fum_Info t in infoList)
                        {
                            info.functionMasterList.Add(t);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
            return info;
        }

        private Sys_UserPurview_usp_Info FindFormPurview(Sys_UserPurview_usp_Info info)
        {
            Sys_FormMaster_fom_Info formInfo = new Sys_FormMaster_fom_Info();
            if (info.formMasterList != null)
            {
                formInfo = info.formMasterList[0];

                string sqlString = string.Empty;
                sqlString += "SELECT frp_iRecordID, frp_cPurviewCode,frp_cFunctionNumber " + Environment.NewLine;
                sqlString += "FROM Sys_FormPurview_frp " + Environment.NewLine;
                sqlString += "LEFT JOIN  Sys_FormMaster_fom" + Environment.NewLine;
                sqlString += "ON fom_cFormNumber=frp_cFormNumber WHERE fom_cFormNumber='" + formInfo.fom_cFormNumber + "'";

                IEnumerable<Sys_FormPurview_frp_Info> infos = null;
                List<Sys_FormPurview_frp_Info> infoList = null;

                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        infos = db.ExecuteQuery<Sys_FormPurview_frp_Info>(sqlString, new object[] { });

                        if (infos != null)
                        {
                            infoList = infos.ToList<Sys_FormPurview_frp_Info>();
                        }
                        foreach (Sys_FormPurview_frp_Info t in infoList)
                        {
                            info.formPurviewList.Add(t);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
            return info;
        }

        private bool DelUserPurview(Sys_UserPurview_usp_Info info)
        {
            string sqlString = string.Empty;
            sqlString += "SELECT DISTINCT frp_cPurviewCode" + Environment.NewLine;
            sqlString += "FROM Sys_FormPurview_frp" + Environment.NewLine;
            sqlString += "LEFT JOIN Sys_FormMaster_fom" + Environment.NewLine;
            sqlString += "ON frp_cFormNumber=fom_cFormNumber WHERE fom_cFormNumber='" + info.formMasterList[0].fom_cFormNumber + "'" + Environment.NewLine;

            IEnumerable<Sys_FormPurview_frp_Info> frps = null;
            List<Sys_FormPurview_frp_Info> frpList = null;

            IEnumerable<Sys_UserPurview_usp_Info> usps = null;

            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    frps = db.ExecuteQuery<Sys_FormPurview_frp_Info>(sqlString, new object[] { });

                    if (frps != null)
                    {
                        frpList = frps.ToList<Sys_FormPurview_frp_Info>();
                    }
                    for (int i = 0; i < frpList.Count; i++)
                    {
                        sqlString = "delete from Sys_UserPurview_usp where usp_cPurviewCode='" + frpList[i].frp_cPurviewCode + "'";

                        usps = db.ExecuteQuery<Sys_UserPurview_usp_Info>(sqlString, new object[] { });
                    }
                }
                return true;
            }
            catch (Exception Ex)
            {
                //throw Ex;
                return false;
            }
        }

        #region IDataBaseCommandDA<Sys_UserPurview_usp_Info> Members

        public Sys_UserPurview_usp_Info GetRecord_First()
        {
            try
            {

                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    IQueryable<Sys_UserPurview_usp> taQuery =
                        (from ta in db.Sys_UserPurview_usp
                         orderby ta.usp_iRecordID ascending
                         select ta).Take(1);
                    Sys_UserPurview_usp_Info info = new Sys_UserPurview_usp_Info();
                    if (taQuery.Count() > 0)
                    {
                        foreach (var t in taQuery)
                        {
                            info = Common.General.CopyObjectValue<Sys_UserPurview_usp, Sys_UserPurview_usp_Info>(t);
                            FindUser(info);
                            FindRole(info);
                            FindFunction(info);
                        }
                    }
                    return info;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        public Sys_UserPurview_usp_Info GetRecord_Last()
        {
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    IQueryable<Sys_UserPurview_usp> taQuery =
                        (from ta in db.Sys_UserPurview_usp
                         orderby ta.usp_iRecordID descending
                         select ta).Take(1);
                    Sys_UserPurview_usp_Info info = new Sys_UserPurview_usp_Info();
                    if (taQuery.Count() > 0)
                    {
                        foreach (var t in taQuery)
                        {
                            info = Common.General.CopyObjectValue<Sys_UserPurview_usp, Sys_UserPurview_usp_Info>(t);
                            FindUser(info);
                            FindRole(info);
                            FindFunction(info);
                        }
                    }
                    return info;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }

        public Sys_UserPurview_usp_Info GetRecord_Previous(Model.Base.DataBaseCommandInfo commandInfo)
        {
            Sys_UserPurview_usp_Info info = null;
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    string iRecordId = string.Empty;
                    foreach (var id in commandInfo.KeyInfoList)
                    {
                        iRecordId = id.KeyValue;
                        break;
                    }
                    IQueryable<Sys_UserPurview_usp> taQuery =
                        (from ta in db.Sys_UserPurview_usp
                         where ta.usp_iRecordID < Convert.ToInt32(iRecordId)
                         orderby ta.usp_iRecordID descending
                         select ta).Take(1);

                    if (taQuery.Count() > 0)
                    {
                        foreach (var t in taQuery)
                        {
                            info = Common.General.CopyObjectValue<Sys_UserPurview_usp, Sys_UserPurview_usp_Info>(t);
                            FindUser(info);
                            FindRole(info);
                            FindFunction(info);
                        }
                    }
                    return info;
                }
            }
            catch (Exception Ex)
            {
                return info;
            }
        }

        public Sys_UserPurview_usp_Info GetRecord_Next(Model.Base.DataBaseCommandInfo commandInfo)
        {
            Sys_UserPurview_usp_Info info = null;
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    string iRecordId = string.Empty;
                    foreach (var id in commandInfo.KeyInfoList)
                    {
                        iRecordId = id.KeyValue;
                        break;
                    }
                    IQueryable<Sys_UserPurview_usp> taQuery =
                        (from ta in db.Sys_UserPurview_usp
                         where ta.usp_iRecordID > Convert.ToInt32(iRecordId)
                         orderby ta.usp_iRecordID ascending
                         select ta).Take(1);
                    if (taQuery.Count() > 0)
                    {
                        foreach (var t in taQuery)
                        {
                            info = Common.General.CopyObjectValue<Sys_UserPurview_usp, Sys_UserPurview_usp_Info>(t);
                            FindUser(info);
                            FindRole(info);
                            FindFunction(info);
                        }
                    }
                    return info;
                }
            }
            catch (Exception Ex)
            {
                return info;
            }
        }

        #endregion

        #region IExtraDA Members

        public bool IsExistRecord(object KeyObject)
        {
            throw new NotImplementedException();
        }

        public Model.General.ReturnValueInfo LockRecord(object KeyObject)
        {
            throw new NotImplementedException();
        }

        public Model.General.ReturnValueInfo UnLockRecord(object KeyObject)
        {
            throw new NotImplementedException();
        }

        public bool IsMyLockedRecord(object KeyObject)
        {
            throw new NotImplementedException();
        }

        public Model.IModel.IModelObject GetTableFieldLenght()
        {
            LocalGeneral general = new LocalGeneral();
            Sys_UserPurview_usp_Info info = null;

            try
            {
                info = general.GetTableFieldLenght<Sys_UserPurview_usp_Info>("Sys_UserPurview_usp");
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return info;
        }

        #endregion

        #region IMainDA<Sys_UserPurview_usp_Info> Members

        public bool InsertRecord(Sys_UserPurview_usp_Info infoObject)
        {
            Sys_UserPurview_usp_Info uspInfo = new Sys_UserPurview_usp_Info();
            Sys_FormMaster_fom_Info formInfo = new Sys_FormMaster_fom_Info();
            Sys_UserMaster_usm_Info userInfo = null;
            Sys_RoleMaster_rlm_Info roleInfo = null;
            using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
            {
                try
                {
                    formInfo = infoObject.formMasterList[0];
                    DelUserPurview(infoObject);
                    for (int i = 0; i < infoObject.userMasterList.Count; i++)
                    {
                        for (int j = 0; j < infoObject.userMasterList[i].functionMasterList.Count; j++)
                        {
                            Sys_UserPurview_usp uspUser = new Sys_UserPurview_usp();
                            uspUser = Common.General.CopyObjectValue<Sys_UserPurview_usp_Info, Sys_UserPurview_usp>(infoObject);
                            userInfo = new Sys_UserMaster_usm_Info();
                            userInfo = infoObject.userMasterList[i];
                            uspUser.usp_cUserLoginID = userInfo.usm_cUserLoginID;

                            uspUser.usp_cPurviewCode = infoObject.userMasterList[i].functionMasterList[j].fum_cFunctionNumber + formInfo.fom_cFormNumber;
                            uspUser.usp_cAdd = infoObject.usp_cAdd;
                            uspUser.usp_cLast = infoObject.usp_cLast;
                            uspUser.usp_dAddDate = infoObject.usp_dAddDate.Value;
                            uspUser.usp_dLastDate = infoObject.usp_dLastDate.Value;

                            db.Sys_UserPurview_usp.InsertOnSubmit(uspUser);

                        }
                    }
                    for (int i = 0; i < infoObject.roleMasterList.Count; i++)
                    {
                        for (int j = 0; j < infoObject.roleMasterList[i].functionMasterList.Count; j++)
                        {
                            Sys_UserPurview_usp uspUser = new Sys_UserPurview_usp();
                            uspUser = Common.General.CopyObjectValue<Sys_UserPurview_usp_Info, Sys_UserPurview_usp>(infoObject);
                            roleInfo = new Sys_RoleMaster_rlm_Info();
                            roleInfo = infoObject.roleMasterList[i];
                            uspUser.usp_cRoleID = roleInfo.rlm_cRoleID;

                            uspUser.usp_cPurviewCode = infoObject.roleMasterList[i].functionMasterList[j].fum_cFunctionNumber + formInfo.fom_cFormNumber;
                            uspUser.usp_cAdd = infoObject.usp_cAdd;
                            uspUser.usp_cLast = infoObject.usp_cLast;
                            uspUser.usp_dAddDate = infoObject.usp_dAddDate.Value;
                            uspUser.usp_dLastDate = infoObject.usp_dLastDate.Value;

                            db.Sys_UserPurview_usp.InsertOnSubmit(uspUser);

                        }
                    }
                    db.SubmitChanges();
                    return true;
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }

        public bool UpdateRecord(Sys_UserPurview_usp_Info infoObject)
        {
            throw new NotImplementedException();
        }

        public bool DeleteRecord(Model.IModel.IModelObject KeyObject)
        {
            throw new NotImplementedException();
        }

        public Sys_UserPurview_usp_Info DisplayRecord(Model.IModel.IModelObject KeyObject)
        {
            Sys_UserPurview_usp_Info usp = new Sys_UserPurview_usp_Info();
            usp = KeyObject as Sys_UserPurview_usp_Info;

            FindUser(usp);
            FindRole(usp);
            FindFunction(usp);
            return usp;
        }

        public List<Sys_UserPurview_usp_Info> SearchRecords(Model.IModel.IModelObject searchCondition)
        {
            Sys_UserPurview_usp_Info usp = new Sys_UserPurview_usp_Info();
            List<Sys_UserPurview_usp_Info> uspInfo = new List<Sys_UserPurview_usp_Info>();
            usp = searchCondition as Sys_UserPurview_usp_Info;

            FindFunctionByUR(usp);
            uspInfo.Add(usp);
            return uspInfo;
        }

        #endregion

        private Sys_UserPurview_usp_Info FindFunctionByUR(Sys_UserPurview_usp_Info info)
        {
            string temp = string.Empty;
            Sys_FormMaster_fom_Info formInfo = new Sys_FormMaster_fom_Info();
            if (info.formMasterList != null)
            {
                formInfo = info.formMasterList[0];
                if (info.roleMasterList[0].rlm_cRoleID != "")
                    temp = info.roleMasterList[0].rlm_cRoleID.ToString();
                else
                    temp = info.userMasterList[0].usm_cUserLoginID.ToString();

                string sqlString = string.Empty;
                sqlString += "SELECT DISTINCT fum_cFunctionNumber,fum_cFunctionDesc " + Environment.NewLine;
                sqlString += "FROM Sys_FunctionMaster_fum " + Environment.NewLine;
                sqlString += "LEFT JOIN  Sys_FormPurview_frp" + Environment.NewLine;
                sqlString += "ON fum_cFunctionNumber=frp_cFunctionNumber" + Environment.NewLine;

                sqlString += "LEFT JOIN  Sys_UserPurview_usp" + Environment.NewLine;
                sqlString += "ON usp_cPurviewCode=frp_cPurviewCode" + Environment.NewLine;

                sqlString += "LEFT JOIN Sys_FormMaster_fom" + Environment.NewLine;
                if (info.roleMasterList[0].rlm_cRoleID != "")
                    sqlString += "ON frp_cFormNumber=fom_cFormNumber WHERE fom_cFormNumber='" + formInfo.fom_cFormNumber + "' AND rlm_cRoleID='" + temp + "'";
                else
                    sqlString += "ON frp_cFormNumber=fom_cFormNumber WHERE fom_cFormNumber='" + formInfo.fom_cFormNumber + "' AND usp_cUserLoginID='" + temp + "'";

                IEnumerable<Sys_FunctionMaster_fum_Info> infos = null;
                List<Sys_FunctionMaster_fum_Info> infoList = null;

                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        infos = db.ExecuteQuery<Sys_FunctionMaster_fum_Info>(sqlString, new object[] { });

                        if (infos != null)
                        {
                            infoList = infos.ToList<Sys_FunctionMaster_fum_Info>();
                        }
                        foreach (Sys_FunctionMaster_fum_Info t in infoList)
                        {
                            info.functionMasterList.Add(t);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
            return info;
        }

        #region IUserPurviewDA Members

        List<Sys_UserPurview_usp_Info> IUserPurviewDA.GetFormPurview(Sys_UserPurview_usp_Info query)
        {
            List<Sys_UserPurview_usp_Info> returnList = null;

            if (query != null)
            {
                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        IEnumerable<Sys_UserPurview_usp> allInfo = from t in db.Sys_UserPurview_usp
                                                                   where t.usp_iFormID == query.usp_iFormID
                                                                   select t;

                        if (allInfo != null && allInfo.Count() > 0)
                        {
                            returnList = new List<Sys_UserPurview_usp_Info>();

                            foreach (Sys_UserPurview_usp item in allInfo)
                            {
                                Sys_UserPurview_usp_Info info = Common.General.CopyObjectValue<Sys_UserPurview_usp, Sys_UserPurview_usp_Info>(item);

                                info.userMasterList = new List<Sys_UserMaster_usm_Info>();

                                info.roleMasterList = new List<Sys_RoleMaster_rlm_Info>();

                                if (info.usp_cUserLoginID != "")
                                {
                                    Sys_UserMaster_usm userData = db.Sys_UserMaster_usm.FirstOrDefault(t => t.usm_cUserLoginID == info.usp_cUserLoginID);

                                    if (userData != null)
                                    {
                                        Sys_UserMaster_usm_Info userInfo = Common.General.CopyObjectValue<Sys_UserMaster_usm, Sys_UserMaster_usm_Info>(userData);

                                        info.userMasterList.Add(userInfo);
                                    }
                                }

                                if (info.usp_cRoleID != "")
                                {
                                    Sys_RoleMaster_rlm roleData = db.Sys_RoleMaster_rlm.FirstOrDefault(t => t.rlm_cRoleID == info.usp_cRoleID);

                                    if (roleData != null)
                                    {
                                        Sys_RoleMaster_rlm_Info roleInfo = Common.General.CopyObjectValue<Sys_RoleMaster_rlm, Sys_RoleMaster_rlm_Info>(roleData);

                                        info.roleMasterList.Add(roleInfo);
                                    }
                                }

                                returnList.Add(info);
                            }
                        }
                    }
                }
                catch (Exception Ex)
                {

                    throw Ex;
                }
            }

            return returnList;
        }

        ReturnValueInfo IUserPurviewDA.SavePruview(List<Sys_UserPurview_usp_Info> userAndRoleInfo, int formID)
        {
            ReturnValueInfo returnValue = new ReturnValueInfo(false);

            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {

                    db.Connection.Open();

                    db.Transaction = db.Connection.BeginTransaction();

                    Sys_UserPurview_usp_Info info = new Sys_UserPurview_usp_Info();

                    info.usp_iFormID = formID;

                    IEnumerable<Sys_UserPurview_usp> deleteData = from t in db.Sys_UserPurview_usp
                                                                  where t.usp_iFormID == info.usp_iFormID
                                                                  select t;

                    if (deleteData != null)
                    {
                        db.Sys_UserPurview_usp.DeleteAllOnSubmit(deleteData);
                    }

                    if (userAndRoleInfo != null && userAndRoleInfo.Count > 0)
                    {
                        foreach (Sys_UserPurview_usp_Info item in userAndRoleInfo)
                        {
                            Sys_UserPurview_usp insertData = Common.General.CopyObjectValue<Sys_UserPurview_usp_Info, Sys_UserPurview_usp>(item);

                            db.Sys_UserPurview_usp.InsertOnSubmit(insertData);
                        }
                    }

                    try
                    {
                        db.SubmitChanges();

                        db.Transaction.Commit();

                        db.Connection.Close();

                        returnValue.boolValue = true;
                    }
                    catch (Exception Ex)
                    {

                        db.Transaction.Rollback();

                        returnValue.messageText = Ex.Message;
                    }
                }
            }
            catch (Exception Ex)
            {

                returnValue.messageText = Ex.Message;
            }

            return returnValue;
        }

        #endregion

        #region IDataBaseCommandDA<Sys_UserPurview_usp_Info> Members

        Sys_UserPurview_usp_Info DAL.IDAL.IDataBaseCommandDA<Sys_UserPurview_usp_Info>.GetRecord_First()
        {
            throw new NotImplementedException();
        }

        Sys_UserPurview_usp_Info DAL.IDAL.IDataBaseCommandDA<Sys_UserPurview_usp_Info>.GetRecord_Last()
        {
            throw new NotImplementedException();
        }

        Sys_UserPurview_usp_Info DAL.IDAL.IDataBaseCommandDA<Sys_UserPurview_usp_Info>.GetRecord_Previous(Model.Base.DataBaseCommandInfo commandInfo)
        {
            throw new NotImplementedException();
        }

        Sys_UserPurview_usp_Info DAL.IDAL.IDataBaseCommandDA<Sys_UserPurview_usp_Info>.GetRecord_Next(Model.Base.DataBaseCommandInfo commandInfo)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IExtraDA Members

        bool DAL.IDAL.IExtraDA.IsExistRecord(object KeyObject)
        {
            throw new NotImplementedException();
        }

        ReturnValueInfo DAL.IDAL.IExtraDA.LockRecord(object KeyObject)
        {
            throw new NotImplementedException();
        }

        ReturnValueInfo DAL.IDAL.IExtraDA.UnLockRecord(object KeyObject)
        {
            throw new NotImplementedException();
        }

        bool DAL.IDAL.IExtraDA.IsMyLockedRecord(object KeyObject)
        {
            throw new NotImplementedException();
        }

        Model.IModel.IModelObject DAL.IDAL.IExtraDA.GetTableFieldLenght()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IMainDA<Sys_UserPurview_usp_Info> Members

        bool DAL.IDAL.IMainDA<Sys_UserPurview_usp_Info>.InsertRecord(Sys_UserPurview_usp_Info infoObject)
        {
            throw new NotImplementedException();
        }

        bool DAL.IDAL.IMainDA<Sys_UserPurview_usp_Info>.UpdateRecord(Sys_UserPurview_usp_Info infoObject)
        {
            throw new NotImplementedException();
        }

        bool DAL.IDAL.IMainDA<Sys_UserPurview_usp_Info>.DeleteRecord(Model.IModel.IModelObject KeyObject)
        {
            throw new NotImplementedException();
        }

        Sys_UserPurview_usp_Info DAL.IDAL.IMainDA<Sys_UserPurview_usp_Info>.DisplayRecord(Model.IModel.IModelObject KeyObject)
        {
            throw new NotImplementedException();
        }

        List<Sys_UserPurview_usp_Info> DAL.IDAL.IMainDA<Sys_UserPurview_usp_Info>.SearchRecords(Model.IModel.IModelObject searchCondition)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IUserPurviewDA Members

        public List<Sys_UserAndRoleGeneral_Info> SearchUserAndRole(Sys_UserAndRoleGeneral_Info query)
        {
            List<Sys_UserAndRoleGeneral_Info> returnList = new List<Sys_UserAndRoleGeneral_Info>();

            if (query != null)
            {
                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        IEnumerable<Sys_UserMaster_usm> users = db.Sys_UserMaster_usm.Where(t => t.usm_cChaName.Contains(query.searchKey) || t.usm_cUserLoginID.Contains(query.searchKey));

                        if (users != null && users.Count() > 0)
                        {
                            foreach (Sys_UserMaster_usm item in users)
                            {
                                Sys_UserAndRoleGeneral_Info info = new Sys_UserAndRoleGeneral_Info();

                                info.recordID = item.usm_iRecordID;

                                info.stringID = item.usm_cUserLoginID;

                                info.remark = item.usm_cChaName;

                                info.accountCType = Sys_UserAndRoleGeneral_Info.accountType.userID;

                                info.accountTypeName = "用户";

                                returnList.Add(info);
                            }
                        }

                        IEnumerable<Sys_RoleMaster_rlm> roles = db.Sys_RoleMaster_rlm.Where(t => t.rlm_cRoleDesc.Contains(query.searchKey) || t.rlm_cRoleID.Contains(query.searchKey));

                        if (roles != null && roles.Count() > 0)
                        {
                            foreach (Sys_RoleMaster_rlm item in roles)
                            {
                                Sys_UserAndRoleGeneral_Info info = new Sys_UserAndRoleGeneral_Info();

                                info.recordID = item.rlm_iRecordID;

                                info.stringID = item.rlm_cRoleID;

                                info.remark = item.rlm_cRoleDesc;

                                info.accountCType = Sys_UserAndRoleGeneral_Info.accountType.roleID;

                                info.accountTypeName = "角色";

                                returnList.Add(info);
                            }
                        }
                    }
                }
                catch (Exception Ex)
                {

                    throw Ex;
                }
            }

            return returnList;
        }

        public ReturnValueInfo SavePruview(List<Sys_UserPurview_usp_Info> userAndRoleInfo, string objID, Sys_UserAndRoleGeneral_Info.accountType typeID)
        {
            ReturnValueInfo returnInfo = new ReturnValueInfo(false);

            if (userAndRoleInfo != null)
            {
                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        db.Connection.Open();

                        db.Transaction = db.Connection.BeginTransaction();

                        try
                        {
                            IEnumerable<Sys_UserPurview_usp> delteData = null;
                            if (typeID == Sys_UserAndRoleGeneral_Info.accountType.userID)
                            {
                                delteData = from t in db.Sys_UserPurview_usp
                                            where t.usp_cUserLoginID == objID
                                            select t;

                            }
                            else
                            {
                                delteData = from t in db.Sys_UserPurview_usp
                                            where t.usp_cRoleID == objID
                                            select t;
                            }

                            if (delteData != null && delteData.Count() > 0)
                            {
                                db.Sys_UserPurview_usp.DeleteAllOnSubmit(delteData);
                            }

                            foreach (Sys_UserPurview_usp_Info item in userAndRoleInfo)
                            {
                                Sys_UserPurview_usp insertData = Common.General.CopyObjectValue<Sys_UserPurview_usp_Info, Sys_UserPurview_usp>(item);

                                db.Sys_UserPurview_usp.InsertOnSubmit(insertData);
                            }

                            db.SubmitChanges();

                            db.Transaction.Commit();

                            db.Connection.Close();

                            returnInfo.boolValue = true;

                        }
                        catch (Exception Ex)
                        {

                            db.Transaction.Rollback();

                            db.Connection.Close();

                            returnInfo.messageText = Ex.Message;
                        }
                    }
                }
                catch (Exception Ex)
                {

                    returnInfo.messageText = Ex.Message;
                }
            }

            return returnInfo;
        }

        public List<Sys_UserPurview_usp_Info> GetUserOrRolePurview(Sys_UserPurview_usp_Info query)
        {
            List<Sys_UserPurview_usp_Info> returnList = null;

            if (query != null)
            {
                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        IEnumerable<Sys_UserPurview_usp> result = null;

                        if (query.usp_cUserLoginID != "")
                        {
                            result = from t in db.Sys_UserPurview_usp
                                     where t.usp_cUserLoginID == query.usp_cUserLoginID
                                     select t;
                        }
                        else
                        {
                            result = from t in db.Sys_UserPurview_usp
                                     where t.usp_cRoleID == query.usp_cRoleID
                                     select t;
                        }

                        if (result != null && result.Count() > 0)
                        {
                            returnList = new List<Sys_UserPurview_usp_Info>();

                            foreach (Sys_UserPurview_usp item in result)
                            {
                                Sys_UserPurview_usp_Info info = Common.General.CopyObjectValue<Sys_UserPurview_usp, Sys_UserPurview_usp_Info>(item);

                                returnList.Add(info);
                            }
                        }
                    }
                }
                catch (Exception Ex)
                {

                    throw Ex;
                }
            }

            return returnList;
        }

        #endregion
    }
}


text:
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {
  MaterialModule,MdTableModule,MdPaginator,MdProgressSpinner
} from '@angular/material'
import {Component,OnInit,ElementRef, ViewChild,Injectable,NgModule} from '@angular/core';
import {DataSource,CdkTableModule} from '@angular/cdk';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/startWith';
import 'rxjs/add/observable/merge';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/observable/fromEvent';
import {DialogsService} from './dialog.service';
import {UserDataService} from '../misc/services'
import {AF} from '../login/authfire'

var showSpinner = false;

@Component({
  selector: 'app-repositories',
  templateUrl: './repositories.component.html',
  styleUrls: ['./repositories.component.scss']
})
export class RepositoriesComponent implements OnInit {
  displayedColumns = ['repoName', 'openIssues', 'latestIssue'];
  repoDatabase = new RepoDatabase();
  dataSource: RepoDataSource | null;
  @ViewChild(MdPaginator) paginator: MdPaginator;
  @ViewChild('filter') filter: ElementRef;

  constructor (
    private afService: AF,
    private dialogsService: DialogsService
  ) {}

  ngOnInit() {
    this.dataSource = new RepoDataSource(this.repoDatabase, this.paginator);
    Observable.fromEvent(this.filter.nativeElement, 'keyup')
    .debounceTime(150)
    .distinctUntilChanged()
    .subscribe(() => {
      if (!this.dataSource) { return; }
      this.dataSource.filter = this.filter.nativeElement.value;
    });

    this.afService.user.subscribe(
      (user) => {
        if(user != null) {
          user.getIdToken().then(token=>{
            this.repoDatabase.populate(token)
          });
        }
      });
  }

  showLoader(){return showSpinner}

  public openAddDialog() {
    this.dialogsService
      .add()
      .subscribe((data)=>{
       if (data){
          showSpinner = true;
          this.afService.user.subscribe(
            (user) => {
              if(user != null) {
                user.getIdToken().then(token=>{
                  this.repoDatabase.subscribe(token,data)
                });
              }
            });
        }
      });
  }
  public openSettingsDialog(repo: string) {
    this.dialogsService
      .settings(repo)
      .subscribe((data)=>{
       if (data){
          this.afService.user.subscribe(
            (user) => {
              if(user != null) {
                user.getIdToken().then(token=>{
                    // Call Update subsciption here
                    this.repoDatabase.updatePreference(token,repo,data)
                });
              }
            });
        }
      });
  }
  public removeRepo(index: number,name: string) {
    this.afService.user.subscribe(
      (user) => {
        if(user != null) {
          user.getIdToken().then(token=>{
            this.repoDatabase.removeRepo(token,index,name)
          });
        }
      });

  }
}

export interface RepoData {
  index: number;
  name: string;
  openIssues: number;
  lastUpdate: number;
  url: string;
}

/** The database that the data source uses to retrieve data for the table. */
export class RepoDatabase {
  /** Stream that emits whenever the data has been modified. */
  dataChange: BehaviorSubject<RepoData[]> = new BehaviorSubject<RepoData[]>([]);
  get data(): RepoData[] { return this.dataChange.value; }

  constructor() {}

  populate(token: string)
  {
    showSpinner = true;
    var result = fetch('/api/users/repos',{
      method:'GET',
      headers:{
        'Authorization': token
      }
    }).then((response)=>{
        showSpinner = false;
        return response.json()
    },(err)=>{console.log(err); showSpinner = false;}).then((json)=>{
        // Populate RepoDatabase
        json.forEach(repo => {
          if(this.exists(repo["Name"])==false){
            this.addRepo(repo["Name"],repo["IssuesOpen"],repo["UpdatedAt"])
        }
      });
      showSpinner = false;
    }).catch((err)=>{console.log(err); showSpinner = false;});
  }

  subscribe(token: string, data)
  {
    var formData = new FormData()
    formData.append("repo",data["repo"]);
    // Make an API call to subscribe to the repository
    var result = fetch('/api/subscriptions/add',{
      method:'POST',
      headers:{
        'Authorization': token
      },
      body:formData
    }).then((response)=>{
        return response.json()
    },(err)=>{console.log(err)}).then((json)=>{
      if(!json["Code"]){
        this.populate(token)
      }
    });

  }
  updatePreference(token: string,repo: string, data)
  {
    var formData = new FormData();
    formData.append("repo",repo);
    formData.append("defaultEmail",data["email"]);
    formData.append("settings",JSON.stringify(data["settings"]));
    // Make an API call to update notification preferences
    var result = fetch('/api/subscriptions/update',{
      method:'POST',
      headers:{
        'Authorization': token
      },
      body:formData
    }).then((response)=>{
        return response.json();
    },(err)=>{console.log(err)}).then((json)=>{
      if(!json["Code"]){
        this.populate(token);
      }
    });
  }

  /** Adds a new repo to the database. */
  addRepo(repo: string,open: number,lastUpdate: string) {
    const copiedData = this.data.slice();
    copiedData.push(this.createNewRepo(repo,open,lastUpdate));
    this.dataChange.next(copiedData);
  }

  /** Removes repo from the database. */
  removeRepo(token: string,repoIndex: number, repoName: string) {
    let pos = this.data.findIndex((value,index,obj)=>{
      if(value.index == repoIndex)
        return true;
      return false;
    })
    if (pos != -1){
      var formData = new FormData();
      formData.append("repo",repoName);
      // Make an API call to subscribe to the repository
      var result = fetch('/api/subscriptions/remove',{
        method:'POST',
        headers:{
          'Authorization': token
        },
        body:formData
      }).then((response)=>{
        return response.json();
      },(err)=>{console.log(err)}).then((json)=>{
        if(json["Code"] == 200){
          const copiedData = this.data.slice();
          copiedData.splice(pos,1);
          this.dataChange.next(copiedData)
        }
      });
    }

  }

  exists(repo: string){
   let pos =  this.data.findIndex((value,index,obj)=>{
      if(value.name == repo)
        return true;
      return false;
    })
    if (pos == -1)
      return false;
    else{
      return true;
    }

  }
  /** Builds and returns a new repo. */
  private createNewRepo(repo: string,open: number,lastUpdate: string) {
    var currentDate = new Date();
    var updateDate = new Date(lastUpdate);
    // get the difference between the dates in milliseconds and divide by 3600000
    var difference=Math.abs(updateDate.getTime()-currentDate.getTime()) / 36e5;
    difference = Math.trunc(difference)
    return {
      index: (this.data.length + 1),
      name: repo,
      openIssues: open,
      lastUpdate: difference,
      url: "https://github.com/"+repo+"/issues"
    };
  }
}

/**
* Data source to provide what data should be rendered in the table. Note that the data source
* can retrieve its data in any way. In this case, the data source is provided a reference
* to a common data base, RepoDatabase. It is not the data source's responsibility to manage
* the underlying data. Instead, it only needs to take the data and send the table exactly what
* should be rendered.
*/
export class RepoDataSource extends DataSource<any> {
  _filterChange = new BehaviorSubject('');
  get filter(): string { return this._filterChange.value; }
  set filter(filter: string) { this._filterChange.next(filter); }

  constructor(private _repoDatabase: RepoDatabase, private _paginator: MdPaginator) {
    super();
  }

  /** Connect function called by the table to retrieve one stream containing the data to render. */
  connect(): Observable<RepoData[]> {
    const displayDataChanges = [
      this._repoDatabase.dataChange,
      this._paginator.page,
      this._filterChange,
    ];

    return Observable.merge(...displayDataChanges).map(() => {
      const data = this._repoDatabase.data.slice().filter((item: RepoData) => {
        let searchStr = (item.name).toLowerCase();
        return searchStr.indexOf(this.filter.toLowerCase()) != -1;
      });

      // Grab the page's slice of data.
      const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
      return data.splice(startIndex, this._paginator.pageSize);
    });
  }

  disconnect() {}
}


text:
from cms.models import CMSPlugin
from datetime import timedelta
from django.core.validators import MaxValueValidator
from django.db import models
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from member.models import Member

class BirthdaysPluginModel(CMSPlugin):
	# following http://docs.django-cms.org/en/latest/introduction/plugins.html
	caption = models.CharField(max_length=32, default=_('Happy birthday to...'))
	max_days = models.PositiveSmallIntegerField(default=7, blank=True, null=True, validators=[MaxValueValidator(365)])
	max_entries = models.PositiveSmallIntegerField(default=None, blank=True, null=True)

	def birthdays(self):
		return Member.objects.filter( #todo how to query this for every year?
			birthday__gt=now(),
			birthday__lt=now()+timedelta(self.max_days)
		).order_by('birthday', 'first_name')[:self.max_entries]


text:
package com.nuevapartida.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JTable;

import org.apache.log4j.Logger;

import com.nuevapartida.mysql.dao.ItemDAO;
import com.nuevapartida.mysql.dto.ItemDTO;
import com.nuevapartida.tools.Processing;
import com.nuevapartida.utils.DBUtils;

public class GameManagerActionListener implements ActionListener {
	private static Logger logger = Logger.getLogger(GameManagerActionListener.class);

	public static enum Action {
		MERGE, DELETE, NEW, PUBLISH, REPROCESS
	};

	private JTable table;
	private GameManagerTableModel model;
	private String type;
	private Action action;

	public GameManagerActionListener(JTable table, String type, Action action) {
		this.table = table;
		model = (GameManagerTableModel) table.getModel();
		this.type = type;
		this.action = action;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		Thread thread = new Thread() {
			public void run() {
				int[] rows = null;
				switch (action) {
				case DELETE:
					rows = table.getSelectedRows();
					if (rows.length > 0) {
						for (int row : rows) {
							row = table.convertRowIndexToModel(row);
							ItemDTO game = model.getItem(row);
							if (game.getStatus().equals("publicado")) {
								game.setStatus("borrado");
								ItemDAO.update(game);
							}
							List<ItemDTO> versions = ItemDAO.getChildren(game
									.getId());
							for (ItemDTO version : versions) {
								if (version.getStatus().equals("publicado")) {
									version.setStatus("borrado");
									ItemDAO.update(version);
								}
								List<ItemDTO> editions = ItemDAO
										.getChildren(version.getId());
								for (ItemDTO edition : editions) {
									if (edition.getStatus().equals("publicado")) {
										edition.setStatus("borrado");
										ItemDAO.update(edition);
									}
								}
							}
						}
						table.clearSelection();
						model.refresh();
					}
					break;

				case PUBLISH:
					rows = table.getSelectedRows();
					if (rows.length > 0) {
						for (int row : rows) {
							row = table.convertRowIndexToModel(row);
							ItemDTO game = model.getItem(row);
							if (game.getStatus().equals("borrado")) {
								game.setStatus("publicado");
								ItemDAO.update(game);
							}
							List<ItemDTO> versions = ItemDAO.getChildren(game
									.getId());
							for (ItemDTO version : versions) {
								if (version.getStatus().equals("borrado")) {
									version.setStatus("publicado");
									ItemDAO.update(version);
								}
								List<ItemDTO> editions = ItemDAO
										.getChildren(version.getId());
								for (ItemDTO edition : editions) {
									if (edition.getStatus().equals("borrado")) {
										edition.setStatus("publicado");
										ItemDAO.update(edition);
									}
								}
							}
						}
						table.clearSelection();
						model.refresh();
					}
					break;

				case MERGE:
					rows = table.getSelectedRows();
					if (rows.length > 1) {
						List<Long> mixGamesIds = new ArrayList<Long>();
						for (int row : rows) {
							row = table.convertRowIndexToModel(row);
							mixGamesIds.add(model.getItem(row).getId());
						}
						DBUtils.mixGames(mixGamesIds);
						table.clearSelection();
						model.refresh();
					}
					break;

				case REPROCESS:
					rows = table.getSelectedRows();
					if (rows.length > 0) {
						for (int row : rows) {
							row = table.convertRowIndexToModel(row);
							Processing.checkGame(model.getItem(row));
						}
						table.clearSelection();
						model.refresh();
					}
					break;

				case NEW:
					if (type.equals("Juegos")) {
						new GameManagerGameWindow(null);
					} else if (type.equals("Sagas")) {
						new GameManagerSagaWindow(null);
					} else if (type.equals("Compañías")) {
						new GameManagerCompanyWindow(null);
					} else {
						logger.error("Acción no implementada");
					}
					break;

				default:
					logger.error("Acción no implementada");
					break;
				}

			}
		};
		thread.start();
	}

}


text:
"""
:Copyright: 2014-2022 Jochen Kupperschmidt
:License: Revised BSD (see `LICENSE` file for details)
"""

from byceps.services.seating import seat_service
from byceps.services.seating.transfer.models import SeatUtilization

def test_aggregate_seat_utilizations():
    sus = [
        SeatUtilization(occupied=23, total=60),
        SeatUtilization(occupied=0, total=50),
        SeatUtilization(occupied=42, total=80),
    ]

    expected = SeatUtilization(occupied=65, total=190)

    assert seat_service.aggregate_seat_utilizations(sus) == expected


text:
<!--
  Generated template for the Alert page.

  See http://ionicframework.com/docs/components/#navigation for more info on
  Ionic pages and navigation.
-->
<ion-header>

  <ion-navbar>
    <ion-title>Página de Alertas</ion-title>
  </ion-navbar>

</ion-header>

<ion-content padding>
  <p> Olá {{ user }}</p>
  <button ion-button (click)="showAlert()">Exibir alerta</button>
</ion-content>