static bool IsDeclaredInScope(Node n, DocumentScope scope) { return (n != scope && // not the scope node itself n.InstanceType != InstanceType.Global && (n.Scope == scope || IsInnerClassDeclaration(n))); }
public void BindDocMgr(string docScope, int recordType, decimal recordID) { staticScope = new DocumentScope().CreateNew(docScope, recordType, "", recordID, ""); SessionManager.DocumentContext = staticScope; pnlDocMgr.Visible = true; Bind_gvUploadedFiles(); }
public void OpenManageAttachmentsWindow(int recordType, decimal recordID, string recordStep, string windowTitle, string description, PageUseMode viewMode) { staticScope = new DocumentScope(); staticScope.CompanyID = 1; staticScope.RecordType = recordType; staticScope.RecordID = recordID; staticScope.RecordStep = recordStep; uclUpload.SetReportOption(false); uclUpload.SetSizeOption(true); if (viewMode == PageUseMode.ViewOnly) { uclUpload.SetViewMode(false); uclUpload.SetDescription(false); btnSave.Visible = false; } else { uclUpload.SetViewMode(true); uclUpload.SetDescription(false); btnSave.Visible = true; } uclUpload.GetUploadedFiles(recordType, recordID, recordStep); winManageAttachments.Title = windowTitle; lblManageAttachments.Text = description; string script = "function f(){OpenManageAttachmentsWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); }
// Local scopes public static Node[] NodesToInitializeInScope(this DocumentScope scope) { return(scope .NodesDeclaredInScope().Where(n => n is NewObjectNode || n is NameTableNode) .Concat(new [] { scope }) .ToArray()); }
public HttpResponseMessage GetAllToolkitbyId(Int64 id, DocumentScope scope) { var documentCourse = UnitOfWork.ToolkitRepository.GetById(id); var course = CreateCourseInstance(documentCourse, scope); return this.Request.CreateResponse(HttpStatusCode.OK, new { Course = course }); }
public static Node[] NodesDeclaredInScope(this DocumentScope scope) { return(scope.InstantiationOrder .OfType <NodeSource>() .Select(n => n.Node) .OrderByDescending(IsInnerClassDeclaration) .Where(n => IsDeclaredInScope(n, scope)) .ToArray()); }
private void cbocar_SelectedIndexChanged(object sender, EventArgs e) { DocumentScope p = cbocar.EditValue as DocumentScope; if (p != null) { txtresp.Text = p.Responsable; } StartChangeOperation(); }
public HttpResponseMessage PostUploadAttachment(DocumentScope scope) { HttpContext context = HttpContext.Current; List<AttachedDocument> attachedFiles = new List<AttachedDocument>(); try { string erroredAtchmnts = String.Empty; string imageURL = String.Empty; //Loop through the multiple files. for (int i = 0; i < context.Request.Files.Count; i++) { var file = context.Request.Files.Get(i); try { AttachedDocument fileAttachment = new AttachedDocument() { //Path = savePath, FileSize = file.ContentLength, FileType = file.ContentType, DocumentName = file.FileName, Scope = scope }; using (var binaryReader = new BinaryReader(file.InputStream)) { fileAttachment.FileData = binaryReader.ReadBytes(file.ContentLength); } UnitOfWork.AttachedDocumentRepository.Insert(fileAttachment); UnitOfWork.SaveChange(); attachedFiles.Add(fileAttachment); var base64String = Convert.ToBase64String(fileAttachment.FileData, 0, fileAttachment.FileData.Length); imageURL = String.Format("data:{0};base64,{1}", fileAttachment.FileType, base64String); } catch (Exception) { if (String.IsNullOrEmpty(erroredAtchmnts)) { erroredAtchmnts = "Attachments that could not be saved due to some error: " + file.FileName; } else { erroredAtchmnts += ", " + file.FileName; } } } return Request.CreateResponse(HttpStatusCode.OK, new { erroredAttachments = erroredAtchmnts, attachedFiles = attachedFiles, imageURL = imageURL }); } catch (UnauthorizedAccessException uex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, uex); } catch (Exception ex) { return Request.CreateResponse(HttpStatusCode.InternalServerError, ex); } }
public void OpenManageVideosWindow(int recordType, decimal recordID, string recordStep, string windowTitle, string description, string videoType, string injuryType, string bodyPart, decimal plantId, PageUseMode viewMode) { _recordType = recordType; _recordId = recordID; _recordStep = recordStep; _injuryType = injuryType; _bodyPart = bodyPart; _videoType = videoType; _plantId = plantId; staticScope = new DocumentScope(); staticScope.CompanyID = 1; staticScope.RecordType = recordType; staticScope.RecordID = recordID; staticScope.RecordStep = recordStep; //uclUpload.SetReportOption(false); //uclUpload.SetSizeOption(true); if (viewMode == PageUseMode.ViewOnly) { //uclUpload.SetViewMode(false); //winManageVideos.Visible = false; pnlAddVideos.Visible = false; btnSave.Visible = false; } else { //winManageVideos.Visible = true; pnlAddVideos.Visible = true; rtbTitle.Text = ""; rtbFileDescription.Text = ""; btnSave.Visible = true; } LoadDefaults(); if (_recordType == (int)TaskRecordType.Audit || _recordType == (int)TaskRecordType.HealthSafetyIncident) { GetUploadedFiles(); pnlListVideo.Visible = true; } else { pnlListVideo.Visible = false; } //winManageVideos.Title = windowTitle; lblManageVideos.Text = description; //string script = "function f(){OpenManageVideosWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); pnlAddVideos.Visible = true; }
public void Initialize() { DocumentScopeHandler h = new DocumentScopeHandler(); DocumentScope s = h.GetElementById("1") as DocumentScope; if (!s.IsDefaultpathValid) { //prendo una locazione di default nel file sistem. string sp = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); s.DefaultPath = sp; h.SaveOrUpdate(s); } }
private string CalculateProtocollo() { ILastProtocolNumberRetriever protocolRetriever = ProtocolRetrieverFactory.GetProtocolRetriever(DataAccessServices.Instance().PersistenceFacade, Properties.Settings.Default.Main_ProtocolStrategy); //_current.Responsable = txtresp.Text; //_current.Date = dtpdata.DateTime; //_current.Contacts = new ArrayList(); //foreach (Customer item in lstcont.Items) //{ // _current.Contacts.Add(item); //} //_current.Priority = (PriorityType)Enum.Parse(typeof(PriorityType), cbopri.Text); //_current.Nature = (WIN.SCHEDULING_APPLICATION.DOMAIN.Document.DocumentNature)Enum.Parse(typeof(WIN.SCHEDULING_APPLICATION.DOMAIN.Document.DocumentNature), cbotip.Text); //_current.Operator = cboop.SelectedItem as Operator; //_current.Type = cbocau.SelectedItem as DocumentType; //_current.Scope = cbocar.SelectedItem as DocumentScope; DocumentType _type = cbocau.SelectedItem as DocumentType; DocumentScope _scope = cbocar.SelectedItem as DocumentScope; Operator _operator = cboop.SelectedItem as Operator; DateTime _date = dtpdata.DateTime; string _protocol = ""; if (_type != null) { if (!string.IsNullOrEmpty(_type.ProtocolCode)) { _protocol = _type.ProtocolCode; } } _protocol = _protocol + protocolRetriever.GetLastProtocolNumber(_date.Year).ToString() + "/"; if (_scope != null) { _protocol += _scope.ProtocolCode + "/"; _protocol += _scope.ResponsableProtocolCode; } if (_operator != null) { _protocol += "/" + _operator.ProtocolCode; } return(_protocol); }
public static T MatchWith <T>( this DocumentScope self, Func <ClassNode, T> a1, Func <TemplateNode, T> a3) { var t1 = self as ClassNode; if (t1 != null) { return(a1(t1)); } var t3 = self as TemplateNode; if (t3 != null) { return(a3(t3)); } throw new ArgumentException(); }
private bool IsProtocolCalculable() { DocumentType _type = cbocau.SelectedItem as DocumentType; DocumentScope _scope = cbocar.SelectedItem as DocumentScope; Operator _operator = cboop.SelectedItem as Operator; if (_type == null) { return(false); } if (_scope == null) { return(false); } if (_operator == null) { return(false); } return(true); }
protected void Bind_gvUploadedFiles() { DocumentScope docScope = null; // get HR company docs if (SessionManager.UserContext.HRLocation.IsPrimaryCompany()) { docScope = new DocumentScope().CreateNew(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, "SYS", 0, "", 0, "", 10); } else if (SessionManager.UserContext.HRLocation.IsSupplierCompany(false)) { docScope = new DocumentScope().CreateNew(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, "SYS", 0, "", 0, "", 11); } else if (SessionManager.UserContext.HRLocation.IsCustomerCompany(false)) { docScope = new DocumentScope().CreateNew(SessionManager.UserContext.HRLocation.Company.COMPANY_ID, "SYS", 0, "", 0, "", 12); } docList = SQMDocumentMgr.SelectDocListFromContext(docScope); // get working location docs docScope = new DocumentScope().CreateNew(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, "BLI", 0, "", SessionManager.UserContext.WorkingLocation.Plant.PLANT_ID, "", 0, 15); docList.AddRange(SQMDocumentMgr.SelectDocListFromContext(docScope)); uclDocList.BindRadDocsList(docList); // setup for doc upload if enabled for this user SessionManager.DocumentContext = new DocumentScope().CreateNew(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, "BLI", 0, "", SessionManager.UserContext.WorkingLocation.Plant.PLANT_ID, "", 0); lblPostedDocuments.Text = ""; foreach (DOCUMENT doc in docList) { if (doc.DOCUMENT_SCOPE == "BLI" && doc.RECORD_ID == SessionManager.UserContext.WorkingLocation.Plant.PLANT_ID) { lblPostedDocuments.Text += (doc.FILE_NAME + ", "); } } }
private ToolkitViewModel CreateCourseInstance(Toolkit item, DocumentScope scope) { var documentList = UnitOfWork.ToolkitAttachmentRepository.Get(ch => ch.toolkitId == item.Id); var viewModel = new ToolkitViewModel() { toolkitID = item.Id, toolkitName = item.ToolkitName, //startDate = item.StartDate, //endDate = item.EndDate, price = item.Price, currencyType = item.CurrencyType, }; if (scope == DocumentScope.allDocument || scope == DocumentScope.freeDocument) { viewModel.freeContent = new Content() { description = item.ToolkitFreeContent }; } if (scope == DocumentScope.allDocument || scope == DocumentScope.paidDocument) { viewModel.paidContent = new Content() { description = item.ToolkitPaidContent }; } if (scope == DocumentScope.allDocument || scope == DocumentScope.publicDocument) { viewModel.publicContent = new Content() { description = item.ToolkitPublicContent }; } foreach (var attDocument in documentList) { AttachedDocument document = null; if (scope == DocumentScope.allDocument) document = UnitOfWork.AttachedDocumentRepository.Get(ch => ch.Id == attDocument.toolkitDocumentID && !ch.IsDeleted).FirstOrDefault(); else document = UnitOfWork.AttachedDocumentRepository.Get(ch => ch.Id == attDocument.toolkitDocumentID && !ch.IsDeleted && ch.Scope == scope).FirstOrDefault(); if (document != null) { if (document.Scope == DocumentScope.freeDocument && viewModel.freeContent != null && viewModel.freeContent.fileAttachment == null) viewModel.freeContent.fileAttachment = new List<DocumentAttached>(); else if (document.Scope == DocumentScope.publicDocument && viewModel.publicContent != null && viewModel.publicContent.fileAttachment == null) viewModel.publicContent.fileAttachment = new List<DocumentAttached>(); else if (document.Scope == DocumentScope.paidDocument && viewModel.paidContent != null && viewModel.paidContent.fileAttachment == null) viewModel.paidContent.fileAttachment = new List<DocumentAttached>(); var base64String = Convert.ToBase64String(document.FileData, 0, document.FileData.Length); var attachedDocument = new DocumentAttached() { attachmentID = document.Id, imageURL = String.Format("data:{0};base64,{1}", document.FileType, base64String), documentScope = document.Scope, documentName = document.DocumentName }; if (document.Scope == DocumentScope.freeDocument) viewModel.freeContent.fileAttachment.Add(attachedDocument); else if (document.Scope == DocumentScope.paidDocument) viewModel.paidContent.fileAttachment.Add(attachedDocument); else if (document.Scope == DocumentScope.publicDocument) viewModel.publicContent.fileAttachment.Add(attachedDocument); } } return viewModel; }
string GetUnique(UXIL.Node n, string baseId, Node pathOrigin) { var id = baseId; if ((n.InstanceType == InstanceType.Local || n.InstanceType == InstanceType.None) && !DocumentScope.ContainsNode(n) && (pathOrigin != null)) { var ps = pathOrigin.ParentScope; if (n == ps && ps is TemplateNode) { return("__parentInstance"); } var prefix = "__parent"; while (ps != null) { if (n == ps) { return(prefix); } if (ps.ContainsNode(n)) { return(prefix + "." + id); } ps = ps.ParentScope; prefix = prefix + ".__parent"; } throw new Exception(id + " cannot be accessed from this scope"); } var c = 0; while (true) { if (!_identifiers.ContainsIdentifier(id) && !reservedWords.Contains(id) && (id != DocumentScope.GeneratedClassName.Surname)) { if (_identifiers.ContainsNode(n)) { return(_identifiers.Get(n)); } _identifiers.Add(n, id); return(id); } c++; id = baseId + c; } }
public void OpenManageVideosWindow(int recordType, decimal recordID, string recordStep, decimal plantID, string windowTitle, string description, string videoType, string injuryType, string bodyPart, PageUseMode viewMode, bool showCancel, string context) { _recordType = recordType; _recordId = recordID; _recordStep = recordStep; _plantId = plantID; _injuryType = injuryType; _bodyPart = bodyPart; _videoType = videoType; _showCancel = showCancel; staticScope = new DocumentScope(); staticScope.CompanyID = 1; staticScope.RecordType = recordType; staticScope.RecordID = recordID; staticScope.RecordStep = recordStep; //uclUpload.SetReportOption(false); //uclUpload.SetSizeOption(true); if (viewMode == PageUseMode.ViewOnly) { //uclUpload.SetViewMode(false); pnlAttachVideoBody.Visible = btnSave.Visible = false; rgFiles.MasterTableView.GetColumn("DeleteButtonColumn").Visible = false; } else { pnlAttachVideoBody.Visible = btnSave.Visible = true; dmFromDate.ShowPopupOnFocus = true; } if (context == "mediapage") { btnSave.Visible = false; btnSaveNA.Visible = true; } else { btnSave.Visible = true; btnSaveNA.Visible = false; } LoadDefaults(); GetUploadedFiles(); if (viewMode == PageUseMode.ViewOnly && !pnlListVideo.Visible) { pnlNoVideosClosed.Visible = true; litInstructions.Visible = false; } else { pnlNoVideosClosed.Visible = false; litInstructions.Visible = true; } tbTitle.Text = tbFileDescription.Text = ""; lblManageVideos.Text = description; pnlManageAttachVideos.Visible = true; pnlAttachMsg.Visible = false; btnCancel.Visible = showCancel; }
private void SetAttachmentsScope(int recordType, string sessionID, decimal recordID, string recordStep) { staticScope = new DocumentScope().CreateNew("REC", recordType, sessionID, recordID, recordStep); SessionManager.DocumentContext = staticScope; }
/// <summary> /// Parse and compile string expression and return BsonExpression /// </summary> internal static BsonExpression ParseAndCompile(Tokenizer tokenizer, BsonExpressionParserMode mode, BsonDocument parameters, DocumentScope scope) { if (tokenizer == null) { throw new ArgumentNullException(nameof(tokenizer)); } var context = new ExpressionContext(); var expr = mode == BsonExpressionParserMode.Full ? BsonExpressionParser.ParseFullExpression(tokenizer, context, parameters, scope) : mode == BsonExpressionParserMode.Single ? BsonExpressionParser.ParseSingleExpression(tokenizer, context, parameters, scope) : mode == BsonExpressionParserMode.SelectDocument ? BsonExpressionParser.ParseSelectDocumentBuilder(tokenizer, context, parameters) : BsonExpressionParser.ParseUpdateDocumentBuilder(tokenizer, context, parameters); // compile linq expression (with left+right expressions) Compile(expr, context); return(expr); }
public static Lambda GenerateScopeConstructor(this DocumentScope scope, TypeName simulatedType, TypeName producedType, Context ctx) { var nodesToDeclare = scope.NodesDeclaredInScope(); var nodesToInitialize = scope.NodesToInitializeInScope(); var usedNames = ctx.Names; var self = usedNames.GetUniqueName(); var names = usedNames.Add(scope, self).GenerateNames(nodesToDeclare); var newCtx = ctx.With(names: names); var parameters = ImmutableList <Parameter> .Empty; var cs = scope as ClassNode; if (cs != null) { parameters = cs.DeclaredDependencies .Select(x => new Parameter(TypeName.Parse(x.ResultingType.FullName), names[x])) .ToImmutableList(); } var isApp = parameters.Count == 0 && producedType == App; if (isApp) { parameters = List.Create(new Parameter(App, Variable.This)); } var baseParameters = scope.Properties .Where(x => x.Facet.IsConstructorArgument && x.HasValue) .Select(x => { if (x is ReferenceProperty) { return(((ReferenceProperty)x).Source.GetExpression(newCtx)); } else if (x is AtomicProperty) { return(((AtomicProperty)x).Value.GetExpression(newCtx)); } else { throw new Exception("Unsupported constructor argument property type"); } }) .ToArray(); return(new Lambda( new Signature( parameters: parameters, returnType: producedType), localVariables: new[] { new BindVariable(self, isApp ? new ReadVariable(Variable.This) // use object passed to ctor as this for the App tag : producedType.Instantiate(baseParameters, newCtx, newCtx.TryGetTagHash(scope))) } .Concat(nodesToDeclare.GetDeclarations(newCtx)), statements: nodesToInitialize .GetInitializations(newCtx) .Concat(new [] { new Return(new ReadVariable(self)) }))); }