コード例 #1
0
        public string PrintForCollaborators(PrintForCollaboratorsModel model, FormCollection forms)
        {
            // Param
            var channels      = ChannelRepository.GetAll().Count > 0 ? ChannelRepository.GetAll() : ChannelRepository.GetAll();
            var maxRowPerPage = model.MaxRowsPerPage;
            var branchId      = UserContext.GetDefaultBranch();
            var userId        = UserContext.GetCurrentUser().UserID;
            var fromdate      = string.IsNullOrEmpty(model.FromDate)
                ? DateTime.Now.Date
                : DateTime.ParseExact(model.FromDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            var todate = string.IsNullOrEmpty(model.ToDate)
               ? DateTime.Now.Date.AddDays(1).AddSeconds(-1)
               : DateTime.ParseExact(model.ToDate, "dd/MM/yyyy", CultureInfo.InvariantCulture).AddDays(1).AddSeconds(-1);
            var channelIds     = string.Empty;
            var channelAmounts = string.Empty;

            foreach (var channelInfo in channels
                     .Where(c => !forms.Get(c.ChannelId + "_chkChannel").IsStringNullOrEmpty())
                     .Where(c => forms.Get(c.ChannelId + "_txtChannelItems").ToInt32() > 0))
            {
                var amount = forms.Get(channelInfo.ChannelId + "_txtChannelItems").ToInt32();
                channelAmounts = channelAmounts.IsStringNullOrEmpty() ? amount.ToString() : "," + amount;
                channelIds     = channelIds.IsStringNullOrEmpty() ? channelInfo.ChannelId.ToString() : "," + channelInfo.ChannelId;
            }
            if (maxRowPerPage.IsIntegerNull() ||
                channelIds.IsStringNullOrEmpty() ||
                channelAmounts.IsStringNullOrEmpty())
            {
                return(string.Empty);
            }

            // Print
            var printId = ContactRepository.ContactPrintAll(branchId, fromdate, todate, channelIds, channelAmounts, maxRowPerPage, userId, DateTime.Now);

            return(printId.ToString());
        }