Exemplo n.º 1
0
 public int AddDepartment(Department department)
 {
     try
     {
         bool b=CheckAccountByDepartment(department.Account.AccountId, department.DepartmentName);
         if (b)
         {
             int isDefault = 0;
             if (department.IsDefault == false)
                 isDefault = 0;
             else
                 isDefault = 1;
             string sql = string.Format("insert into LiveSupport_Department(DepartmentId,DepartmentName,AccountId,IsDefault,AddDate) values('{0}','{1}','{2}','{3}','{4}')", department.DepartmentId, department.DepartmentName, department.Account.AccountId, isDefault, department.AddDate);
             return DBHelper.ExecuteCommand(sql);
         }
         else
         {
             return 0;
         }
     }
     catch (Exception ex)
     {
         System.Console.Write(ex.ToString());
         return 0;
     }
 }
Exemplo n.º 2
0
 public static bool AddDepartment(Department department)
 {
     int i = 0;
     i = Provider.AddDepartment(department);
     if (i != 0)
         return true;
     else
         return false;
 }
Exemplo n.º 3
0
        public static bool AddAccount(Account account,string NickName, string loginName, string loginPwd)
        {
            int i = 0;
            int di = 0;
            int oi = 0;
            i = SqlAccountProvider.Default.AddAccount(account);
            if (i != 0)
            {
                //添加默认部门
                Department dt = new Department();
                dt.Account = account;
                dt.DepartmentId = Guid.NewGuid().ToString();
                dt.DepartmentName = "默认部门";
                dt.IsDefault = true;
                dt.AddDate = DateTime.Now.ToString();
                di=new SqlDepartmentProvider().AddDepartment(dt);
                if (di!=0)
                {

                    Operator op = new Operator();
                    op.Account =  account;
                    op.LoginName = loginName;
                    op.Password = loginPwd;
                    op.IsAdmin = true;
                    op.NickName = NickName;
                    op.Department = dt;
                    op.Email = account.Email;
                    op.AVChatStatus = OperatorStatus.Offline.ToString();
                    op.Status = OperatorStatus.Offline;
                    oi=new SqlOperatorProvider().NewOperator(op);
                }
                WebSite wst = WebSiteManager.GetWebSiteByDomainName(Util.GetDomainName(account.Url));
                if (wst == null)
                {
                    wst = new WebSite();
                    wst.DomainName =Util.GetDomainName(account.Url);
                    wst.ChatStyle = "0";
                    wst.IcoLocation = "0";
                    wst.IconStyle = "0";
                    wst.InviteStyle = "0";
                    wst.RegisterId = account.AccountId;
                    LiveSupport.BLL.WebSiteManager.NewWebSite(wst);
                }
                if (i != 0 && di != 0 && oi != 0)
                {
                    return true;
                }
                else
                    return false;

            }
            else
                return false;
        }
Exemplo n.º 4
0
 public List<Department> GetDepartmentByAccountId(string AccountId)
 {
     List<Department> list = new List<Department>();
     string sql = "select * from LiveSupport_Department where AccountId='" + AccountId + "' order by AddDate";
     using (SqlDataReader sdr = DBHelper.GetReader(sql))
     {
         while (sdr.Read())
         {
             Department department = new Department();
             department.DepartmentId = sdr["DepartmentId"].ToString();
             department.DepartmentName = sdr["DepartmentName"].ToString();
             department.IsDefault = Convert.ToBoolean(sdr["IsDefault"]);
             string aid = sdr["AccountId"].ToString();
             department.Account = accountProvider.GetAccountByAccountId(aid);
             list.Add(department);
         }
         return list;
     }
 }
Exemplo n.º 5
0
 public Department GetDepartmentById(string departmentId)
 {
     string sql = "select * from LiveSupport_Department where DepartmentId='" + departmentId + "'";
     using (SqlDataReader sdr = DBHelper.GetReader(sql))
     {
         if (sdr.Read())
         {
             Department department = new Department();
             department.DepartmentId = sdr["DepartmentId"].ToString();
             department.DepartmentName = sdr["DepartmentName"].ToString();
             department.IsDefault = Convert.ToBoolean(sdr["IsDefault"]);
             string aid = sdr["AccountId"].ToString();
             department.Account = accountProvider.GetAccountByAccountId(aid);
             return department;
         }
         else
         {
             return null;
         }
     }
 }