コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: BrackerWriterImpl.cs プロジェクト: dmpas/odnoskobka
        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();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: Pop3Receiver.cs プロジェクト: regcpr1c/oscript-mail
        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);
        }
コード例 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 public Stack(ArrayImpl data)
 {
     _stack = new System.Collections.Generic.Stack <IValue>(data);
 }
コード例 #7
0
        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));
        }
コード例 #8
0
        public void UndeleteMessages(ArrayImpl deletedData)
        {
            var messages = GetMessagesList(deletedData);

            _currentFolder.RemoveFlags(messages, MessageFlags.Deleted, silent: true);
        }
コード例 #9
0
        public ArrayImpl GetKeys()
        {
            var arr = new ArrayImpl(_requestSession.Keys.Select(ValueFactory.Create));

            return(arr);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: InternetMail.cs プロジェクト: regcpr1c/oscript-mail
 public void UndeleteMessages(ArrayImpl deletedData)
 {
     receiver?.UndeleteMessages(deletedData);
 }
コード例 #12
0
ファイル: InternetMail.cs プロジェクト: regcpr1c/oscript-mail
 public ArrayImpl Get(bool?deleteMessages = null, ArrayImpl ids = null, bool?markAsRead = null)
 {
     return(receiver?.Get(deleteMessages ?? true, ids, markAsRead ?? true));
 }
コード例 #13
0
        public void DeleteMessages(ArrayImpl dataToDelete)
        {
            var messages = GetMessagesList(dataToDelete);

            _currentFolder.AddFlags(messages, MessageFlags.Deleted, silent: true);
        }
コード例 #14
0
ファイル: InternetMail.cs プロジェクト: regcpr1c/oscript-mail
 public void DeleteMessages(ArrayImpl dataToDelete)
 {
     receiver?.DeleteMessages(dataToDelete);
 }
コード例 #15
0
 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;
 }
コード例 #16
0
 public void UndeleteMessages(ArrayImpl deletedData)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
        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);
        }
コード例 #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="data"></param>
 public Queue(ArrayImpl data)
 {
     _queue = new System.Collections.Generic.Queue <IValue>(data);
 }
コード例 #19
0
        /// <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)));
        }
コード例 #20
0
ファイル: FtpConnection.cs プロジェクト: dmpas/oscript-ftp
        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);
        }
コード例 #21
0
ファイル: InternetMail.cs プロジェクト: regcpr1c/oscript-mail
 public ArrayImpl GetIdentifiers(ArrayImpl identifiers = null, StructureImpl filter = null)
 {
     return(receiver?.GetIdentifiers(identifiers, filter));
 }