Example #1
0
        private CallLogFilter ConvertFilterDTOToFilterEntity(CallLog_CallLogFilterDTO CallLog_CallLogFilterDTO)
        {
            CallLogFilter CallLogFilter = new CallLogFilter();

            CallLogFilter.Selects   = CallLogSelect.ALL;
            CallLogFilter.Skip      = CallLog_CallLogFilterDTO.Skip;
            CallLogFilter.Take      = CallLog_CallLogFilterDTO.Take;
            CallLogFilter.OrderBy   = CallLog_CallLogFilterDTO.OrderBy;
            CallLogFilter.OrderType = CallLog_CallLogFilterDTO.OrderType;

            CallLogFilter.Id                = CallLog_CallLogFilterDTO.Id;
            CallLogFilter.Title             = CallLog_CallLogFilterDTO.Title;
            CallLogFilter.Content           = CallLog_CallLogFilterDTO.Content;
            CallLogFilter.Phone             = CallLog_CallLogFilterDTO.Phone;
            CallLogFilter.CallTime          = CallLog_CallLogFilterDTO.CallTime;
            CallLogFilter.EntityReferenceId = CallLog_CallLogFilterDTO.EntityReferenceId;
            CallLogFilter.EntityId          = CallLog_CallLogFilterDTO.EntityId;
            CallLogFilter.CallTypeId        = CallLog_CallLogFilterDTO.CallTypeId;
            CallLogFilter.CallCategoryId    = CallLog_CallLogFilterDTO.CallCategoryId;
            CallLogFilter.CallEmotionId     = CallLog_CallLogFilterDTO.CallEmotionId;
            CallLogFilter.CallStatusId      = CallLog_CallLogFilterDTO.CallStatusId;
            CallLogFilter.AppUserId         = CallLog_CallLogFilterDTO.AppUserId;
            CallLogFilter.CreatorId         = CallLog_CallLogFilterDTO.CreatorId;
            CallLogFilter.CreatedAt         = CallLog_CallLogFilterDTO.CreatedAt;
            CallLogFilter.UpdatedAt         = CallLog_CallLogFilterDTO.UpdatedAt;
            return(CallLogFilter);
        }
Example #2
0
        public async Task <ActionResult <int> > Count([FromBody] CallLog_CallLogFilterDTO CallLog_CallLogFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            CallLogFilter CallLogFilter = ConvertFilterDTOToFilterEntity(CallLog_CallLogFilterDTO);

            CallLogFilter = await CallLogService.ToFilter(CallLogFilter);

            int count = await CallLogService.Count(CallLogFilter);

            return(count);
        }
Example #3
0
        public async Task <ActionResult <List <CallLog_CallLogDTO> > > List([FromBody] CallLog_CallLogFilterDTO CallLog_CallLogFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            CallLogFilter CallLogFilter = ConvertFilterDTOToFilterEntity(CallLog_CallLogFilterDTO);

            CallLogFilter = await CallLogService.ToFilter(CallLogFilter);

            List <CallLog> CallLogs = await CallLogService.List(CallLogFilter);

            List <CallLog_CallLogDTO> CallLog_CallLogDTOs = CallLogs
                                                            .Select(c => new CallLog_CallLogDTO(c)).ToList();

            return(CallLog_CallLogDTOs);
        }
