示例#1
0
        private String ConditionSQL(Model.Condition Condition)
        {
            switch (Condition.GetType().Name)
            {
            case "And":

                String andsql = "(";

                for (int i = 0; i < Condition.Children.Count(); i++)
                {
                    andsql += this.ConditionSQL(Condition.Children.ElementAt(i));

                    if (i < (Condition.Children.Count() - 1))
                    {
                        andsql += " and ";
                    }
                }

                andsql += ")";

                return(andsql);

            case "Or":

                String orsql = "(";

                for (int i = 0; i < Condition.Children.Count(); i++)
                {
                    orsql += this.ConditionSQL(Condition.Children.ElementAt(i));

                    if (i < (Condition.Children.Count() - 1))
                    {
                        orsql += " or ";
                    }
                }

                orsql += ")";

                return(orsql);

            case "Property":
                Model.Conditions.Property propcondition = (Model.Conditions.Property)Condition;
                Model.PropertyType        proptype      = this.ItemType.PropertyType(propcondition.Name);
                return("(" + this.Session.Table(proptype.ItemType).Name + "." + proptype.Name.ToLower() + this.OperatorSQL(propcondition.Operator) + this.ValueSQL(proptype, propcondition.Value) + ")");

            default:
                throw new NotImplementedException("Condition Type not implemented: " + Condition.GetType().Name);
            }
        }
        public static string GetConditions(Model.Condition condition)
        {
            string paramValue = condition.paramValue;

            string[] values = paramValue.Split(new char[] { ';', ';' }, StringSplitOptions.RemoveEmptyEntries);
            //最后拼接的条件语句
            string strWhere = string.Empty;

            foreach (var value in values)
            {
                if (value == "=")
                {
                    strWhere += " or " + condition + " is null ";
                }
                else if (value == "<>")
                {
                    strWhere += " or " + condition + " is not null ";
                }
                else
                {
                    switch (condition.FieldType)
                    {
                    case Model.Condition.FieldDbType.String:
                    default:
                        strWhere += GetFromText(condition.paramName, value);
                        break;

                    case Model.Condition.FieldDbType.DateTime:
                        strWhere += GetFromDate(condition.paramName, value);
                        break;

                    case Model.Condition.FieldDbType.Number:
                        strWhere += GetFromNumber(condition.paramName, value);
                        break;
                    }
                }
            }
            if (strWhere.Length > 4)
            {
                strWhere = "(" + strWhere.Substring(4) + ")";
            }
            return(strWhere);
        }
示例#3
0
        private Boolean MatchCondition(Model.Condition Condition)
        {
            switch (Condition.GetType().Name)
            {
            case "Property":

                Model.PropertyType proptype = this.ItemType.PropertyType(((Model.Conditions.Property)Condition).Name);
                Property           property = (Property)this.Property(proptype);

                switch (property.PropertyType.Type)
                {
                case Model.PropertyTypeValues.String:
                    String propvalue      = (String)property.Object;
                    String conditionvalue = (String)(((Model.Conditions.Property)Condition).Value);

                    switch (((Model.Conditions.Property)Condition).Operator)
                    {
                    case Model.Conditions.Operators.eq:
                        return(String.Compare(propvalue, conditionvalue, true) == 0);

                    case Model.Conditions.Operators.ge:
                        return((String.Compare(propvalue, conditionvalue, true) == 1) || (String.Compare(propvalue, conditionvalue, true) == 0));

                    case Model.Conditions.Operators.gt:
                        return(String.Compare(propvalue, conditionvalue, true) == 1);

                    case Model.Conditions.Operators.le:
                        return((String.Compare(propvalue, conditionvalue, true) == -1) || (String.Compare(propvalue, conditionvalue, true) == 0));

                    case Model.Conditions.Operators.lt:
                        return(String.Compare(propvalue, conditionvalue, true) == -1);

                    case Model.Conditions.Operators.ne:
                        return(String.Compare(propvalue, conditionvalue, true) != 0);

                    default:
                        throw new NotImplementedException("Condition Operator not implemeted: " + ((Model.Conditions.Property)Condition).Operator);
                    }

                case Model.PropertyTypeValues.Boolean:
                    Boolean boolvalue          = (Boolean)property.Object;
                    Boolean boolconditionvalue = (Boolean)(((Model.Conditions.Property)Condition).Value);

                    switch (((Model.Conditions.Property)Condition).Operator)
                    {
                    case Model.Conditions.Operators.eq:
                        return(boolvalue == boolconditionvalue);

                    case Model.Conditions.Operators.ne:
                        return(boolvalue != boolconditionvalue);

                    default:
                        throw new NotImplementedException("Condition Operator not implemeted: " + ((Model.Conditions.Property)Condition).Operator);
                    }

                default:
                    throw new NotImplementedException("PropertyType not implemented: " + property.PropertyType.Type);
                }

            default:
                throw new NotImplementedException("Condition Type not implemneted: " + Condition.GetType().Name);
            }
        }
