示例#1
0
        public TwitchChat(ChatConfig config)
            : base(config)
        {
            EmoticonUrl         = "http://api.twitch.tv/kraken/chat/emoticons";
            EmoticonFallbackUrl = @"Content\twitchemoticons.json";

            ReceiveOwnMessages = true;
            AnonymousNickName  = "justinfan" + random.Next(1000000, 9999999).ToString();
            NickName           = AnonymousNickName;

            CreateChannel = () => { return(new TwitchChannel(this)); };

            ContentParsers.Add(MessageParser.ParseURLs);
            ContentParsers.Add(MessageParser.ParseEmoticons);

            Info = new StreamInfo()
            {
                HasDescription = false,
                HasGame        = true,
                HasTopic       = true,
                ChatName       = Config.ChatName,
            };

            Games = new ObservableCollection <Game>();

            ChatUsers = new SmartCollection <ChatUser>();
        }
示例#2
0
        protected ColumnViewModelBase(IContextEntry context, ColumnDefinition definition, IConfig config,
                                      IStreamParser parser, IMessenger messenger = null, IColumnActionDispatcher actionDispatcher = null)
            : base(messenger)
        {
            Configuration = config;
            Definition    = definition;
            Context       = context;
            Width         = definition.Width;
            IsLoading     = true;
            Items         = ItemCollection = new SmartCollection <ColumnItem>();
            Parser        = parser;
            MessengerInstance.Register <FilterUpdateMessage>(this, OnFiltersUpdated);

            ColumnConfiguration        = new ColumnConfigurationViewModel(definition);
            ColumnConfiguration.Saved += ColumnConfiguration_Saved;

            if (config.General.RealtimeStreaming)
            {
                Parser.StatusReceived        += Parser_StatusReceived;
                Parser.StatusDeleted         += Parser_ItemDeleted;
                Parser.DirectMessageDeleted  += Parser_ItemDeleted;
                Parser.DirectMessageReceived += Parser_DirectMessageReceived;
                Parser.FavoriteEventReceived += Parser_FavoriteEventReceived;
            }

            ActionDispatcher = actionDispatcher ?? new ColumnActionDispatcher();
            ActionDispatcher.HeaderClicked += ActionDispatcher_HeaderClicked;
            ActionDispatcher.BottomReached += ActionDispatcher_BottomReached;

            MaxIdFilterExpression   = s => s.MaxID == MaxId - 1;
            SinceIdFilterExpression = s => s.SinceID == SinceId;
            CountExpression         = s => s.Count == config.General.TweetFetchCount;
            SubTitle = "@" + Context.AccountName;
        }
示例#3
0
        public SmartCollection<User> GetData(string token)
        {
            this.Token = token;

            if (AppLib.DesignMode) {
                SmartCollection<User> users = new SmartCollection<User>();
                users.Add(
                    new User() {
                        UserId = 0,
                        FirstName = "Jens",
                        LastName = "Serna",
                        Email = "*****@*****.**",
                        Username = "******"
                    });

                return users;
            }else {
                try {
                    using (UserDAO usersDao = new UserDAO()) {
                        return usersDao.GetUsers();
                    }
                }catch (Exception) {
                    throw;
                }
            }
        }
示例#4
0
        public SmartCollection<SampleTest> GetData(string token, object recordIds)
        {
            SmartCollection<SampleTest> results = new SmartCollection<SampleTest>();
            this.RecordList = new List<string>();
            User user = new User();
            int userId = 0;
            this.Token = token;
            this.RecordList.AddRange(((object[])recordIds).Select(x => x.ToString()).ToList());

            if (AppLib.DesignMode) {
                LoadSampleTestMockData(ref results);
            }else {
                try {
                    using (SystemDAO systemDao = new SystemDAO()) {
                        userId = systemDao.GetToken(new Guid(this.Token));
                    }
                    if (userId > 0) {
                        using (UserDAO userDao = new UserDAO()) {
                            user = userDao.GetUser(userId);
                        }
                        using (SampleDAO ordersDao = new SampleDAO()) {
                            results = ordersDao.GetWorkOrders(RecordList, new Identification() { Token = new Guid(this.Token), UserId = (int)user.UserId });
                        }
                    }
                }catch (Exception) {
                    throw;
                }
            }
            return results;
        }
        public void ResetTest()
        {
            var sc  = new SmartCollection <TestItem, object>(new object());
            var si1 = new TestItem();
            var si2 = new TestItem();
            var si3 = new TestItem();

            sc.Add(si1);
            si2.Collection = sc;
            sc.Add(si3);

            Assert.AreEqual(sc, si1.Collection);
            Assert.AreEqual(sc, si2.Collection);
            Assert.AreEqual(sc, si3.Collection);

            Assert.IsTrue(sc.Contains(si1));
            Assert.IsTrue(sc.Contains(si2));
            Assert.IsTrue(sc.Contains(si3));

            sc.Clear();

            Assert.AreEqual(null, si1.Collection);
            Assert.AreEqual(null, si2.Collection);
            Assert.AreEqual(null, si3.Collection);

            Assert.IsFalse(sc.Contains(si1));
            Assert.IsFalse(sc.Contains(si2));
            Assert.IsFalse(sc.Contains(si3));
        }
示例#6
0
        public void Shuffle()
        {
            if (IsShuffled)
            {
                NonShuffledPlaylist = new SmartCollection <IMediaItem>(Playlist);
                Random r = new Random();
                for (int i = 0; i < Playlist.Count; i++)
                {
                    if (i > CurrentMedia)
                    {
                        int index1 = r.Next(i, Playlist.Count);
                        int index2 = r.Next(i, Playlist.Count);
                        Playlist.Move(index1, index2);
                    }
                }
                var pl = Playlist.ToList <IMediaItem>();
            }
            else
            {
                IMediaItem m = Playlist[CurrentMedia];

                Playlist.Clear();
                Playlist.AddRange(NonShuffledPlaylist);

                CurrentMedia = Playlist.IndexOf(m);
            }
        }
