コード例 #1
0
 public bool LogImport(long idUser, string text = "")
 {
     using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
     {
         DataTable dt = cnn.CreateDataTable("select * from Tbl_Log_Loai where IdRow=" + Loai);
         if (dt == null || dt.Rows.Count == 0)
         {
             Error = "Loại đối tượng không đúng";
             return(false);
         }
         string    ip  = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();
         Hashtable val = new Hashtable();
         val.Add("IdLoaiLog", Loai);
         val.Add("IdHanhDong", 7);
         val.Add("IP", ip);
         val.Add("NoiDung", "Import danh sách " + dt.Rows[0]["LoaiLog"].ToString().ToLower() + " " + text);
         val.Add("CreatedBy", idUser);
         val.Add("CreatedDate", DateTime.Now);
         int kq = cnn.Insert(val, "Tbl_Log");
         cnn.Disconnect();
         if (kq == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="type">1: Update, 2: Check, 3: Get</param>
        /// <param name="request">reqtest json khi bắn API</param>
        /// <param name="response">response json khi API trả về</param>
        /// <param name="ErrorCode">ErrorCode</param>
        /// <param name="ErrorMessage">ErrorMessage</param>
        /// <returns></returns>
        public bool LogJeedocs(int type, string request, string response, string ProcessCode, string ProcessMessage, int idUser, bool Success)
        {
            try
            {
                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    Hashtable val = new Hashtable();
                    //val.Add("type", Loai);
                    val.Add("ProcessCode", ProcessCode);
                    val.Add("ProcessMessage", ProcessMessage);
                    val.Add("ResponseJson", response);
                    val.Add("Request", request);
                    val.Add("Type", type);
                    val.Add("Success", Success);

                    val.Add("CreatedBy", idUser);
                    val.Add("CreatedDate", DateTime.Now);

                    int kq = cnn.Insert(val, "Tbl_JeeDocs_Log");
                    cnn.Disconnect();
                    if (kq == 1)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            { return(false); }
        }
コード例 #3
0
        /// <summary>
        /// Lưu lịch sử Tbl_LichSu
        /// </summary>
        /// <param name="Loai">1: văn bản đến, 2: văn bản đi, 3: hồ sơ, 4: công việc</param>
        /// <param name="hanhDong"></param>
        /// <param name="idUser"></param>
        /// <param name="noidung"></param>
        /// <param name="idDoituong"></param>
        /// <param name="cnn"></param>
        /// <param name="IdProcess"></param>
        /// <param name="LSDetails">IdRow của bảng bị tác động</param>
        /// <returns></returns>
        public static long LuuLichSu(int Loai, string hanhDong, long idUser, string noidung, bool email, bool sms, long idDoituong, DpsConnection cnn, long IdProcess = 0, bool traLoi = false)
        {
            Hashtable val = new Hashtable();

            val.Add("Loai", Loai);
            val.Add("HanhDong", hanhDong);
            val.Add("NoiDung", string.IsNullOrEmpty(noidung) ? "" : noidung);
            val.Add("Email", email);
            val.Add("SMS", sms);
            val.Add("YeuCauTraLoi", traLoi);
            val.Add("Id", idDoituong);

            val.Add("CreatedBy", idUser);
            val.Add("CreatedDate", DateTime.Now);
            if (IdProcess > 0)
            {
                val.Add("IdProcess", IdProcess);
            }
            int kq = cnn.Insert(val, "Tbl_LichSu");

            if (kq == 1)
            {
                var id = cnn.ExecuteScalar("select IDENT_CURRENT ('Tbl_LichSu')");
                return(long.Parse(id.ToString()));
            }
            else
            {
                return(0);
            }
        }
コード例 #4
0
        public object Create_TrangCanNhan()
        {
            {
                SqlConditions Conds = new SqlConditions();
                DataTable     dt    = new DataTable();
                DataRow[]     dr;
                DataTable     dt_tb    = new DataTable();
                Hashtable     val      = new Hashtable();
                DataTable     dt_token = new DataTable();
                string        tam      = "";
                int           id_user  = 0;
                try
                {
                    //Conds.Add("email", Email);
                    //Conds.Add("password", Pass);



                    //val.Add("ID_COMMENT", data.id_cmt);
                    // val.Add("ID_BAIDANG", data.ID_BaiDang);



                    //Conds.Add("ID_USER", data.ID_User);
                    using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                    {
                        dt_tb = cnn.CreateDataTable(@"SELECT Max(ID_USER) as asLastID FROM TBL_Account");

                        dr  = dt_tb.Select();
                        tam = dt_tb.Rows[0]["asLastID"].ToString();

                        id_user = Int32.Parse(tam);


                        Thread.Sleep(500);

                        val.Add("ID_USER", id_user);

                        if (cnn.Insert(val, "TBL_TRANGCANHAN") < 0)
                        {
                            return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                        }
                    }

                    return(JsonResultCommon.ThanhCong());
                }
                catch (Exception ex)
                {
                    return(JsonResultCommon.Exception(ex));
                }
            }
        }
コード例 #5
0
        public object addTBLGhim(int id_user, int id_thongdiep)
        {
            {
                int           status = 0;
                SqlConditions Conds  = new SqlConditions();
                DataTable     dt     = new DataTable();
                DataRow[]     dr;
                Hashtable     val      = new Hashtable();
                Hashtable     val2     = new Hashtable();
                DataTable     dt_token = new DataTable();
                try
                {
                    //Conds.Add("email", Email);
                    //Conds.Add("password", Pass);



                    //val.Add("ID_COMMENT", data.id_cmt);
                    //val.Add("ID_BAIDANG", data.ID_BaiDang);
                    val.Add("ID_THONGDIEP", id_thongdiep);


                    val.Add("ID_USER", id_user);


                    //Conds.Add("ID_USER", id_user);
                    Conds.Add("ID_THONGDIEP", id_thongdiep);
                    //Conds.Add("ID_USER", data.ID_User);
                    using (DpsConnection cnn = new DpsConnection("ConnectSQLMXH", true))
                    {
                        //    dt = cnn.CreateDataTable(@"SELECT COL_DISABLE FROM TBL_THONGDIEPCEO as g where  g.ID_THONGDIEP="+id_thongdiep, Conds);
                        //    dr = dt.Select();
                        //    var total = dt.Rows.Count;


                        if (cnn.Insert(val, "TBL_GHIM") < 0)
                        {
                            return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                        }
                    }



                    return(JsonResultCommon.ThanhCong());
                }
                catch (Exception ex)
                {
                    return(JsonResultCommon.Exception(ex));
                }
            }
        }
コード例 #6
0
        public object UpdateQuyenLoaiBaiDang(int loai)
        {
            {
                string    Token     = lc.GetHeader(Request);
                LoginData loginData = lc._GetInfoUser(Token);
                if (loginData == null)
                {
                    return(JsonResultCommon.DangNhap());
                }

                int    status = 0;
                string Id     = "";

                SqlConditions Conds = new SqlConditions();
                DataTable     dt    = new DataTable();
                DataRow[]     dr;
                bool          Visible = true;
                Hashtable     val = new Hashtable();
                List <object> rs = new List <object>();
                string        title = "", link = "";

                DataTable dt_token = new DataTable();
                try
                {
                    //Conds.Add("password", Pass);
                    using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                    {
                        val.Add("ID_LOAIBAIDANG", loai);



                        val.Add("ID_USER", loginData.Id);


                        if (cnn.Insert(val, "TBL_NHOM_QUYEN_LOAIBAIDANG") < 0)
                        {
                            return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                        }
                        return(JsonResultCommon.ThanhCong());
                    }
                }
                catch (Exception ex)
                {
                    return(JsonResultCommon.Exception(ex));
                }
            }
        }
コード例 #7
0
        public Task OnConnectedTokenAsync(string infoToken)
        {
            try
            {
                var id = Context.ConnectionId;
                TokenRequesModel infoDataCon = JsonConvert.DeserializeObject <TokenRequesModel>(infoToken);
                string           Token       = infoDataCon.Token;
                string           idUser      = infoDataCon.UserID.ToString();
                string           clientId    = Context.ConnectionId;
                if (!ConnectedClients.Keys.Contains(Token))
                {
                    ConnectedClients.Add(Token, clientId);
                }
                else
                {
                    ConnectedClients[Token] = clientId;
                }
                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    Hashtable has = new Hashtable();
                    has.Add("Token", Token);
                    has.Add("TimeConnect", DateTime.Now);
                    has.Add("TimeTokenConnect", DateTime.Now);
                    has.Add("ConnectionId", clientId);

                    string sql_ = @" IF EXISTS (SELECT * FROM SignalR_Connect c WHERE c.Token=@Token)
		                                BEGIN
			                                DELETE SignalR_Connect WHERE Token =@Token 
		                                END "        ;

                    cnn.ExecuteNonQuery(sql_, new SqlConditions {
                        { "Token", Token }
                    });
                    if (cnn.Insert(has, "SignalR_Connect") == 1)
                    {
                    }
                }
            }catch (Exception ex)
            {
                return(base.OnDisconnectedAsync(ex));
            }
            return(base.OnConnectedAsync());
        }
コード例 #8
0
        public object addFlow(int id_canhan)
        {
            string    Token     = lc.GetHeader(Request);
            LoginData loginData = lc._GetInfoUser(Token);

            if (loginData == null)
            {
                return(JsonResultCommon.DangNhap());
            }
            SqlConditions Conds = new SqlConditions();
            DataTable     dt    = new DataTable();

            DataRow[]     dr;
            bool          Visible = true;
            List <object> rs = new List <object>();
            string        title = "", link = "";
            Hashtable     val      = new Hashtable();
            DataTable     dt_token = new DataTable();

            try
            {
                val.Add("ID_CANHAN", id_canhan);



                val.Add("USER_Flow", loginData.Id);

                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    if (cnn.Insert(val, "TBL_Flow") < 0)
                    {
                        return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                    }
                }
                return(JsonResultCommon.ThanhCong());
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
コード例 #9
0
        public object addUserGroup(int id_group, int id_user, Models.Group.User_Group data)
        {
            string sqlq = "";

            SqlConditions Conds = new SqlConditions();

            sqlq = "select * from TBL_GROUPMEMBER  where ID_USER="******" and ID_GROUP=" + id_group;

            bool value = true;

            DataRow[] dr;
            int       re         = 0;
            int       id_gr      = 0;
            Hashtable val_member = new Hashtable();
            string    Id         = "";
            DataTable lastid     = new DataTable();
            Hashtable val        = new Hashtable();

            try
            {
                //string Token = Request.Headers.GetValues("Token").FirstOrDefault();
                //LoginData loginData = API_KD.Assets.Common.GetUserByToken(Token);
                //if (loginData == null)
                //    return JsonResultCommon.DangNhap();
                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    Thread.Sleep(500);
                    DataTable dt = cnn.CreateDataTable(sqlq);
                    if (cnn.LastError != null || dt == null)
                    {
                        return(JsonResultCommon.Exception(cnn.LastError));
                    }

                    if (dt.Rows.Count == 0 && id_group != 0)
                    {
                        val.Add("ID_GROUP", data.Id_Group);


                        val.Add("CREATE_DATE", DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
                        val.Add("ID_USER", id_user);

                        val.Add("QUYEN_ADMIN", data.quyen_group);

                        re = cnn.Insert(val, "TBL_GROUPMEMBER");
                    }
                    else if (data.Id_Group == 0 || id_group == 0)
                    {
                        lastid = cnn.CreateDataTable(@"
            SELECT TOP 1 ID_GROUP asLastID FROM TBL_GROUP ORDER BY ID_GROUP DESC");
                        dr     = lastid.Select();

                        foreach (DataRow r in dr[0].Table.Rows)
                        {
                            Id = r["asLastID"].ToString();
                        }
                        id_gr = Int32.Parse(Id);

                        val_member.Add("ID_GROUP", id_gr);


                        val_member.Add("CREATE_DATE", DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
                        val_member.Add("ID_USER", id_user);
                        val_member.Add("QUYEN_ADMIN", 1);


                        if (cnn.Insert(val_member, "TBL_GROUPMEMBER") < 0)

                        {
                            return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                        }
                    }
                    else
                    {
                        return(JsonResultCommon.ThatBai("Thành viên đã tồn tại !", cnn.LastError));
                    }


                    return(JsonResultCommon.ThanhCong());
                }
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
コード例 #10
0
        public object UpdateQuyenLoaiBaiDang_Default()
        {
            {
                int           status = 0;
                string        Id     = "";
                string        Token  = "";
                SqlConditions Conds  = new SqlConditions();
                DataTable     dt     = new DataTable();
                DataRow[]     dr;
                int           id_user;
                DataTable     lastid = new DataTable();
                bool          Visible = true;
                Hashtable     val = new Hashtable();
                Hashtable     val2 = new Hashtable();
                List <object> rs = new List <object>();
                string        title = "", link = "";

                DataTable dt_token = new DataTable();
                try
                {
                    //Conds.Add("password", Pass);
                    using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                    {
                        Thread.Sleep(500);

                        lastid = cnn.CreateDataTable(@"
                SELECT Max(ID_USER) as asLastID FROM TBL_USER");
                        dr     = lastid.Select();

                        Id = lastid.Rows[0]["asLastID"].ToString();

                        id_user = Int32.Parse(Id);



                        val.Add("ID_LOAIBAIDANG", 6);
                        //val.Add("ID_LOAIBAIDANG", 1);



                        val.Add("ID_USER", id_user);



                        if (cnn.Insert(val, "TBL_NHOM_QUYEN_LOAIBAIDANG") < 0)
                        {
                            return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                        }


                        val2.Add("ID_LOAIBAIDANG", 1);
                        //val.Add("ID_LOAIBAIDANG", 1);



                        val2.Add("ID_USER", id_user);


                        if (cnn.Insert(val2, "TBL_NHOM_QUYEN_LOAIBAIDANG") < 0)
                        {
                            return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                        }
                        return(JsonResultCommon.ThanhCong());
                    }
                }
                catch (Exception ex)
                {
                    return(JsonResultCommon.Exception(ex));
                }
            }
        }
コード例 #11
0
        public object addGroup(Models.Group.Group data)
        {
            string    Token     = lc.GetHeader(Request);
            LoginData loginData = lc._GetInfoUser(Token);

            if (loginData == null)
            {
                return(JsonResultCommon.DangNhap());
            }
            int           status   = 0;
            string        Id       = "";
            int           id_group = 0;
            SqlConditions Conds    = new SqlConditions();
            DataTable     dt       = new DataTable();

            DataRow[]     dr;
            bool          Visible = true;
            List <object> rs = new List <object>();
            string        title = "", link = "";
            Hashtable     val        = new Hashtable();
            Hashtable     val_member = new Hashtable();
            DataTable     dt_token   = new DataTable();
            DataTable     lastid     = new DataTable();
            string        sqlq       = "";



            try
            {
                val.Add("TEN_GROUP", data.ten_group);


                val.Add("CREATE_DATE", DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
                val.Add("CREATE_BY", loginData.Id);
                val.Add("UPDATE_DATE", DateTime.Now.ToString("MM/dd/yyyy HH:mm"));


                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    sqlq = "select TEN_GROUP from TBL_GROUP where TEN_GROUP='" + data.ten_group + "'";

                    dt = cnn.CreateDataTable(sqlq);
                    if (dt.Rows.Count == 0)
                    {
                        if (cnn.Insert(val, "TBL_GROUP") < 0)

                        {
                            return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                        }
                    }
                    else
                    {
                        return(JsonResultCommon.ThatBai("Tên Nhóm Đã Tồn Tại", cnn.LastError));
                    }


                    lastid = cnn.CreateDataTable(@"
SELECT TOP 1 ID_GROUP asLastID FROM TBL_GROUP ORDER BY ID_GROUP DESC");
                    dr     = lastid.Select();

                    foreach (DataRow r in dr[0].Table.Rows)
                    {
                        Id = r["asLastID"].ToString();
                    }
                    id_group = Int32.Parse(Id);


                    val_member.Add("ID_GROUP", id_group);


                    val_member.Add("CREATE_DATE", DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
                    val_member.Add("ID_USER", loginData.Id);
                    val_member.Add("QUYEN_ADMIN", 1);


                    if (cnn.Insert(val_member, "TBL_GROUPMEMBER") < 0)

                    {
                        return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                    }
                }
                return(JsonResultCommon.ThanhCong(id_group));
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }
コード例 #12
0
        /// <summary>
        /// Tạo tiến trình và xác định checkers đầu tiên<para/>
        /// </summary>
        /// <returns></returns>
        public bool Begin()
        {
            string    check   = "select * from DP_Process where IdDoiTuong=19 and Id=" + Id;
            DataTable dtCheck = cnn.CreateDataTable(check);

            if (dtCheck.Rows.Count > 0)
            {
                Error = "Quy trình cho phản ánh đã được thiết lập";
                return(false);
            }
            string    sql = "select * from DP_Action where Disabled=0";
            DataTable dt  = cnn.CreateDataTable(sql);

            if (dt == null || dt.Rows.Count == 0)
            {
                Error = "Không tìm thấy quy trình";
                return(false);
            }
            Hashtable val;

            foreach (DataRow dr in dt.Rows)
            {
                val                  = new Hashtable();
                val["Id"]            = Id;
                val["IdStep"]        = dr["IdStep"];
                val["Next"]          = dr["Next"];
                val["ButtonText"]    = dr["ButtonText"];
                val["IsComeBackPro"] = dr["IsComeBack"];
                val["IdDoiTuong"]    = 19;
                cnn.Insert(val, "DP_Process");
            }
            string    lstUser   = "";
            string    str1      = @"SELECT distinct pro.IdRow, pro.IdStep, pro.Next, pro.IsComeBackPro from DP_Process pro
join DP_Step step on pro.IdStep = step.IdRow and step.disabled=0 where step.Loai=0 and Id=" + Id;
            DataTable dtProcess = cnn.CreateDataTable(str1);

            foreach (DataRow dr in dtProcess.Rows)
            {
                //Tim Checkers dau tien
                List <string> lst = GetCheckers(dr["IdStep"].ToString(), dr["Next"].ToString(), Convert.ToBoolean(dr["IsComeBackPro"]));
                if (!string.IsNullOrEmpty(Error))
                {
                    return(false);
                }
                lstUser = string.Join(",", lst);
                foreach (string id in lst)
                {
                    Hashtable val1 = new Hashtable();
                    val1["IdProcess"] = dr["IdRow"];
                    val1["Checker"]   = id;
                    cnn.Insert(val1, "DP_Process_Detail");
                }
            }
            if (string.IsNullOrEmpty(lstUser))
            {
                string    str1084    = @"	select  distinct UserID from Dps_User_GroupUser gu inner join Dps_UserGroupRoles gr on gu.IdGroupUser=gr.IdGroupUser
                            inner join Dps_Roles on IdRole = gr.IDGroupRole
                            inner join DPS_User u on u.UserID = gu.IdUser
                             where IdRole = 1084 and Deleted = 0";
                DataTable dtUser1084 = cnn.CreateDataTable(str1084);
                var       temp       = dtUser1084.AsEnumerable().Select(x => x["UserID"].ToString()).ToList();
                lstUser = string.Join(",", temp);
            }
            string msg = "Bạn có một phản ánh góp ý mới cần xử lý.";

            return(notify(lstUser, msg));
        }
コード例 #13
0
        /// <summary>
        /// Tiến hành gửi mail
        /// </summary>
        /// <param name="mailTo"></param>
        /// <param name="title"></param>
        /// <param name="cc"></param>
        /// <param name="contents"></param>
        /// <param name="AttacheFiles"></param>
        /// <param name="SaveCannotSend"></param>
        /// <param name="ErrorMessage"></param>
        /// <param name="MInfo"></param>
        /// <returns></returns>
        public static bool Send(MailAddressCollection mailTo, string title, MailAddressCollection cc, MailAddressCollection bcc, string contents, string[] AttacheFiles, bool SaveCannotSend, out string ErrorMessage, MailInfo MInfo)
        {
            bool success = true;

            ErrorMessage = "";
            //Lưu lại email đã gửi
            Hashtable val = new Hashtable();

            if (MInfo == null || MInfo.Email == "")
            {
                ErrorMessage = "Không tìm thấy cấu hình mail";
                return(false);
            }
            if (mailTo.Count == 0 && cc.Count == 0 && bcc.Count == 0)
            {
                ErrorMessage = "Không có người nhận mail";
                return(false);
            }
            val.Add("Loai", MInfo.Loai);
            val.Add("Id", MInfo.Id);
            val.Add("Title", title);
            val.Add("Contents", contents);
            val.Add("SendDate", DateTime.Now);
            val.Add("SendFrom", MInfo.Email);
            MailMessage m = new MailMessage();
            string      guiden = "", strcc = "", strbcc = "";

            for (int i = 0; i < mailTo.Count; i++)
            {
                m.To.Add(mailTo[i]);
                guiden += "," + mailTo[i];
            }
            m.From = new MailAddress(MInfo.Email);
            if (AttacheFiles != null)
            {
                foreach (var AttacheFile in AttacheFiles)
                {
                    if ((!"".Equals(AttacheFile)) && (File.Exists(AttacheFile)))
                    {
                        Attachment att = new Attachment(AttacheFile);
                        m.Attachments.Add(att);
                    }
                }
            }
            if (cc != null)
            {
                for (int i = 0; i < cc.Count; i++)
                {
                    m.CC.Add((MailAddress)cc[i]);
                    strcc += "," + cc[i];
                }
            }
            if (bcc != null)
            {
                for (int i = 0; i < bcc.Count; i++)
                {
                    m.Bcc.Add((MailAddress)bcc[i]);
                    strbcc += "," + bcc[i];
                }
            }
            m.IsBodyHtml = true;
            m.Subject    = title;
            m.Body       = contents;
            if (!"".Equals(guiden))
            {
                guiden = guiden.Substring(1);
            }
            val.Add("MailTo", guiden);
            if (!"".Equals(strcc))
            {
                strcc = strcc.Substring(1);
            }
            val.Add("CC", strcc);
            if (!"".Equals(strbcc))
            {
                strbcc = strbcc.Substring(1);
            }
            val.Add("BCC", strbcc);
            if ("".Equals(MInfo.Email))
            {
                ErrorMessage = "Không tìm thấy cấu hình mailserver";
                success      = false;
            }
            if (!success)
            {
                val.Add("Success", success);
                val.Add("ErrorMsg", ErrorMessage);
                DpsConnection cnn1 = new DpsConnection(MInfo._config.ConnectionString);
                cnn1.Insert(val, "Sys_SendMail");
                return(false);
            }
            string str = "";

            Task.Factory.StartNew((Action)(() =>
            {
                SmtpClient s = new SmtpClient(MInfo.SmptClient, MInfo.Port);
                s.UseDefaultCredentials = false;
                s.EnableSsl = MInfo.EnableSSL;
                s.Credentials = new NetworkCredential(MInfo.UserName, MInfo.Password);
                s.DeliveryMethod = SmtpDeliveryMethod.Network;
                try
                {
                    s.Send(m);
                }
                catch (Exception ex)
                {
                    str = ex.Message;
                    success = false;
                }
                val.Add("Success", success);
                val.Add("ErrorMsg", str);
                DpsConnection cnn1 = new DpsConnection(MInfo._config.ConnectionString);
                cnn1.Insert(val, "Sys_SendMail");
            }));
            ErrorMessage = str;
            return(success);
        }
コード例 #14
0
        public BaseModel <object> GetCreateUser(Models.User.Account data)
        {
            {
                int           status  = 0;
                string        Id      = "";
                string        Token   = "";
                SqlConditions Conds   = new SqlConditions();
                DataTable     dt      = new DataTable();
                DataTable     dt_user = new DataTable();
                DataRow[]     dr;
                Hashtable     val_user = new Hashtable();
                Hashtable     val = new Hashtable();
                bool          Visible = true;
                List <object> rs = new List <object>();
                string        title = "", link = "";
                string        name;
                bool          check;

                DataTable dt_token = new DataTable();
                try
                {
                    //Conds.Add("email", Email);
                    //Conds.Add("password", Pass);

                    using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                    {
                        dt_user = cnn.CreateDataTable(@"
        select Email from TBL_Account

        ", Conds);
                        dr      = dt_user.Select();



                        if (dpsUserMr.ktma(data.email.ToString()) == false)
                        {
                            val.Add("IDNV", data.IDNV);

                            val.Add("Email", data.email);
                            val.Add("UserName", data.username);
                            val.Add("Pass", data.pass);
                            val.Add("TINHTRANG", data.TinhTrang);
                        }
                        else
                        {
                            val.Add("IDNV", data.IDNV);

                            val.Add("Email", data.email + "hufi");
                            val.Add("UserName", data.username);
                            val.Add("Pass", data.pass);
                            val.Add("TINHTRANG", data.TinhTrang);

                            return(JsonResultCommon.Trung("Tài khoản" + data.email));
                            //val.Add("IDNV", data.IDNV);

                            //val.Add("Email", data.email);
                            //val.Add("UserName", data.username);
                            //val.Add("Pass", data.pass);
                            //val.Add("TINHTRANG", data.TinhTrang);
                        }


                        if (cnn.Insert(val, "TBL_Account") < 0)
                        {
                            return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                        }


                        return(JsonResultCommon.ThanhCong());
                    }
                }

                catch (Exception ex)
                {
                    return(JsonResultCommon.Exception(ex));
                }
            }
        }
コード例 #15
0
        public object addThongDiep(Models.ThongDiepCEO data)
        {
            int           status   = 0;
            string        Id       = "";
            int           id_group = 0;
            string        Token    = "";
            SqlConditions Conds    = new SqlConditions();
            DataTable     dt       = new DataTable();

            DataRow[] dr;
            string    Idtb = "";
            int       id_thongd;

            DataRow[]     dr_tb;
            DataTable     lastidTD = new DataTable();
            bool          Visible = true;
            List <object> rs = new List <object>();
            string        title = "", link = "";
            Hashtable     val        = new Hashtable();
            Hashtable     val_member = new Hashtable();
            DataTable     dt_token   = new DataTable();
            DataTable     lastid     = new DataTable();
            string        sqlq       = "";



            try
            {
                using (DpsConnection cnn = new DpsConnection(_config.ConnectionString))
                {
                    val.Add("TIEUDE", data.title);
                    val.Add("COL_DISABLE", false);

                    val.Add("NOIDUNG", data.noidung);
                    val.Add("CreatedBy", data.create_by);
                    val.Add("CreatedDate", DateTime.Now.ToString("MM/dd/yyyy HH:mm"));

                    if (cnn.Insert(val, "TBL_THONGDIEPCEO") < 0)

                    {
                        return(JsonResultCommon.ThatBai("Cập nhật thất bại", cnn.LastError));
                    }
                    dt       = cnn.CreateDataTable(@"select * from TBL_THONGDIEPCEO as td ,TBL_USER as u where u.ID_USER=td.CreatedBy", Conds);
                    lastidTD = cnn.CreateDataTable(@"SELECT Max(ID_THONGDIEP) as asLastTB FROM TBL_THONGDIEPCEO");


                    dr_tb = lastidTD.Select();

                    Idtb = lastidTD.Rows[0]["asLastTB"].ToString();

                    id_thongd = Int32.Parse(Idtb);

                    Thread.Sleep(500);
                    dr = dt.Select();

                    var dl = from g in dt.AsEnumerable()
                             where g["ID_THONGDIEP"].Equals(id_thongd)
                             select new
                    {
                        id_thongdiep = g["ID_THONGDIEP"],
                        title        = g["TIEUDE"],
                        noidung      = g["NOIDUNG"],
                        media        = g["TYPEPOST"],
                        imgmedia     = $"{link}/UploadedFiles/{g["TYPEPOST"]}",
                        //id_user = r["ID_USER"],
                        ghim = g["COL_DISABLE"],
                        //user_name = r["UserName"],
                        create_by  = g["CreatedBy"],
                        createdate = g["CreatedDate"],
                        hinhanh    = g["AVATAR"],
                        AlowEdit   = g["CreatedBy"],
                        Avatar     = $"{link}/Avatar/{  g["AVATAR"]}",
                    };
                    return(JsonResultCommon.ThanhCong(dl));

                    //  mangxahoi.PushTChangelThongDiep(dl, null);
                }
                return(JsonResultCommon.ThanhCong());
            }
            catch (Exception ex)
            {
                return(JsonResultCommon.Exception(ex));
            }
        }