public virtual IEnumerable UploadFile(PXAdapter adapter) { this.Save.Press(); if (this.NewFacePanel.AskExt() == WebDialogResult.OK) { var person = this.Persons.Current; if (person != null) { const string PanelSessionKey = "FaceFile"; var info = PXContext.SessionTyped <PXSessionStatePXData>().FileInfo[PanelSessionKey] as PX.SM.FileInfo; try { var faceId = Api.AddPersonFace(person, info.BinData); info.UID = faceId; try { info.UID = faceId; SaveFile(info); } catch (Exception ex) { PXTrace.WriteError(ex); Api.DeletePersonFace(person, faceId); } } finally { System.Web.HttpContext.Current.Session.Remove(PanelSessionKey); } PXLongOperation.StartOperation(this, () => { Api.Train(person.GroupName); }); } } return(adapter.Get()); }
private void SetRecognitionResult(APInvoiceRecognitionEntry graph) { var fileIdEncoded = Request.QueryString[APInvoiceRecognitionEntry.FileIdParameter]; if (fileIdEncoded == null) { return; } var fileIdString = HttpUtility.UrlDecode(fileIdEncoded); Guid fileId; if (!Guid.TryParse(fileIdString, out fileId)) { return; } var file = graph.GetSystemFile(fileId); if (file == null) { return; } var fileInfoInMemory = new PX.SM.FileInfo(fileId, file.Name, null, file.Data); PXContext.SessionTyped <PXSessionStatePXData>().FileInfo[fileInfoInMemory.UID.ToString()] = fileInfoInMemory; var uriEncoded = Request.QueryString[APInvoiceRecognitionEntry.RecognitionUriParameter]; if (uriEncoded == null) { return; } var uriString = HttpUtility.UrlDecode(uriEncoded); var uri = new Uri(uriString, UriKind.RelativeOrAbsolute); var recognitionTask = Task.Run(() => graph.InvoiceRecognitionClient.GetRecognitionResult(uri)); recognitionTask.Wait(); graph.StoreRecognitionResultIntoSession(recognitionTask.Result, fileIdString); }
public virtual IEnumerable UploadFile(PXAdapter adapter) { bool doImport = true; if (CASetup.Current.ImportToSingleAccount == true) { CABankTranHeader row = Header.Current; if (row == null || Header.Current.CashAccountID == null) { throw new PXException(Messages.CashAccountMustBeSelectedToImportStatement); } else { CashAccount acct = PXSelect <CashAccount, Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID); if (acct != null && string.IsNullOrEmpty(acct.StatementImportTypeName)) { throw new PXException(Messages.StatementImportServiceMustBeConfiguredForTheCashAccount); } } } else { if (string.IsNullOrEmpty(CASetup.Current.StatementImportTypeName)) { throw new PXException(Messages.StatementImportServiceMustBeConfiguredInTheCASetup); } } if (Header.Current != null && this.IsDirty == true) { if (CASetup.Current.ImportToSingleAccount != true) { if (Header.Ask(Messages.ImportConfirmationTitle, Messages.UnsavedDataInThisScreenWillBeLostConfirmation, MessageButtons.YesNo) != WebDialogResult.Yes) { doImport = false; } } else { doImport = true; } } if (doImport) { if (this.NewRevisionPanel.AskExt() == WebDialogResult.OK) { CABankTranHeader currHeader = Header.Current; const string PanelSessionKey = "ImportStatementProtoFile"; PX.SM.FileInfo info = PXContext.SessionTyped <PXSessionStatePXData>().FileInfo[PanelSessionKey] as PX.SM.FileInfo; System.Web.HttpContext.Current.Session.Remove(PanelSessionKey); ImportStatement(info, true); Save.Press(); CABankTranHeader newRow = this.Header.Current; List <CABankTranHeader> result = new List <CABankTranHeader>(); result.Add(newRow); return(result); } } return(adapter.Get()); }
public IEnumerable insertFromExcel(PXAdapter adapter) { if (this.MatrixItems4Creation.AskExt() == WebDialogResult.OK) { int num1 = 1; FileInfo fileInfo = PXContext.SessionTyped <PXSessionStatePXData>().FileInfo["ImportMatrixFile"]; //HttpContext.Current.Session.Remove("ImportMatrixFile"); using (XLSXReader xlsxReader = new XLSXReader(fileInfo.BinData)) { xlsxReader.Reset(); xlsxReader.IndexKeyPairs.ToDictionary <KeyValuePair <int, string>, int, string>((Func <KeyValuePair <int, string>, int>)(p => p.Key), (Func <KeyValuePair <int, string>, string>)(p => p.Value)); xlsxReader.MoveNext(); while (xlsxReader.MoveNext()) { try { InventoryItem template = InventoryItem.PK.Find((PXGraph)this.Base, this.Base1.Header.Current.TemplateItemID); CreateMatrixItemsHelper matrixItemsHelper = new CreateMatrixItemsHelper((PXGraph)this.Base); System.Collections.Generic.List <INMatrixGenerationRule> idGenerationRules; System.Collections.Generic.List <INMatrixGenerationRule> descrGenerationRules; matrixItemsHelper.GetGenerationRules(this.Base1.Header.Current.TemplateItemID, out idGenerationRules, out descrGenerationRules); foreach (EntryMatrix row in this.Base1.Matrix.Cache.Cached.Cast <EntryMatrix>().Where <EntryMatrix>((Func <EntryMatrix, bool>)(entry => { bool?isPreliminary = entry.IsPreliminary; bool flag = true; return(!(isPreliminary.GetValueOrDefault() == flag & isPreliminary.HasValue)); }))) { for (int attributeNumber = 0; attributeNumber < row.InventoryIDs.Length; ++attributeNumber) { MatrixInventoryItem newItem = matrixItemsHelper.CreateMatrixItemFromTemplate(row, attributeNumber, template, idGenerationRules, descrGenerationRules); if (newItem != null) { newItem.InventoryCD = xlsxReader.GetValue(2); newItem.Descr = xlsxReader.GetValue(3); newItem.InventoryID = new int?(++num1); newItem.Duplicate = new bool?(this.Base.Caches[typeof(MatrixInventoryItem)].Cached.RowCast <MatrixInventoryItem>().Any <MatrixInventoryItem>((Func <MatrixInventoryItem, bool>)(mi => mi.InventoryCD == newItem.InventoryCD))); MatrixInventoryItem matrixInventoryItem = newItem; bool?exists = newItem.Exists; bool flag1 = true; int num2; if (!(exists.GetValueOrDefault() == flag1 & exists.HasValue)) { bool?duplicate = newItem.Duplicate; bool flag2 = true; num2 = !(duplicate.GetValueOrDefault() == flag2 & duplicate.HasValue) ? 1 : 0; } else { num2 = 0; } bool?nullable = new bool?(num2 != 0); matrixInventoryItem.Selected = nullable; System.Collections.Generic.List <string> stringList = new System.Collections.Generic.List <string>(); for (int index = 15; index <= xlsxReader.IndexKeyPairs.Count; ++index) { stringList.Add(xlsxReader.GetValue(index)); } newItem.AttributeValues = stringList.ToArray(); this.Base1.MatrixItemsForCreation.Cache.Hold((object)newItem); } } } } catch (Exception ex) { throw ex; } finally { xlsxReader.Dispose(); } } } } return(adapter.Get()); }