示例#7
0
        protected ColumnViewModelBase(IContextEntry context, ColumnDefinition definition, IConfig config,
                                      IStreamParser parser)
        {
            Configuration = config;
            Definition    = definition;
            Context       = context;
            Width         = definition.Width;
            IsLoading     = true;
            Statuses      = StatusCollection = new SmartCollection <StatusViewModel>();
            Parser        = parser;

            ColumnConfiguration        = new ColumnConfigurationViewModel(definition);
            ColumnConfiguration.Saved += ColumnConfiguration_Saved;

            if (config.General.RealtimeStreaming)
            {
                Parser.FriendsReceived += Parser_FriendsReceived;
                Parser.StatusReceived  += Parser_StatusReceived;
                Parser.StatusDeleted   += Parser_StatusDeleted;
            }

            ActionDispatcher = new ColumnActionDispatcher();
            ActionDispatcher.HeaderClicked += ActionDispatcher_HeaderClicked;
            ActionDispatcher.BottomReached += ActionDispatcher_BottomReached;

            MaxIdFilterExpression   = s => s.MaxID == MaxId - 1;
            SinceIdFilterExpression = s => s.SinceID == SinceId;
            CountExpression         = s => s.Count == config.General.TweetFetchCount;
            SubTitle = "@" + context.AccountName;
        }
示例#8
0
        public void Simple()
        {
            var data = new List <Task>
            {
                new Task {
                    Title = "task1"
                }
            };
            var groupBuilder = new GroupBuilder <Task>(
                p => p.Title,
                p => p.Title,
                (g1, g2) => g1.Title.CompareTo(g2.Title),
                (p1, p2) => p1.Title.CompareTo(p2.Title));

            var collection = new SmartCollection <Task>(data, groupBuilder, t => !t.Completed.HasValue);

            Assert.AreEqual(1, collection.Items.Count);
            Assert.AreEqual(1, collection.Items[0].Count);
            Assert.AreEqual("task1", collection.Items[0][0].Title);

            data[0].IsCompleted = true;
            collection.InvalidateItem(data[0]);

            Assert.AreEqual(0, collection.Items.Count);

            data[0].IsCompleted = false;
            collection.InvalidateItem(data[0]);

            Assert.AreEqual(1, collection.Items.Count);
            Assert.AreEqual(1, collection.Items[0].Count);
            Assert.AreEqual("task1", collection.Items[0][0].Title);
        }
 public ChangeHistoryViewModel(ModuleNames module, int? rootModelKey)
 {
     DisplayName = module.ToString() + " Change History";
     Module = module;
     RootModelKey = rootModelKey;
     Results = new SmartCollection<AuditedModelValue>();
 }
示例#10
0
        public UserSelectorPage(IWizardViewModel wizard, ITimerFactory timerFactory)
            : base(wizard)
        {
            Timer       = timerFactory.Create(1000);
            Timer.Tick += Timer_Tick;

            UserCollection = new SmartCollection <UserViewModel>();
        }
示例#11
0
        public void EmptyConstructorCreatesEmptyList()
        {
            // Arrange Act
            var collection = new SmartCollection <int>();

            // Assert
            Assert.AreEqual(0, collection.Count);
        }
        public CityListViewModel(IStore store) : base(store)
        {
            Cities = new SmartCollection <City>();

            ConnectToStore(state => state.Cities, cities =>
            {
                Cities.Reset(cities);
            });
        }
        public UserListViewModel(IStore store) : base(store)
        {
            Users = new SmartCollection <User>();

            ConnectToStore(state => state.Users, users =>
            {
                Users.Reset(users);
            });
        }
示例#14
0
        public void EmptyConstructorCreatesEmptyList()
        {
            // Arrange Act
            // ReSharper disable once CollectionNeverUpdated.Local
            var collection = new SmartCollection <int>();

            // Assert
            Assert.AreEqual(0, collection.Count);
        }
示例#15
0
        public void SelectionPropertyTest()
        {
            IEnumerable <ISelectable>     enumerable      = new List <ISelectable>();
            SmartCollection <ISelectable> smartCollection = new SmartCollection <ISelectable>(new List <ISelectable>());

            DynamoSelection.Instance.Selection = smartCollection;

            Assert.AreEqual(smartCollection, DynamoSelection.Instance.Selection);
        }
示例#16
0
 public void Setup(int width, int height)
 {
     CurrentWidth  = width;
     CurrentHeight = height;
     GridWidth     = CurrentWidth;
     GridHeight    = CurrentHeight;
     PivotGrid     = new SmartCollection <char>();
     ApplyChanges  = false;
     UpdateGrid();
 }
