Example #1
0
 internal static DataSource getSrc(SiteTable t, string id)
 {
     // Need to clone a new source for test suites that might change the
     // properties.
     DataSource theSource = new DataSource();
     DataSource result = new DataSource();
     result.Modality = "HIS";
     result.Port = theSource.Port;
     result.Protocol = theSource.Protocol;
     result.SiteId = new SiteId(id);
     result.Provider = theSource.Provider;
     return result;
 }
        public QueryThreadPool(int connectionPoolSize, int cxnRefreshTime, 
            AbstractAccount account, AbstractCredentials creds, SiteTable siteTable, IList<Site> cxnSites)
        {
            MaxActiveConnections = connectionPoolSize;
            _cxnRefreshTime = cxnRefreshTime;
            _account = account;
            _credentials = creds;
            _siteTable = siteTable;
            _poolSites = cxnSites;

            _queue = new QueryThreadPoolQueue();
            _queue.Changed += new EventHandler(QueueChanged);

            //start();
            //startAsync();
        }
Example #3
0
    	/// <summary>Adds sites to the available sites.</summary>
    	/// <param name="additionalSites">Sites to add.</param>
		public void AddSites(IEnumerable<Site> additionalSites)
        {
			var previous = sites;
			sites = previous.Add(additionalSites);

			var args = new SitesChangedEventArgs();
			args.PreviousDefault = previous.DefaultSite;
			args.PreviousSites = previous.Sites;
			args.CurrentDefault = sites.DefaultSite;
			args.CurrentSites = sites.Sites;
			
			if (SitesChanged != null)
				SitesChanged.Invoke(this, args);
		}
Example #4
0
		public Host(IWebContext context, Site defaultSite)
		{
			this.context = context;
			this.sites = new SiteTable(defaultSite, Enumerable.Empty<Site>());
		}
Example #5
0
    	/// <summary>Replaces the site list with new sites.</summary>
		/// <param name="newDefaultSite">The default site to use.</param>
    	/// <param name="newSites">The new site list.</param>
    	public void ReplaceSites(Site newDefaultSite, IEnumerable<Site> newSites)
        {
            if(newSites == null) throw new ArgumentNullException("newSites");

			var previous = sites;
			sites = new SiteTable(newDefaultSite, newSites);

			var args = new SitesChangedEventArgs();
			args.PreviousDefault = previous.DefaultSite;
			args.PreviousSites = previous.Sites;
			args.CurrentDefault = sites.DefaultSite;
			args.CurrentSites = sites.Sites;

			if (SitesChanged != null)
			{
				SitesChanged.Invoke(this, args);
			}
		}
