Exemplo n.º 1
0
        private void AddAddIns(List <ContentURI> addedURIs, List <AccountToAddIn> addedMs)
        {
            string sParentNodeName = string.Empty;
            int    iParentId       = 0;

            foreach (ContentURI addedURI in addedURIs)
            {
                Helpers.GeneralHelpers.GetParentIdAndNodeName(addedURI, out iParentId, out sParentNodeName);
                if (!string.IsNullOrEmpty(addedURI.ErrorMessage))
                {
                    _dtoContentURI.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                        string.Empty, "INSERT_NOPARENT");
                    return;
                }
                //selections are made use base addins
                if (addedURI.URINodeName == LinkedViews.LINKEDVIEWS_TYPES.linkedview.ToString() &&
                    _dtoContentURI.URINodeName == AddIns.ADDIN_TYPES.addinaccountgroup.ToString())
                {
                    var newAccountToAddIn = new AccountToAddIn
                    {
                        LinkedViewName      = addedURI.URIName,
                        IsDefaultLinkedView = false,
                        LinkingNodeId       = _dtoContentURI.URIId,
                        Account             = null,
                        LinkedViewId        = addedURI.URIId,
                        LinkedView          = null
                    };
                    _dataContext.AccountToAddIn.Add(newAccountToAddIn);
                    _dataContext.Entry(newAccountToAddIn).State = EntityState.Added;
                    addedMs.Add(newAccountToAddIn);
                }
            }
        }
Exemplo n.º 2
0
        public async Task <List <AccountToAddIn> > GetAddInsByClubIdAsync(
            ContentURI uri, int accountId)
        {
            List <AccountToAddIn> colClubAddIns = new List <AccountToAddIn>();

            if (accountId == 0)
            {
                //set default objects
                AccountToAddIn atoa = new AccountToAddIn(true);
                colClubAddIns.Add(atoa);
                return(colClubAddIns);
            }
            Helpers.SqlIOAsync sqlIO    = new Helpers.SqlIOAsync(uri);
            SqlParameter[]     colPrams =
            {
                sqlIO.MakeInParam("@AccountId", SqlDbType.Int, 4, accountId)
            };
            SqlDataReader dataReader = await sqlIO.RunProcAsync(
                "0GetAddInsByClubId", colPrams);

            if (dataReader != null)
            {
                using (dataReader)
                {
                    while (await dataReader.ReadAsync())
                    {
                        AccountToAddIn atoa = new AccountToAddIn(true);
                        atoa.PKId                      = dataReader.GetInt32(0);
                        atoa.LinkedViewName            = dataReader.GetString(1);
                        atoa.LinkingNodeId             = dataReader.GetInt32(2);
                        atoa.LinkedViewId              = dataReader.GetInt32(3);
                        atoa.IsDefaultLinkedView       = dataReader.GetBoolean(4);
                        atoa.Account                   = new Account(true);
                        atoa.LinkedView                = new LinkedView(true);
                        atoa.LinkedView.PKId           = dataReader.GetInt32(5);
                        atoa.LinkedView.LinkedViewNum  = dataReader.GetString(6);
                        atoa.LinkedView.LinkedViewName = dataReader.GetString(7);
                        atoa.LinkedView.LinkedViewDesc = dataReader.GetString(8);
                        atoa.LinkedView.LinkedViewFileExtensionType = dataReader.GetString(9);
                        atoa.LinkedView.LinkedViewLastChangedDate   = dataReader.GetDateTime(10);
                        atoa.LinkedView.LinkedViewFileName          = dataReader.GetString(11);
                        atoa.LinkedView.LinkedViewXml           = string.Empty;
                        atoa.LinkedView.LinkedViewAddInName     = dataReader.GetString(13);
                        atoa.LinkedView.LinkedViewAddInHostName = dataReader.GetString(14);
                        atoa.LinkedView.LinkedViewPackId        = dataReader.GetInt32(15);
                        colClubAddIns.Add(atoa);
                    }
                }
            }
            else
            {
                //set default objects
                AccountToAddIn atoa = new AccountToAddIn(true);
                colClubAddIns.Add(atoa);
            }
            sqlIO.Dispose();
            return(colClubAddIns);
        }