示例#4
0
        protected void RefreshControl()
        {
            if (this.Query != null)
            {
                // Set Condition
                if (String.IsNullOrEmpty(this.QueryString.Value))
                {
                    this.Query.Condition = null;
                }
                else
                {
                    List <Model.Condition> conditions = new List <Model.Condition>();

                    foreach (Model.PropertyType proptype in this.Query.Store.ItemType.SearchPropertyTypes)
                    {
                        Model.Condition condition = this.Condition(proptype);

                        if (condition != null)
                        {
                            conditions.Add(condition);
                        }
                    }

                    if (conditions.Count() > 0)
                    {
                        if (conditions.Count() == 1)
                        {
                            this.Query.Condition = conditions[0];
                        }
                        else
                        {
                            this.Query.Condition = Aras.Conditions.Or(conditions[0], conditions[1]);

                            if (conditions.Count() > 2)
                            {
                                for (int i = 2; i < conditions.Count(); i++)
                                {
                                    ((Model.Conditions.Or) this.Query.Condition).Add(conditions[i]);
                                }
                            }
                        }
                    }
                    else
                    {
                        this.Query.Condition = null;
                    }
                }

                // Set PageSize and required Page
                this.Query.Store.PageSize = (System.Int32) this.PageSize.Value;
                this.Query.Store.Page     = (System.Int32) this.Page.Value;

                // Refresh Query
                this.Query.Store.Refresh();

                // Update NoPages
                this.NoPages.Value = this.Query.Store.NoPages;
            }
            else
            {
                this.NoPages.Value = 0;
            }

            // Load Grid
            this.LoadRows();

            // Refresh Buttons
            this.NextPage.Refesh();
            this.PreviousPage.Refesh();
        }