Example #4
0
        public async Task <ActionResult> ExportTemplate([FromBody] CallLog_CallLogFilterDTO CallLog_CallLogFilterDTO)
        {
            if (UnAuthorization)
            {
                return(Forbid());
            }
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            MemoryStream memoryStream = new MemoryStream();

            using (ExcelPackage excel = new ExcelPackage(memoryStream))
            {
                #region CallLog
                var CallLogHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "EntityReferenceId",
                        "CallTypeId",
                        "CallEmotionId",
                        "AppUserId",
                        "Title",
                        "Content",
                        "Phone",
                        "CallTime",
                        "Used",
                    }
                };
                List <object[]> CallLogData = new List <object[]>();
                excel.GenerateWorksheet("CallLog", CallLogHeaders, CallLogData);
                #endregion

                #region AppUser
                var AppUserFilter = new AppUserFilter();
                AppUserFilter.Selects   = AppUserSelect.ALL;
                AppUserFilter.OrderBy   = AppUserOrder.Id;
                AppUserFilter.OrderType = OrderType.ASC;
                AppUserFilter.Skip      = 0;
                AppUserFilter.Take      = int.MaxValue;
                List <AppUser> AppUsers = await AppUserService.List(AppUserFilter);

                var AppUserHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Username",
                        "DisplayName",
                        "Address",
                        "Email",
                        "Phone",
                        "SexId",
                        "Birthday",
                        "Avatar",
                        "PositionId",
                        "Department",
                        "OrganizationId",
                        "ProvinceId",
                        "Longitude",
                        "Latitude",
                        "StatusId",
                    }
                };
                List <object[]> AppUserData = new List <object[]>();
                for (int i = 0; i < AppUsers.Count; i++)
                {
                    var AppUser = AppUsers[i];
                    AppUserData.Add(new Object[]
                    {
                        AppUser.Id,
                        AppUser.Username,
                        AppUser.DisplayName,
                        AppUser.Address,
                        AppUser.Email,
                        AppUser.Phone,
                        AppUser.SexId,
                        AppUser.Birthday,
                        AppUser.Avatar,
                        AppUser.PositionId,
                        AppUser.Department,
                        AppUser.OrganizationId,
                        AppUser.ProvinceId,
                        AppUser.Longitude,
                        AppUser.Latitude,
                        AppUser.StatusId,
                    });
                }
                excel.GenerateWorksheet("AppUser", AppUserHeaders, AppUserData);
                #endregion
                #region EntityReference
                var EntityReferenceFilter = new EntityReferenceFilter();
                EntityReferenceFilter.Selects   = EntityReferenceSelect.ALL;
                EntityReferenceFilter.OrderBy   = EntityReferenceOrder.Id;
                EntityReferenceFilter.OrderType = OrderType.ASC;
                EntityReferenceFilter.Skip      = 0;
                EntityReferenceFilter.Take      = int.MaxValue;
                List <EntityReference> EntityReferences = await EntityReferenceService.List(EntityReferenceFilter);

                var EntityReferenceHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Code",
                        "Name",
                    }
                };
                List <object[]> EntityReferenceData = new List <object[]>();
                for (int i = 0; i < EntityReferences.Count; i++)
                {
                    var EntityReference = EntityReferences[i];
                    EntityReferenceData.Add(new Object[]
                    {
                        EntityReference.Id,
                        EntityReference.Code,
                        EntityReference.Name,
                    });
                }
                excel.GenerateWorksheet("EntityReference", EntityReferenceHeaders, EntityReferenceData);
                #endregion
                #region CallType
                var CallTypeFilter = new CallTypeFilter();
                CallTypeFilter.Selects   = CallTypeSelect.ALL;
                CallTypeFilter.OrderBy   = CallTypeOrder.Id;
                CallTypeFilter.OrderType = OrderType.ASC;
                CallTypeFilter.Skip      = 0;
                CallTypeFilter.Take      = int.MaxValue;
                List <CallType> CallTypes = await CallTypeService.List(CallTypeFilter);

                var CallTypeHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Code",
                        "Name",
                        "ColorCode",
                        "StatusId",
                        "Used",
                    }
                };
                List <object[]> CallTypeData = new List <object[]>();
                for (int i = 0; i < CallTypes.Count; i++)
                {
                    var CallType = CallTypes[i];
                    CallTypeData.Add(new Object[]
                    {
                        CallType.Id,
                        CallType.Code,
                        CallType.Name,
                        CallType.ColorCode,
                        CallType.StatusId,
                        CallType.Used,
                    });
                }
                excel.GenerateWorksheet("CallType", CallTypeHeaders, CallTypeData);
                #endregion
                #region CallEmotion
                var CallEmotionFilter = new CallEmotionFilter();
                CallEmotionFilter.Selects   = CallEmotionSelect.ALL;
                CallEmotionFilter.OrderBy   = CallEmotionOrder.Id;
                CallEmotionFilter.OrderType = OrderType.ASC;
                CallEmotionFilter.Skip      = 0;
                CallEmotionFilter.Take      = int.MaxValue;
                List <CallEmotion> CallEmotions = await CallEmotionService.List(CallEmotionFilter);

                var CallEmotionHeaders = new List <string[]>()
                {
                    new string[] {
                        "Id",
                        "Name",
                        "Code",
                        "StatusId",
                        "DisplayOrder",
                        "Description",
                    }
                };
                List <object[]> CallEmotionData = new List <object[]>();
                for (int i = 0; i < CallEmotions.Count; i++)
                {
                    var CallEmotion = CallEmotions[i];
                    CallEmotionData.Add(new Object[]
                    {
                        CallEmotion.Id,
                        CallEmotion.Name,
                        CallEmotion.Code,
                        CallEmotion.StatusId,
                        CallEmotion.Description,
                    });
                }
                excel.GenerateWorksheet("CallEmotion", CallEmotionHeaders, CallEmotionData);
                #endregion
                excel.Save();
            }
            return(File(memoryStream.ToArray(), "application/octet-stream", "CallLog.xlsx"));
        }