Ejemplo n.º 1
0
 protected void AssertCreateType <T>(Type RegType)
 {
     AtawDebug.Assert(ObjectUtil.IsSubType(typeof(T), RegType),
                      string.Format(ObjectUtil.SysCulture,
                                    "注册类型{0}不是参数T类型{1}的子类,无法进行类型转换,请确认",
                                    RegType, typeof(T)), this);
 }
Ejemplo n.º 2
0
        private string SetTextIndex()
        {
            AtawDebug.Assert(LastNodeIndex >= 0 && LastNodeIndex < 1000, "同一个级的树节点不能超过1000个", this);
            string str = string.Format(ObjectUtil.SysCulture, "{0:000}", LastNodeIndex);

            return(str);
        }
Ejemplo n.º 3
0
 private void JudgeListContainCurrentException(ListNode <T> current)
 {
     AtawDebug.AssertNotNull(fHead, "该链表为空!", this);
     //判断当前节点是否为当前链表中
     //传送LinkList<T>对象给ListNode<T>构造函数,是为了确定不同的节点对应到各自不同的类节点链表里面
     //判断当前节点是否在this链表中
     AtawDebug.Assert(current.List == this, "您插入的当前链表不匹配!", this);
 }
Ejemplo n.º 4
0
        public static IList <ImageCut> GetImageCutsByCutConfigName(string cutGroupName)
        {
            ImageCutGroup cut = FileManagementConfig.ImageCutGroups.Find(a => a.Name == cutGroupName);

            AtawDebug.Assert(cut != null && cut.ImageCuts.Count > 0, string.Format(ObjectUtil.SysCulture,
                                                                                   "名称为{0}的截图配置不存在,或者没有截图配置项", cutGroupName), AtawAppContext.Current);

            return(cut.ImageCuts);
        }
Ejemplo n.º 5
0
        public void ParseExpr(string format)
        {
            FormatString = format;

            var ptr    = 0;
            var length = format.Length;

            while (ptr < length)
            {
                var c = format[ptr++];
                if (c == fOpen)
                {
                    // check for escaped open bracket

                    if (format[ptr] == fOpen)
                    {
                        ptr++;
                        continue;
                    }

                    var marcoStart = ptr;

                    while (format[ptr++] != fClose)
                    {
                        if (ptr >= length)
                        {
                            break;
                        }
                    }

                    AtawDebug.Assert(ptr <= length, string.Format(ObjectUtil.SysCulture,
                                                                  "扫描字符串{0}发现,存在只有{1}而没有与之匹配的{2}结束的字符串", format, fOpen, fClose), format);

                    string marco = format.Substring(marcoStart, ptr - marcoStart - 1);
                    AtawDebug.Assert(!string.IsNullOrEmpty(marco), string.Format(ObjectUtil.SysCulture,
                                                                                 "字符串{0}中存在{1}与{2}之间没有任何宏名称,空宏是不被允许的", format, fOpen, fClose), format);
                    fParameters.Add(new AtawExpressionParameter()
                    {
                        ParameterName = marco, StartIndex = marcoStart - 1
                    });

                    //result.Append("{" + (marcoCount++) + "}");
                }
                else if (c == fClose && ptr < length && format[ptr] == fClose)
                {
                    //result.Append(format, start, ptr - start - 1);
                    ptr++;
                    //result.Append("}");
                }
                else if (c == fClose)
                {
                    AtawDebug.Assert(false, string.Format(ObjectUtil.SysCulture,
                                                          "扫描字符串{0}发现,存在单独的{2},如果要显示{2},请写两个{2},否则请与{1}配对", format, fOpen, fClose), format);
                }
            }
        }
Ejemplo n.º 6
0
        public static object GetFirstEnumValue(Type enumType)
        {
            AtawDebug.AssertArgumentNull(enumType, "enumType", null);

            Array values = Enum.GetValues(enumType);

            AtawDebug.Assert(values.Length > 0, string.Format(ObjectUtil.SysCulture,
                                                              "枚举类型{0}中没有枚举值", enumType), null);
            return((values as IList)[0]);
        }
