コード例 #1
0
        public void HasAmountOnInvoice(DlgInfos dlgInfos)
        {
            var amount  = dlgInfos.Values.First(n => n.FieldName == "AMOUNT");
            var docType = dlgInfos.Values.First(n => n.FieldName == "DOCUMENT_TYPE");

            if (amount.Item == null && docType.Item != null && docType.Item.ToString().ToLower() == "invoice")
            {
                throw new NoAmountFoundException("You did not provide any amount for this invoice");
            }
        }
コード例 #2
0
        public void IsDuplicate(DlgInfos dlgInfos)
        {
            var query = new DialogExpression()
            {
                Operation = DialogExpressionOperation.And,
                Condition = GetDialogExpressionConditions(dlgInfos)
            };
            int count = GetDocumentsByQuery(dlgInfos.FileCabinetGuid, isDocumentTray: false, query: query).Count;

            if (count > 0)
            {
                throw new DuplicateDocumentException("Document with same index data already exists!");
            }
        }
コード例 #3
0
        public void ProjectExistsInExternalApp(DlgInfos dlgInfos)
        {
            var project = dlgInfos.Values.First(n => n.FieldName == "PROJECT");

            if (project.Item == null)
            {
                throw new ProjectNumberNotSpecifiedException("Please provide a Project Number");
            }
            else
            {
                int projectNumber = Int32.Parse(project.Item.ToString());
                if (!(projectNumber >= 100))
                {
                    throw new InvalidProjectNumberException("Please provide a valid Project Number >= 100");
                }
            }
        }
コード例 #4
0
        public static List <DialogExpressionCondition> GetDialogExpressionConditions(DlgInfos dlgInfos)
        {
            List <DialogExpressionCondition> dialogExpressionConditions = new List <DialogExpressionCondition>();

            foreach (var item in dlgInfos.Values)
            {
                if (item.Item != null && item.ItemElementName.ToLower() == "string")
                {
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: item.Item.ToString()));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "decimal")
                {
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: item.Item.ToString()));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "int")
                {
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: item.Item.ToString()));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "memo")
                {
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: item.Item.ToString()));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "date")
                {
                    DateTime dateTime = DateTime.Parse(item.Item.ToString());
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: dateTime.Date.ToString("s", CultureInfo.CreateSpecificCulture("en-US"))));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "datetime")
                {
                    DateTime dateTime = DateTime.Parse(item.Item.ToString());
                    dialogExpressionConditions.Add(DialogExpressionCondition.Create(fieldName: item.FieldName, value: dateTime.ToString("s", CultureInfo.CreateSpecificCulture("en-US"))));
                }
                if (item.Item != null && item.ItemElementName.ToLower() == "keywords")
                {
                    var key = JsonConvert.DeserializeObject <DocumentIndexFieldKeywords>(item.Item.ToString());

                    foreach (var keyword in key.Keyword)
                    {
                        dialogExpressionConditions.Add(DialogExpressionCondition.Create(item.FieldName, keyword));
                    }
                }
            }
            return(dialogExpressionConditions);
        }
コード例 #5
0
        public void IsPendingDateInFuture(DlgInfos dlgInfos)
        {
            var date = dlgInfos.Values.First(n => n.FieldName == "PENDING_DATE");

            if (date.Item == null)
            {
                throw new NoPendingDateException("Pending date has to be filled!");
            }

            if (date.Item != null)
            {
                DateTime dateTimeNow = DateTime.UtcNow.Date;
                DateTime dateTime    = DateTime.Parse(date.Item.ToString());
                if (dateTimeNow > dateTime)
                {
                    throw new PendingDateIsNotInFutureException("Please provide a pending date value in future!");
                }
            }
        }