Esempio n. 1
0
        private string GetAllUsersMessage()
        {
            var msg = new MessageBuilder();

            msg.AppendLine($"Users in the chat:");
            foreach (var u in users)
            {
                msg.AppendLine(u);
            }

            return(msg.ToString());
        }
Esempio n. 2
0
        private string GetGreetingsMessage(string username)
        {
            var msg = new MessageBuilder();

            msg.AppendLine($"Hi, {username}!")
            .AppendLine("Questions:");

            foreach (var q in questions.Select(q => q.Key))
            {
                msg.AppendLine(q);
            }

            msg.AppendLine("Commands:")
            .AppendLine($"{ByeCmd} - end the chat")
            .AppendLine($"{GetUsersCmd} - get all users in the chat");

            msg.AppendLine("Please enter a command or a number of a question");

            return(msg.ToString());
        }
Esempio n. 3
0
 public IStatus Get(string id)
 {
     try
     {
         using (var cmd = new DBCommand())
         {
             return StatusDAL.Get(cmd, id);
         }
     }
     catch (Exception ex)
     {
         using (var builder = new MessageBuilder())
         {
             string err = builder.AppendLine("读取状态信息错误!").AppendLine(ex).Message;
             throw new Exception(err);
         }
     }
 }
Esempio n. 4
0
 public IList <ICustomer> GetAll(IDictionary <IAttributeDefinition, object> criterias)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             return(CustomerDAL.GetAll(cmd, criterias));
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("读取客户信息列表错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 5
0
 public IApplication Get(string id)
 {
     try
     {
         using (var cmd = new DBCommand())
         {
             return(ApplicationDAL.Get(cmd, id));
         }
     }
     catch (Exception ex)
     {
         using (var builder = new MessageBuilder())
         {
             string err = builder.AppendLine("读取申请单错误!").AppendLine(ex).Message;
             throw new Exception(err);
         }
     }
 }
Esempio n. 6
0
 public IList <IApplication> GetAllPaged(IDictionary <IAttributeDefinition, object> criterias, ref int pageNum, ref int pageCount, int pageSize, ref int itemCount)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             return(ApplicationDAL.GetAllPaged(cmd, criterias, ref pageNum, pageSize, ref pageCount, ref itemCount));
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("读取申请单列表错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 7
0
 public ICase Create(string id, string type, string text)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             ICase instance = CaseDAL.Create(cmd, id, type, text);
             cmd.Commit();
             return(instance);
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建问题信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 8
0
 public IApplication Delete(IApplication instance)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             ApplicationDAL.Delete(cmd, instance);
             cmd.Commit();
             return(instance);
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("删除申请单错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 9
0
 public IStatus Create(string id, string value)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             IStatus instance = StatusDAL.Create(cmd, id,value);
             cmd.Commit();
             return instance;
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建状态信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 10
0
 public IStatus Create(string id, string value)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             IStatus instance = StatusDAL.Create(cmd, id, value);
             cmd.Commit();
             return(instance);
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建状态信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 11
0
 public ICollection Create(string id, decimal?value, decimal?offset)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             ICollection instance = CollectionDAL.Create(cmd, id, value, offset);
             cmd.Commit();
             return(instance);
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建付费信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 12
0
 public ICollection Create(string id, decimal? value, decimal? offset)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             ICollection instance = CollectionDAL.Create(cmd, id, value,offset);
             cmd.Commit();
             return instance;
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建付费信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 13
0
 public ICase Create(string id, string type, string text)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             ICase instance = CaseDAL.Create(cmd, id, type, text);
             cmd.Commit();
             return instance;
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建问题信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 14
0
 public ICustomer Create(string id, string name, string sex, string phone, string address)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             ICustomer instance = CustomerDAL.Create(cmd, id, name, sex, phone, address);
             cmd.Commit();
             return(instance);
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建客户信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 15
0
 public IStatus Delete(IStatus instance)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             StatusDAL.Delete(cmd, instance);
             cmd.Commit();
             return instance;
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("删除状态信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 16
0
        public void ShowMessage(TLogger entity)
        {
#if SERVER
            if (entity.FLogLevel != this.LogLevel)
            {
                return;
            }
#endif

            if (!CanShow(this.LogLevel))
            {
                return;
            }

            MessageBuilder.Clear();
            var    last       = entity.FStackInfo.LastIndexOf('\\');
            string lastString = null;
            if (!string.IsNullOrEmpty(entity.FStackInfo) && last < entity.FStackInfo.Length)
            {
                lastString = entity.FStackInfo.Substring(entity.FStackInfo.LastIndexOf('\\') + 1);
            }
            MessageBuilder.Append($"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss ")}{Enum.GetName(typeof(LogLevel), this.LogLevel)} {lastString}");
            if (!string.IsNullOrEmpty(entity.FMessage))
            {
                MessageBuilder.Append($" {entity.FMessage}");
            }
            if (!string.IsNullOrEmpty(entity.FArgs))
            {
                MessageBuilder.Append($" args:{entity.FArgs}");
            }
            if (!string.IsNullOrEmpty(entity.FExceptionName))
            {
                MessageBuilder.AppendLine();
                MessageBuilder.AppendLine($"name:{entity.FExceptionName}");
                MessageBuilder.AppendLine($"message:{entity.FExceptionMessage}");
                MessageBuilder.AppendLine($"exception:{entity.FExceptionInfo.Trim()}");
            }
            ConsoleLogger.ShowMessage(MessageBuilder.ToString());
        }
Esempio n. 17
0
 public IUser Create(string name, string password, UserRole? role)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             string id = Guid.NewGuid().ToString();
             IUser instance = UserDAL.Create(cmd, id,name, password, role);
             cmd.Commit();
             return instance;
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建用户信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 18
0
        public ICustomer Create(string id, string name, string sex, string phone, string address)
        {
            using (var cmd = new DBCommand())
            {
                try
                {

                    ICustomer instance = CustomerDAL.Create(cmd, id,name,sex,phone,address);
                    cmd.Commit();
                    return instance;
                }
                catch (Exception ex)
                {
                    cmd.RollBack();
                    using (var builder = new MessageBuilder())
                    {
                        string err = builder.AppendLine("创建客户信息错误!").AppendLine(ex).Message;
                        throw new Exception(err);
                    }
                }
            }
        }
Esempio n. 19
0
        public IUser Update(IUser instance, string name, string password, UserRole?role)
        {
            using (var cmd = new DBCommand())
            {
                try
                {
                    UserDAL.Update(cmd, instance, name, password, role);

                    cmd.Commit();
                    return(instance);
                }
                catch (Exception ex)
                {
                    cmd.RollBack();
                    using (var builder = new MessageBuilder())
                    {
                        string err = builder.AppendLine("更新用户信息错误!").AppendLine(ex).Message;
                        throw new Exception(err);
                    }
                }
            }
        }
Esempio n. 20
0
 public IUser Create(string name, string password, UserRole?role)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             string id       = Guid.NewGuid().ToString();
             IUser  instance = UserDAL.Create(cmd, id, name, password, role);
             cmd.Commit();
             return(instance);
         }
         catch (Exception ex)
         {
             cmd.RollBack();
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("创建用户信息错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 21
0
        public IApplication Update(IApplication instance, string id, string customerId, string region, DateTime?dateApplied, DateTime?dateTraved, string offNoteNo, DateTime?offNoteDate, string remark)
        {
            using (var cmd = new DBCommand())
            {
                try
                {
                    ApplicationDAL.Update(cmd, instance, id, customerId, region, dateApplied, dateTraved, offNoteNo,
                                          offNoteDate, remark);

                    cmd.Commit();
                    return(instance);
                }
                catch (Exception ex)
                {
                    cmd.RollBack();
                    using (var builder = new MessageBuilder())
                    {
                        string err = builder.AppendLine("更新申请单错误!").AppendLine(ex).Message;
                        throw new Exception(err);
                    }
                }
            }
        }
Esempio n. 22
0
 public bool IsExisting(string appId)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             var od = AppCore.AppSingleton.FindObjDef <ApplicationObjDef>();
             return(ApplicationDAL.IsExisting(cmd,
                                              new Dictionary <IAttributeDefinition, object>()
             {
                 { od.ID, appId }
             }));
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("查找申请表错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 23
0
 public IUser Get(string name, string password)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             var   od   = AppCore.AppSingleton.FindObjDef <UserObjDef>();
             IUser user = UserDAL.Get(cmd,
                                      new Dictionary <IAttributeDefinition, object>()
             {
                 { od.Name, name }, { od.Password, password }
             });
             return(user);
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("查找用户错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 24
0
        public IApplication Create(string id, string customerId, string region, DateTime? dateApplied, DateTime? dateTraved, string offNoteNo, DateTime? offNoteDate, string remark)
        {
            using (var cmd = new DBCommand())
            {
                try
                {

                    IApplication instance = ApplicationDAL.Create(cmd, id, customerId, region, dateApplied, dateTraved,
                                                                  offNoteNo, offNoteDate,
                                                                  remark);
                    cmd.Commit();
                    return instance;
                }
                catch (Exception ex)
                {
                    cmd.RollBack();
                    using (var builder = new MessageBuilder())
                    {
                        string err = builder.AppendLine("创建申请单错误!").AppendLine(ex).Message;
                        throw new Exception(err);
                    }
                }
            }
        }
Esempio n. 25
0
        public IUser Update(IUser instance, string name, string password, UserRole? role)
        {
            using (var cmd = new DBCommand())
            {
                try
                {
                    UserDAL.Update(cmd, instance, name, password,role);

                    cmd.Commit();
                    return instance;
                }
                catch (Exception ex)
                {
                    cmd.RollBack();
                    using (var builder = new MessageBuilder())
                    {
                        string err = builder.AppendLine("更新用户信息错误!").AppendLine(ex).Message;
                        throw new Exception(err);
                    }
                }
            }
        }
Esempio n. 26
0
 public bool IsExisting(string appId)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             var od = AppCore.AppSingleton.FindObjDef<StatusObjDef>();
             return StatusDAL.IsExisting(cmd,
                                       new Dictionary<IAttributeDefinition, object>() { { od.ID, appId } });
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("查找状态记录错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 27
0
 public bool IsExisting(string name)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             var od = AppCore.AppSingleton.FindObjDef<UserObjDef>();
             return UserDAL.IsExisting(cmd,
                                       new Dictionary<IAttributeDefinition, object>() {{od.Name, name}});
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("查找用户错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 28
0
 public IList<IUser> GetAllPaged(IDictionary<IAttributeDefinition, object> criterias, ref int pageNum, ref int pageCount, int pageSize, ref int itemCount)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             return UserDAL.GetAllPaged(cmd, criterias, ref pageNum, pageSize, ref pageCount,ref itemCount);
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("读取用户信息列表错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 29
0
 public IUser Get(string name, string password)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             var od = AppCore.AppSingleton.FindObjDef<UserObjDef>();
             IUser user = UserDAL.Get(cmd,
                                      new Dictionary<IAttributeDefinition, object>()
                                          {{od.Name, name}, {od.Password, password}});
             return user;
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("查找用户错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }
Esempio n. 30
0
 public IList<ICustomer> GetAll(IDictionary<IAttributeDefinition, object> criterias)
 {
     using (var cmd = new DBCommand())
     {
         try
         {
             return CustomerDAL.GetAll(cmd, criterias);
         }
         catch (Exception ex)
         {
             using (var builder = new MessageBuilder())
             {
                 string err = builder.AppendLine("读取客户信息列表错误!").AppendLine(ex).Message;
                 throw new Exception(err);
             }
         }
     }
 }