示例#1
0
        private string NameSpaceToString(NameSpaceEntity entity)
        {
            StringBuilder sb       = new StringBuilder();
            int           tableNum = 0;

            if (!string.IsNullOrEmpty(entity.Name.Value))
            {
                tableNum = 1;
                sb.AppendFormat("namespace {0}", entity.Name.Value).NewLine().Append("{");
            }

            foreach (var en in entity.Enums)
            {
                sb.Append(EnumToString(en, tableNum));
            }

            foreach (var st in entity.Structs)
            {
                sb.Append(StructToString(st, tableNum));
            }

            foreach (var sv in entity.Services)
            {
                sb.Append(ServiceToString(sv, entity.Name.Value, tableNum));
            }

            if (!string.IsNullOrEmpty(entity.Name.Value))
            {
                sb.Append('}');
            }

            sb.NewLine();
            return(sb.ToString());
        }
示例#2
0
        /// <summary>
        /// 查找指定名称的名称标识
        /// </summary>
        /// <param name="communityID">社区标识</param>
        /// <param name="nameDescription">名称</param>
        /// <param name="languageID">语言标识 (默认: 30 简体中文)</param>
        /// <returns>名称标识</returns>
        private int FindNameID(
            int communityID,
            string nameDescription,
            int languageID = 30)
        {
            Repository <BizNameSpaceEntity> names = null;

            try
            {
                names = GetRepository();
            }
            catch (Exception error)
            {
                Log.InstanceID.WriteMsg <IRAPSysNamespaceSet>(
                    LogType.ERROR,
                    $"获取[BizNameSpaceEntity]资源库的时候发生错误: {error.Message}");
                return(0);
            }

            try
            {
                NameSpaceEntity entity =
                    names
                    .Table
                    .Where(
                        p => p.LanguageID == languageID &&
                        p.PartitioningKey == communityID * 10000 &&
                        p.NameDescription == nameDescription)
                    .FirstOrDefault();
                if (entity == null)
                {
                    return(0);
                }
                else
                {
                    return(entity.NameID);
                }
            }
            catch (Exception error)
            {
                Log.InstanceID.WriteMsg <IRAPSysNamespaceSet>(
                    LogType.ERROR,
                    $"查找名称标识时发生错误:{error.Message}");
                return(0);
            }
        }
示例#3
0
        public IRAPError Delete(NameSpaceEntity src)
        {
            Repository <BizNameSpaceEntity> names = null;

            try
            {
                names = GetRepository();
            }
            catch (Exception error)
            {
                string msg = $"获取[BizNameSpaceEntity]资源库的时候发生错误: {error.Message}";
                Console.WriteLine(msg);
                return
                    (new IRAPError()
                {
                    ErrCode = 9999,
                    ErrText = msg,
                });
            }

            if (src is BizNameSpaceEntity)
            {
                try
                {
                    var entity =
                        names.Entities.Find(
                            src.PartitioningKey,
                            src.LanguageID,
                            src.NameID);
                    if (entity == null)
                    {
                        return
                            (new IRAPError()
                        {
                            ErrCode = 9999,
                            ErrText =
                                $"未找到 PartitioningKey={src.PartitioningKey}|" +
                                $"LanguagID={src.LanguageID}|" +
                                $"NameID={src.NameID}的记录",
                        });
                    }

                    names.Delete(entity, false);
                    names.SaveChanges();

                    return
                        (new IRAPError()
                    {
                        ErrCode = 0,
                        ErrText = "删除成功",
                    });
                }
                catch (Exception error)
                {
                    string msg = $"删除名称时发生错误: {error.Message}";

                    Console.WriteLine(msg);
                    return
                        (new IRAPError()
                    {
                        ErrCode = 9999,
                        ErrText = msg,
                    });
                }
            }
            else
            {
                string msg = $"传入的参数不是 BizNameSpaceEntity 对象";

                Console.WriteLine(msg);
                return
                    (new IRAPError()
                {
                    ErrCode = 9999,
                    ErrText = msg,
                });
            }
        }
示例#4
0
        public IRAPError Modify(NameSpaceEntity src)
        {
            Repository <BizNameSpaceEntity> names = null;

            try
            {
                names = GetRepository();
            }
            catch (Exception error)
            {
                string msg = $"获取[BizNameSpaceEntity]资源库的时候发生错误: {error.Message}";
                Log.InstanceID.WriteMsg <IRAPSysNamespaceSet>(LogType.ERROR, msg);
                return
                    (new IRAPError()
                {
                    ErrCode = 9999,
                    ErrText = msg,
                });
            }

            if (src is BizNameSpaceEntity)
            {
                try
                {
                    var entity =
                        names.Entities.Find(
                            src.PartitioningKey,
                            src.LanguageID,
                            src.NameID);
                    if (entity == null)
                    {
                        return
                            (new IRAPError()
                        {
                            ErrCode = 9999,
                            ErrText =
                                $"未找到 PartitioningKey={src.PartitioningKey}|" +
                                $"LanguagID={src.LanguageID}|" +
                                $"NameID={src.NameID}的记录",
                        });
                    }

                    names.Update(src as BizNameSpaceEntity);
                    names.SaveChanges();

                    return
                        (new IRAPError()
                    {
                        ErrCode = 0,
                        ErrText = "更新成功",
                    });
                }
                catch (Exception error)
                {
                    string msg = $"更新内容时发生错误: {error.Message}";

                    Log.InstanceID.WriteMsg <IRAPSysNamespaceSet>(LogType.ERROR, msg);
                    return
                        (new IRAPError()
                    {
                        ErrCode = 9999,
                        ErrText = msg,
                    });
                }
            }
            else
            {
                string msg = $"传入的参数不是 BizNameSpaceEntity 对象";

                Log.InstanceID.WriteMsg <IRAPSysNamespaceSet>(LogType.ERROR, msg);
                return
                    (new IRAPError()
                {
                    ErrCode = 9999,
                    ErrText = msg,
                });
            }
        }