public override async Task <CreateResp> Create(CreateReq request, ServerCallContext context) { var createPersistentSubscriptionSource = new TaskCompletionSource <CreateResp>(); var settings = request.Options.Settings; var correlationId = Guid.NewGuid(); var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, CreateOperation, context.CancellationToken).ConfigureAwait(false)) { throw AccessDenied(); } _publisher.Publish(new ClientMessage.CreatePersistentSubscription( correlationId, correlationId, new CallbackEnvelope(HandleCreatePersistentSubscriptionCompleted), request.Options.StreamIdentifier, request.Options.GroupName, settings.ResolveLinks, new StreamRevision(settings.Revision).ToInt64(), settings.MessageTimeoutCase switch { CreateReq.Types.Settings.MessageTimeoutOneofCase.MessageTimeoutMs => settings.MessageTimeoutMs, CreateReq.Types.Settings.MessageTimeoutOneofCase.MessageTimeoutTicks => (int)TimeSpan .FromTicks(settings.MessageTimeoutTicks).TotalMilliseconds, _ => 0 },
public override async Task <CreateResp> Create(CreateReq request, ServerCallContext context) { var options = request.Options; var user = await GetUser(_authenticationProvider, context.RequestHeaders).ConfigureAwait(false); var createSource = new TaskCompletionSource <bool>(); var envelope = new CallbackEnvelope(OnMessage); _queue.Publish(new UserManagementMessage.Create(envelope, user, options.LoginName, options.FullName, options.Groups.ToArray(), options.Password)); await createSource.Task.ConfigureAwait(false); return(new CreateResp()); void OnMessage(Message message) { if (HandleErrors(options.LoginName, message, createSource)) { return; } createSource.TrySetResult(true); } }
public override async Task <CreateResp> Create(CreateReq request, ServerCallContext context) { var createPersistentSubscriptionSource = new TaskCompletionSource <CreateResp>(); var settings = request.Options.Settings; var correlationId = Guid.NewGuid(); var user = await GetUser(_authenticationProvider, context.RequestHeaders).ConfigureAwait(false); _queue.Publish(new ClientMessage.CreatePersistentSubscription( correlationId, correlationId, new CallbackEnvelope(HandleCreatePersistentSubscriptionCompleted), request.Options.StreamName, request.Options.GroupName, settings.ResolveLinks, new StreamRevision(settings.Revision).ToInt64(), (int)TimeSpan.FromTicks(settings.MessageTimeout).TotalMilliseconds, settings.ExtraStatistics, settings.MaxRetryCount, settings.HistoryBufferSize, settings.LiveBufferSize, settings.ReadBatchSize, (int)TimeSpan.FromTicks(settings.CheckpointAfter).TotalMilliseconds, settings.MinCheckpointCount, settings.MaxCheckpointCount, settings.MaxSubscriberCount, settings.NamedConsumerStrategy.ToString(), user,
public override async Task <CreateResp> Create(CreateReq request, ServerCallContext context) { var options = request.Options; var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, CreateOperation, context.CancellationToken).ConfigureAwait(false)) { throw RpcExceptions.AccessDenied(); } var createSource = new TaskCompletionSource <bool>(); var envelope = new CallbackEnvelope(OnMessage); _publisher.Publish(new UserManagementMessage.Create(envelope, user, options.LoginName, options.FullName, options.Groups.ToArray(), options.Password)); await createSource.Task.ConfigureAwait(false); return(new CreateResp()); void OnMessage(Message message) { if (HandleErrors(options.LoginName, message, createSource)) { return; } createSource.TrySetResult(true); } }
public async Task <IActionResult> CreateAnswer([FromForm] CreateReq req) { if ((req.Formula == null || !req.Formula.IsValid()) && req.IonPeak < 0) { return(BadRequest(ApiResponse.Error("bad descriptions"))); } if (string.IsNullOrEmpty(req.Answer) || string.IsNullOrEmpty(req.Problem)) { return(BadRequest(ApiResponse.Error("please input problem and answer descriptions"))); } // save files var problemPictures = new List <string>(); var ansPictures = new List <string>(); if (req.ProbFiles != null && req.ProbFiles.Any()) { foreach (var pic in req.ProbFiles) { problemPictures.Add(await _fileUtil.CopyToServerFileAsync(pic)); } } if (req.AnsFiles != null && req.AnsFiles.Any()) { foreach (var pic in req.AnsFiles) { ansPictures.Add(await _fileUtil.CopyToServerFileAsync(pic)); } } var answer = await _repo.CreateAnswerAsync(req.Problem, req.Answer, problemPictures, ansPictures, req.Formula, req.IonPeak); return(Ok(ApiResponse.Success(ResponseUtil.AnswerConvert(answer)))); }
public override async Task <CreateResp> Create(CreateReq request, ServerCallContext context) { var createdSource = new TaskCompletionSource <bool>(); var options = request.Options; var user = await GetUser(_authenticationProvider, context.RequestHeaders).ConfigureAwait(false); const string handlerType = "JS"; var name = options.ModeCase switch { ModeOneofCase.Continuous => options.Continuous.Name, ModeOneofCase.Transient => options.Transient.Name, ModeOneofCase.OneTime => Guid.NewGuid().ToString("D"), _ => throw new InvalidOperationException() }; var projectionMode = options.ModeCase switch { ModeOneofCase.Continuous => ProjectionMode.Continuous, ModeOneofCase.Transient => ProjectionMode.Transient, ModeOneofCase.OneTime => ProjectionMode.OneTime, _ => throw new InvalidOperationException() }; var emitEnabled = options.ModeCase switch { ModeOneofCase.Continuous => options.Continuous.TrackEmittedStreams, _ => false }; var checkpointsEnables = options.ModeCase switch { ModeOneofCase.Continuous => true, ModeOneofCase.OneTime => false, ModeOneofCase.Transient => false, _ => throw new InvalidOperationException() }; var enabled = true; var trackEmittedStreams = (options.ModeCase, emitEnabled) switch { (ModeOneofCase.Continuous, false) => true, _ => false }; var runAs = new ProjectionManagementMessage.RunAs(user); var envelope = new CallbackEnvelope(OnMessage); _queue.Publish(new ProjectionManagementMessage.Command.Post(envelope, projectionMode, name, runAs, handlerType, options.Query, enabled, checkpointsEnables, emitEnabled, trackEmittedStreams, true)); await createdSource.Task.ConfigureAwait(false); return(new CreateResp()); void OnMessage(Message message) { if (!(message is ProjectionManagementMessage.Updated)) { createdSource.TrySetException(UnknownMessage <ProjectionManagementMessage.Updated>(message)); return; } createdSource.TrySetResult(true); } } } }
public CreateReq Create(CreateReq request) { _unitOfWork.OrderRepository.Add(new Models.DomainModels.Order() { }); _unitOfWork.Commit(); return(null); }
public static void CreateTable(int playoffs, int times, int jiangma, int maima, string token) { Table.CreateReq table = new CreateReq(); table.token = token; table.playoffs = playoffs; table.times = times; table.jiangma = jiangma; table.maima = maima; NetClient.Instance().WriteMsg("Table.CreateReq", table); }
public async Task <IActionResult> Create([FromBody] CreateReq req) { if (string.IsNullOrWhiteSpace(req.Key)) { return(NotFound("Method Dictionary/Create params")); } Logger.LogInformation($"Create dictionary key: {req.Key}"); await _service.Create(req.Key).ConfigureAwait(false); return(Ok()); }
public void OnNpcPutOut(SelItemGrid_N selItem) { if (mCurrentSelItem != selItem) { mCurrentSelItem = selItem; CreateReq req = new CreateReq(); req.mType = OpType.NpcSetting; // req.mReq = AssetBundlesMan.Instance.AddReq(mCurrentSelItem.mNpcPath, Vector3.zero, Quaternion.identity); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); CreateMode(Instantiate(Resources.Load(mCurrentSelItem.mNpcPath)) as GameObject, req); } }
void CreateMode(GameObject go, CreateReq req) { BoxCollider bc = go.AddComponent <BoxCollider>(); Bounds bound = bc.bounds; Collider[] childCols = go.GetComponentsInChildren <Collider>(); foreach (Collider col in childCols) { bound.Encapsulate(col.bounds); if (!req.mIsLoad) { col.enabled = false; } } bc.center = bound.center - go.transform.position; bc.size = bound.size; BuildOpItem opItem = go.AddComponent <BuildOpItem>(); switch (req.mType) { case OpType.ItemSetting: opItem.mType = OpType.ItemSetting; opItem.mItemID = req.mItemId; mItemList.Add(opItem); break; case OpType.NpcSetting: opItem.mType = OpType.NpcSetting; mNpcList.Add(opItem); bc.center += 1f * Vector3.up; bc.size += 0.5f * Vector3.up; break; } if (!req.mIsLoad) { mPutOutItem = opItem; } }
public async Task <IActionResult> UpdateAnswer([FromRoute] int id, [FromForm] CreateReq req) { var ans = _repo.RetrieveAnswerById(id); if (ans == null) { return(NotFound(ApiResponse.Error("answer not found"))); } if ((req.Formula == null || !req.Formula.IsValid()) && req.IonPeak < 0) { return(BadRequest(ApiResponse.Error("please limit conditions"))); } if (string.IsNullOrEmpty(req.Answer) || string.IsNullOrEmpty(req.Problem)) { return(BadRequest(ApiResponse.Error("please input problem and answer descriptions"))); } var problemPictures = new List <string>(); var ansPictures = new List <string>(); if (req.ProbFiles != null && req.ProbFiles.Any()) { foreach (var pic in req.ProbFiles) { problemPictures.Add(await _fileUtil.CopyToServerFileAsync(pic)); } } if (req.AnsFiles != null && req.AnsFiles.Any()) { foreach (var pic in req.AnsFiles) { ansPictures.Add(await _fileUtil.CopyToServerFileAsync(pic)); } } var answer = await _repo.UpdateAnswerAsync(id, req.Problem, req.Answer, problemPictures, ansPictures, req.IonPeak, req.Formula); return(Ok(ApiResponse.Success(ResponseUtil.AnswerConvert(answer)))); }
public override async Task <CreateResp> Create(CreateReq request, ServerCallContext context) { var createPersistentSubscriptionSource = new TaskCompletionSource <CreateResp>(); var settings = request.Options.Settings; var correlationId = Guid.NewGuid(); var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, CreateOperation, context.CancellationToken).ConfigureAwait(false)) { throw AccessDenied(); } _publisher.Publish(new ClientMessage.CreatePersistentSubscription( correlationId, correlationId, new CallbackEnvelope(HandleCreatePersistentSubscriptionCompleted), request.Options.StreamIdentifier, request.Options.GroupName, settings.ResolveLinks, new StreamRevision(settings.Revision).ToInt64(), (int)TimeSpan.FromTicks(settings.MessageTimeout).TotalMilliseconds, settings.ExtraStatistics, settings.MaxRetryCount, settings.HistoryBufferSize, settings.LiveBufferSize, settings.ReadBatchSize, (int)TimeSpan.FromTicks(settings.CheckpointAfter).TotalMilliseconds, settings.MinCheckpointCount, settings.MaxCheckpointCount, settings.MaxSubscriberCount, settings.NamedConsumerStrategy.ToString(), user)); return(await createPersistentSubscriptionSource.Task.ConfigureAwait(false)); void HandleCreatePersistentSubscriptionCompleted(Message message) { if (message is ClientMessage.NotHandled notHandled && RpcExceptions.TryHandleNotHandled(notHandled, out var ex)) { createPersistentSubscriptionSource.TrySetException(ex); return; } if (!(message is ClientMessage.CreatePersistentSubscriptionCompleted completed)) { createPersistentSubscriptionSource.TrySetException( RpcExceptions.UnknownMessage <ClientMessage.CreatePersistentSubscriptionCompleted>(message)); return; } switch (completed.Result) { case CreatePersistentSubscriptionResult.Success: createPersistentSubscriptionSource.TrySetResult(new CreateResp()); return; case CreatePersistentSubscriptionResult.Fail: createPersistentSubscriptionSource.TrySetException(RpcExceptions.PersistentSubscriptionFailed(request.Options.StreamIdentifier, request.Options.GroupName, completed.Reason)); return; case CreatePersistentSubscriptionResult.AlreadyExists: createPersistentSubscriptionSource.TrySetException(RpcExceptions.PersistentSubscriptionExists(request.Options.StreamIdentifier, request.Options.GroupName)); return; case CreatePersistentSubscriptionResult.AccessDenied: createPersistentSubscriptionSource.TrySetException(RpcExceptions.AccessDenied()); return; default: createPersistentSubscriptionSource.TrySetException(RpcExceptions.UnknownError(completed.Result)); return; } } }
void OnLoadBtn() { if (mFileName.text == "") { return; } string _strFilePath = GameConfig.GetUserDataPath() + "/PlanetExplorers/Building/"; if (!Directory.Exists(_strFilePath)) { Directory.CreateDirectory(_strFilePath); } for (int i = 0; i < mItemList.Count; i++) { Destroy(mItemList[i].gameObject); } mItemList.Clear(); for (int i = 0; i < mNpcList.Count; i++) { Destroy(mNpcList[i].gameObject); } mNpcList.Clear(); if (null != Block45Man.self.DataSource) { Block45Man.self.DataSource.Clear(); } if (File.Exists(_strFilePath + mFileName.text + ".txt")) { using (FileStream _fileStream = new FileStream(_strFilePath + mFileName.text + ".txt", FileMode.Open, FileAccess.Read)) { BinaryReader _in = new BinaryReader(_fileStream); int readVersion = _in.ReadInt32(); switch (readVersion) { case 2: int Size = _in.ReadInt32(); for (int i = 0; i < Size; i++) { IntVector3 index = new IntVector3(_in.ReadInt32(), _in.ReadInt32(), _in.ReadInt32()); Block45Man.self.DataSource.SafeWrite(new B45Block(_in.ReadByte(), _in.ReadByte()), index.x, index.y, index.z, 0); } break; } _in.Close(); } } if (File.Exists(_strFilePath + mFileName.text + "SubInfo.txt")) { using (FileStream _fileStream = new FileStream(_strFilePath + mFileName.text + "SubInfo.txt", FileMode.Open, FileAccess.Read)) { BinaryReader _in = new BinaryReader(_fileStream); int version = _in.ReadInt32(); int count = _in.ReadInt32(); switch (version) { case 1: for (int i = 0; i < count; i++) { Vector3 npcPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.NpcSetting; // req.mReq = AssetBundlesMan.Instance.AddReq("Model/PlayerModel/Male", npcPos, Quaternion.identity); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load("Model/PlayerModel/Male")) as GameObject; obj.transform.position = npcPos; CreateMode(obj, req); } break; case 2: for (int i = 0; i < count; i++) { Vector3 npcPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.NpcSetting; // req.mReq = AssetBundlesMan.Instance.AddReq("Model/PlayerModel/Male", npcPos, Quaternion.identity); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load("Model/PlayerModel/Male")) as GameObject; obj.transform.position = npcPos; CreateMode(obj, req); } count = _in.ReadInt32(); for (int i = 0; i < count; i++) { Vector3 itemPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle()); Quaternion ItemRot = Quaternion.Euler(new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle())); int itemID = _in.ReadInt32(); ItemProto itemData = ItemProto.GetItemData(itemID); if (null == itemData || !itemData.IsBlock()) { continue; } CreateReq req = new CreateReq(); req.mIsLoad = true; req.mType = OpType.ItemSetting; req.mItemId = itemID; // req.mReq = AssetBundlesMan.Instance.AddReq(ItemData.GetItemData(itemID).m_ModelPath, itemPos, ItemRot); // req.mReq.ReqFinishWithReqHandler += OnSpawned; // mCreateReqList.Add(req); GameObject obj = Instantiate(Resources.Load(ItemProto.GetItemData(itemID).resourcePath)) as GameObject; obj.transform.position = itemPos; obj.transform.localRotation = ItemRot; CreateMode(obj, req); // CreateMode(Instantiate(Resources.Load(ItemData.GetItemData(itemID).m_ModelPath)) as GameObject, req); } break; } _in.Close(); } } }
public override async Task <CreateResp> Create(CreateReq request, ServerCallContext context) { var createPersistentSubscriptionSource = new TaskCompletionSource <CreateResp>(); var settings = request.Options.Settings; var correlationId = Guid.NewGuid(); var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, CreateOperation, context.CancellationToken).ConfigureAwait(false)) { throw AccessDenied(); } string streamId = null; switch (request.Options.StreamOptionCase) { case StreamOptionOneofCase.Stream: case StreamOptionOneofCase.None: /*for backwards compatibility*/ { StreamRevision startRevision; if (request.Options.StreamOptionCase == StreamOptionOneofCase.Stream) { streamId = request.Options.Stream.StreamIdentifier; startRevision = request.Options.Stream.RevisionOptionCase switch { RevisionOptionOneofCase.Revision => new StreamRevision(request.Options.Stream.Revision), RevisionOptionOneofCase.Start => StreamRevision.Start, RevisionOptionOneofCase.End => StreamRevision.End, _ => throw new InvalidOperationException() }; } else /*for backwards compatibility*/ { #pragma warning disable 612 streamId = request.Options.StreamIdentifier; startRevision = new StreamRevision(request.Options.Settings.Revision); #pragma warning restore 612 } _publisher.Publish( new ClientMessage.CreatePersistentSubscriptionToStream( correlationId, correlationId, new CallbackEnvelope(HandleCreatePersistentSubscriptionCompleted), streamId, request.Options.GroupName, settings.ResolveLinks, startRevision.ToInt64(), settings.MessageTimeoutCase switch { CreateReq.Types.Settings.MessageTimeoutOneofCase.MessageTimeoutMs => settings .MessageTimeoutMs, CreateReq.Types.Settings.MessageTimeoutOneofCase.MessageTimeoutTicks => (int)TimeSpan .FromTicks(settings.MessageTimeoutTicks).TotalMilliseconds, _ => 0 }, settings.ExtraStatistics, settings.MaxRetryCount, settings.HistoryBufferSize, settings.LiveBufferSize, settings.ReadBatchSize, settings.CheckpointAfterCase switch { CreateReq.Types.Settings.CheckpointAfterOneofCase.CheckpointAfterMs => settings .CheckpointAfterMs, CreateReq.Types.Settings.CheckpointAfterOneofCase.CheckpointAfterTicks => (int)TimeSpan .FromTicks(settings.CheckpointAfterTicks).TotalMilliseconds, _ => 0 },
public ActionResult pivotNewInpatients([Bind(Include = "ProvCode,FacilityId,Year")] CreateReq req) { string ProvinceCode; int FacilityId, Year; ProvinceCode = req.ProvCode; FacilityId = req.FacilityId; Year = req.Year; var data = _context.PvtNewInpatientCases.AsNoTracking().ToList(); if (ProvinceCode != "" && FacilityId != 0 && Year != 0) { data = _context.PvtNewInpatientCases.AsNoTracking().Where(m => m.Year.Equals(Year) && m.Province.Equals(ProvinceCode) && m.FacilityId.Equals(FacilityId)).ToList(); } else if (ProvinceCode != "" & FacilityId != 0) { data = _context.PvtNewInpatientCases.AsNoTracking().Where(m => m.Province.Equals(ProvinceCode) && m.FacilityId.Equals(FacilityId)).ToList(); } else if (ProvinceCode != "" && Year != 0) { data = _context.PvtNewInpatientCases.AsNoTracking().Where(m => m.Province.Equals(ProvinceCode) && m.Year.Equals(Year)).ToList(); } else if (ProvinceCode != "") { data = _context.PvtNewInpatientCases.AsNoTracking().Where(m => m.Province.Equals(ProvinceCode)).ToList(); } else if (FacilityId != 0 && Year != 0) { data = _context.PvtNewInpatientCases.AsNoTracking().Where(m => m.FacilityId.Equals(FacilityId) && m.Year.Equals(Year)).ToList(); } else if (FacilityId != 0) { data = _context.PvtNewInpatientCases.AsNoTracking().Where(m => m.FacilityId.Equals(FacilityId)).ToList(); } else if (Year != 0) { data = _context.PvtNewInpatientCases.AsNoTracking().Where(m => m.Year.Equals(Year)).ToList(); } ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2013; IWorkbook workbook = application.Workbooks.Create(2); IWorksheet sheet = workbook.Worksheets[0]; sheet.ImportData(data, 1, 1, true); sheet.Name = "Data"; IWorksheet pivotSheet = workbook.Worksheets[1]; pivotSheet.Name = "PivotTable"; pivotSheet["A2"].Text = "HMIR New Inpatient Cases"; pivotSheet.Range["A2"].CellStyle.Font.Size = 14f; pivotSheet.Range["A2"].CellStyle.Font.Bold = true; pivotSheet.Range["A3"].Text = "Date extracted: " + DateTime.Now.ToString();; pivotSheet.Range["A3"].CellStyle.Font.Size = 10f; pivotSheet.Range["A3"].CellStyle.Font.Bold = true; pivotSheet.Range["A3"].CellStyle.Font.Italic = true; if (sheet == null) { ModelState.AddModelError("Error", "There was error in selection or there is no data for the selected criteria"); return(RedirectToAction("Index")); } IPivotCache cash_data = workbook.PivotCaches.Add(sheet.UsedRange); IPivotTable pivotTable = pivotSheet.PivotTables.Add("PivotTable1", pivotSheet["A5"], cash_data); IPivotTableOptions options = pivotTable.Options; options.ShowFieldList = false; pivotTable.Fields["District"].Axis = PivotAxisTypes.Page; pivotTable.Fields["Province"].Axis = PivotAxisTypes.Page; pivotTable.Fields["FacilityId"].Axis = PivotAxisTypes.Page; pivotTable.Fields["FacilityName"].Axis = PivotAxisTypes.Page; pivotTable.Fields["FacilityType"].Axis = PivotAxisTypes.Page; pivotTable.Fields["Year"].Axis = PivotAxisTypes.Page; pivotTable.Fields["Month"].Axis = PivotAxisTypes.Page; pivotTable.Fields["ElementName"].Axis = PivotAxisTypes.Row; IPivotField FemaleOver5 = pivotTable.Fields["FemaleOver5"]; IPivotField FemaleUnder5 = pivotTable.Fields["FemaleUnder5"]; IPivotField MaleOver5 = pivotTable.Fields["MaleOver5"]; IPivotField MaleUnder5 = pivotTable.Fields["MaleUnder5"]; IPivotField ReferreddIn = pivotTable.Fields["ReferredIn"]; IPivotField ReferredOut = pivotTable.Fields["ReferredOut"]; IPivotField Deaths = pivotTable.Fields["Deaths"]; IPivotField Total = pivotTable.Fields["Total"]; pivotTable.DataFields.Add(FemaleOver5, "FO5", PivotSubtotalTypes.Sum); pivotTable.DataFields.Add(FemaleUnder5, "FU5", PivotSubtotalTypes.Sum); pivotTable.DataFields.Add(MaleOver5, "MO5", PivotSubtotalTypes.Sum); pivotTable.DataFields.Add(MaleUnder5, "MU5", PivotSubtotalTypes.Sum); pivotTable.DataFields.Add(ReferreddIn, "ReferIns", PivotSubtotalTypes.Sum); pivotTable.DataFields.Add(ReferredOut, "ReferOuts", PivotSubtotalTypes.Sum); pivotTable.DataFields.Add(Deaths, "Deaths", PivotSubtotalTypes.Sum); pivotTable.DataFields.Add(Total, "Total", PivotSubtotalTypes.Sum); IPivotTableOptions option = pivotTable.Options; option.ErrorString = "X"; pivotTable.BuiltInStyle = PivotBuiltInStyles.PivotStyleDark20; pivotSheet.Activate(); string ContentType = "Application/msexcel"; string filename = "HMIR_" + "NewInpatientCases" + "_" + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + ".xlsx"; MemoryStream ms = new MemoryStream(); workbook.SaveAs(ms); ms.Position = 0; workbook.Close(); excelEngine.Dispose(); return(File(ms, ContentType, filename)); }