public ArrayImpl FindRows(IValue filter) { var filterStruct = filter.GetRawValue() as StructureImpl; if (filterStruct == null) { throw RuntimeException.InvalidArgumentType(); } ArrayImpl Result = new ArrayImpl(); foreach (ValueTableRow row in _rows) { if (CheckFilterCriteria(row, filterStruct)) { Result.Add(row); } } return(Result); }
public ArrayImpl GetBackgroundJobs(StructureImpl filter = null) { if (filter == null || filter == ValueFactory.Create()) { return(GetAllJobs()); } ArrayImpl result = new ArrayImpl(); foreach (System.Collections.Generic.KeyValuePair <Guid, WebBackgroundJob> ci in WebBackgroundJobsManager.Jobs) { bool shouldAdd = true; foreach (KeyAndValueImpl cfi in filter) { if ( (cfi.Key.AsString().ToLower() == "ключ" && cfi.Value.AsString() != ci.Value.Key) || (cfi.Key.AsString().ToLower() == "наименование" && cfi.Value.AsString() != ci.Value.Description) || (cfi.Key.AsString().ToLower() == "имяметода" && cfi.Value.AsString() != ci.Value.MethodName) || (cfi.Key.AsString().ToLower() == "начало" && cfi.Value.AsDate() != ci.Value.Begin) || (cfi.Key.AsString().ToLower() == "конец" && cfi.Value.AsDate() != ci.Value.End) || (cfi.Key.AsString().ToLower() == "состояние" && cfi.Value.AsNumber() != (int)ci.Value.State) || (cfi.Key.AsString().ToLower() == "регламентноезадание") || (cfi.Key.AsString().ToLower() == "уникальныйидентификатор" && ((GuidWrapper)cfi.Value).AsString() != ci.Value.UUID.ToString()) ) { shouldAdd = false; break; } } if (shouldAdd) { result.Add(new WebBackgroundJobImpl(ci.Value)); } } return(result); }
public void WriteArray(ArrayImpl array, bool writeCount = false) { WriteStartElement(); if (writeCount) { WriteValue(array.Count().ToString()); } foreach (var value in array) { if (value is ArrayImpl) { WriteArray(value as ArrayImpl, writeCount); } else { WriteValue(value.AsString()); } } WriteEndElement(); }
public ArrayImpl GetHeaders(StructureImpl filter) { var result = new ArrayImpl(); var dataToFetch = MessageSummaryItems.Envelope | MessageSummaryItems.Flags | MessageSummaryItems.UniqueId | MessageSummaryItems.InternalDate | MessageSummaryItems.MessageSize ; IList <IMessageSummary> allHeaders; if (filter == null) { allHeaders = _currentFolder.Fetch(0, -1, dataToFetch); } else { var ids = SearchMessages(filter); if (ids.Count == 0) { return(result); } allHeaders = _currentFolder.Fetch(ids, dataToFetch); } foreach (var headers in allHeaders) { var mailMessage = new InternetMailMessage(headers); mailMessage.Uid.Add(ValueFactory.Create(UniqueIdToInternalId(headers.UniqueId))); result.Add(mailMessage); } return(result); }
public ArrayImpl Get(bool deleteMessages, ArrayImpl ids, bool markAsRead) { if (markAsRead != true) { throw RuntimeException.InvalidArgumentValue(); // TODO: Внятное сообщение } var result = new ArrayImpl(); var processedMessages = GetMessagesList(ids); foreach (var i in processedMessages) { var mimeMessage = client.GetMessage(i); var iMessage = new InternetMailMessage(mimeMessage, client.GetMessageUid(i)); result.Add(iMessage); } if (deleteMessages && processedMessages.Count > 0) { client.DeleteMessages(processedMessages); Relogon(); } return(result); }
/// <summary> /// /// </summary> /// <param name="data"></param> public Stack(ArrayImpl data) { _stack = new System.Collections.Generic.Stack <IValue>(data); }
public void WaitForCompletion(ArrayImpl backgroundJobs, int?timeout = null) { int delta = WebBackgroundJobsManager.CheckInterval; long timeoutMs = 1000; if (timeout == null) { delta = 0; } else { timeoutMs = (long)(timeout * 1000); } long current = 0; WebBackgroundJobImpl failedJob = null; WebBackgroundJobImpl notCompletedJob = null; do { System.Threading.Thread.Sleep(WebBackgroundJobsManager.CheckInterval); current += delta; notCompletedJob = null; foreach (IValue cj in backgroundJobs) { if (((WebBackgroundJobImpl)cj).State == WebBackgroundJobStateImpl.Active) { notCompletedJob = (WebBackgroundJobImpl)cj; } if (((WebBackgroundJobImpl)cj).State == WebBackgroundJobStateImpl.Failed) { failedJob = (WebBackgroundJobImpl)cj; break; } } } while (current < timeoutMs && notCompletedJob != null && failedJob == null); System.IO.TextWriter logWriter; if (failedJob != null) { logWriter = AspNetLog.Open(); string logStr = failedJob.ErrorInfo.ModuleName + "`n" + failedJob.ErrorInfo.LineNumber + "`n" + failedJob.ErrorInfo.Description + "`n" + failedJob.ErrorInfo.DetailedDescription; AspNetLog.Write(logWriter, logStr); AspNetLog.Close(logWriter); throw (new Exception("Одно или несколько фоновых заданий завершились с ошибкой.")); } if (notCompletedJob == null) { return; } string exceptionString = "Timeout expires for job: "; exceptionString += "start date: " + notCompletedJob.Begin.ToString() + " "; exceptionString += "method: " + notCompletedJob.MethodName + " "; if (notCompletedJob.Description != null) { exceptionString += "description: " + notCompletedJob.Description + " "; } if (notCompletedJob.Key != null) { exceptionString += "key: " + notCompletedJob.Description + " "; } logWriter = AspNetLog.Open(); AspNetLog.Write(logWriter, exceptionString); AspNetLog.Close(logWriter); throw (new Exception(exceptionString)); }
public void UndeleteMessages(ArrayImpl deletedData) { var messages = GetMessagesList(deletedData); _currentFolder.RemoveFlags(messages, MessageFlags.Deleted, silent: true); }
public ArrayImpl GetKeys() { var arr = new ArrayImpl(_requestSession.Keys.Select(ValueFactory.Create)); return(arr); }
public BackgroundTask Execute(IRuntimeContextInstance target, string methodName, ArrayImpl parameters = null) { var task = new BackgroundTask(target, methodName, parameters); _tasks.Add(task); var worker = new Task(() => { _engine.Environment.LoadMemory(MachineInstance.Current); task.ExecuteOnCurrentThread(); }, TaskCreationOptions.LongRunning); task.WorkerTask = worker; worker.Start(); return(task); }
public void UndeleteMessages(ArrayImpl deletedData) { receiver?.UndeleteMessages(deletedData); }
public ArrayImpl Get(bool?deleteMessages = null, ArrayImpl ids = null, bool?markAsRead = null) { return(receiver?.Get(deleteMessages ?? true, ids, markAsRead ?? true)); }
public void DeleteMessages(ArrayImpl dataToDelete) { var messages = GetMessagesList(dataToDelete); _currentFolder.AddFlags(messages, MessageFlags.Deleted, silent: true); }
public void DeleteMessages(ArrayImpl dataToDelete) { receiver?.DeleteMessages(dataToDelete); }
public DirectorySearcherImpl(DirectoryEntryImpl directoryEntry, string filter, ArrayImpl propsToLoad, SearchScopeImpl searchScope) { _directorySearcher = new DirectorySearcher(directoryEntry._directoryEntry, filter, propsToLoad.Select(p => p.AsString()).ToArray(), SearchScopeConverter.ToSearchScope(searchScope)); SearchRoot = directoryEntry; PropertiesToLoad = propsToLoad; SearchScope = searchScope; }
public void UndeleteMessages(ArrayImpl deletedData) { throw new NotImplementedException(); }
public IValue ReadJSONInStruct(JSONReader Reader, bool nestedArray = false) { if (nestedArray) { ArrayImpl NestedArray = new ArrayImpl(); while (Reader.Read()) { if (Reader.CurrentJsonTokenType == JsonToken.EndArray) { break; } else if (Reader.CurrentJsonTokenType == JsonToken.StartObject) { NestedArray.Add(ReadJSONInStruct(Reader)); } else if (Reader.CurrentJsonTokenType == JsonToken.StartArray) { NestedArray.Add(ReadJSONInStruct(Reader, true)); } else { NestedArray.Add(Reader.CurrentValue); } } return(NestedArray); } StructureImpl ResStruct = new StructureImpl(); while ((Reader).Read()) { if (Reader.CurrentJsonTokenType == JsonToken.PropertyName) { string PropertyName = Reader.CurrentValue.AsString(); Reader.Read(); if (Reader.CurrentJsonTokenType == JsonToken.StartObject) { ResStruct.Insert(PropertyName, ReadJSONInStruct(Reader)); } else if (Reader.CurrentJsonTokenType == JsonToken.StartArray) { ResStruct.Insert(PropertyName, ReadJSONInStruct(Reader, true)); } else { ResStruct.Insert(PropertyName, Reader.CurrentValue); } } else if (Reader.CurrentJsonTokenType == JsonToken.EndObject) { break; } else if (Reader.CurrentJsonTokenType == JsonToken.StartArray) { return(ReadJSONInStruct(Reader, true)); } } return(ResStruct); }
/// <summary> /// /// </summary> /// <param name="data"></param> public Queue(ArrayImpl data) { _queue = new System.Collections.Generic.Queue <IValue>(data); }
/// <summary> /// Строит объекты OneScript на основе результатов парсинга /// </summary> /// <param name="source"></param> /// <returns></returns> private IValue BuildResults(object source) { if (source == null) { return(ValueFactory.Create()); } if (source is string) { return(ValueFactory.Create(System.Convert.ToString(source))); } if (source is List <object> ) { ArrayImpl array = new ArrayImpl(); foreach (object element in (List <object>)source) { array.Add(BuildResults(element)); } return(array); } if (source is Dictionary <object, object> ) { MapImpl map = new MapImpl(); foreach (var element in (Dictionary <object, object>)source) { map.Insert(ValueFactory.Create(System.Convert.ToString(element.Key)), BuildResults(element.Value)); } return(map); } if (source is bool) { return(ValueFactory.Create(System.Convert.ToBoolean(source))); } if (source is sbyte || source is byte || source is short || source is ushort || source is int || source is uint || source is long || source is ulong || source is float || source is double || source is decimal ) { return(ValueFactory.Create(System.Convert.ToDecimal(source))); } if (source is DateTime) { return(ValueFactory.Create(System.Convert.ToDateTime(source))); } //нечто другое return(ValueFactory.Create(System.Convert.ToString(source))); }
public ArrayImpl FindFiles(string path, string mask = null, bool recursive = true) { var result = ArrayImpl.Constructor() as ArrayImpl; Regex maskChecker = null; if (!string.IsNullOrEmpty(mask)) { maskChecker = FtpCrutch.GetRegexForFileMask(mask); } if (!string.IsNullOrEmpty(path) && !path.EndsWith("/", StringComparison.Ordinal)) { path += "/"; } path = ApplyCurrentPath(path); IList <string> files, directories; try { ListFiles(path, out directories, out files); } catch (System.Net.ProtocolViolationException) { return(result); } catch (WebException ex) { var error = (FtpWebResponse)ex.Response; if (error.StatusCode == FtpStatusCode.ActionNotTakenFileUnavailable) { return(result); } throw ex; } catch { throw; } foreach (var dirName in directories) { var dirEntry = new FtpFile(this, path, dirName, isDir: true); if (maskChecker?.IsMatch(dirName) ?? true) { result.Add(dirEntry); } if (recursive) { var filesInDir = FindFiles(dirEntry.FullName, mask, recursive); foreach (var fileEntry in filesInDir) { result.Add(fileEntry); } } } foreach (var fileName in files) { if (maskChecker?.IsMatch(fileName) ?? true) { var fileEntry = new FtpFile(this, path, fileName); result.Add(fileEntry); } } return(result); }
public ArrayImpl GetIdentifiers(ArrayImpl identifiers = null, StructureImpl filter = null) { return(receiver?.GetIdentifiers(identifiers, filter)); }