Example #6
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!IsEdit && ChkField)
            {
                Alert(Label1, "字段已经存在!", "line1px_2");
            }
            else
            {
                Int32 _length = 0;
                Int32.TryParse(@Length.Text, out _length);
                @Length.Text = _length.ToString();

                Int32 _columns = 1;
                Int32.TryParse(RepeatColumns.Text, out _columns);
                RepeatColumns.Text = _columns.ToString();

                String sql            = String.Empty;
                Int32  _datatypevalue = Convert.ToInt32(Enum.Parse(db.dbType, @DataType.SelectedValue, true));
                DataTypeValue.Value = _datatypevalue.ToString();
                if (IsEdit)
                {
                    CurrentField = CurrentFields.Find(a => { return(a.ID == EditID); });

                    #region 检查数据库改动

                    if (isVirtual.SelectedIndex == 1)
                    {
                        //类型类型改动
                        sql = String.Format("ALTER TABLE {0} ALTER COLUMN {1} {2}", CurrentTable.TableName, CurrentField.FieldName, @DataType.SelectedValue);
                        if (CurrentField.Length != _length && _length != 0)//检查长度
                        {
                            sql += "(" + _length + ")";
                        }
                        if (CurrentField.DataType != _datatypevalue || (CurrentField.Length != _length && _length != 0))
                        {
                            try
                            {
                                db.ExecuteCommand(sql);
                            }
                            catch (Exception ex)
                            {
                                Alert(Label1, ex.Message, "line1px_2");
                                return;
                            }
                        }
                    }

                    #endregion
                }
                else
                {
                    CurrentField = new WebSite.Core.Table.Field()
                    {
                        ID = Guid.NewGuid()
                    };
                    if (isVirtual.SelectedIndex == 1)//添加真实字段
                    {
                        sql = sql = String.Format("ALTER TABLE {0} ADD {1} {2}", CurrentTable.TableName, FieldName.Text, @DataType.SelectedValue);
                        if (_length != 0)//设置长度
                        {
                            sql += "(" + _length + ")";
                        }

                        try
                        {
                            db.ExecuteCommand(sql);
                        }
                        catch (Exception ex)
                        {
                            Alert(Label1, ex.Message, "line1px_2");
                            return;
                        }
                    }

                    CurrentFields.Add(CurrentField);
                }
                CurrentField = this.GetFormValue <WebSite.Core.Table.Field>(CurrentField);

                //数据源类型
                CurrentField.DataSource = this.GetFormValue <FieldDataSource>(CurrentField.DataSource);
                //布局模式
                CurrentField.DataSource.Layout = this.GetFormValue <DataSourceLayout>(CurrentField.DataSource.Layout);
                //SQL数据源
                CurrentField.DataSource.SQLDataSource = this.GetFormValue <SQLDataSource>(CurrentField.DataSource.SQLDataSource);
                //列表项目
                if (Repeater1.Items.Count > 0)
                {
                    CurrentField.DataSource.ListItemDataSource = new List <ListItemDataSource>();
                    foreach (RepeaterItem item in Repeater1.Items)
                    {
                        String             text     = ((TextBox)item.Controls[0].FindControl("t1")).Text;
                        String             value    = ((TextBox)item.Controls[0].FindControl("t2")).Text;
                        Boolean            chk      = ((CheckBox)item.Controls[0].FindControl("c1")).Checked;
                        ListItemDataSource listitem = new ListItemDataSource
                        {
                            Selected = chk,
                            Text     = text,
                            Value    = value
                        };
                        CurrentField.DataSource.ListItemDataSource.Add(listitem);
                    }
                }

                SiteTable.SaveTables(SiteTable.Tables);
                Alert(Label1, "保存成功!", "line1px_3");
            }
        }
Example #7
0
 public void addConnections(string sitelist, SiteTable siteTbl)
 {
     string[] siteIds = StringUtils.split(sitelist, StringUtils.COMMA);
     for (int i = 0; i < siteIds.Length; i++)
     {
         Site site = siteTbl.getSite(siteIds[i]);
         if (site == null)
         {
             throw new Exception("No such site: " + siteIds[i]);
         }
         DataSource src = site.getDataSourceByModality(this.modality);
         if (src == null)
         {
             throw new Exception("No " + modality + " data source at site " + siteIds[i]);
         }
         int protocol = DaoFactory.getConstant(src.Protocol);
         DaoFactory daoFactory = DaoFactory.getDaoFactory(protocol);
         addConnection(daoFactory.getConnection(src));
     }
 }
Example #8
0
 public Host(IWebContext context, Site defaultSite)
 {
     this.context = context;
     this.sites   = new SiteTable(defaultSite, Enumerable.Empty <Site>());
 }
Example #9
0
 void watcher_Changed(object sender, FileSystemEventArgs e)
 {
     _siteTable = new SiteTable(_mdwsConfig.ResourcesPath + "xml\\" + _mdwsConfig.FacadeConfiguration.SitesFileName);
 }
Example #10
0
 /// <summary>
 /// 初始化编辑数据
 /// </summary>
 protected void LoadData()
 {
     CurrentTable = SiteTable.Tables.Find(a => { return(a.ID == EditID); });
     this.SetFormValue(CurrentTable);
 }
