Untitled
🧩 Syntax:
using System;
using System.Text;
var str = Context.Field("pPaymentDescriptionRawData").Text;
if (!string.IsNullOrEmpty(str))
{
String[] kwords = new[] {"по договору", "по дог.","по дог","по ген. согл. ","ПО КОНТРАКТ №","ПО ДОГОВОРУ","ПО ДОГ.","ПО ДОГ","ДИЛ. ДОГ."};
String[] arr = str.Split(kwords, StringSplitOptions.RemoveEmptyEntries);
//>DMA
if (arr.Length <= 1)
{
kwords = new[] {"дог"};
arr = str.Split(kwords, StringSplitOptions.RemoveEmptyEntries);
}
//<DMA
if (arr.Length > 1)
{
String rightPart = arr[1].Trim();
//>DMA
//String[] arr2 = rightPart.Split(' ');
if (rightPart.IndexOf("от") > 0)
{
if (rightPart.Substring(rightPart.IndexOf("от")-1, 1) != " ")
{
rightPart = rightPart.Substring(1, rightPart.IndexOf("от")-1) + ' ' + rightPart.Substring(rightPart.IndexOf("от"));
}
}
String[] arr2 = rightPart.Split(' ');
//><DMA
if (arr2.Length > 2)
{
String docNum = arr2[0].Length > 2 ? arr2[0] : arr2[1];
docNum = docNum.Replace("\r\n","").Replace(" ","").Replace(".N","").Replace("№","").Replace("\n","").Trim();
// String dt = arr2[0].Length > 2 ? arr2[2] : arr2[3];
String dt = arr2[0].Length == 1 ? arr2[3] : arr2[1].ToLower().Contains("от") && arr2[1].Length > 2 ? arr2[1].Replace("ОТ","").Replace("от","").Replace("\r\n","") : arr2[2];
bool isDate = false;
var dtTemp = DateTime.Now;
dt = dt.Trim();
dt = dt.Length > 10 ? dt.Remove(10) : dt;
Context.Field("txtPaymentDescAgreementNum").Text = docNum;
isDate = DateTime.TryParse(dt, out dtTemp);
if(isDate)
Context.Field("txtPaymentDescAgreementDate").Text = dt;
}
}
}