示例#17
0
        private async Task RestorePlaylist()
        {
            try
            {
                var playlist = await BackgroundTrackRepository.LoadPlaylist();

                if (!playlist.Any())
                {
                    return;
                }

                var trackIds         = playlist.Select(node => node.TrackId);
                var restoredplaylist = new SmartCollection <IMediaItem>();
                foreach (int trackId in trackIds)
                {
                    var trackItem = await Locator.MediaLibrary.LoadTrackById(trackId);

                    if (trackItem != null)
                    {
                        restoredplaylist.Add(trackItem);
                    }
                }

                if (!ApplicationSettingsHelper.Contains(nameof(CurrentMedia)))
                {
                    return;
                }
                var index = (int)ApplicationSettingsHelper.ReadSettingsValue(nameof(CurrentMedia));
                if (restoredplaylist.Any())
                {
                    if (index == -1)
                    {
                        // Background Audio was terminated
                        // We need to reset the playlist, or set the current track 0.
                        ApplicationSettingsHelper.SaveSettingsValue(nameof(CurrentMedia), 0);
                        index = 0;
                    }
                    SetCurrentMediaPosition(index);
                }

                if (CurrentMedia >= restoredplaylist.Count || CurrentMedia == -1)
                {
                    CurrentMedia = 0;
                }

                if (restoredplaylist.Any())
                {
                    await SetPlaylist(restoredplaylist, true, false, restoredplaylist[CurrentMedia]);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("Failed to restore the playlist");
            }
        }
示例#18
0
        public ViewModel()
        {
            TheModel = new MainModel();
            TheModel.ReadConfiguration(@"F:\Oplandsmodel\NitrateModel\config_clgw122_Rerun11.xml");

            SubModels = new SmartCollection <BaseModel>();
            SubModels.AddRange(TheModel.SourceModels.Cast <BaseModel>());
            SubModels.AddRange(TheModel.InternalReductionModels.Cast <BaseModel>());
            SubModels.AddRange(TheModel.MainStreamRecutionModels.Cast <BaseModel>());
            TheModel.LoadCatchments();
        }
示例#19
0
        public void CollectionCanBeConstructedFromEnumerable()
        {
            // Arrange
            var enumerable = Enumerable.Range(0, 5);

            // Act
            var collection = new SmartCollection <int>(enumerable);

            // Assert
            CollectionAssert.AreEqual(enumerable.ToArray(), collection.ToArray());
        }
示例#20
0
    public ViewModel()
    {
      TheModel = new MainModel();
      TheModel.ReadConfiguration(@"F:\Oplandsmodel\NitrateModel\config_clgw122_Rerun11.xml");

      SubModels = new SmartCollection<BaseModel>();
      SubModels.AddRange(TheModel.SourceModels.Cast<BaseModel>());
      SubModels.AddRange(TheModel.InternalReductionModels.Cast<BaseModel>());
      SubModels.AddRange(TheModel.MainStreamRecutionModels.Cast<BaseModel>());
      TheModel.LoadCatchments();

    }
        public void OneItemOneCollectionAddTest()
        {
            var sc = new SmartCollection <TestItem, object>(new object());
            var si = new TestItem();

            Assert.AreEqual(null, si.Collection);

            sc.Add(si);

            Assert.AreEqual(sc, si.Collection);
            Assert.IsTrue(sc.Contains(si));
        }
示例#22
0
 public PlaybackService()
 {
     Task.Run(() => RestorePlaylist());
     _mediasCollection = new SmartCollection <IMediaItem>();
     InitializePlaylist();
     _mediaService.MediaFailed     += MediaFailed;
     _mediaService.StatusChanged   += PlayerStateChanged;
     _mediaService.TimeChanged     += UpdateTime;
     _mediaService.OnLengthChanged += OnLengthChanged;
     _mediaService.OnStopped       += OnStopped;
     _mediaService.OnEndReached    += OnEndReached;
     _mediaService.OnBuffering     += OnBuffering;
 }
        public void OneItemTwoCollectionsPropertyTest()
        {
            var sc1 = new SmartCollection <TestItem, object>(new object());
            var sc2 = new SmartCollection <TestItem, object>(new object());
            var si  = new TestItem();

            si.Collection = sc1;
            si.Collection = sc2;

            Assert.AreEqual(sc2, si.Collection);
            Assert.IsFalse(sc1.Contains(si));
            Assert.IsTrue(sc2.Contains(si));
        }
示例#24
0
        public void CollectionCanBeConstructedFromList()
        {
            // Arrange
            var list = new List <int> {
                3, 6, 3, 2
            };

            // Act
            var collection = new SmartCollection <int>(list);

            // Assert
            CollectionAssert.AreEqual(list.ToArray(), collection.ToArray());
        }
示例#25
0
        public void ResetReplacesContent()
        {
            // Arrange
            var collection = new SmartCollection <int>
            {
                1, 2, 3
            };

            // Act
            collection.Reset(new[] { 4, 5, 6 });

            // Assert
            CollectionAssert.AreEqual(new[] { 4, 5, 6 }, collection.ToArray());
        }
示例#26
0
        private void GetMethodsResponse(IAsyncResult result)
        {
            try {
                Result = ((ISystemService)result.AsyncState).EndGetMethods(result);
            } catch (Exception ex) {
                Error = ex;
            } finally {
                service.Close();
                service = null;
            }

            // Execute Last
            Caliburn.Micro.Execute.OnUIThread(() => Completed(this, new ResultCompletionEventArgs()));
        }
    private async Task <Unit> ApplyUpdateRequest(TvContext dbContext, SmartCollection c, UpdateSmartCollection request)
    {
        c.Query = request.Query;

        // rebuild playouts
        if (await dbContext.SaveChangesAsync() > 0)
        {
            // refresh all playouts that use this smart collection
            foreach (int playoutId in await _mediaCollectionRepository.PlayoutIdsUsingSmartCollection(request.Id))
            {
                await _channel.WriteAsync(new BuildPlayout(playoutId, PlayoutBuildMode.Refresh));
            }
        }

        return(Unit.Default);
    }
示例#28
0
        public GmcManager(BusyIndicatorViewModel busyIndicator, ICacheProvider cacheProvider, IOperationsManager operationsManager)
        {
            _busyIndicator            = busyIndicator;
            _cacheProvider            = cacheProvider;
            _operationsManager        = operationsManager;
            Filter                    = new GmcManagerFilterViewModel();
            Filter.FilterInvalidated += OnFilterInvalidated;
            LocalTransactions         = new SmartCollection <BasicTransactionModel>();
            RemoteTransactions        = new SmartCollection <BasicTransactionModel>();

            RefreshRemoteKnowledgeCommand           = new AsyncCommand(ComputeDeltaWithRemote);
            PushChangesToGmcCommand                 = new AsyncCommand(PushChangesToGmc);
            PullCategoriesFromGmcCommand            = new AsyncCommand(PullCategoriesFromGmc);
            ClearCurrentAccountCacheAndResetCommand = new AsyncCommand(ClearCurrentAccountCacheAndReset);

            MessengerInstance.Register <AccountViewModel>(this, OnAccountViewModelReceived);
        }
示例#29
0
        public static decimal[] CalculateTestPrice(SampleTest sampleTest, SmartCollection<ClientPricing> discounts, Priority priority, SmartCollection<PricingRule> matrixItems, int analytes, decimal basePrice)
        {
            decimal[] pricingArray = new decimal[2];

            // PricingArray[0] = Total Price
            // PricingArray[1] = RUSH Only additional charge for invoicing only not used in calculations

            decimal price = 0; // Calculated set and returned
            decimal testPrice = 0;
            decimal priorityPriceAdjustment = 0;
            decimal matrixPrice = 0;
            decimal discount = 0;

            if (sampleTest.DiscountAllowedYN) {
                if (matrixItems.Count > 0) {
                    matrixPrice = testPrice * matrixItems.Sum(x => x.PriceAdjustment);
                    if (matrixPrice <= 0) matrixPrice = 0;
                }
            }

            if (discounts.Count > 0) {
                discount = (matrixPrice + testPrice) * (decimal)discounts.Sum(x => x.Discount);
                if (!sampleTest.DiscountAllowedYN) discount = 0;
                //if (discount <= 0) discount = 0;
            }
            priorityPriceAdjustment = testPrice * priority.PriceAdjustment;

            //if (priority.DiscountAllowedYN) {
                //Might need to create line item detail here for invoicing.
                //if (discounts.Count > 0) {
                    //priorityPriceAdjustment = priorityPriceAdjustment - (priorityPriceAdjustment * (decimal)discounts.Sum(x => x.Discount));
                    //if (priorityPriceAdjustment <= 0) priorityPriceAdjustment = 0;
                //}
            //}

            if (priority.PriorityName.ToUpper().Contains("RUSH"))
                pricingArray[1] = priorityPriceAdjustment;

            price = (testPrice + matrixPrice + priorityPriceAdjustment) - discount;

            if (price <= 0) price = 0;

            pricingArray[0] = Math.Round(price, 2);

            return pricingArray;
        }
示例#30
0
        private void shufflePlaylist(int doNotMoveIndex = -1)
        {
            _nonShuffledPlaylist = new SmartCollection <IMediaItem>(Playlist);
            Random r = new Random();

            // Perform three iterations to improve the randomness.
            for (int i = 0; i < Playlist.Count * 3; i++)
            {
                int index1 = r.Next(0, Playlist.Count);
                int index2 = r.Next(0, Playlist.Count);
                if (index1 == doNotMoveIndex || index2 == doNotMoveIndex)
                {
                    continue;
                }
                Playlist.Move(index1, index2);
            }
        }
        public void OneItemOneCollectionPropertyTest()
        {
            var sc = new SmartCollection <TestItem, object>(new object());
            var si = new TestItem();

            Assert.AreEqual(null, si.Collection);

            si.Collection = sc;

            Assert.AreEqual(sc, si.Collection);
            Assert.IsTrue(sc.Contains(si));

            si.Collection = null;

            Assert.AreEqual(null, si.Collection);
            Assert.IsFalse(sc.Contains(si));
        }
示例#32
0
        public void Setup()
        {
            this.data = new List <MetaTask>
            {
                new MetaTask {
                    Title = "task0", IsCompleted = false, Meta = 0, Order = 1
                },
                new MetaTask {
                    Title = "task1", IsCompleted = false, Meta = 0, Order = 2
                },
                new MetaTask {
                    Title = "task2", IsCompleted = true, Meta = 0, Order = 3
                },
                new MetaTask {
                    Title = "task3", IsCompleted = false, Meta = 1, Order = 1
                },
                new MetaTask {
                    Title = "task4", IsCompleted = false, Meta = 1, Order = 2
                },
                new MetaTask {
                    Title = "task5", IsCompleted = true, Meta = 1, Order = 3
                },
                new MetaTask {
                    Title = "task6", IsCompleted = true, Meta = 2, Order = 1
                },
                new MetaTask {
                    Title = "task7", IsCompleted = true, Meta = 2, Order = 2
                },
                new MetaTask {
                    Title = "task8", IsCompleted = false, Meta = 2, Order = 3
                },
                new MetaTask {
                    Title = "task9", IsCompleted = true, Meta = 3, Order = 1
                },
            };

            var groupBuilder = new GroupBuilder <MetaTask>(
                t => t.Title,
                t => t.Meta.ToString(),
                (g1, g2) => g1[0].Meta.CompareTo(g2[0].Meta),
                (t1, t2) => t1.Order.CompareTo(t2.Order));

            Predicate <MetaTask> focusFilter = t => t.Meta == 0;

            this.collection = new SmartCollection <MetaTask>(this.data, groupBuilder, p => true, focusFilter);
        }
示例#33
0
        public IEnumerable<Wrapper2> GetContainerLabels(int arlNumber)
        {
            SmartCollection<SampleContainer> results = new SmartCollection<SampleContainer>();

            try
            {
                using (SampleDAO sampleDao = new SampleDAO())
                {
                    results = sampleDao.GetContainerLabels(arlNumber);
                }
                return IndexData(results);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#34
0
        public override async void Execute(object parameter)
        {
            var items = (ObservableCollection <IVLCStorageItem>)parameter;
            var files = new List <VLCStorageFile>();

            foreach (var item in items)
            {
                var file = item as VLCStorageFile;
                if (file == null)
                {
                    continue;
                }

                if (file.Media != null || VLCFileExtensions.Supported.Contains((file.StorageItem as StorageFile)?.FileType.ToLower()))
                {
                    files.Add((VLCStorageFile)item);
                }
            }
            var playlist = new SmartCollection <IMediaItem>();

            foreach (var file in files)
            {
                if (VLCFileExtensions.AudioExtensions.Contains((file.StorageItem as StorageFile)?.FileType.ToLower()))
                {
                    var trackItem = await Locator.MediaLibrary.GetTrackItemFromFile(file.StorageItem as StorageFile);

                    playlist.Add(trackItem);
                }
                else if (VLCFileExtensions.VideoExtensions.Contains((file.StorageItem as StorageFile)?.FileType.ToLower()))
                {
                    var video = await MediaLibraryHelper.GetVideoItem(file.StorageItem as StorageFile);

                    playlist.Add(video);
                }
                else
                {
                    var stream = MediaLibraryHelper.GetStreamItem(file);
                    playlist.Add(stream);
                }
            }
            if (playlist.Count > 0)
            {
                Locator.NavigationService.GoOnPlaybackStarted(VLCPage.MusicPlayerPage);
                await Locator.PlaybackService.SetPlaylist(playlist);
            }
        }
示例#35
0
        public static List <ITask> SelectTasks(IAbstractFolder folder, ISettings settings)
        {
            var  groupBuilder  = GroupBuilderFactory.GetGroupBuilder(folder, settings);
            bool showCompleted = (folder is ISystemView) && ((ISystemView)folder).ViewKind == ViewKind.Completed;
            bool showTaskWithStartDateInFuture = settings.GetValue <bool>(CoreSettings.ShowFutureStartDates);

            DateTime dateTimeNow = DateTime.Now;

            var smartCollection = new SmartCollection <ITask>(
                folder.Tasks,
                groupBuilder,
                t =>
            {
                return((!(folder is ISystemView) || t.Folder.ShowInViews.HasValue && t.Folder.ShowInViews.Value) &&
                       (showCompleted || !t.IsCompleted) &&
                       (showTaskWithStartDateInFuture || (!t.Start.HasValue || t.Start.Value <= dateTimeNow)) &&
                       t.ParentId == null);            // exlude subtasks
            });

            return(smartCollection.Items.SelectMany(g => g).ToList());
        }
示例#36
0
        public void Setup()
        {
            this.a0_0 = new Person("a0_0", 0);
            this.data = new List <Person>
            {
                this.a0_0,
                new Person("a1_1", 1),
                new Person("b2_2", 2), new Person("b3_2", 2),
                new Person("c4_3", 3), new Person("c5_3", 3), new Person("d6_3", 3),
                new Person("d7_4", 4), new Person("e8_4", 4), new Person("e9_4", 4), new Person("f10_4", 4),
                new Person("f11_5", 5), new Person("g12_5", 5), new Person("g13_5", 5), new Person("h14_5", 5), new Person("h15_5", 5),
            };
            var groupBuilder = new GroupBuilder <Person>(
                p => p.Name,
                p => p.Age.ToString(),
                (g1, g2) => g1.Title.CompareTo(g2.Title),
                (p1, p2) => p1.Name.CompareTo(p2.Name));

            Predicate <Person> filter = p => p.Age % 2 == 0;

            this.collection = new SmartCollection <Person>(this.data, groupBuilder, p => true, filter);
        }
示例#37
0
        public void SmartCollectionConstructorTest()
        {
            IEnumerable <int> enumerable = new List <int>()
            {
                1
            };
            SmartCollection <int> smartCollection = new SmartCollection <int>(enumerable);

            Assert.AreEqual(1, smartCollection.Count);
            Assert.IsTrue(smartCollection.Contains(1));

            var list = new List <int>()
            {
                1, 2
            };

            smartCollection = new SmartCollection <int>(list);

            Assert.AreEqual(2, smartCollection.Count);
            Assert.IsTrue(smartCollection.Contains(1));
            Assert.IsTrue(smartCollection.Contains(2));
        }
示例#38
0
        public SmartCollection<ClientNote> GetClientNotes(int clientId)
        {
            try {
                SmartCollection<ClientNote> resultList = new SmartCollection<ClientNote>();
                using (DbConnection = new MsSqlPersistence(DbConnectionSettings)) {
                    if (DbConnection.IsConnected()) {
                        using (DbCommand) {
                            dbCommand.CommandType = CommandType.StoredProcedure;
                            dbCommand.CommandText = "uspGetClientNotes";
                            dbCommand.Parameters.Clear();
                            dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = clientId;

                            DataTable notesDT = DbConnection.ExecuteQuery(DbCommand);
                            foreach (DataRow row in notesDT.Rows) {
                                ClientNote note = new ClientNote();
                                note.ClientNoteId = Convert.ToInt32(row["ClientNoteID"]);
                                note.ClientId = Convert.ToInt32(row["ClientID"]);
                                note.Note = row["Note"].ToString();
                                note.CopyToSampleYN = Convert.ToBoolean(row["CopyToSampleYN"]);
                                note.IncludeOnCOAYN = Convert.ToBoolean(row["IncludeOnCOAYN"]);
                                note.CreatedUser = row["CreatedUser"].ToString();
                                note.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null;
                                note.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : -1;
                                note.ModifiedUser = row["ModifiedUser"].ToString();
                                note.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null;
                                resultList.Add(note);
                            }
                            notesDT = null;
                        }
                    }else {
                        throw new Exception("Unable to Connect");
                    }
                }
                return resultList;
            }catch {
                throw;
            }
        }
示例#39
0
        public SmartCollection<ClientPricing> GetClientPricings(int ClientId)
        {
            try {
                SmartCollection<ClientPricing> resultList = new SmartCollection<ClientPricing>();
                using (DbConnection = new MsSqlPersistence(DbConnectionSettings)) {
                    if (DbConnection.IsConnected()) {
                        using (DbCommand) {
                            dbCommand.CommandType = CommandType.StoredProcedure;
                            dbCommand.CommandText = "uspGetClientPricings";
                            dbCommand.Parameters.Clear();
                            dbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = ClientId;

                            DataTable returnDT = DbConnection.ExecuteQuery(DbCommand);
                            foreach (DataRow row in returnDT.Rows) {
                                ClientPricing price = new ClientPricing();
                                price.ClientPricingId = Convert.ToInt32(row["ClientPricingID"]);
                                price.ClientId = Convert.ToInt32(row["ClientID"]);
                                if (row["MethodID"] != DBNull.Value)
                                    price.MethodId = Convert.ToInt32(row["MethodID"]);
                                if (row["MethodNumberID"] != DBNull.Value)
                                    price.MethodNumberId = Convert.ToInt32(row["MethodNumberID"]);
                                if (row["AnalyteID"] != DBNull.Value)
                                    price.AnalyteId = Convert.ToInt32(row["AnalyteID"]);
                                price.Description = row["Description"].ToString();
                                price.Discount = row["Discount"] != DBNull.Value ? Convert.ToDouble(row["Discount"]) : 0;
                                price.FlatRate = row["FlatRate"] != DBNull.Value ? Convert.ToDouble(row["FlatRate"]) : 0;
                                price.CreatedBy = row["CreatedBy"] != DBNull.Value ? Convert.ToInt32(row["CreatedBy"]) : new Int32();
                                price.CreatedUser = row["CreatedUser"].ToString();
                                price.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null;
                                price.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : new Int32();
                                price.ModifiedUser = row["ModifiedUser"].ToString();
                                price.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null;

                                if (price.MethodId.HasValue)
                                    price.Method = new Method { MethodId = price.MethodId, MethodName = row["MethodName"].ToString() };
                                else
                                    price.Method = null;

                                if (price.MethodNumberId.HasValue)
                                    price.MethodNumber = new MethodNumber { MethodNumberId = price.MethodNumberId, MethodNumberName = row["MethodNumberName"].ToString() };
                                else
                                    price.MethodNumber = null;

                                if (price.AnalyteId.HasValue)
                                    price.AnalyteItem = new Analyte { AnalyteId = price.AnalyteId, AnalyteName = row["AnalyteName"].ToString() };
                                else
                                    price.AnalyteItem = null;

                                resultList.Add(price);
                            }
                            returnDT = null;
                        }
                    }else {
                        throw new Exception("Unable to Connect");
                    }
                }
                return resultList;
            }catch {
                throw;
            }
        }
示例#40
0
        public SmartCollection<ClientDocument> GetClientDocuments(int clientId)
        {
            try {
                var result = new SmartCollection<ClientDocument>();

                using (DbConnection = new MsSqlPersistence(DbConnectionSettings))
                    if (DbConnection.IsConnected())
                        using (DbCommand)
                            result.AddRange(GetClientDocuments(ref dbConnection, ref dbCommand, clientId));

                return result;
            }catch {
                throw;
            }
        }
示例#41
0
        public SmartCollection<ClientDocument> GetClientDocuments(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int clientId)
        {
            var result = new SmartCollection<ClientDocument>();

            dbCommand.CommandType = CommandType.StoredProcedure;
            dbCommand.CommandText = "uspGetClientDocuments";
            dbCommand.Parameters.Clear();
            dbCommand.Parameters.AddWithValue("@ClientId", clientId);

            using (var reader = dbConnection.ExecuteReader(dbCommand)) {
                while (reader.Read()) {
                    result.Add(new ClientDocument {
                        ClientDocumentId = (int)reader["ClientDocumentID"],
                        Filename = reader["Filename"].ToString(),
                        CreatedBy = reader["CreatedBy"] != DBNull.Value ? Convert.ToInt32(reader["CreatedBy"]) : -1,
                        CreatedUser = reader["CreatedUser"].ToString(),
                        CreatedDate = reader["CreatedDate"] != DBNull.Value ? (DateTime)reader["CreatedDate"] : (DateTime)SqlDateTime.Null,
                        ModifiedBy = reader["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(reader["ModifiedBy"]) : -1,
                        ModifiedUser = reader["ModifiedUser"].ToString(),
                        ModifiedDate = reader["ModifiedDate"] != DBNull.Value ? (DateTime)reader["ModifiedDate"] : (DateTime)SqlDateTime.Null
                    });
                }
            }

            return result;
        }
示例#42
0
        public void SaveAdministrators(SmartCollection<User> admins)
        {
            if (admins == null) return;

            if (this.hostSettings != null) {
                if (hostSettings.ValidateModel()) {
                    using (HostDAO dao = new HostDAO()) {
                        dao.SaveHostSettings(this.hostSettings);
                        AppVars.dbSettings = hostSettings;
                    }
                }
            }

            try {
                int result = -1;
                string sql;
                using (HostDAO dao = new HostDAO()) {
                    this.HostSettings = new SMHostSettings(dao.GetHostSettings());
                    AppVars.dbSettings = hostSettings;

                }
                using (SystemDAO systemDao = new SystemDAO()) {
                    using (systemDao.DbConnection = new MsSqlPersistence(systemDao.DbConnectionSettings)) {
                        if (systemDao.DbConnection.IsConnected()) {
                            using (systemDao.DbCommand) {
                                foreach (User user in admins) {
                                    systemDao.DbCommand.CommandType = System.Data.CommandType.StoredProcedure;
                                    systemDao.DbCommand.Parameters.Clear();
                                    if (user.UserId <= 0 || user.UserId == null) {
                                        systemDao.DbCommand.CommandText = "uspInsertAdministrator";
                                        string hashedPassword = Security.GetSha2Hash(user.Password.Trim(), user.Username.Trim());
                                        systemDao.DbCommand.Parameters.AddWithValue("@Password", hashedPassword);
                                    }else {
                                        systemDao.DbCommand.CommandText = "uspUpdateAdministrator";
                                        systemDao.DbCommand.Parameters.AddWithValue("@UserId", user.UserId);
                                    }
                                    systemDao.DbCommand.Parameters.AddWithValue("@Username", user.Username);
                                    systemDao.DbCommand.Parameters.AddWithValue("@FirstName", user.FirstName);
                                    systemDao.DbCommand.Parameters.AddWithValue("@LastName", user.LastName);
                                    systemDao.DbCommand.Parameters.AddWithValue("@AdministratorYN", true);
                                    string administratorKey = Security.GetSha2Hash(user.Username, hostSettings.BaseKey);
                                    systemDao.DbCommand.Parameters.AddWithValue("@AdministratorKey", administratorKey);
                                    if (user.UserId <= 0 || user.UserId == null) {
                                        result = (int)systemDao.DbConnection.ExecuteCommand(systemDao.DbCommand);
                                    }else result = systemDao.DbConnection.ExecuteCommand(systemDao.DbCommand);
                                }
                            }
                        }else {
                            throw new Exception("Unable to Connect");
                        }
                    }
                }
            }catch {
                throw ;
            }
        }
示例#43
0
        public SmartCollection<SampleTest> DoGetSampleTestsResultsList(SmartCollection<SampleTest> list, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (SampleDAO dao = new SampleDAO()) {
                return dao.GetSampleTestsResultsList(list, identification);
            }
        }
示例#44
0
        public SmartCollection<Contact> GetContacts(int clientId)
        {
            try
            {
                SmartCollection<Contact> resultList = new SmartCollection<Contact>();

                using (DbConnection = new MsSqlPersistence(DbConnectionSettings))
                {
                    if (DbConnection.IsConnected())
                    {
                        using (DbCommand)
                        {
                            DbCommand.CommandType = CommandType.StoredProcedure;
                            DbCommand.CommandText = "uspGetContacts";
                            DbCommand.Parameters.Clear();
                            DbCommand.Parameters.Add("@ClientId", System.Data.SqlDbType.Int).Value = clientId;

                            DataTable contactsDT = DbConnection.ExecuteQuery(DbCommand);
                            foreach (DataRow row in contactsDT.Rows)
                            {
                                Contact contact = new Contact();
                                contact.ContactId = Convert.ToInt32(row["ContactID"]);
                                contact.ClientId = Convert.ToInt32(row["ClientID"]);
                                contact.FirstName = row["FirstName"].ToString();
                                contact.LastName = row["LastName"].ToString();
                                contact.PrimaryEmail = row["PrimaryEmail"].ToString();
                                contact.PrimaryEmailSendYN = row["PrimaryEmailSendYN"] != DBNull.Value ? (bool)row["PrimaryEmailSendYN"] : false;
                                contact.SecondaryEmail = row["SecondaryEmail"].ToString();
                                contact.SecondaryEmailSendYN = row["SecondaryEmailSendYN"] != DBNull.Value ? (bool)row["SecondaryEmailSendYN"] : false;
                                contact.PrimaryPhone = row["PrimaryPhone"].ToString();
                                contact.SecondaryPhone = row["SecondaryPhone"].ToString();
                                contact.Fax = row["Fax"].ToString();
                                contact.FaxSendYN = row["FaxSendYN"] != DBNull.Value ? (bool)row["FaxSendYN"] : false;
                                contact.Comments = row["Comments"].ToString();
                                contact.CreatedBy = row["CreatedBy"] != DBNull.Value ? Convert.ToInt32(row["CreatedBy"]) : -1;
                                contact.CreatedUser = row["CreatedUser"].ToString();
                                contact.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null;
                                contact.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : -1;
                                contact.ModifiedUser = row["ModifiedUser"].ToString();
                                contact.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null;
                                resultList.Add(contact);
                            }
                            contactsDT = null;
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }
                }
                return resultList;
            }
            catch
            {
                throw;
            }
        }
示例#45
0
 public IAsyncResult BeginGetSampleTestsResultsList(SmartCollection<SampleTest> list, Identification identification, AsyncCallback callback, object state)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     if (AppLib.VerifyToken(identification.Token) <= 0) {
         throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
     }
     var task = Task<SmartCollection<SampleTest>>.Factory.StartNew(process => DoGetSampleTestsResultsList(list, identification), state);
     return task.ContinueWith(res => callback(task));
 }
 public SaveStorageLocationsRequest(SmartCollection<StorageLocation> items)
 {
     this.items = items;
 }
示例#47
0
 public SaveResultsRequest(SmartCollection<Result> results)
 {
     this.results = results;
 }
示例#48
0
 public SaveTestsRequest(SmartCollection<Test> items)
 {
     this.items = items;
 }
示例#49
0
 public IAsyncResult BeginSaveResults(SmartCollection<Result> results, Identification identification, AsyncCallback callback, object state)
 {
     logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
     identification.UserId = AppLib.VerifyToken(identification.Token);
     if (identification.UserId <= 0)
     {
         throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));
     }
     var task = Task<int>.Factory.StartNew(process => DoSaveResults(results, identification), state);
     return task.ContinueWith(res => callback(task));
 }
示例#50
0
        public IAsyncResult BeginGetWorkLoad(CatalogItem filterItem, SmartCollection<Analyte> filterAnalytes, DateTime beginStartDate, DateTime beginEndDate, Identification identification, AsyncCallback callback, object state)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));
            if (AppLib.VerifyToken(identification.Token) <= 0)
                throw new FaultException<ServiceFault>(new ServiceFault("Invalid Authentication", "Authorization"), new FaultReason("Unauthorized"));

            var task = Task<SmartCollection<SampleTest>>.Factory.StartNew(process => DoGetWorkLoad(filterItem, filterAnalytes, beginStartDate, beginEndDate, identification), state);
            return task.ContinueWith(res => callback(task));
        }