Ejemplo n.º 7
0
 internal static string GetXmlFilePattern(string pattern)
 {
     if (string.IsNullOrEmpty(pattern))
     {
         return("*.xml");
     }
     AtawDebug.Assert(pattern.EndsWith(".xml", StringComparison.OrdinalIgnoreCase),
                      string.Format(ObjectUtil.SysCulture, "{0}应该是以.xml结束,而现在不是", pattern), null);
     return(pattern);
 }
Ejemplo n.º 8
0
        public static void AddPro(this ExpandoObject expando, string name, object obj)
        {
            IDictionary <string, object> oo = (IDictionary <string, object>)expando;
            string mesg = string.Format(ObjectUtil.SysCulture, "已经有成员{0}了,再添加就要覆盖了", name);

            AtawDebug.Assert(!oo.ContainsKey(name), mesg, expando);
            //if (oo.ContainsKey(name)) ;
            oo.Add(name, obj);
            // SetPro();
            // oo.Add(name, obj);
        }
Ejemplo n.º 9
0
        public static object ReadFromFile(string filePath, Type type)
        {
            AtawDebug.Assert(type.IsSubclassOf(typeof(XmlConfigBase)), string.Format("类型{0}不是XmlConfigBase的子类不是xml插件", type.Name), type);
            XmlReader xmlReader = XmlUtil.GetXmlReader(filePath);

            using (xmlReader)
            {
                XmlSerializer xmlSerializer = new XmlSerializer(type);
                Object        obj           = xmlSerializer.Deserialize(xmlReader);
                CallBackSerialed(obj);
                return(obj);
            }
        }
Ejemplo n.º 10
0
        private void FromString(string idlist)
        {
            fIdList.Clear();
            string[] arr = idlist.Split(',');

            foreach (string s in arr)
            {
                string item = s.Trim();
                AtawDebug.Assert(item.Length >= 2, string.Format(ObjectUtil.SysCulture,
                                                                 "字符串必须是\"value\"格式的,现在值为{0},式样不对", item), this);
                fIdList.Add(item.Substring(1, item.Length - 2));
            }
        }
Ejemplo n.º 11
0
        public EnumCodeTable(Type type)
        {
            DataList = new Dictionary <string, HashCodeDataModel>();
            //string key = "SELECTOR_ENUM";
            // HasCache = true;
            AtawDebug.Assert(type.IsEnum, "代码表 只能用于枚举", this);
            var arrs  = Enum.GetValues(type);
            int count = arrs.Length;

            foreach (var en in arrs)
            {
                if (en.Equals(arrs.GetValue(count - 1)))
                {
                    var cdm = new HashCodeDataModel()
                    {
                        CODE_VALUE = en.Value <int>().ToString(),
                        CODE_TEXT  = en.GetDescription(),
                        CODE_NAME  = en.ToString(),
                    };
                    DataList.Add(cdm.CODE_VALUE, cdm);
                }
                else
                {
                    if (en.Equals(arrs.GetValue(0)))
                    {
                        var cdm2 = new HashCodeDataModel()
                        {
                            CODE_VALUE = en.Value <int>().ToString(),
                            CODE_TEXT  = en.GetDescription(),
                            CODE_NAME  = en.ToString(),
                        };
                        DataList.Add(cdm2.CODE_VALUE, cdm2);
                    }
                    else
                    {
                        var cdm = new HashCodeDataModel()
                        {
                            CODE_VALUE = en.Value <int>().ToString(),
                            CODE_TEXT  = en.GetDescription(),
                            CODE_NAME  = en.ToString(),
                        };
                        DataList.Add(cdm.CODE_VALUE, cdm);
                    }
                }
                // AtawAppContext.Current.AtawCache.Set<EnumCodeDataModel>(KEY_NAME + en.Value<int>().ToString(), cdm);
                //  AtawAppContext.Current.AtawCache.Set<CodeDataModel>(key + en, new CodeDataModel() {  CODE_TEXT});
            }
            //AtawAppContext.Current.AtawCache.Set<CodeDataModel>(, DataList);
        }
