Ejemplo n.º 1
0
        /// <summary>
        /// Create LastSaveTime field.
        /// </summary>
        /// <param name="field">LastSaveTime field to create.</param>
        /// <returns>Id of the newly created field.</returns>
        public int CreateField(LastSaveTimeField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("LastSaveTimeField");
                }
                #endregion

                XmlDocument xmlDoc = GetXmlDocument();
                XmlNode fieldsNode = GetFieldsNode(field.ViewElement);
                View view = field.GetView();
                XmlElement fieldElement = xmlDoc.CreateElement("Field");

                XmlAttribute fieldIdAttribute = xmlDoc.CreateAttribute("FieldId");
                fieldIdAttribute.Value = view.GetFieldId(field.ViewElement).ToString();
                fieldElement.Attributes.Append(fieldIdAttribute);
                field.Id = Int32.Parse(fieldIdAttribute.Value);

                XmlAttribute fieldTypeId = xmlDoc.CreateAttribute("FieldTypeId");
                fieldTypeId.Value = field.FieldType.ToString();
                fieldElement.Attributes.Append(fieldTypeId);

                XmlAttribute fieldNameAttribute = xmlDoc.CreateAttribute("Name");
                fieldNameAttribute.Value = field.Name;
                fieldElement.Attributes.Append(fieldNameAttribute);

                XmlAttribute fieldViewId = xmlDoc.CreateAttribute("ViewId");
                fieldViewId.Value = view.Id.ToString();
                fieldElement.Attributes.Append(fieldViewId);

                XmlAttribute dataTableName = xmlDoc.CreateAttribute("DataTableName");
                dataTableName.Value = field.TableName;
                fieldElement.Attributes.Append(dataTableName);

                fieldsNode.AppendChild(fieldElement);
                view.Project.Save();
                return field.Id;
            }
            finally
            {
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fills the listbox with controls to be searched for
        /// </summary>
        private void BuildControlsList()
        {
            lbxSearchFields.Items.Clear();

            if (view.Pages.Count > 0)
            {
                foreach (Page page in view.Pages)
                {
                    foreach (Epi.Fields.Field field in page.Fields)
                    {
                         if (!(field is UniqueKeyField) && !(field is RecStatusField) && !(field is MirrorField) && !(field is RelatedViewField) && !(field is LabelField) && !(field is GridField) && !(field is GroupField) && !(field is CommandButtonField))
                           {
                            if (field is IPatternable)
                            {
                                lbxSearchFields.Items.Add(new SearchListBoxItem(field.Name.ToString(), field.Id, field.FieldType.ToString(), ((IPatternable)field).Pattern, string.Empty));
                            }
                            else
                            {
                                lbxSearchFields.Items.Add(new SearchListBoxItem(field.Name.ToString(), field.Id, field.FieldType.ToString(), string.Empty, string.Empty));
                            }
                        }
                    }
                 }
                //--Ei-139
                RecStatusField recstatus = new RecStatusField(view);
                lbxSearchFields.Items.Add(new SearchListBoxItem(recstatus.Name.ToString(), recstatus.Id, recstatus.FieldType.ToString(), string.Empty, string.Empty));
                GlobalRecordIdField globalfld = new GlobalRecordIdField(view);
                lbxSearchFields.Items.Add(new SearchListBoxItem(globalfld.Name.ToString(), globalfld.Id, globalfld.FieldType.ToString(), string.Empty, string.Empty));
                FirstSaveTimeField firstsavetime = new FirstSaveTimeField(view);
                lbxSearchFields.Items.Add(new SearchListBoxItem(firstsavetime.Name.ToString(), firstsavetime.Id, firstsavetime.FieldType.ToString(), string.Empty, string.Empty));
                LastSaveTimeField lastsavetime = new LastSaveTimeField(view);
                lbxSearchFields.Items.Add(new SearchListBoxItem(lastsavetime.Name.ToString(), lastsavetime.Id, lastsavetime.FieldType.ToString(), string.Empty, string.Empty));
                //--
              }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Retrieves data for LastSaveTime field from xml metadata
 /// </summary>
 /// <param name="field">A Last Save Time field</param>
 /// <param name="fieldNode">The field node in the Xml metadata file</param>
 public void GetFieldData(LastSaveTimeField field, XmlNode fieldNode)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Checks and adds records metafieldtype and Metafield tables and also adds fields to datatable
 /// </summary>
 private void VerifyandUpdateViewSystemVars()
 {
     DataTable fieldSysVars = GetMetadata().GetSystemFields(this.id);
     bool FlagColumnExists = false;
     //check table for fields
     foreach (DataRow row in fieldSysVars.Rows)
     {
         if (row[ColumnNames.NAME].ToString() == ColumnNames.RECORD_FIRST_SAVE_TIME)
         {
             FlagColumnExists = true;
             return;
         }
     }
     if (FlagColumnExists == false)
     {
         GetMetadata().SynchronizeMetaFieldtypes(this);
         FirstSaveTimeField firstsavetimeField = new FirstSaveTimeField(this);
         firstsavetimeField.SaveToDb();
         LastSaveTimeField lastsavetimeField = new LastSaveTimeField(this);
         lastsavetimeField.SaveToDb();
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Insert a FirstSaveTimeField record into the metaFields table.
        /// </summary>
        /// <param name="field">LastSaveTime field.</param>
        /// <returns>Returns the Id of the lastSaveTime Field added.</returns>
        public int CreateField(LastSaveTimeField field)
        {
            try
            {
                #region InputValidation
                if (field == null)
                {
                    throw new ArgumentNullException("LastSaveTimeField");
                }
                #endregion
                Query insertQuery = db.CreateQuery("insert into metaFields([DataTableName], [ViewId], [FieldTypeId], [Name]) " +
                  "values (@DataTableName, @ViewId, @FieldTypeId, @Name)");

                insertQuery.Parameters.Add(new QueryParameter("@DataTableName", DbType.String, field.TableName));
                insertQuery.Parameters.Add(new QueryParameter("@ViewId", DbType.Int32, field.GetView().Id));
                insertQuery.Parameters.Add(new QueryParameter("@FieldTypeId", DbType.Int32, (int)field.FieldType));
                insertQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, field.Name));

                db.ExecuteNonQuery(insertQuery);
                return GetMaxFieldId(field.GetView().Id);
            }
            catch (Exception ex)
            {
                throw new GeneralException("Unable to get LastSaveTime field from the database", ex);
            }
            finally
            {

            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a view in a specified project
        /// </summary>
        /// <old-param name="isrelatedview">Whether or not this view is a related (child) view</old-param>
        /// <old-param name="viewname">Name of the view</old-param>
        public void InsertView(View view)
        {
            #region Input Validation
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            #endregion Input Validation

            try
            {
                Query insertQuery = db.CreateQuery("insert into metaViews([Name], [IsRelatedView], [CheckCode], [Width], [Height], [Orientation], [LabelAlign] ) values (@Name, @IsRelatedView, @CheckCode, @Width, @Height, @Orientation, @LabelAlign)");
                insertQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, view.Name));
                insertQuery.Parameters.Add(new QueryParameter("@IsRelatedView", DbType.Boolean, view.IsRelatedView));
                insertQuery.Parameters.Add(new QueryParameter("@CheckCode", DbType.String, view.CheckCode));
                insertQuery.Parameters.Add(new QueryParameter("@Width", DbType.Int32, view.PageWidth));
                insertQuery.Parameters.Add(new QueryParameter("@Height", DbType.Int32, view.PageHeight));
                insertQuery.Parameters.Add(new QueryParameter("@Orientation", DbType.String, view.PageOrientation));
                insertQuery.Parameters.Add(new QueryParameter("@LabelAlign", DbType.String, view.PageLabelAlign));
                db.ExecuteNonQuery(insertQuery);
                view.Id = this.GetMaxViewId();

                RecStatusField recStatusField = new RecStatusField(view);
                UniqueKeyField uniqueKeyField = new UniqueKeyField(view);
                GlobalRecordIdField globalRecordIdField = new GlobalRecordIdField(view);

                //---123
                FirstSaveTimeField firstsavetimeField = new FirstSaveTimeField(view);
                firstsavetimeField.SaveToDb();
                LastSaveTimeField lastsavetimeField = new LastSaveTimeField(view);
                lastsavetimeField.SaveToDb();
                //---

                uniqueKeyField.SaveToDb();
                recStatusField.SaveToDb();
                globalRecordIdField.SaveToDb();
                if (view.IsRelatedView)
                {
                    ForeignKeyField foreignKeyField = new ForeignKeyField(view);
                    foreignKeyField.SaveToDb();
                }
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not create view in the database", ex);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets all the fields in a view
        /// </summary>
        /// <param name="view">A view object</param>
        /// <returns>A collection of fields</returns>
        public virtual FieldCollectionMaster GetFields(View view)
        {
            FieldCollectionMaster fields = new FieldCollectionMaster();
            try
            {
                DataTable table = GetFieldsAsDataTable(view);
                foreach (DataRow row in table.Rows)
                {
                    MetaFieldType fieldTypeId = (MetaFieldType)row[ColumnNames.FIELD_TYPE_ID];
                    Field field = null;
                    switch (fieldTypeId)
                    {
                        case MetaFieldType.Text:
                            field = new SingleLineTextField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.LabelTitle:
                            field = new LabelField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.TextUppercase:
                            field = new UpperCaseTextField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Multiline:
                            field = new MultilineTextField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Number:
                            field = new NumberField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.PhoneNumber:
                            field = new PhoneNumberField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Date:
                            field = new DateField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Time:
                            field = new TimeField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.DateTime:
                            field = new DateTimeField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Checkbox:
                            field = new CheckBoxField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.YesNo:
                            field = new YesNoField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Option:
                            field = new OptionField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.CommandButton:
                            field = new CommandButtonField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Image:
                            field = new ImageField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Mirror:
                            field = new MirrorField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Grid:
                            field = new GridField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Group:
                            field = new GroupField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.GUID:
                            field = new GUIDField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.LegalValues:
                            field = new DDLFieldOfLegalValues(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Codes:
                            field = new DDLFieldOfCodes(view);
                            ((DDLFieldOfCodes)field).LoadFromRow(row);  //zack
                            break;
                        case MetaFieldType.List:
                            field = new DDListField(view);
                            ((DDListField)field).LoadFromRow(row);
                            break;
                        case MetaFieldType.CommentLegal:
                            field = new DDLFieldOfCommentLegal(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.Relate:
                            field = new RelatedViewField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.RecStatus:
                            field = new RecStatusField(view);
                            field.LoadFromRow(row);
                            break;
                        //----123
                        case MetaFieldType.FirstSaveTime:
                            field = new FirstSaveTimeField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.LastSaveTime:
                            field = new LastSaveTimeField(view);
                            field.LoadFromRow(row);
                            break;
                        //----
                        case MetaFieldType.UniqueKey:
                            field = new UniqueKeyField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.ForeignKey:
                            field = new ForeignKeyField(view);
                            field.LoadFromRow(row);
                            break;
                        case MetaFieldType.GlobalRecordId:
                            field = new GlobalRecordIdField(view);
                            field.LoadFromRow(row);
                            break;
                        default:
                            throw new ApplicationException("Invalid Field Type");
                    }
                    // Note: This check ideally shouldn't be necessary, but Epi 3.5.1 and previous versions actually do allow duplicate field names for group fields.
                    if (fields.Contains(field))
                    {
                        Logger.Log(DateTime.Now + ":  " + string.Format("The {0} field with name \"{1}\" already exists in {2}. This field has not been imported.", field.GetType().ToString(), field.Name, view.Name));
                    }
                    else
                    {
                        fields.Add(field);
                    }
                }

            }
            catch (Exception ex)
            {
                //
            }
            return (fields);
        }