示例#5
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public SetupViewModel()
        {
            CloseSetupWindow    = new RelayCommand(param => CloseSettingsWindow(), param => true);
            SetupWindowFired    = new RelayCommand(param => OpenSessionWindow(), param => true);
            AddGroupWindow      = new RelayCommand(param => OpenAddGroupDialog(), param => true);
            AddIndividualWindow = new RelayCommand(param => OpenAddIndividualDialog(), param => true);
            AddEvaluationWindow = new RelayCommand(param => OpenAddEvaluationDialog(), param => true);
            AddConditionWindow  = new RelayCommand(param => OpenAddConditionDialog(), param => true);
            AddKeyboardWindow   = new RelayCommand(param => OpenAddKeyboardDialog(), param => true);
            AddCollectorWindow  = new RelayCommand(param => OpenAddCollectorDialog(), param => true);
            AddTherapistWindow  = new RelayCommand(param => OpenAddTherapistWindow(), param => true);

            groupListViewModel      = new GroupListViewModel(new GroupRepository());
            groupListViewModel.mInt = this;

            individualListViewModel      = new IndividualListModel();
            individualListViewModel.mInt = this;

            evaluationListViewModel      = new EvaluationListModel();
            evaluationListViewModel.mInt = this;

            conditionListViewModel      = new ConditionListModel();
            conditionListViewModel.mInt = this;

            keyboardListViewModel      = new KeyboardListViewModel();
            keyboardListViewModel.mInt = this;

            collectorListViewModel      = new CollectorListViewModel();
            collectorListViewModel.mInt = this;

            therapistListViewModel      = new PrimaryTherapistViewModel();
            therapistListViewModel.mInt = this;

            bool mRestore = Properties.Settings.Default.RestoreSelection;

            #region Restore Settings Options

            if (mRestore)
            {
                string path = Path.Combine(Properties.Settings.Default.SaveLocation, "SavedState.json");

                if (File.Exists(path))
                {
                    try
                    {
                        var json        = File.ReadAllText(path);
                        var mSavedState = JsonConvert.DeserializeObject <SavedState>(json);

                        Group mGroup = groupListViewModel.AllGroups.Where(g => g.GroupName == mSavedState.Group).First();

                        if (mGroup != null)
                        {
                            groupListViewModel.GroupSelection = mGroup;
                            Individual mIndividual = individualListViewModel.AllIndividuals.Where(i => i.IndividualName == mSavedState.Individual).First();

                            if (mIndividual != null)
                            {
                                individualListViewModel.IndividualSelection = mIndividual;
                                Evaluation mEvaluation = evaluationListViewModel.AllEvaluations.Where(e => e.EvaluationName == mSavedState.Evaluation).First();

                                if (mEvaluation != null)
                                {
                                    evaluationListViewModel.EvaluationSelection = mEvaluation;
                                    Model.Condition mCondition = conditionListViewModel.AllConditions.Where(c => c.ConditionName == mSavedState.Condition).First();

                                    if (mCondition != null)
                                    {
                                        conditionListViewModel.ConditionSelection = mCondition;
                                        KeyboardStorage mKeySet = keyboardListViewModel.AllKeyboards.Where(k => k.name == mSavedState.KeySet).First();

                                        if (mKeySet != null)
                                        {
                                            keyboardListViewModel.keyboardSelection = mKeySet;
                                            Therapist mTherapist = therapistListViewModel.AllTherapists.Where(t => t.TherapistsName == mSavedState.Therapist).First();

                                            if (mTherapist != null)
                                            {
                                                therapistListViewModel.TherapistSelection = mTherapist;
                                                Collector mCollector = collectorListViewModel.AllCollectors.Where(c => c.CollectorsName == mSavedState.DataCollector).First();

                                                if (mCollector != null)
                                                {
                                                    collectorListViewModel.CollectorSelection = mCollector;

                                                    if (mSavedState.Role != null && (mSavedState.Role == "Primary" || mSavedState.Role == "Reliability"))
                                                    {
                                                        SelectedDataRole = mSavedState.Role;

                                                        if (mSavedState.Duration != null &&
                                                            (mSavedState.Duration == "1 Minute") ||
                                                            (mSavedState.Duration == "5 Minutes") ||
                                                            (mSavedState.Duration == "10 Minutes") ||
                                                            (mSavedState.Duration == "15 Minutes") ||
                                                            (mSavedState.Duration == "20 Minutes") ||
                                                            (mSavedState.Duration == "25 Minutes") ||
                                                            (mSavedState.Duration == "30 Minutes") ||
                                                            (mSavedState.Duration == "60 Minutes"))
                                                        {
                                                            SelectedTime = mSavedState.Duration;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("e: " + e.ToString());
                    }
                }
                else
                {
                    Console.WriteLine("Doesn't exist");
                }
            }

            #endregion
        }
示例#6
0
        public Model.Condition Condition()
        {
            Model.Condition ret = null;

            foreach (Control prop in this.Table.Children)
            {
                Model.Condition condition = null;

                switch (prop.GetType().Name)
                {
                case "Boolean":

                    if (((Properties.Boolean)prop).Value != null)
                    {
                        if ((System.Boolean)((Properties.Boolean)prop).Value)
                        {
                            condition = Aras.Conditions.Eq(((Properties.Boolean)prop).PropertyType.Name, "1");
                        }
                        else
                        {
                            condition = Aras.Conditions.Eq(((Properties.Boolean)prop).PropertyType.Name, "0");
                        }
                    }

                    break;

                case "Date":
                    break;

                case "Decimal":

                    if (((Properties.Decimal)prop).Value != null)
                    {
                        condition = Aras.Conditions.Eq(((Properties.Decimal)prop).PropertyType.Name, ((Properties.Decimal)prop).Value);
                    }

                    break;

                case "Float":

                    if (((Properties.Float)prop).Value != null)
                    {
                        condition = Aras.Conditions.Eq(((Properties.Float)prop).PropertyType.Name, ((Properties.Float)prop).Value);
                    }

                    break;

                case "Integer":

                    if (((Properties.Integer)prop).Value != null)
                    {
                        condition = Aras.Conditions.Eq(((Properties.Integer)prop).PropertyType.Name, ((Properties.Integer)prop).Value);
                    }

                    break;

                case "Item":

                    if (((Properties.Item)prop).PropetyItem != null)
                    {
                        condition = Aras.Conditions.Eq(((Properties.Item)prop).PropertyType.Name, ((Properties.Item)prop).PropetyItem.ID);
                    }

                    break;

                case "List":

                    if (!String.IsNullOrEmpty(((Properties.List)prop).Value))
                    {
                        condition = Aras.Conditions.Eq(((Properties.List)prop).PropertyType.Name, ((Properties.List)prop).Value);
                    }

                    break;

                case "Sequence":

                    if (!String.IsNullOrEmpty(((Properties.Sequence)prop).Value))
                    {
                        condition = Aras.Conditions.Like(((Properties.Sequence)prop).PropertyType.Name, ((Properties.Sequence)prop).Value);
                    }

                    break;

                case "String":


                    if (!String.IsNullOrEmpty(((Properties.String)prop).Value))
                    {
                        condition = Aras.Conditions.Like(((Properties.String)prop).PropertyType.Name, ((Properties.String)prop).Value);
                    }

                    break;

                case "Text":

                    if (!String.IsNullOrEmpty(((Properties.Text)prop).Value))
                    {
                        condition = Aras.Conditions.Like(((Properties.Text)prop).PropertyType.Name, ((Properties.Text)prop).Value);
                    }

                    break;

                case "Federated":

                    if (!String.IsNullOrEmpty(((Properties.Federated)prop).Value))
                    {
                        condition = Aras.Conditions.Like(((Properties.Federated)prop).PropertyType.Name, ((Properties.Federated)prop).Value);
                    }

                    break;

                default:
                    throw new Model.Exceptions.ArgumentException("Property Type not implemented: " + prop.GetType().Name);
                }

                if (condition != null)
                {
                    if (ret == null)
                    {
                        ret = condition;
                    }
                    else
                    {
                        if (ret is Model.Conditions.And)
                        {
                            ((Model.Conditions.And)ret).Add(condition);
                        }
                        else
                        {
                            ret = Aras.Conditions.And(ret, condition);
                        }
                    }
                }
            }

            if (ret == null)
            {
                ret = Aras.Conditions.All();
            }

            return(ret);
        }
 private void btnOK_Click(object sender, RoutedEventArgs e)
 {
     bool status = ValidateField();
     if (status == true)
     {
         this.Column.ConditionList = new List<Model.Condition>();
         SetColumnFilterType();
         if (this.VM.NumericFilterType == NumericFilterSelectionType.RANGE || this.VM.NumericFilterType == NumericFilterSelectionType.CUSTOM)
         {
             Model.Condition parentCondition = new Model.Condition(Column.ColumnName, OperatorType.NA);
             parentCondition.LogicalOperatorOfIncludedCondition = LogicOperatorType.AND;
             this.VM.FirstCondition.ParentCondition = parentCondition;
             this.VM.SecondCondition.ParentCondition = parentCondition;
             parentCondition.IncludedConditionList.Add(this.VM.FirstCondition);
             parentCondition.IncludedConditionList.Add(this.VM.SecondCondition);
             if (this.VM.NumericFilterType == NumericFilterSelectionType.CUSTOM)
             {
                 if (this.rdoAND.IsChecked != null && (this.rdoAND.IsChecked.Value == true))
                 {
                     parentCondition.LogicalOperatorOfIncludedCondition = LogicOperatorType.AND;
                 }
                 else if (this.rdoOR.IsChecked != null && (this.rdoOR.IsChecked.Value == true))
                 {
                     parentCondition.LogicalOperatorOfIncludedCondition = LogicOperatorType.OR;
                 }
                 else
                 {
                     parentCondition = new Model.Condition();
                     this.VM.FirstCondition.ParentCondition = null;
                     parentCondition = this.VM.FirstCondition;
                 }
             }
             this.Column.ConditionList.Add(parentCondition);
         }
         else
         {
             this.Column.ConditionList.Add(this.VM.FirstCondition);
         }
         this.DialogResult = true;
         this.Close();
     }
 }