Ejemplo n.º 12
0
        public static string EscapeString(string source, string[] replaceString, Func <char, int> escapeFunc)
        {
            if (string.IsNullOrEmpty(source))
            {
                return(string.Empty);
            }
            AtawDebug.AssertArgumentNull(escapeFunc, "escapeFunc", null);
            AtawDebug.AssertEnumerableArgumentNull <string>(replaceString, "replaceString", null);

            StringBuilder cachedStringBuilder = null;
            int           start = 0;
            int           pos   = 0;
            int           count = source.Length;

            for (int i = 0; i < count; ++i)
            {
                pos = escapeFunc(source[i]);
                if (pos < 0)
                {
                    continue;
                }
                if (cachedStringBuilder == null)
                {
                    cachedStringBuilder = new StringBuilder();
                }
                cachedStringBuilder.Append(source.Substring(start, i - start));
                AtawDebug.Assert(pos < replaceString.Length, string.Format(ObjectUtil.SysCulture,
                                                                           "参数escapeFunc返回的值有误,replaceString的长度为{0},但是返回值却是{1},越界了",
                                                                           replaceString.Length, pos), null);
                cachedStringBuilder.Append(replaceString[pos]);
                start = i + 1;
            }
            if (start == 0)
            {
                return(source);
            }
            else if (start < count)
            {
                cachedStringBuilder.Append(source.Substring(start, count - start));
            }
            string s = cachedStringBuilder.ToString();

            return(s);
        }
        protected virtual void FillDataSet(FormConfig fc)
        {
            IListDataTable dt = fc.DataPlug.InstanceByPage <IListDataTable>(fc.Name);

            dt.PageStyle = PageStyle;
            var dataForm = fc.File.InstanceByPage <DataFormConfig>(fc.Name);
            var keyCols  = dataForm.Columns.Where(a => a.IsKey);

            if (keyCols != null)
            {
                AtawDebug.Assert(keyCols.ToList().Count == 1, string.Format("{0}只能指定一个主键", fc.File), dataForm);
            }
            if (dataForm.PrimaryKey.IsEmpty())
            {
                dataForm.PrimaryKey = dataForm.Columns.First(col => col.IsKey).Name;
            }
            MergeColumns(fc, dataForm, ModuleConfig);
            //dt.Initialize(this.PostDataSet, ModuleConfig.PageSize, KeyValue, ForeignKeyValue, fc.TableName, dataForm.PrimaryKey);
            int pageSize = 0;

            if (fc.Pager != null)
            {
                pageSize = fc.Pager.PageSize;
            }
            string foreignKey = GetForeignKey(fc);

            if (!foreignKey.IsEmpty())
            {
                string _foreignKeyValue = KeyValue;
                var    _relations1      = this.ModuleConfig.Relations.Where(a => a.DetailForm == fc.Name).ToList();
                if (_relations1.Count > 0)
                {
                    var    _ra           = _relations1.First();
                    string __relationKey = "_foreignkey_{0}_{1}".AkFormat(_ra.MasterForm, _ra.MasterField);
                    if (AtawAppContext.Current.GetItem(__relationKey) != null)
                    {
                        _foreignKeyValue = AtawAppContext.Current.GetItem(__relationKey).ToString();
                    }
                    else
                    {
                        _foreignKeyValue = KeyValue;
                    }
                }

                dt.Initialize(new ModuleFormInfo(this.PostDataSet, pageSize, KeyValue, _foreignKeyValue,
                                                 fc.TableName, dataForm.PrimaryKey, foreignKey, IsFillEmpty, dataForm, fc.OrderSql, ModuleConfig.DataBase, fc));
            }
            else
            {
                dt.Initialize(new ModuleFormInfo(this.PostDataSet, pageSize, KeyValue, "", fc.TableName,
                                                 dataForm.PrimaryKey, "", IsFillEmpty, dataForm, fc.OrderSql, ModuleConfig.DataBase, fc));
            }

            //  if(this.ModuleConfig.Relations.Find(a=>a.MasterForm == fc.Name))
            var _relations = this.ModuleConfig.Relations.Where(a => a.MasterForm == fc.Name).ToList();

            if (dt.List.Count() > 0)
            {
                var row = dt.List.ToList()[0];
                if (_relations.Count > 0)
                {
                    _relations.ForEach((_relation) => {
                        string _key          = _relation.MasterField;
                        object _value        = row.Row[_key];
                        string __relationKey = "_foreignkey_{0}_{1}".AkFormat(_relation.MasterForm, _relation.MasterField);
                        AtawAppContext.Current.SetItem(__relationKey, _value);
                    });
                }
            }

            if (PageStyle != PageStyle.Insert)
            {
                var _list  = dt.List;
                var __list = _list.ToList();
                __list.ForEach(a =>
                {
                    if (!fc.ButtonRightPlug.IsEmpty())
                    {
                        var gh         = fc.ButtonRightPlug.CodePlugIn <IButtonRight>();
                        var buttons    = gh.GetButtons(a, dt.List);
                        a.BUTTON_RIGHT = SetDataBtnFilterButtonConfig(buttons);
                    }
                    if (fc.HasReview)
                    {
                        a.BUTTON_RIGHT = a.BUTTON_RIGHT + "|Review";
                    }
                });

                dt.AppendTo(this.BasePageView.Data);
                //给数据源添加虚拟字段
                var dataTable = this.BasePageView.Data.Tables[dt.RegName];
                if (dataTable != null)
                {
                    var virtualCols = dataForm.Columns.Where(a => a.Kind == ColumnKind.Virtual && !a.SourceName.IsEmpty());
                    if (virtualCols != null)
                    {
                        foreach (var col in virtualCols)
                        {
                            dataTable.Columns.Add(col.Name);
                            foreach (DataRow row in dataTable.Rows)
                            {
                                row[col.Name] = row[col.SourceName].ToString();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        //SubmitData ListDataTable_SubmitFilterEvent(ResponseResult arg)
        //{
        //    throw new NotImplementedException();
        //}

        public virtual void Merge(bool isBat)
        {
            DataTable dt             = this.PostDataSet.Tables[RegName];
            var       _editorColumns = DataFormConfig.Columns.FindAll(a => a.ControlType == ControlType.Editor);

            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    _editorColumns.ForEach(
                        a =>
                    {
                        if (dt.Columns.Contains(a.Name))
                        {
                            dt.Rows[i][a.Name] = StringUtil.hexToString(dt.Rows[i][a.Name].ToString());
                        }
                    }
                        );
                }
            }
            var sysDt = this.PostDataSet.Tables[PAGE_SYS]; //该表存放主从表的主表主键值

            if (sysDt != null)
            {
                ForeignKeyValue = sysDt.Rows[0][KEYVALUE].ToString();
            }



            List <ObjectDataView> InsertDataViewList = new List <ObjectDataView>();
            List <ObjectDataView> UpdateDataViewList = new List <ObjectDataView>();
            List <string>         DeleteStringList   = new List <string>();

            if (dt != null)
            {
                this.ObjectType = this.ObjectType ?? typeof(ObjectData);
                List <ObjectData> list = DataSetUtil.FillModel(dt, this.ObjectType, XmlColumns);
                foreach (ObjectData objectData in list)
                {
                    DataRow row = objectData.Row;
                    // DataFormConfig.Columns.Find(a=>a.Name ==
                    row.BeginEdit();

                    bool isInsert = !row.Table.Columns.Contains(PrimaryKey) || (row.Table.Columns.Contains(PrimaryKey) && row[PrimaryKey].Value <string>().IsEmpty());
                    MergeTable(isBat, isInsert);
                    if (isInsert)
                    {
                        string _insertKey = GetInsertKey(objectData);
                        if (string.IsNullOrEmpty(ForeignKey))
                        {
                            var insertKeys = AtawAppContext.Current.PageFlyweight.PageItems["InsertKeys"] as List <string>;
                            if (insertKeys == null)
                            {
                                AtawAppContext.Current.PageFlyweight.PageItems.Add("InsertKeys", new List <string> {
                                    _insertKey
                                });
                            }
                            else
                            {
                                insertKeys.Add(_insertKey);
                            }
                        }
                        SetPostDataRow(objectData, DataAction.Insert, _insertKey);
                        InsertForeach(objectData, row, _insertKey);
                        InsertDataViewList.Add(new ObjectDataView()
                        {
                            KeyId      = _insertKey,
                            objectData = objectData
                        });
                    }
                    else
                    {
                        string key = row[PrimaryKey].Value <string>();
                        SetPostDataRow(objectData, DataAction.Update, key);
                        UpdateForeach(objectData, row, key);

                        UpdateDataViewList.Add(
                            new ObjectDataView()
                        {
                            KeyId      = key,
                            objectData = objectData
                        }
                            );
                    }
                    row.EndEdit();
                }
            }
            DataTable opdt = this.PostDataSet.Tables[RegName + "_OPERATION"];

            if (opdt != null && opdt.Rows.Count > 0)
            {
                foreach (DataRow row in opdt.Rows)
                {
                    string _key = row["KeyValue"].ToString();
                    if (row["OperationName"].ToString() == "Delete")
                    {
                        DeleteForeach(_key, "");
                        DeleteStringList.Add(_key);
                    }
                }
            }
            bool isCheck = CheckPostData(InsertDataViewList, UpdateDataViewList, DeleteStringList);

            AtawDebug.Assert(isCheck, "数据源插件{0},的提交数据验证不通过".AkFormat(RegName), this);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 判断常规异常
 /// </summary>
 /// <param>链表是空的</param>
 /// <param>索引过小</param>
 /// <param >索引过大</param>
 private void JudgeNormalException(int index)
 {
     AtawDebug.AssertNotNull(fHead, "链表是空的。", this);
     //Assert的bool值参数如果返回false则报错!
     AtawDebug.Assert(index >= 0 && index < fCount, "索引超出链表范围。", this);
 }
Ejemplo n.º 16
0
 private void InternalRegisterType <TTo, TFrom>(string Regname) where TTo : TFrom
 {
     //MainContainer.RegisterType<TTo, TFrom>("");
     AtawDebug.Assert(Regname.IndexOf("-") == -1, "注册名{0}不允许包含‘-’字符", this);
     MainContainer.RegisterType <TFrom, TTo>(Regname);
 }
Ejemplo n.º 17
0
 private PlugInModel InternalRegisterPlugIn(Type baseType, object instance, string Regname)
 {
     AtawDebug.Assert(Regname.IndexOf("-") == -1, "注册名{0}不允许包含‘-’字符", this);
     MainContainer.RegisterInstance(baseType, Regname, instance);
     return(null);
 }
Ejemplo n.º 18
0
 public void InternalRegisterType <T>(T instace, string Regname)
 {
     AtawDebug.Assert(Regname.IndexOf("-") == -1, "注册名{0}不允许包含‘-’字符", this);
     MainContainer.RegisterInstance <T>(Regname, instace);
 }
Ejemplo n.º 19
0
 private void InternalRegisterType(Type from, Type to, string Regname)
 {
     AtawDebug.Assert(Regname.IndexOf("-") == -1, "注册名{0}不允许包含‘-’字符", this);
     MainContainer.RegisterType(from, to, Regname);
 }