Example #11
0
        /// <summary>
        /// Visit a single data source and authorize without a previous login.
        /// </summary>
        /// <remarks>
        /// This method is for visits without logins.  It makes its credentials
        /// and user the session credentials and session user.
        /// </remarks>
        /// <param name="pwd">Client app's BSE security phrase</param>
        /// <param name="sourceId">Station number of site to visit</param>
        /// <param name="userSourceId">User's station number</param>
        /// <param name="userName">User's name as it appears in VistA</param>
        /// <param name="userLocalId">User's DUZ</param>
        /// <param name="userFederatedId">User's SSN</param>
        /// <param name="permissionString">If blank defaults to CPRS context</param>
        /// <returns>UserTO</returns>
        public UserTO visitAndAuthorize(
            string pwd,
            string sourceId,
            string userSourceId,
            string userName,
            string userLocalId,
            string userFederatedId,
            string permissionString)
        {
            UserTO result = new UserTO();

            //Make sure we have all the args we need
            if (mySession == null || mySession.SiteTable == null)
            {
                result.fault = new FaultTO("No session has been started");
            }
            else if (sourceId == "")
            {
                result.fault = new FaultTO("Missing sitecode of site to visit");
            }
            else if (mySession.SiteTable.getSite(sourceId) == null)
            {
                result.fault = new FaultTO("No site " + sourceId + " in the site table");
            }
            else if (mySession.ConnectionSet != null &&
                     mySession.ConnectionSet.Count > 0 &&
                     mySession.ConnectionSet.IsConnected(sourceId))
            {
                result.fault = new FaultTO("Site " + sourceId + " already connected");
            }
            else if (mySession.ConnectionSet != null && mySession.ConnectionSet.Count > 0)
            {
                result.fault = new FaultTO("This session has pre-existing connections and this method should be the base connection.", "Do a disconnect?");
            }
            else if (userSourceId == "")
            {
                result.fault = new FaultTO("Missing userSitecode");
            }
            else if (userName == "")
            {
                result.fault = new FaultTO("Missing userName");
            }
            else if (userLocalId == "")
            {
                result.fault = new FaultTO("Missing DUZ");
            }
            else if (userFederatedId == "")
            {
                result.fault = new FaultTO("Missing SSN");
            }
            if (result.fault != null)
            {
                return(result);
            }

            try
            {
                SiteTable t        = mySession.SiteTable;
                Site      userSite = (Site)t.Sites[userSourceId];
                if (userSite == null)
                {
                    result.fault = new FaultTO("No such site: " + userSourceId);
                    return(result);
                }

                Site visitSite = (Site)t.Sites[sourceId];
                if (visitSite == null)
                {
                    result.fault = new FaultTO("No such site: " + sourceId);
                    return(result);
                }

                DataSource dataSource = visitSite.getDataSourceByModality("HIS");
                if (dataSource == null)
                {
                    result.fault = new FaultTO("Site " + sourceId + " has no HIS");
                    return(result);
                }

                mySession.Credentials = MdwsUtils.setVisitCredentials(userLocalId, userFederatedId, userName, "", userSite.getDataSourceByModality("HIS"), pwd);
                mySession.Credentials.SecurityPhrase = pwd;

                if (permissionString == "")
                {
                    permissionString = mySession.DefaultPermissionString;
                }
                mySession.PrimaryPermission = new MenuOption(permissionString);

                mySession.User = doTheVisit(sourceId, mySession.Credentials, mySession.PrimaryPermission);

                mySession.User.Name        = new PersonName(userName);
                mySession.User.SSN         = new SocSecNum(userFederatedId);
                mySession.User.LogonSiteId = dataSource.SiteId;

                addMyCxn2CxnSet();
                result = new UserTO(mySession.User);
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e.Message);
            }
            return(result);
        }