示例#51
0
        public SmartCollection<Client> GetClientsList()
        {
            try {
                SmartCollection<Client> results = new SmartCollection<Client>();

                using (DbConnection = new MsSqlPersistence(DbConnectionSettings)) {
                    if (DbConnection.IsConnected()) {
                        using (DbCommand) {
                            DbCommand.CommandType = CommandType.StoredProcedure;
                            DbCommand.CommandText = "uspGetClientsList";
                            DbCommand.Parameters.Clear();
                            var reader = DbConnection.ExecuteReader(DbCommand);
                            results.AddRange(AutoMap.MapReaderToList<Client>(reader));
                        }
                    }else {
                        throw new Exception("Unable to Connect");
                    }
                }
                return results;
            }catch {
                throw;
            }
        }
示例#52
0
        public SmartCollection<SampleTest> DoGetWorkLoad(CatalogItem filterItem, SmartCollection<Analyte> filterAnalytes, DateTime beginStartDate, DateTime beginEndDate, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            using (SampleDAO dao = new SampleDAO()) {
                return dao.GetWorkLoad(filterItem, filterAnalytes, beginStartDate, beginEndDate, identification);
            }
        }
示例#53
0
        public SmartCollection<Client> GetClientsRecent(int userId)
        {
            try {
                SmartCollection<Client> resultList = new SmartCollection<Client>();
                using (DbConnection = new MsSqlPersistence(DbConnectionSettings)) {
                    if (DbConnection.IsConnected()) {
                        using (DbCommand) {
                            DbCommand.CommandType = CommandType.StoredProcedure;
                            DbCommand.CommandText = "uspGetClientsRecent";
                            DbCommand.Parameters.Clear();
                            DataTable clientDT = DbConnection.ExecuteQuery(DbCommand);
                            foreach (DataRow row in clientDT.Rows)
                            {
                                Client client = new Client();
                                client.ClientId = Convert.ToInt32(row["ClientID"]);
                                client.AccountingId = row["AccountingID"].ToString();
                                client.ClientName = row["ClientName"].ToString();
                                client.TermId = row["TermID"] != DBNull.Value ? (int)row["TermID"] : -1;
                                if (client.TermId != null && client.TermId != -1)
                                    client.Term = new Term() { TermId = (int)row["TermID"], TermName = row["TermName"].ToString() };
                                client.WebClientYN = row["WebClientYN"] != DBNull.Value ? Convert.ToBoolean(row["WebClientYN"]) : false;
                                client.CreditCheckYN = row["CreditCheckYN"] != DBNull.Value ? Convert.ToBoolean(row["CreditCheckYN"]) : false;
                                client.CreditHoldYN = row["CreditHoldYN"] != DBNull.Value ? Convert.ToBoolean(row["CreditHoldYN"]) : false;
                                client.GMPYN = row["GMPYN"] != DBNull.Value ? Convert.ToBoolean(row["GMPYN"]) : false;
                                client.BillingAddress = row["BillingAddress"].ToString();
                                client.BillingCity = row["BillingCity"].ToString();
                                client.BillingStateId = row["BillingStateID"] != DBNull.Value ? (int)row["BillingStateID"] : -1;
                                if (client.BillingStateId != null && client.BillingStateId != -1)
                                    client.BillingState = new State() { StateId = (int)row["BillingStateID"], StateName = row["BillingStateName"].ToString() };
                                client.BillingZip = row["BillingZip"].ToString();
                                client.BillingCountryId = row["BillingCountryID"] != DBNull.Value ? (int)row["BillingCountryID"] : -1;
                                if (client.BillingCountryId != null && client.BillingCountryId != -1)
                                    client.BillingCountry = new Country() { CountryId = (int)row["BillingCountryID"], CountryName = row["BillingCountryName"].ToString() };
                                client.SameAsBillingYN = row["SameAsBillingYN"] != DBNull.Value ? Convert.ToBoolean(row["SameAsBillingYN"]) : false;
                                client.ShippingAddress = row["ShippingAddress"].ToString();
                                client.ShippingCity = row["ShippingCity"].ToString();
                                client.ShippingStateId = row["ShippingStateID"] != DBNull.Value ? (int)row["ShippingStateID"] : -1;
                                if (client.ShippingStateId != null && client.ShippingStateId != -1)
                                    client.ShippingState = new State() { StateId = (int)row["ShippingStateID"], StateName = row["ShippingStateName"].ToString() };
                                client.ShippingZip = row["ShippingZip"].ToString();
                                client.ShippingCountryId = row["ShippingCountryID"] != DBNull.Value ? (int)row["ShippingCountryID"] : -1;
                                if (client.ShippingCountryId != null && client.ShippingCountryId != -1)
                                    client.ShippingCountry = new Country() { CountryId = (int)row["ShippingCountryID"], CountryName = row["ShippingCountryName"].ToString() };
                                client.CreatedUser = row["CreatedUser"].ToString();
                                client.CreatedBy = row["CreatedBy"] != DBNull.Value ? (int)row["CreatedBy"] : -1;
                                client.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null;
                                client.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? (int)row["ModifiedBy"] : -1;
                                client.ModifiedUser = row["ModifiedUser"].ToString();
                                client.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null;

                                // Other client objects
                                client.Contacts = GetContacts(client.ClientId);
                                client.Prices = GetClientPricings(client.ClientId);
                                client.Documents = GetClientDocuments(client.ClientId);
                                client.Notes = GetClientNotes(client.ClientId);
                                client.Complaints = GetClientComplaints(client.ClientId);

                                resultList.Add(client);
                            }
                            clientDT = null;
                        }
                    }else {
                        throw new Exception("Unable to Connect");
                    }
                }
                return resultList;
            }catch {
                throw;
            }
        }
