private void PopulateScreenParameterWithRelatedControlValue(List <ScreenDataCommandParameter> parameters) { if (!String.IsNullOrEmpty(this.RelatedControl)) { List <ScreenDataCommandParameter> ctrlValueParameters = parameters.Where(p => ( (p.InputType == ScreenInputType.Special) && (p.InputKey.ToLower().Trim() == "relatedcontrolvalue") ) ).ToList <ScreenDataCommandParameter>(); foreach (ScreenDataCommandParameter p in ctrlValueParameters) { CodeTorch.Web.FieldTemplates.BaseFieldTemplate f = ((BasePage)this.Page).FindFieldRecursive(this.RelatedControl); if (f != null) { p.Value = f.Value; } } } }
public void PopulateFormByDataTable(Control container, List <Widget> controls, DataTable data, bool RefreshControls) { if (data.Rows.Count >= 1) { DataRow row = data.Rows[0]; foreach (Widget control in controls) { string DataField = null; //determine if we are in edit mode - check label ends with _ReadOnly_Label DataField = control.DataField; if (!String.IsNullOrEmpty(DataField)) { if (data.Columns.Contains(DataField)) { if (!String.IsNullOrEmpty(control.Name)) { CodeTorch.Web.FieldTemplates.BaseFieldTemplate c = this.FindFieldRecursive(container, control.Name); if (c != null) { try { if (RefreshControls) { c.Refresh(); } c.ValueObject = row[control.DataField]; c.Value = row[control.DataField].ToString(); c.RecordObject = row; } catch { } } else { //likely a read only control - lets try seach again c = this.FindFieldRecursive(container, (control.Name + "_ReadOnly_Label")); if (c != null) { try { if (RefreshControls) { c.Refresh(); } c.ValueObject = row[control.ReadOnlyDataField]; c.Value = row[control.ReadOnlyDataField].ToString(); c.RecordObject = row; } catch { } } } } else { throw new ApplicationException("Control is missing ControlName - " + control.DataField); } } } } } }
private object GetParameterInputValue(IScreenParameter parameter, object newID) { object retVal = null; App app = CodeTorch.Core.Configuration.GetInstance().App; CodeTorch.Web.FieldTemplates.BaseFieldTemplate f = null; switch (parameter.InputType) { case ScreenInputType.AppSetting: retVal = ConfigurationManager.AppSettings[parameter.InputKey]; break; case ScreenInputType.Control: throw new NotSupportedException(); //if (container == null) //{ // f = page.FindFieldRecursive(parameter.InputKey); //} //else //{ // f = page.FindFieldRecursive(container, parameter.InputKey); //} //if (f != null) //{ // retVal = f.Value; //} break; case ScreenInputType.ControlText: //if (container == null) //{ // f = page.FindFieldRecursive(parameter.InputKey); //} //else //{ // f = page.FindFieldRecursive(container, parameter.InputKey); //} //if (f != null) //{ // retVal = f.DisplayText; //} throw new NotSupportedException(); break; case ScreenInputType.Cookie: retVal = HttpContext.Current.Request.Cookies[parameter.InputKey].Value; break; case ScreenInputType.File: //currently onlu supports storage to database if (HttpContext.Current.Request.ContentType.ToLower().Contains("multipart")) { HttpPostedFile file = null; if (HttpContext.Current.Request.Files.Count == 1) { //for refit support file = HttpContext.Current.Request.Files[0] as HttpPostedFile; } else { file = HttpContext.Current.Request.Files[parameter.InputKey] as HttpPostedFile; } file = HttpContext.Current.Request.Files[parameter.InputKey] as HttpPostedFile; if (file != null) { if (file.ContentLength > 0) { DocumentService documentService = DocumentService.GetInstance(); if (String.IsNullOrEmpty(parameter.Default)) { retVal = ReadFully(file.InputStream); } else { DocumentRepository repo = DocumentRepository.GetByName(parameter.Default); if (repo == null) { throw new Exception(String.Format("Parameter {0} is assigned to a missing document repository - {1}. Please check configuration.", parameter.Name, parameter.Default)); } IDocumentProvider documentProvider = documentService.GetProvider(repo); if (documentProvider == null) { throw new Exception(String.Format("Parameter {0} is assigned to document repository - {1}. The provider for this repository could not be found. Please check configuration", parameter.Name, parameter.Default)); } // AppendDocumentID(DocumentID); Document document = new Document(); //need to clone from config document.FileName = file.FileName; document.ContentType = file.ContentType; if (String.IsNullOrEmpty(document.ContentType)) { document.ContentType = "application / octet - stream"; } document.Size = Convert.ToInt32(file.ContentLength); document.Stream = file.InputStream; document.EntityID = "TEMP"; document.EntityType = "TEMP"; document.Settings.Add(new Setting("ModifiedBy", "SYSTEM")); //perform actual upload document.ID = documentProvider.Upload(document); retVal = document.ID; } } } } break; case ScreenInputType.Form: retVal = HttpContext.Current.Request.Form[parameter.InputKey]; break; case ScreenInputType.Header: retVal = HttpContext.Current.Request.Headers[parameter.InputKey]; break; case ScreenInputType.QueryString: retVal = HttpContext.Current.Request.QueryString[parameter.InputKey]; break; case ScreenInputType.Session: retVal = HttpContext.Current.Session[parameter.InputKey]; break; case ScreenInputType.Special: switch (parameter.InputKey.ToLower()) { case "null": retVal = null; break; case "newid": retVal = newID; break; case "dbnull": retVal = DBNull.Value; break; case "username": retVal = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); break; case "hostheader": retVal = HttpContext.Current.Request.ServerVariables["HTTP_HOST"]; break; case "applicationpath": retVal = HttpContext.Current.Request.ApplicationPath; break; case "urlsegment": try { retVal = this.RouteData.Values[parameter.Default]; } catch { } break; case "absoluteapplicationpath": retVal = String.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.ServerVariables["HTTP_HOST"], ((HttpContext.Current.Request.ApplicationPath == "/") ? String.Empty : HttpContext.Current.Request.ApplicationPath)); break; } break; case ScreenInputType.User: try { List <string> profileProperties = CodeTorch.Core.Configuration.GetInstance().App.ProfileProperties; int propertyIndex = Enumerable.Range(0, profileProperties.Count).First(i => profileProperties[i].ToLower() == parameter.InputKey.ToLower()); FormsIdentity identity = (FormsIdentity)HttpContext.Current.User.Identity; FormsAuthenticationTicket ticket = identity.Ticket; retVal = ticket.UserData.Split('|')[propertyIndex]; } catch { } break; case ScreenInputType.Constant: retVal = parameter.InputKey; break; case ScreenInputType.ServerVariables: retVal = HttpContext.Current.Request.ServerVariables[parameter.InputKey]; break; } if ( (parameter.InputType != ScreenInputType.Special) && (parameter.InputType != ScreenInputType.File) ) { if (retVal == null) { retVal = parameter.Default; } } return(retVal); }
public static object GetParameterInputValue(BasePage page, IScreenParameter parameter, Control container) { object retVal = null; App app = CodeTorch.Core.Configuration.GetInstance().App; CodeTorch.Web.FieldTemplates.BaseFieldTemplate f = null; switch (parameter.InputType) { case ScreenInputType.AppSetting: retVal = ConfigurationManager.AppSettings[parameter.InputKey]; break; case ScreenInputType.Control: if (container == null) { f = page.FindFieldRecursive(parameter.InputKey); } else { f = page.FindFieldRecursive(container, parameter.InputKey); } if (f != null) { retVal = f.Value; } break; case ScreenInputType.ControlText: if (container == null) { f = page.FindFieldRecursive(parameter.InputKey); } else { f = page.FindFieldRecursive(container, parameter.InputKey); } if (f != null) { retVal = f.DisplayText; } break; case ScreenInputType.Cookie: retVal = page.Request.Cookies[parameter.InputKey].Value; break; case ScreenInputType.Form: retVal = page.Request.Form[parameter.InputKey]; break; case ScreenInputType.Header: retVal = page.Request.Headers[parameter.InputKey]; break; case ScreenInputType.QueryString: retVal = page.Request.QueryString[parameter.InputKey]; break; case ScreenInputType.Session: retVal = page.Session[parameter.InputKey]; break; case ScreenInputType.Special: switch (parameter.InputKey.ToLower()) { case "null": retVal = null; break; case "dbnull": retVal = DBNull.Value; break; case "username": retVal = UserIdentityService.GetInstance().IdentityProvider.GetUserName(); break; case "hostheader": retVal = HttpContext.Current.Request.ServerVariables["HTTP_HOST"]; break; case "applicationpath": retVal = HttpContext.Current.Request.ApplicationPath; break; case "absoluteapplicationpath": retVal = String.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.ServerVariables["HTTP_HOST"], ((HttpContext.Current.Request.ApplicationPath == "/") ? String.Empty : HttpContext.Current.Request.ApplicationPath)); break; } break; case ScreenInputType.User: try { retVal = GetProfileProperty(parameter.InputKey); } catch { } break; case ScreenInputType.Constant: retVal = parameter.InputKey; break; case ScreenInputType.ServerVariables: retVal = HttpContext.Current.Request.ServerVariables[parameter.InputKey]; break; } if (parameter.InputType != ScreenInputType.Special) { if (retVal == null) { retVal = parameter.Default; } } return(retVal); }