/// <summary> /// create a new document /// </summary> /// <param name="folderId"></param> /// <param name="name"></param> /// <param name="description"></param> /// <param name="revision"></param> /// <param name="documentState"></param> /// <returns></returns> public Document CreateDocument(Guid folderId, string name, string description, string revision, DocumentState documentState) { if (folderId.Equals(Guid.Empty)) { throw new ArgumentException("FolderId is required but was an empty Guid", "folderId"); } dynamic postData = new ExpandoObject(); postData.folderId = folderId; if (!String.IsNullOrWhiteSpace(name)) { postData.Name = name; } if (!String.IsNullOrWhiteSpace(description)) { postData.Description = description; } if (!String.IsNullOrWhiteSpace(revision)) { postData.Revision = revision; } postData.documentState = documentState; return HttpHelper.Post<Document>(GlobalConfiguration.Routes.Documents, string.Empty, GetUrlParts(), this.ClientSecrets, this.ApiTokens, postData); }
public DocumentMetaDataCreated(Guid documentId, string title, DocumentState state, DateTime utcCreated) { Title = title; ProcessingState = state; UtcDate = utcCreated; AggregateId = documentId; }
public void ChangeDocumentState(long Id, DocumentState documentState) { SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@State", SqlDbType.Int, (int)documentState); sql.AddParameter("@Id", SqlDbType.BigInt, Id); sql.ExecuteSql(Sql_ChangeDocumentState); }
public ActionResult ProgressBar(DocumentState state, int scanProgress) { if (state == DocumentState.Scanned) return Content("Scanned"); return PartialView(new Models.ProgressBarModel { Progress = scanProgress, Caption = GetBarCaption(state, scanProgress) }); }
/// <summary> /// Creates a new PDF document in memory. /// To open an existing PDF file, use the PdfReader class. /// </summary> public PdfDocument() { //PdfDocument.Gob.AttatchDocument(this.Handle); this.creation = DateTime.Now; this.state = DocumentState.Created; this.version = 14; Initialize(); Info.CreationDate = this.creation; }
/// <summary> /// Creates a new PDF document in memory. /// To open an existing PDF file, use the PdfReader class. /// </summary> public PdfDocument() { //PdfDocument.Gob.AttatchDocument(Handle); _creation = DateTime.Now; _state = DocumentState.Created; _version = 14; Initialize(); Info.CreationDate = _creation; }
/// <summary> /// Creates a new document, updates the indexFields for the new document and adds the zeroByte file = true post data attribute /// </summary> /// <param name="folderId"></param> /// <param name="name"></param> /// <param name="description"></param> /// <param name="revision"></param> /// <param name="filename"></param> /// <param name="fileLength"></param> /// <param name="documentState"></param> /// <param name="indexFields"></param> /// <returns></returns> public Document CreateDocumentWithEmptyFile(Guid folderId, string name, string description, string revision, string filename, int fileLength, DocumentState documentState, List<KeyValuePair<string, string>> indexFields) { if (folderId.Equals(Guid.Empty)) { throw new ArgumentException("FolderId is required but was an empty Guid", "folderId"); } if (string.IsNullOrWhiteSpace(filename)) { throw new ArgumentException("Filename is required but was an empty string", "filename"); } if (!(fileLength > 0)) { throw new ArgumentException("FileLength must be an accurate file length and should be greater than 0", "fileLength"); } dynamic postData = new ExpandoObject(); postData.folderId = folderId; if (!String.IsNullOrWhiteSpace(name)) { postData.Name = name; } if (!String.IsNullOrWhiteSpace(description)) { postData.Description = description; } if (!String.IsNullOrWhiteSpace(revision)) { postData.Revision = revision; } if (!String.IsNullOrWhiteSpace(filename)) { postData.Filename = filename; } postData.FileLength = fileLength; postData.DocumentState = documentState; postData.AllowNoFile = true; var jobject = new JObject(); foreach (var indexField in indexFields) { jobject.Add(new JProperty(indexField.Key, indexField.Value)); } var jobjectString = JsonConvert.SerializeObject(jobject); postData.indexFields = jobjectString; return HttpHelper.Post<Document>(GlobalConfiguration.Routes.Documents, string.Empty, GetUrlParts(), this.ClientSecrets, this.ApiTokens, postData); }
protected void SetOutput(XmlStreamNodeWriter writer) { _inList = false; _writer = writer; _nodeWriter = writer; _writeState = WriteState.Start; _documentState = DocumentState.None; _nsMgr.Clear(); if (_depth != 0) { _elements = null; _depth = 0; } _attributeLocalName = null; _attributeValue = null; }
public void OperationTransformer_TransformDeleteInsert_LocalBeforeRemote() { var localState = new DocumentState(1, "123456789"); var remoteState = new DocumentState(1, "123456789"); var localOperation = new DeleteOperation(localState, 2); var remoteOperation = new InsertOperation(remoteState, 4, 'a'); var transformed = OperationTransformer.Transform(remoteOperation, localOperation); var stateStr = localState.CurrentState; stateStr = localOperation.ApplyTransform(stateStr); stateStr = transformed.ApplyTransform(stateStr); Assert.AreEqual("124a56789", stateStr); }
internal PdfDocument(Lexer lexer) { //PdfDocument.Gob.AttatchDocument(Handle); _creation = DateTime.Now; _state = DocumentState.Imported; //_info = new PdfInfo(this); //_pages = new PdfPages(this); //_fontTable = new PdfFontTable(); //_catalog = new PdfCatalog(this); ////_font = new PdfFont(); //_objects = new PdfObjectTable(this); //_trailer = new PdfTrailer(this); _irefTable = new PdfCrossReferenceTable(this); _lexer = lexer; }
public void OperationTransformer_TransformInsertInsert_LocalEqualToRemote() { var localState = new DocumentState(0, "123456789"); var remoteState = new DocumentState(1, "123456789"); var localOperation = new InsertOperation(localState, 2, 'a'); var remoteOperation = new InsertOperation(remoteState, 2, 'b'); var transformed = OperationTransformer.Transform(remoteOperation, localOperation); var stateStr = localState.CurrentState; stateStr = localOperation.ApplyTransform(stateStr); stateStr = transformed.ApplyTransform(stateStr); Assert.AreEqual("12ba3456789", stateStr); }
private Chunk CreateTextChunk(DocumentState state, string text) { var chunk = new Chunk(text) { Font = GetFont(state.Font) }; if (_styles.Count > 0) { var colorStyle = _styles.FirstOrDefault(kv => kv.ContainsKey("color")); if (colorStyle != null) { chunk.Font.Color = new BaseColor(ParseColor(colorStyle["color"])); } } return(chunk); }
public static TestDocumentSnapshot Create(string filePath, string text, VersionStamp version) { var testProject = TestProjectSnapshot.Create(filePath + ".csproj"); using var testWorkspace = TestWorkspace.Create(); var hostDocument = new HostDocument(filePath, filePath); var sourceText = SourceText.From(text); var documentState = new DocumentState( testWorkspace.Services, hostDocument, SourceText.From(text), version, () => Task.FromResult(TextAndVersion.Create(sourceText, version))); var testDocument = new TestDocumentSnapshot(testProject, documentState); return(testDocument); }
/// <summary> /// Creates a new PDF document with the specified file name. The file is immediately created and keeps /// locked until the document is closed, at that time the document is saved automatically. /// Do not call Save() for documents created with this constructor, just call Close(). /// To open an existing PDF file and import it, use the PdfReader class. /// </summary> public PdfDocument(string filename) { //PdfDocument.Gob.AttatchDocument(Handle); _creation = DateTime.Now; _state = DocumentState.Created; _version = 14; Initialize(); Info.CreationDate = _creation; // TODO 4STLA: encapsulate the whole c'tor with #if !NETFX_CORE? #if !NETFX_CORE _outStream = new FileStream(filename, FileMode.Create); #else throw new NotImplementedException(); #endif }
internal PdfDocument(Lexer lexer) { //PdfDocument.Gob.AttatchDocument(this.Handle); this.creation = DateTime.Now; this.state = DocumentState.Imported; //this.info = new PdfInfo(this); //this.pages = new PdfPages(this); //this.fontTable = new PdfFontTable(); //this.catalog = new PdfCatalog(this); ////this.font = new PdfFont(); //this.objects = new PdfObjectTable(this); //this.trailer = new PdfTrailer(this); this.irefTable = new PdfReferenceTable(this); this.lexer = lexer; }
public void OperationTransformer_Transform_CP1TP1Satisfied() { var site1Str = "abcd"; var site2Str = "abcd"; var site1 = new DocumentState(1, site1Str); var site2 = new DocumentState(2, site2Str); var op1 = new InsertOperation(site1, 0, '1'); var op2 = new InsertOperation(site2, 0, '2'); site1Str = op2.ApplyTransform(site1Str); site1Str = OperationTransformer.Transform(op1, op2).ApplyTransform(site1Str); site2Str = op1.ApplyTransform(site2Str); site2Str = OperationTransformer.Transform(op2, op1).ApplyTransform(site2Str); Assert.AreEqual(site1Str, site2Str); }
public void RecieveResponse(IPP ipp) { foreach (IPP.Attribute attr in ipp.AttrGroup[AttrGroups.JobAttributesTag]) { if (attr.Tag == Tag.Integer && attr.Name.CompareTo("job-id") == 0) { this.JobID = (int)attr.ValueAsObject; } if (attr.Tag == Tag.URI && attr.Name.CompareTo("job-uri") == 0) { this.JobURI = (String)attr.ValueAsObject; } if (attr.Tag == Tag.Enum && attr.Name.CompareTo("job-state") == 0) { this.State = (DocumentState)attr.ValueAsObject; } } }
public IChordDefinition ResolveChord(DocumentState documentState, Chord chord) { if (chord.Fingering != null) { return(new InlineChordDefinition(chord)); } var chordDefinition = documentState.DefinedChords.FirstOrDefault( c => c.Name.Equals(chord.Name, StringComparison.InvariantCulture)); if (chordDefinition != null) { return(chordDefinition); } return(_chords.TryGetValue(chord.Name, out chordDefinition) ? chordDefinition : null); }
protected void SetOutput(XmlStreamNodeWriter writer) { this.inList = false; this.writer = writer; this.nodeWriter = writer; this.writeState = WriteState.Start; this.documentState = DocumentState.None; this.nsMgr.Clear(); if (this.depth != 0) { this.elements = null; this.depth = 0; } this.attributeLocalName = null; this.attributeValue = null; this.oldWriter = null; this.oldStream = null; }
public async Task AddDocumentFromTemplate(string userId, int idTemplate, string name, string @abstract, IList <string> tags, IDictionary <int, string> items) { var now = DateTime.Now; var document = new Document { Name = name, IdDocumentTemplate = idTemplate, Abstract = @abstract, DateAdded = now, UserId = userId, }; var state = new DocumentState { DocumentStatus = DocumentStatus.Draft, Version = DocumentVersions.FIRST_DRAFT, StatusDate = now, DocumentData = new DocumentDataTemplate() }; var documentData = (DocumentDataTemplate)state.DocumentData; foreach (var item in items) { documentData.DocumentDataTemplateItems.Add(new DocumentDataTemplateItem { IdDocumentTemplateItem = item.Key, Value = item.Value, DocumentData = documentData }); } document.DocumentStates.Add(state); foreach (var tag in tags) { var dbTag = await dbContext .Tags .FirstOrDefaultAsync(it => it.Name == tag); document.DocumentTags.Add(new DocumentTag { Tag = dbTag ?? new Tag { Name = tag } }); } dbContext.Documents.Add(document); }
public void StartAndPersistInstance(Guid _documentId, DocumentState _state, IDictionary <string, object> documentData) { try { var documentTable = _DocumentService.Find(_documentId); IDictionary <string, object> inputArguments = new Dictionary <string, object>(); inputArguments.Add("inputStep", _state); inputArguments.Add("inputDocumentId", _documentId); inputArguments.Add("inputCurrentUser", HttpContext.Current.User.Identity.Name); inputArguments.Add("documentData", documentData); WorkflowApplication application = new WorkflowApplication(activity, inputArguments); application.InstanceStore = instanceStore; application.Extensions.Add(new WFTrackingParticipant()); #region Workflow Delegates application.PersistableIdle = (e) => { var ex = e.GetInstanceExtensions <WFTrackingParticipant>(); outputParameters = ex.First().Outputs; //instanceUnloaded.Set(); return(PersistableIdleAction.Unload); }; application.Unloaded = (e) => { instanceUnloaded.Set(); }; #endregion Workflow Delegates application.Persist(); application.Run(); instanceUnloaded.WaitOne(); documentTable.WWFInstanceId = application.Id; documentTable.DocumentState = (DocumentState)outputParameters["outputStep"]; _DocumentService.UpdateDocument(documentTable); } catch (Exception ex) { throw ex; } }
// events could be used for this callback as well, but using private inner // classes calling a private member is probably the simplest. private void TransitionToState <T>() where T : DocumentState, new() { // save prior for a moment DocumentState priorState = State; // this can be lookup from map instead of new() if you need to keep them // alive for some reason. I personally like flyweight states. DocumentState nextState = new T(); // activate the new state. it will get notified so it can do any one- // time setup State = nextState; State.EnterState(this); // let the prior state know as well, so it can cleanup if needed if (priorState != null) { priorState.ExitState(); } }
private static void RunCodeFixWhileDocumentChanges(DiagnosticAnalyzer diagnosticAnalyzer, CodeFixProvider codeFixProvider, string codeFixTitle, Document document, ParseOptions parseOption, string pathToExpected) { var currentDocument = document; var state = new DocumentState(diagnosticAnalyzer, currentDocument, parseOption); state.Diagnostics.Should().NotBeEmpty(); string codeBeforeFix; var codeFixExecutedAtLeastOnce = false; do { codeBeforeFix = state.ActualCode; var codeFixExecuted = false; for (var diagnosticIndexToFix = 0; !codeFixExecuted && diagnosticIndexToFix < state.Diagnostics.Length; diagnosticIndexToFix++) { var diagnostic = state.Diagnostics[diagnosticIndexToFix]; if (!codeFixProvider.FixableDiagnosticIds.Contains(diagnostic.Id)) { // a Diagnostic can raise issues for different rules, but provide fixes for only one of them // if we don't have a fixer for this rule, we skip it continue; } var codeActionsForDiagnostic = GetCodeActionsForDiagnostic(codeFixProvider, currentDocument, diagnostic); if (CodeActionToApply(codeFixTitle, codeActionsForDiagnostic) is { } codeActionToApply) { currentDocument = ApplyCodeFix(currentDocument, codeActionToApply); state = new DocumentState(diagnosticAnalyzer, currentDocument, parseOption); codeFixExecutedAtLeastOnce = true; codeFixExecuted = true; } } }while (codeBeforeFix != state.ActualCode); codeFixExecutedAtLeastOnce.Should().BeTrue(); AreEqualIgnoringLineEnding(pathToExpected, state); }
// Methods public BusinessDocument() { m_IsDocumentModified = false; m_GuidHash = Guid.NewGuid().ToString(); m_InternalDocumentState = DocumentState.Unchanged; m_EntityName = base.GetType().FullName; m_EntityDescription = string.Empty; foreach ( EntityGeneralAttribute attribute1 in base.GetType().GetCustomAttributes(typeof (EntityGeneralAttribute), false)) { if (attribute1 is EntityNameAttribute) { m_EntityName = (string) attribute1.Value; } else if (attribute1 is EntityDescriptionAttribute) { m_EntityDescription = (string) attribute1.Value; } } }
void IDocument.Show() { OverviewControl overview = new OverviewControl(); form.MinimizeBox = false; form.MaximizeBox = false; form.FormBorderStyle = FormBorderStyle.FixedDialog; form.Text = captionText; form.ClientSize = overview.Size; form.MinimumSize = form.Size; overview.SetDescription(descriptionText); overview.Dock = DockStyle.Fill; overview.Parent = form; form.StartPosition = FormStartPosition.CenterParent; form.Icon = AppHelper.AppIcon; using (form) { form.ShowDialog(AppHelper.MainForm); } state = DocumentState.Visible; }
void IDocument.Close(bool force) { if(!force) { if(!onClosing) { Window.Close(); } return; } Window.Closing -= window_Closing; if(!destroyOnClose) { if(!onClosing) { Window.Hide(); } state = DocumentState.Hidden; } else { if(!onClosing) { Window.Close(); } state = DocumentState.Destroyed; } }
private bool ProcessStyles(ref DocumentState state, CssStyles styles) { if (styles == null || styles.Count <= 0) { return(false); } string value; value = styles.Get("font-family"); if (value != string.Empty) { state.Face = value; } value = styles.Get("font-weight"); if (value != string.Empty) { state.Bold = !value.EqualsIgnoreCase("normal"); } value = styles.Get("font-style"); if (value != string.Empty) { state.Italic = value.EqualsIgnoreCase("italic"); } value = styles.Get("text-decoration"); if (value != string.Empty) { state.Underline = value.EqualsIgnoreCase("underline"); } value = styles.Get("font-size"); if (value != string.Empty) { state.Size = CssParser.ParseFontSize(value, state.Size); } value = styles.Get("color"); if (value != string.Empty) { state.Brush = value.ToColor().ToBrush(); } return(true); }
private void AddListItem() { _PriorLineBreaks = 0; // Add a bullet DocumentState state = _DocumentStates.Peek(); if (state.BulletType == '\0') { return; } string bulletText = null; if (state.BulletType == 'o') { Run numRun = new Run(); DecorateRun(numRun, state); numRun.FontFamily = new FontFamily("Courier New"); numRun.FontWeight = FontWeights.Bold; numRun.Text = state.ListItemNumber.ToString().PadLeft(2); AddTextRun(numRun); bulletText = ". "; } else if (state.BulletType == 'u') { bulletText = "• "; } if (bulletText == null) { return; } Run bulletRun = new Run(); DecorateRun(bulletRun, state); bulletRun.Text = bulletText; AddTextRun(bulletRun); }
public void OperationTransformer_Transform_CP2TP2Satisfied() { var site1Str = "abcd"; var site2Str = "abcd"; var site3Str = "abcd"; var site1 = new DocumentState(1, site1Str); var site2 = new DocumentState(2, site2Str); var site3 = new DocumentState(3, site3Str); var op1 = new InsertOperation(site1, 0, '1'); var op2 = new InsertOperation(site2, 1, '2'); var op3 = new InsertOperation(site3, 2, '3'); var op2dash = OperationTransformer.Transform(op2, op1); var op3dashV1 = OperationTransformer.Transform(OperationTransformer.Transform(op3, op1), op2dash); var op1dash = OperationTransformer.Transform(op1, op2); var op3dashV2 = OperationTransformer.Transform(OperationTransformer.Transform(op3, op2), op1dash); Assert.IsTrue(op3dashV1.IdenticalOperation(op3dashV2)); }
public void SaveOrUpdate(string category, DocumentState documentState) { using (var connection = _AsgardDatabase.GetOpenConnection()) { var existSql = $"SELECT * FROM {DocumentStateTable.TableName} " + $"WHERE Category=@category AND DocumentId=@documentId"; var exist = connection.Query <DocumentStateModel>(existSql, new { category, documentState.DocumentId }).FirstOrDefault(); var model = _documentStateMapper.Map(documentState); model.Category = category; if (exist != null) { connection.Update(model); } else { connection.Insert(model); } } }
public static Strategy GetStrategy <TDocument, TId, TContent>( Collection <TDocument, TId, TContent> collectionInstance, DocumentState <TDocument, TId, TContent> documentState) where TContent : class where TDocument : Document <TContent, TId>, new() { switch (documentState.CurrentState) { case DocumentStates.Modified: return(new UpdateStrategy <TDocument, TId, TContent>(collectionInstance, documentState.Document)); case DocumentStates.Added: return(new InsertStrategy <TDocument, TId, TContent>(collectionInstance, documentState.Document)); case DocumentStates.Removed: return(new RemoveStrategy <TDocument, TId, TContent>(collectionInstance, documentState.Document)); default: throw new ArgumentOutOfRangeException(nameof(documentState), documentState, null); } }
protected override void Execute(CodeActivityContext context) { Guid documentId = context.GetValue(this.inputDocumentId); DocumentState documentStep = context.GetValue(this.inputStep); string currentUser = context.GetValue(this.inputCurrentUser); bool useManual = context.GetValue(this.useManual); int slaOffset = context.GetValue(this.slaOffset); Expression <Func <EmplTable, bool> > predicate = context.GetValue(this.inputPredicate); bool executionStep = context.GetValue(this.executionStep); _service = DependencyResolver.Current.GetService <IWorkflowService>(); WFUserFunctionResult userFunctionResult = _service.WFStaffStructure(documentId, predicate, currentUser); if (userFunctionResult.Skip == false && executionStep != true) { _service.CreateTrackerRecord(documentStep, documentId, this.DisplayName, userFunctionResult.Users, currentUser, this.Id, useManual, slaOffset, executionStep); } outputBookmark.Set(context, this.DisplayName.Replace("<step>", "")); outputSkipStep.Set(context, userFunctionResult.Skip); outputStep.Set(context, documentStep); }
protected override void Execute(CodeActivityContext context) { int level = context.GetValue(this.inputLevel); Guid documentId = context.GetValue(this.inputDocumentId); DocumentState documentStep = context.GetValue(this.inputStep); string currentUser = context.GetValue(this.inputCurrentUser); bool useManual = context.GetValue(this.useManual); int slaOffset = context.GetValue(this.slaOffset); string profileName = context.GetValue(this.profileName); bool executionStep = context.GetValue(this.executionStep); _service = DependencyResolver.Current.GetService <IWorkflowService>(); WFUserFunctionResult userFunctionResult = _service.WFMatchingUpManager(documentId, currentUser, level, profileName); if (userFunctionResult.Skip == false && executionStep != true) { _service.CreateTrackerRecord(documentStep, documentId, this.DisplayName, userFunctionResult.Users, currentUser, this.Id, useManual, slaOffset, executionStep); } outputBookmark.Set(context, this.DisplayName.Replace("<step>", "")); outputSkipStep.Set(context, userFunctionResult.Skip); outputStep.Set(context, documentStep); }
public static PageState ToPageState(this DocumentState documentState) { if (documentState == null) { return(null); } var tokens = documentState.OptionalData.Split(new string[] { Delimiter }, StringSplitOptions.None); var depth = 0; int.TryParse(tokens[0], out depth); var url = tokens.Length == 2 ? new Uri(tokens[1]) : new Uri(documentState.DocumentId); return(new PageState() { Id = documentState.DocumentId, Url = url, HashValue = documentState.HashValue, LastUpdated = documentState.LastUpdated, LastVerified = documentState.LastVerified, VerifyDate = documentState.VerifyDate, Depth = depth }); }
private static void RunFixAllProvider(DiagnosticAnalyzer diagnosticAnalyzer, CodeFixProvider codeFixProvider, string codeFixTitle, FixAllProvider fixAllProvider, Document document, ParseOptions parseOption, string pathToExpected) { var currentDocument = document; var state = new DocumentState(diagnosticAnalyzer, currentDocument, parseOption); state.Diagnostics.Should().NotBeEmpty(); var fixAllDiagnosticProvider = new FixAllDiagnosticProvider( codeFixProvider.FixableDiagnosticIds.ToHashSet(), (doc, ids, ct) => Task.FromResult(state.Diagnostics.AsEnumerable()), null); var fixAllContext = new FixAllContext(currentDocument, codeFixProvider, FixAllScope.Document, codeFixTitle, codeFixProvider.FixableDiagnosticIds, fixAllDiagnosticProvider, CancellationToken.None); var codeActionToExecute = fixAllProvider.GetFixAsync(fixAllContext).Result; codeActionToExecute.Should().NotBeNull(); currentDocument = ApplyCodeFix(currentDocument, codeActionToExecute); state = new DocumentState(diagnosticAnalyzer, currentDocument, parseOption); AreEqualIgnoringLineEnding(pathToExpected, state); }
public async Task AddDocument(string userId, string name, string @abstract, byte[] data, IList <string> tags) { var now = DateTime.Now; var document = new Document { Name = name, DateAdded = now, Abstract = @abstract, UserId = userId }; var state = new DocumentState { DocumentStatus = DocumentStatus.Draft, Version = DocumentVersions.FIRST_DRAFT, StatusDate = now, DocumentData = new DocumentDataUpload { Data = data } }; document.DocumentStates.Add(state); foreach (var tag in tags) { var dbTag = await dbContext .Tags .FirstOrDefaultAsync(it => it.Name == tag); document.DocumentTags.Add(new DocumentTag { Tag = dbTag ?? new Tag { Name = tag } }); } dbContext.Documents.Add(document); }
public MainWindow() { Dispatcher.UnhandledException += Dispatcher_UnhandledException; InitializeComponent(); SocketClient = SocketMessaging.TcpClient.Connect(System.Net.IPAddress.Parse("127.0.0.1"), 8888); SocketClient.SetMode(SocketMessaging.MessageMode.PrefixedLength); SocketClient.ReceivedMessage += SocketClient_ReceivedMessage; var proccesList = System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).OrderBy(p => p.Id).ToArray(); int currentProcesId = System.Diagnostics.Process.GetCurrentProcess().Id; var userId = Array.FindIndex(proccesList, p => p.Id == currentProcesId); Title += " " + userId.ToString(); DocumentState = new DocumentState((uint)userId, string.Empty); // TODO: Handle getting the initial state of the document rather than assuming empty RuntimeTypeModel.Default.Add(typeof(AppliedOperationSurrogate), true); RuntimeTypeModel.Default.Add(typeof(AppliedOperation), false).SetSurrogate(typeof(AppliedOperationSurrogate)); RuntimeTypeModel.Default.Add <OperationBase>() .AddSubType(101, RuntimeTypeModel.Default.Add <InsertOperation>().Type) .AddSubType(102, RuntimeTypeModel.Default.Add <DeleteOperation>().Type) .AddSubType(103, RuntimeTypeModel.Default.Add <IdentityOperation>().Type); }
public IEnumerable<Document> GetDocument(StaffInfo staff, DocumentState state) { IList<Core.Business.Document> documentlist = new List<Core.Business.Document>(); SqlServerUtility sql = new SqlServerUtility(); sql.AddParameter("@id", SqlDbType.Int, staff.Id); sql.AddParameter("@state", SqlDbType.Int, state.ToCode()); SqlDataReader reader = sql.ExecuteSqlReader(Sql_GetDocument); if (reader != null) { while (reader.Read()) { Core.Business.Document document = new Core.Business.Document(); if (!reader.IsDBNull(0)) document.Id = reader.GetInt64(0); if (!reader.IsDBNull(1)) document.Title = reader.GetString(1); if (!reader.IsDBNull(2)) document.SubTitle = reader.GetString(2); if (!reader.IsDBNull(3)) document.Content = reader.GetString(3); if (!reader.IsDBNull(4)) document.SendDate = reader.GetDateTime(4); if (!reader.IsDBNull(5)) document.State = reader.GetInt32(5); if (!reader.IsDBNull(6)) document.Secret = reader.GetInt32(6); if (!reader.IsDBNull(7)) document.Mergency = reader.GetInt32(7); if (!reader.IsDBNull(8)) document.DraftDate = reader.GetDateTime(8); if (!reader.IsDBNull(9)) document.Sender = reader.GetInt32(9); document.MarkOld(); documentlist.Add(document); } reader.Close(); } return documentlist.AsEnumerable(); }
private IEnumerable <(DocumentState ds1, OperationBase op1, DocumentState ds2, OperationBase op2)> GetOperationPairs() { var opFuncs = new Func <DocumentState, int, char, OperationBase>[] { (ds, pos, text) => new InsertOperation(ds, pos, text), (ds, pos, text) => new DeleteOperation(ds, pos), (ds, pos, text) => new IdentityOperation(ds), }; var opIndexes = new[] { 1, 2, 3 }; foreach (var op1Pos in opIndexes) { foreach (var opFunc in opFuncs) { foreach (var op2Func in opFuncs) { var state1 = new DocumentState(1, "abcdef"); var state2 = new DocumentState(2, "abcdef"); yield return(state1, opFunc(state1, op1Pos, state1.UserId.ToString()[0]), state2, op2Func(state2, 2, state2.UserId.ToString()[0])); } } } }
private bool ProcessCommonStyles(ref DocumentState state, XmlReader xmlReader, string elementName) { bool hasStyles = ProcessSelectorStyles(ref state, elementName); if (xmlReader.MoveToFirstAttribute()) do { if (xmlReader.Name.ToLower() == "class") { hasStyles |= ProcessSelectorStyles(ref state, elementName + "." + xmlReader.Value); hasStyles |= ProcessSelectorStyles(ref state, "." + xmlReader.Value); } else if (xmlReader.Name.ToLower() == "id") { hasStyles |= ProcessSelectorStyles(ref state, elementName + "#" + xmlReader.Value); hasStyles |= ProcessSelectorStyles(ref state, "#" + xmlReader.Value); } else if (xmlReader.Name.ToLower() == "style") hasStyles |= ProcessInlineStyles(ref state, xmlReader.Value); } while (xmlReader.MoveToNextAttribute()); return hasStyles; }
protected XmlBaseWriter() { _nsMgr = new NamespaceManager(); _writeState = WriteState.Start; _documentState = DocumentState.None; }
internal HtmlDocument(DocumentState state) : base(state) { state.Type = DocumentHtmlType.Html; }
private bool ProcessSelectorStyles(ref DocumentState state, string selector) { if (_GlobalSelectors == null) return false; CssStyles styles = _GlobalSelectors.GetStyles(selector); bool hasStyles = ProcessStyles(ref state, styles); styles.Dispose(); return hasStyles; }
/// <summary> /// Creates a new PDF document with the specified file name. The file is immediately created and keeps /// looked until the document is saved. /// To open an existing PDF file and import it, use the PdfReader class. /// </summary> public PdfDocument(string filename) { //PdfDocument.Gob.AttatchDocument(this.Handle); this.creation = DateTime.Now; this.state = DocumentState.Created; this.version = 14; Initialize(); Info.CreationDate = this.creation; this.outStream = new FileStream(filename, FileMode.Create); }
// Methods public DocumentIndexValue(int index, DocumentState state, DocumentState prevState) { Index = index; State = state; PrevState = prevState; }
public void SetDocumentState(DocumentState docstate) { this.DocumentState = docstate; }
public override void WriteEndDocument() { if (IsClosed) ThrowClosed(); if (_writeState == WriteState.Start || _writeState == WriteState.Prolog) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlNoRootElement))); FinishDocument(); _writeState = WriteState.Start; _documentState = DocumentState.End; }
private bool ProcessInlineStyles(ref DocumentState state, string style) { CssStyles styles = CssStyles.Create(style); bool hasStyles = ProcessStyles(ref state, styles); styles.Dispose(); return hasStyles; }
protected virtual void SignModification() { m_IsDocumentModified = true; m_InternalDocumentState = DocumentState.Modified; }
internal void SetDocumentState(DocumentState state) { m_InternalDocumentState = state; }
private void ExitScope() { _elements[_depth].Clear(); _depth--; if (_depth == 0 && _documentState == DocumentState.Document) _documentState = DocumentState.Epilog; _nsMgr.ExitScope(); }
internal void SetHtml(FrameworkElement rootElement, string htmlText, Control optionalFontTemplate) { try { // This is the main entry point, initialize everything _RootElement = rootElement; if (!(_RootElement is Panel || _RootElement is RichTextBox)) return; if (_RootElement is Panel) { _CurrentRichTextBox = new RichTextBlock(); (_RootElement as Panel).Children.Clear(); (_RootElement as Panel).Children.Add(_CurrentRichTextBox); } else if (_RootElement is RichTextBox) { _CurrentRichTextBox = _RootElement as RichTextBox; } _CurrentParagraph = new Paragraph(); _CurrentRichTextBox.Blocks.Add(_CurrentParagraph); // Setup the initial document state DocumentState documentState = new DocumentState(); if (optionalFontTemplate == null) optionalFontTemplate = _RootElement as Control; if (optionalFontTemplate != null) { documentState.Brush = optionalFontTemplate.Foreground; documentState.Face = optionalFontTemplate.FontFamily.Source; documentState.Size = optionalFontTemplate.FontSize; documentState.Italic = (optionalFontTemplate.FontStyle == FontStyles.Italic); documentState.Bold = (optionalFontTemplate.FontWeight != FontWeights.Normal); documentState.Underline = false; } else { Run defaultRun = new Run(); documentState.Brush = defaultRun.Foreground; documentState.Face = defaultRun.FontFamily.Source; documentState.Size = defaultRun.FontSize; documentState.Italic = (defaultRun.FontStyle == FontStyles.Italic); documentState.Bold = (defaultRun.FontWeight != FontWeights.Normal); documentState.Underline = (defaultRun.TextDecorations == TextDecorations.Underline); } _DocumentStates = new Stack<DocumentState>(); _DocumentStates.Push(documentState); _PriorLineBreaks = 2; // As if we are following a paragraph bool hasMarkup = (htmlText != null && htmlText.IndexOf("<") >= 0 && htmlText.IndexOf(">") > 0); if (!hasMarkup) // translate ampersands & and the like htmlText = HttpUtility.HtmlEncode(htmlText); bool hasXmlDirective = (hasMarkup && htmlText.IndexOf("<?xml") >= 0); if (!hasXmlDirective) // add an outer <span> to ensure valid XML regardless of the text markup htmlText = string.Concat("<span>", htmlText, "</span>"); bool hasInvalidEntity = (htmlText.IndexOf(" ") >= 0); if (hasInvalidEntity) htmlText = htmlText.Replace(" ", " "); hasInvalidEntity = (htmlText.IndexOf("©") >= 0); if (hasInvalidEntity) htmlText = htmlText.Replace("©", "©"); // Read the XML DOM input StringReader stringReader = new StringReader(htmlText); XmlReaderSettings settings = new XmlReaderSettings(); settings.DtdProcessing = DtdProcessing.Ignore; settings.IgnoreWhitespace = false; settings.IgnoreProcessingInstructions = true; settings.IgnoreComments = true; //settings.CheckCharacters = false; //settings.ConformanceLevel = ConformanceLevel.Auto; XmlReader xmlReader = XmlReader.Create(stringReader, settings); while (xmlReader.Read()) { string nameLower = xmlReader.Name.ToLower(); if (xmlReader.NodeType == XmlNodeType.Element) { // Process the element start bool bEmpty = xmlReader.IsEmptyElement; switch (nameLower) { // Process the following elements: // "style" // "a" "img" "font" // "b" "strong" // "h1" "h2" "h3" "h4" "h5" "h6" // "i" "em" "cite" // "u" "br" "pre" "code" "tt" // "p" "form" // "ol" "ul" "blockquote" "dir" "menu" // "li" "div" "center" "span" case "head": case "object": case "meta": case "title": case "script": case "noscript": { _IgnoreText = true; break; } case "style": { _InternalStyles = string.Empty; break; } case "link": { string rel = null; string href = null; if (xmlReader.MoveToFirstAttribute()) do { if (xmlReader.Name.ToLower() == "rel") rel = xmlReader.Value; else if (xmlReader.Name.ToLower() == "href") href = xmlReader.Value; } while (xmlReader.MoveToNextAttribute()); if (rel == "stylesheet" && href != null) { if (_DocumentUri != null) href = _DocumentUri.Site().Append(href).ToString(); //j CssParser.DownloadStyles(UriHelper.MakeAbsolute(_DocumentUri.Site(), href), ref _GlobalStyles); } break; } case "a": case "area": { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); string href = null; if (xmlReader.MoveToFirstAttribute()) do { if (xmlReader.Name.ToLower() == "href") href = xmlReader.Value; } while (xmlReader.MoveToNextAttribute()); if (href != null) { if (_DocumentUri != null && !href.StartsWith("#")) href = _DocumentUri.Site().Append(href).ToString(); state.Href = href; } _DocumentStates.Push(state); break; } case "base": { string href = null; if (xmlReader.MoveToFirstAttribute()) do { if (xmlReader.Name.ToLower() == "href") href = xmlReader.Value; } while (xmlReader.MoveToNextAttribute()); if (href != null) _DocumentUri = new Uri(href, UriKind.Absolute); break; } case "img": { string source = null; DocumentState state = _DocumentStates.Peek(); if (xmlReader.MoveToFirstAttribute()) do { if (xmlReader.Name.ToLower() == "src") source = xmlReader.Value; } while (xmlReader.MoveToNextAttribute()); if (source != null) { if (_DocumentUri != null) source = _DocumentUri.Site().Append(source).ToString(); AddImage(source); } break; } case "font": { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); if (xmlReader.MoveToFirstAttribute()) do { if (xmlReader.Name.ToLower() == "face") state.Face = xmlReader.Value; else if (xmlReader.Name.ToLower() == "size") state.Size = CssParser.ParseFontSize(xmlReader.Value, state.Size); else if (xmlReader.Name.ToLower() == "color") state.Brush = xmlReader.Value.ToColor().ToBrush(); } while (xmlReader.MoveToNextAttribute()); _DocumentStates.Push(state); break; } case "big": case "small": { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); double percent = (nameLower == "big" ? 1.2 : .8); state.Size *= percent; _DocumentStates.Push(state); break; } case "b": case "strong": { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); state.Bold = true; _DocumentStates.Push(state); break; } case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": { MoveToBeginLine(true); if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); // Special h? font size handling if (!ProcessCommonStyles(ref state, xmlReader, nameLower)) state.Size = CssParser.ParseFontSize(nameLower, state.Size); state.Bold = true; _DocumentStates.Push(state); break; } case "i": case "em": case "cite": case "address": case "dfn": // Definition term case "var": // Variable { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); state.Italic = true; _DocumentStates.Push(state); break; } case "u": case "ins": { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); state.Underline = true; _DocumentStates.Push(state); break; } case "s": case "strike": case "del": { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); //state.StrikeThrough = true; _DocumentStates.Push(state); break; } case "br": { AddLineBreak(); break; } case "pre": case "code": case "samp": // Sample computer code case "kbd": case "tt": { if (nameLower == "pre") MoveToBeginLine(true); if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); state.Face = "Courier New"; _DocumentStates.Push(state); break; } case "ol": case "ul": case "dir": // Same as "ul" case "menu": // Same as "ul" { DocumentState state = _DocumentStates.Peek(); bool newParagraph = (bEmpty || state.BulletType == '\0'); MoveToBeginLine(newParagraph); if (bEmpty) break; ProcessCommonStyles(ref state, xmlReader, nameLower); state.BulletType = (nameLower == "ol" ? 'o' : 'u'); state.ListItemNumber = 0; state.Indent += 8; _DocumentStates.Push(state); break; } case "li": { MoveToBeginLine(false); // Bump the list item number DocumentState state = _DocumentStates.Pop(); state.ListItemNumber++; _DocumentStates.Push(state); //DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); _DocumentStates.Push(state); AddIndent(); AddListItem(); break; } case "blockquote": { MoveToBeginLine(true); if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); state.Indent += 8; _DocumentStates.Push(state); break; } case "div": case "p": case "body": case "form": case "center": case "textarea": { MoveToBeginLine(true); if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); _DocumentStates.Push(state); break; } case "table": case "caption": case "tr": case "td": { if (nameLower != "td") MoveToBeginLine(false); if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); _DocumentStates.Push(state); break; } case "sup": case "sub": { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); _DocumentStates.Push(state); break; } case "dl": case "dt": case "dd": { bool newParagraph = (nameLower == "dl"); MoveToBeginLine(newParagraph); if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); if (nameLower == "dd") state.Indent += 8; ProcessCommonStyles(ref state, xmlReader, nameLower); _DocumentStates.Push(state); break; } case "span": case "label": case "q": case "abbr": case "acronym": { if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); _DocumentStates.Push(state); break; } case "legend": { MoveToBeginLine(false); if (bEmpty) break; DocumentState state = _DocumentStates.Peek(); ProcessCommonStyles(ref state, xmlReader, nameLower); _DocumentStates.Push(state); break; } } } else if (xmlReader.NodeType == XmlNodeType.EndElement) { // Process the element end switch (nameLower) { case "head": case "object": case "meta": case "title": case "script": case "noscript": { _IgnoreText = false; break; } case "style": { _GlobalSelectors = CssSelectors.Create(_InternalStyles); _InternalStyles = null; break; } case "link": { _IgnoreText = false; break; } case "a": case "area": { _DocumentStates.Pop(); break; } case "base": { break; } case "img": { break; } case "font": { _DocumentStates.Pop(); break; } case "big": case "small": { _DocumentStates.Pop(); break; } case "b": case "strong": { _DocumentStates.Pop(); break; } case "h1": case "h2": case "h3": case "h4": case "h5": case "h6": { MoveToBeginLine(true); _DocumentStates.Pop(); break; } case "i": case "em": case "cite": case "address": case "dfn": // Definition term case "var": // Variable { _DocumentStates.Pop(); break; } case "u": case "ins": { _DocumentStates.Pop(); break; } case "s": case "strike": case "del": { _DocumentStates.Pop(); break; } case "br": { break; } case "pre": case "code": case "samp": // Sample computer code case "kbd": case "tt": { if (nameLower == "pre") MoveToBeginLine(true); _DocumentStates.Pop(); break; } case "ol": case "ul": case "dir": case "menu": { MoveToBeginLine(true); _DocumentStates.Pop(); break; } case "li": { MoveToBeginLine(false); _DocumentStates.Pop(); break; } case "blockquote": { MoveToBeginLine(true); _DocumentStates.Pop(); break; } case "div": case "p": case "body": case "form": case "center": case "textarea": { MoveToBeginLine(false); _DocumentStates.Pop(); break; } case "table": case "caption": case "tr": case "td": { if (nameLower != "td") MoveToBeginLine(false); _DocumentStates.Pop(); break; } case "sup": case "sub": { _DocumentStates.Pop(); break; } case "dl": case "dt": case "dd": { bool newParagraph = (nameLower == "dl"); MoveToBeginLine(newParagraph); _DocumentStates.Pop(); break; } case "span": case "label": case "q": case "abbr": case "acronym": { _DocumentStates.Pop(); break; } case "legend": { MoveToBeginLine(false); _DocumentStates.Pop(); break; } } } else if (xmlReader.NodeType == XmlNodeType.Text) { // Process the element text string text = ""; try { text = xmlReader.Value; } catch (Exception ex) { text = ex.Message; } if (_InternalStyles != null) _InternalStyles += text; else if (!_IgnoreText) { // Remove redundant whitespace ala HTML StringBuilder builder = new StringBuilder(text.Length); char cLast = (_PriorLineBreaks > 0 ? ' ' : '\0'); foreach (char ch in text) { char c = ch; if (c == '\t' || c == '\n') c = ' '; bool bSkip = (cLast == ' ' && c == ' '); cLast = c; if (!bSkip) builder.Append(c); } // Output the text string textRun = builder.ToString(); AddText(textRun); } } else if (xmlReader.NodeType == XmlNodeType.Whitespace) { // Process the element whitespace if (_InternalStyles != null) _InternalStyles += " "; else if (!_IgnoreText) { // Remove redundant whitespace ala HTML bool bSkip = (_PriorLineBreaks > 0); if (!bSkip) AddText(" "); } } } FlushAll(); } catch (Exception ex) { //ex.DebugOutput(); ex.Alert(); // Invalid XHTML; Clear any existing collection of Inlines if (_RootElement is RichTextBox) { (_RootElement as RichTextBox).Blocks.Clear(); Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(new Run() { Text = htmlText }); (_RootElement as RichTextBox).Blocks.Add(paragraph); } } finally { _DocumentStates.Clear(); _DocumentStates = null; if (_GlobalSelectors != null) { _GlobalSelectors.Dispose(); _GlobalSelectors = null; } _RootElement = null; _CurrentRichTextBox = null; _CurrentParagraph = null; } }
public override void WriteStartDocument() { if (IsClosed) ThrowClosed(); if (_writeState != WriteState.Start) throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.XmlInvalidWriteState, "WriteStartDocument", WriteState.ToString()))); _writeState = WriteState.Prolog; _documentState = DocumentState.Document; _writer.WriteDeclaration(); }
private bool ProcessStyles(ref DocumentState state, CssStyles styles) { if (styles == null || styles.Count <= 0) return false; string value; value = styles.Get("font-family"); if (value != string.Empty) state.Face = value; value = styles.Get("font-weight"); if (value != string.Empty) state.Bold = !value.EqualsIgnoreCase("normal"); value = styles.Get("font-style"); if (value != string.Empty) state.Italic = value.EqualsIgnoreCase("italic"); value = styles.Get("text-decoration"); if (value != string.Empty) state.Underline = value.EqualsIgnoreCase("underline"); value = styles.Get("font-size"); if (value != string.Empty) state.Size = CssParser.ParseFontSize(value, state.Size); value = styles.Get("color"); if (value != string.Empty) state.Brush = value.ToColor().ToBrush(); return true; }
private TestDocumentSnapshot(DefaultProjectSnapshot projectSnapshot, DocumentState documentState) : base(projectSnapshot, documentState) { }
public void LoadXml(string xmlText) { // Mark as empty to avoid double updates // in the xmldoc_Changed method. this.documentState = DocumentState.Empty; this.xmlText = xmlText; try { this.xmlDoc.LoadXml(xmlText); this.documentState = DocumentState.Valid; this.exception = null; if (RootNode.Name != "NUnitProject") throw new XmlException("Top level element must be <NUnitProject...>."); } catch (Exception ex) { this.documentState = DocumentState.InvalidXml; this.exception = ex; } }
public void SetDocumentState(string filename, DocumentState state) { UtilsRegistry .OpenUserSoftwareKey(Globals.RegKeyDocumentStates) .SaveRegistryJson <DocumentState>(filename, state); }
private void DecorateRun(Inline inline, DocumentState state) { // Style the Run appropriately inline.FontFamily = new FontFamily(state.Face != null ? state.Face : "Arial"); inline.FontSize = state.Size; inline.FontStyle = (state.Italic ? FontStyles.Italic : FontStyles.Normal); inline.FontWeight = (state.Bold ? FontWeights.Bold : FontWeights.Normal); inline.Foreground = state.Brush; inline.TextDecorations = (state.Underline ? TextDecorations.Underline : null); }
void IDocument.Hide() { Window.Hide(); state = DocumentState.Hidden; }
public int Add(BusinessDocument doc, DocumentState iniState) { if (doc.GetType() != m_SupportedType) { throw new DocumentNotSupportedException(); } DocumentIndexValue value1 = (DocumentIndexValue) m_IndexList[GetHash(doc)]; if (value1 != null) { if (value1.State == DocumentState.Deleted) { throw new DocumentInvalidStateException(); } throw new ContainerPKViolationException(); } int num1 = m_AllContainer.Add(doc); m_IndexList.Add(GetHash(doc), new DocumentIndexValue(num1, iniState, DocumentState.Unknown)); doc.SetDocumentState(iniState); return num1; }