示例#54
0
        public int DoSaveResults(SmartCollection<Result> results, Identification identification)
        {
            logger.Log(LogLevel.Trace, AppLib.GetCaller(logger));

            // Save Results
            using (SampleDAO dao = new SampleDAO())
            {
                return dao.SaveResults(results, identification);
            }
        }
 public SaveMethodNumbersRequest(SmartCollection<MethodNumber> items)
 {
     this.items = items;
 }
示例#56
0
 public SaveNotesRequest(SmartCollection<StandardNote> items)
 {
     this.items = items;
 }
示例#57
0
 public SmartCollection<User> GetAdministrators()
 {
     SmartCollection<User> resultList = new SmartCollection<User>();
     try
     {
         AppVars.dbSettings = hostSettings;
         if (HostSettings.ValidateModel()) {
             using (SystemDAO systemDao = new SystemDAO()) {
                 using (systemDao.DbConnection = new MsSqlPersistence(systemDao.DbConnectionSettings)) {
                     if (systemDao.DbConnection.IsConnected()) {
                         using (systemDao.DbCommand) {
                             systemDao.DbCommand.CommandType = System.Data.CommandType.StoredProcedure;
                             systemDao.DbCommand.CommandText = "uspGetAdministrators";
                             resultList.AddRange(AutoMap.MapReaderToList<User>(systemDao.DbConnection.ExecuteReader(systemDao.DbCommand)));
                         }
                     }else {
                         throw new Exception("Unable to Connect");
                     }
                 }
             }
         }
     }catch {
         throw;
     }
     return resultList;
 }
示例#58
0
        public SmartCollection<ClientComplaint> GetClientComplaintsOpen(Identification identification)
        {
            try
            {
                SmartCollection<ClientComplaint> resultList = new SmartCollection<ClientComplaint>();
                using (DbConnection = new MsSqlPersistence(DbConnectionSettings))
                {
                    if (DbConnection.IsConnected())
                    {
                        using (DbCommand)
                        {
                            DbCommand.CommandType = CommandType.StoredProcedure;
                            DbCommand.CommandText = "uspGetClientComplaintsOpen";
                            DbCommand.Parameters.Clear();

                            DataTable returnDT = DbConnection.ExecuteQuery(DbCommand);
                            foreach (DataRow row in returnDT.Rows)
                            {
                                ClientComplaint complaint = new ClientComplaint();
                                complaint.ClientComplaintId = Convert.ToInt32(row["ClientComplaintID"]);
                                complaint.ClientId = Convert.ToInt32(row["ClientID"]);
                                complaint.ClientName = row["ClientName"].ToString();
                                complaint.ClassificationId = row["ClassificationID"] != DBNull.Value ? Convert.ToInt32(row["ClassificationID"]) : -1;
                                if (complaint.ClassificationId.HasValue && complaint.ClassificationId != -1)
                                    complaint.Classification = new Complaint { ComplaintId = complaint.ClassificationId, ComplaintName = row["ComplaintName"].ToString(), Active = true };
                                complaint.Description = row["Description"].ToString();
                                complaint.ARLNumber = row["ARLNumber"].ToString();
                                complaint.StatusYN = (bool)(row["StatusYN"] ?? false);
                                complaint.RootCause = row["RootCause"].ToString();
                                complaint.CorrectiveAction = row["CorrectiveAction"].ToString();
                                if (row["CorrectiveActionDate"] != DBNull.Value)
                                    complaint.CorrectiveActionDate = (DateTime)row["CorrectiveActionDate"];
                                else
                                    complaint.CorrectiveActionDate = null;
                                complaint.CorrectiveActionUserId = row["CorrectiveActionUserID"] != DBNull.Value ? Convert.ToInt32(row["CorrectiveActionUserID"]) : -1;
                                complaint.CorrectiveActionUser = row["CorrectiveUser"].ToString();
                                complaint.NotifyUserId = row["NotifyUserID"] != DBNull.Value ? Convert.ToInt32(row["NotifyUserID"]) : -1;
                                complaint.NotifyUser = row["NotifyUser"].ToString();
                                complaint.CreatedBy = row["CreatedBy"] != DBNull.Value ? Convert.ToInt32(row["CreatedBy"]) : -1;
                                complaint.CreatedUser = row["CreatedUser"].ToString();
                                complaint.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null;
                                complaint.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : -1;
                                complaint.ModifiedUser = row["ModifiedUser"].ToString();
                                complaint.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null;
                                resultList.Add(complaint);
                            }
                            returnDT = null;
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }
                }
                return resultList;
            }
            catch
            {
                throw;
            }
        }
示例#59
0
 public SavePrioritiesRequest(SmartCollection<Priority> items)
 {
     this.items = items;
 }
示例#60
0
 public SaveChargeItemsRequest(SmartCollection<Charge> items)
 {
     this.items = items;
 }